From e7bd7bfd79337b987c95cbd049d9898003dfe680 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Mon, 10 Jan 2022 11:45:31 +0100 Subject: [PATCH] use commit height in GetBlockInfo --- core/fetcher.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/fetcher.go b/core/fetcher.go index 12dd284df9..ff0e88fa97 100644 --- a/core/fetcher.go +++ b/core/fetcher.go @@ -33,7 +33,12 @@ func (f *BlockFetcher) GetBlockInfo(ctx context.Context, height *int64) (*types. return nil, nil, fmt.Errorf("core/fetcher: getting commit: %w", err) } - valSet, err := f.ValidatorSet(ctx, height) + // If a nil `height` is given as a parameter, there is a chance + // that a new block could be produced between getting the latest + // commit and getting the latest validator set. Therefore, it is + // best to get the validator set at the latest commit's height to + // prevent this potential inconsistency. + valSet, err := f.ValidatorSet(ctx, &commit.Height) if err != nil { return nil, nil, fmt.Errorf("core/fetcher: getting validator set: %w", err) }