Skip to content

Commit

Permalink
go/consensus/cometbft/light: Only fetch from light store for now
Browse files Browse the repository at this point in the history
In practice the previously introduced fetch from light client caused
the light client to fall back to slow backwards verification due to
target blocks being in the past, below the pruning window.
  • Loading branch information
kostko committed Nov 28, 2023
1 parent 31fac50 commit 10d3060
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changelog/5481.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/consensus/cometbft/light: Only fetch from light store for now

In practice the previously introduced fetch from light client caused
the light client to fall back to slow backwards verification due to
target blocks being in the past, below the pruning window.
14 changes: 5 additions & 9 deletions go/consensus/cometbft/light/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,17 @@ func (c *client) GetLightBlock(ctx context.Context, height int64) (*consensus.Li
return lb, rpc.NewNopPeerFeedback(), nil
}

// Light client.
lightClientSource := func() (*consensus.LightBlock, rpc.PeerFeedback, error) {
clb, err := c.lc.GetVerifiedLightBlock(ctx, height)
// Light client store.
lightClientStoreSource := func() (*consensus.LightBlock, rpc.PeerFeedback, error) {
lb, err := c.GetStoredLightBlock(height)
if err != nil {
c.logger.Debug("failed to fetch light block from light client",
c.logger.Debug("failed to fetch light block from light client store",
"err", err,
"height", height,
)
return nil, nil, err
}

lb, err := api.NewLightBlock(clb)
if err != nil {
return nil, nil, err
}
return lb, rpc.NewNopPeerFeedback(), nil
}

Expand All @@ -316,7 +312,7 @@ func (c *client) GetLightBlock(ctx context.Context, height int64) (*consensus.Li
var mergedErr error
for _, src := range []func() (*consensus.LightBlock, rpc.PeerFeedback, error){
localBackendSource,
lightClientSource,
lightClientStoreSource,
directPeerQuerySource,
} {
lb, pf, err := src()
Expand Down

0 comments on commit 10d3060

Please sign in to comment.