From ecb523cb17bc093aee004143a3ed43461a270d1b Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Mon, 9 May 2022 09:26:01 -0400 Subject: [PATCH] state: Ensure no of commit sigs equals validator set length Signed-off-by: Thane Thomson --- internal/state/execution.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/state/execution.go b/internal/state/execution.go index 191ed0dbd..c1e9f1692 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -432,7 +432,21 @@ func buildLastExtendedCommitInfo(ec *types.ExtendedCommit, store Store, initialH panic(fmt.Errorf("failed to load validator set at height %d, initial height %d: %w", ec.Height, initialHeight, err)) } - vs := make([]abci.ExtendedVoteInfo, ec.Size()) + var ( + ecSize = ec.Size() + valSetLen = len(valSet.Validators) + ) + + // Ensure that the size of the validator set in the extended commit matches + // the size of the validator set in the state store. + if ecSize != valSetLen { + panic(fmt.Errorf( + "extended commit size (%d) does not match validator set length (%d) at height %d\n\n%v\n\n%v", + ecSize, valSetLen, ec.Height, ec.ExtendedSignatures, valSet.Validators, + )) + } + + vs := make([]abci.ExtendedVoteInfo, ecSize) for i, ecs := range ec.ExtendedSignatures { var ext []byte if ecs.BlockIDFlag == types.BlockIDFlagCommit {