-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove proposer from ValidatorSet #56
Changes from 10 commits
0c104af
c07da9d
04019e9
a45a5c7
1453882
6bd7af7
adbd3d6
dabb16e
6babcbc
8b57fe5
0870d74
eb21bfe
670a173
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ type RoundState struct { | |
// Subjective time when +2/3 precommits for Block at Round were found | ||
CommitTime time.Time `json:"commit_time"` | ||
Validators *types.ValidatorSet `json:"validators"` | ||
Proposer *types.Validator `json:"proposer"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs to output a string for the new field with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good point. Thank you for that. |
||
Proposal *types.Proposal `json:"proposal"` | ||
ProposalBlock *types.Block `json:"proposal_block"` | ||
ProposalBlockParts *types.PartSet `json:"proposal_block_parts"` | ||
|
@@ -111,7 +112,7 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple { | |
panic(err) | ||
} | ||
|
||
addr := rs.Validators.GetProposer().Address | ||
addr := rs.Proposer.Address | ||
idx, _ := rs.Validators.GetByAddress(addr) | ||
|
||
return RoundStateSimple{ | ||
|
@@ -130,7 +131,7 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple { | |
|
||
// NewRoundEvent returns the RoundState with proposer information as an event. | ||
func (rs *RoundState) NewRoundEvent() types.EventDataNewRound { | ||
addr := rs.Validators.GetProposer().Address | ||
addr := rs.Proposer.Address | ||
idx, _ := rs.Validators.GetByAddress(addr) | ||
|
||
return types.EventDataNewRound{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ func TestApplyBlock(t *testing.T) { | |
blockExec := sm.NewBlockExecutor(stateDB, log.TestingLogger(), proxyApp.Consensus(), | ||
mock.Mempool{}, sm.MockEvidencePool{}) | ||
|
||
block := makeBlockWithPrivVal(state, privVals[state.Validators.Proposer.Address.String()], 1) | ||
block := makeBlockWithPrivVal(state, privVals[state.Validators.Validators[0].Address.String()], 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you tell me what your intention is in replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ValidatorSet.Proposer is not available any more. In this test, validatorSet has only one validator, so Validators[0] is the proposer in this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For tests with more than one Validator, I modified it to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, the reason why |
||
blockID := types.BlockID{Hash: block.Hash(), PartsHeader: block.MakePartSet(testPartSize).Header()} | ||
|
||
//nolint:ineffassign | ||
|
@@ -89,10 +89,10 @@ func TestBeginBlockValidators(t *testing.T) { | |
lastCommit := types.NewCommit(1, 0, prevBlockID, tc.lastCommitSigs) | ||
|
||
message := state.MakeHashMessage(0) | ||
proof, _ := privVals[state.Validators.GetProposer().Address.String()].GenerateVRFProof(message) | ||
proof, _ := privVals[state.Validators.Validators[0].Address.String()].GenerateVRFProof(message) | ||
|
||
// block for height 2 | ||
block, _ := state.MakeBlock(2, makeTxs(2), lastCommit, nil, state.Validators.GetProposer().Address, 0, proof) | ||
block, _ := state.MakeBlock(2, makeTxs(2), lastCommit, nil, state.Validators.Validators[0].Address, 0, proof) | ||
|
||
_, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateDB) | ||
require.Nil(t, err, tc.desc) | ||
|
@@ -160,8 +160,8 @@ func TestBeginBlockByzantineValidators(t *testing.T) { | |
lastCommit := types.NewCommit(9, 0, prevBlockID, commitSigs) | ||
for _, tc := range testCases { | ||
message := state.MakeHashMessage(0) | ||
proof, _ := privVals[state.Validators.GetProposer().Address.String()].GenerateVRFProof(message) | ||
block, _ := state.MakeBlock(10, makeTxs(2), lastCommit, nil, state.Validators.GetProposer().Address, 0, proof) | ||
proof, _ := privVals[state.Validators.Validators[0].Address.String()].GenerateVRFProof(message) | ||
block, _ := state.MakeBlock(10, makeTxs(2), lastCommit, nil, state.Validators.Validators[0].Address, 0, proof) | ||
block.Time = now | ||
block.Evidence.Evidence = tc.evidence | ||
_, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateDB) | ||
|
@@ -351,7 +351,7 @@ func TestEndBlockValidatorUpdates(t *testing.T) { | |
) | ||
require.NoError(t, err) | ||
|
||
block := makeBlockWithPrivVal(state, privVals[state.Validators.Proposer.Address.String()], 1) | ||
block := makeBlockWithPrivVal(state, privVals[state.Validators.Validators[0].Address.String()], 1) | ||
blockID := types.BlockID{Hash: block.Hash(), PartsHeader: block.MakePartSet(testPartSize).Header()} | ||
|
||
pubkey := ed25519.GenPrivKey().PubKey() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,8 +240,8 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { | |
for i, val := range genDoc.Validators { | ||
validators[i] = types.NewValidator(val.PubKey, val.Power) | ||
} | ||
validatorSet = types.NewRandomValidatorSet(validators, types.MakeRoundHash(genDoc.Hash(), 1, 0)) | ||
nextValidatorSet = types.NewRandomValidatorSet(validators, types.MakeRoundHash(genDoc.Hash(), 2, 0)) | ||
validatorSet = types.NewValidatorSet(validators) | ||
nextValidatorSet = types.NewValidatorSet(validators) | ||
} | ||
|
||
return State{ | ||
|
@@ -257,7 +257,7 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { | |
|
||
NextValidators: nextValidatorSet, | ||
Validators: validatorSet, | ||
LastValidators: types.NewRandomValidatorSet(nil, types.MakeRoundHash(genDoc.Hash(), 1, 0)), | ||
LastValidators: types.NewValidatorSet(nil), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add LastProposer to State if we need it, but for now, we don't need it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I understand. Thank you. :) |
||
LastHeightValidatorsChanged: 1, | ||
|
||
ConsensusParams: *genDoc.ConsensusParams, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you change this timeout value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll revert it.