Skip to content
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

Merged
merged 13 commits into from
Apr 16, 2020

Conversation

egonspace
Copy link
Contributor

@egonspace egonspace commented Apr 13, 2020

Propose: remove Proposer from ValidatorSet.

Motive for this fix

State.Validators, State.NextValidators, State.LastValidators are all ValidatorSet type.
But ValidatorSet.Proposer can be set by calling SelectProposer(lastProof, height, round) and
height, round are active runtime information of ConsensusState.
Therefore, it is not appropriate for these information to be inside the State, which contains committed block information.
I think Proposer should be only in ConsensusState.
This fix is a proposal for this.

And #55 does not verify the proposer of proposal block, so this PR contains that verification.

I haven't executed the tests yet, but if this proposal is accepted to some degree, I'll take them.

Closes: #XXX

Description


For contributor use:

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer

@egonspace egonspace self-assigned this Apr 13, 2020
@egonspace egonspace added the WIP label Apr 13, 2020
@egonspace egonspace changed the base branch from feature/introduce_vrf_based_proposer_election to develop April 14, 2020 06:33
@egonspace egonspace added C: enhancement Classification: New feature or its request, or improvement in maintainability of code and removed WIP labels Apr 14, 2020
@egonspace
Copy link
Contributor Author

PTAL

@@ -47,7 +47,7 @@ type cleanupFunc func()
// genesis, chain_id, priv_val
var config *cfg.Config // NOTE: must be reset for each _test.go file
var consensusReplayConfig *cfg.Config
var ensureTimeout = time.Millisecond * 100
var ensureTimeout = time.Millisecond * 1000
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revert it.

@@ -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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you add Proposer to the State of the state module, such as the State of the consensus module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand. Thank you. :)

Copy link
Contributor

@torao torao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am also in general agreement with this proposal. I think mutable states for rounds should be in RoundState or consensus.State and not inValidatorSet.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me what your intention is in replacing Proposer with Validator[0] in this test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
If we must get the proposer among several Validators, we should use SelectProposer() function instead of ValidatorSet.Proposer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For tests with more than one Validator, I modified it to use SelectProposer().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the reason why Validator[0] can be swapped with Proposer is because there is only one validator in ValidatorSet.

@@ -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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to output a string for the new field with StringIndented().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good point. Thank you for that.

Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@torao torao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@torao torao merged commit b31cd62 into develop Apr 16, 2020
@egonspace egonspace mentioned this pull request Apr 17, 2020
5 tasks
@zemyblue zemyblue deleted the fix/remove_proposer_from_validator_set branch June 17, 2020 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants