rename vote extension param

This commit is contained in:
William Banfield
2022-05-16 16:46:17 -04:00
parent 17d5e71489
commit 589d4030ce
7 changed files with 28 additions and 27 deletions
+1 -1
View File
@@ -557,7 +557,7 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
// validate the block before we persist it
err = r.blockExec.ValidateBlock(ctx, state, first)
}
if err == nil && state.ConsensusParams.Vote.RequireExtensions(extCommit.Height) {
if err == nil && state.ConsensusParams.ABCI.VoteExtensionsEnabled(extCommit.Height) {
// if vote extensions were required at this height, ensure they exist.
err = extCommit.EnsureExtensions()
}
+1 -1
View File
@@ -656,7 +656,7 @@ func TestSwitchToConsensusVoteExtensions(t *testing.T) {
cs.state.LastBlockHeight = testCase.storedHeight
cs.state.LastValidators = cs.state.Validators.Copy()
cs.state.ConsensusParams.Vote.ExtensionRequireHeight = testCase.initialRequiredHeight
cs.state.ConsensusParams.ABCI.VoteExtensionsEnableHeight = testCase.initialRequiredHeight
propBlock, err := cs.createProposalBlock(ctx)
require.NoError(t, err)
+7 -7
View File
@@ -697,13 +697,13 @@ func (cs *State) sendInternalMessage(ctx context.Context, mi msgInfo) {
// the method will panic on an absent ExtendedCommit or an ExtendedCommit without
// extension data.
func (cs *State) reconstructLastCommit(state sm.State) {
requireExtensions := cs.state.ConsensusParams.Vote.RequireExtensions(state.LastBlockHeight)
votes, err := cs.votesFromExtendedCommit(state, requireExtensions)
extensionsEnabled := cs.state.ConsensusParams.ABCI.VoteExtensionsEnabled(state.LastBlockHeight)
votes, err := cs.votesFromExtendedCommit(state, extensionsEnabled)
if err == nil {
cs.LastCommit = votes
return
}
if requireExtensions {
if extensionsEnabled {
panic(fmt.Sprintf("failed to reconstruct last commit; %s", err))
}
votes, err = cs.votesFromSeenCommit(state)
@@ -713,13 +713,13 @@ func (cs *State) reconstructLastCommit(state sm.State) {
cs.LastCommit = votes
}
func (cs *State) votesFromExtendedCommit(state sm.State, requireExtensions bool) (*types.VoteSet, error) {
func (cs *State) votesFromExtendedCommit(state sm.State, extensionsEnabled bool) (*types.VoteSet, error) {
ec := cs.blockStore.LoadBlockExtendedCommit(state.LastBlockHeight)
if ec == nil {
return nil, fmt.Errorf("commit for height %v not found", state.LastBlockHeight)
}
var vs *types.VoteSet
if requireExtensions {
if extensionsEnabled {
vs = ec.ToStrictVoteSet(state.ChainID, state.LastValidators)
} else {
vs = ec.ToVoteSet(state.ChainID, state.LastValidators)
@@ -845,7 +845,7 @@ func (cs *State) updateToState(state sm.State) {
cs.ValidRound = -1
cs.ValidBlock = nil
cs.ValidBlockParts = nil
if state.ConsensusParams.Vote.RequireExtensions(height) {
if state.ConsensusParams.ABCI.VoteExtensionsEnabled(height) {
cs.Votes = cstypes.NewStrictHeightVoteSet(state.ChainID, height, validators)
} else {
cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators)
@@ -2402,7 +2402,7 @@ func (cs *State) addVote(
cs.metrics.MarkVoteExtensionReceived(err == nil)
} else if !errors.Is(err, types.ErrVoteExtensionAbsent) {
return false, err
} else if cs.state.ConsensusParams.Vote.RequireExtensions(cs.Height) {
} else if cs.state.ConsensusParams.ABCI.VoteExtensionsEnabled(cs.Height) {
return false, err
}
}
+1 -1
View File
@@ -2314,7 +2314,7 @@ func TestVoteExtensionRequiredHeight(t *testing.T) {
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&abci.ResponseFinalizeBlock{}, nil).Maybe()
m.On("Commit", mock.Anything).Return(&abci.ResponseCommit{}, nil).Maybe()
cs1, vss := makeState(ctx, t, makeStateArgs{config: config, application: m, validators: numValidators})
cs1.state.ConsensusParams.Vote.ExtensionRequireHeight = testCase.initialRequiredHeight
cs1.state.ConsensusParams.ABCI.VoteExtensionsEnableHeight = testCase.initialRequiredHeight
height, round := cs1.Height, cs1.Round
timeoutCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose)
+3 -3
View File
@@ -108,7 +108,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
&abci.RequestPrepareProposal{
MaxTxBytes: maxDataBytes,
Txs: block.Txs.ToSliceOfBytes(),
LocalLastCommit: buildExtendedCommitInfo(lastExtCommit, blockExec.store, state.InitialHeight, state.ConsensusParams.Vote),
LocalLastCommit: buildExtendedCommitInfo(lastExtCommit, blockExec.store, state.InitialHeight, state.ConsensusParams.ABCI),
ByzantineValidators: block.Evidence.ToABCI(),
Height: block.Height,
Time: block.Time,
@@ -428,7 +428,7 @@ func buildLastCommitInfo(block *types.Block, store Store, initialHeight int64) a
// data, it returns an empty record.
//
// Assumes that the commit signatures are sorted according to validator index.
func buildExtendedCommitInfo(ec *types.ExtendedCommit, store Store, initialHeight int64, vp types.VoteParams) abci.ExtendedCommitInfo {
func buildExtendedCommitInfo(ec *types.ExtendedCommit, store Store, initialHeight int64, ap types.ABCIParams) abci.ExtendedCommitInfo {
if ec.Height < initialHeight {
// There are no extended commits for heights below the initial height.
return abci.ExtendedCommitInfo{}
@@ -466,7 +466,7 @@ func buildExtendedCommitInfo(ec *types.ExtendedCommit, store Store, initialHeigh
}
var ext []byte
if err := ecs.EnsureExtension(); err != nil && vp.RequireExtensions(ec.Height) {
if err := ecs.EnsureExtension(); err != nil && ap.VoteExtensionsEnabled(ec.Height) {
panic(fmt.Errorf("commit at height %d received with missing vote extensions data", ec.Height))
}