From 10d3060e8c1e6c8cd81969ce7210af80e3d1b58d Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Tue, 28 Nov 2023 13:38:52 +0100 Subject: [PATCH] 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. --- .changelog/5481.bugfix.md | 5 +++++ go/consensus/cometbft/light/service.go | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 .changelog/5481.bugfix.md diff --git a/.changelog/5481.bugfix.md b/.changelog/5481.bugfix.md new file mode 100644 index 00000000000..91f0be46b7f --- /dev/null +++ b/.changelog/5481.bugfix.md @@ -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. diff --git a/go/consensus/cometbft/light/service.go b/go/consensus/cometbft/light/service.go index 16b07a28407..0de447eac9c 100644 --- a/go/consensus/cometbft/light/service.go +++ b/go/consensus/cometbft/light/service.go @@ -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 } @@ -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()