-
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 NextVoters
from state
#100
Changes from 15 commits
79817b5
cc03b38
dce9488
95cab29
1f69835
d2e155f
77700dd
e44b93e
d882bb5
e0b312d
88c436e
88afe5f
46dd04c
f0c1818
f9a9fad
69c1860
2283f43
2e4c788
d2a5d1f
65dd60d
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 |
---|---|---|
|
@@ -5,18 +5,24 @@ | |
### BREAKING CHANGES: | ||
|
||
- State | ||
- [state] [\#92](https://github.com/line/tendermint/pull/92) Genesis state | ||
- [state] [\#83](https://github.com/line/tendermint/pull/92) Add `VoterParams` to state | ||
- [state] [\#100](https://github.com/line/tendermint/pull/100) Remove `NextVoters` from state | ||
|
||
- CLI/RPC/Config | ||
|
||
- Apps | ||
|
||
- P2P Protocol | ||
|
||
- [abci] [\#100](https://github.com/line/tendermint/pull/100) Add `voters_hash` field, which is needed for verification of a block header | ||
|
||
- Go API | ||
|
||
### FEATURES: | ||
- [rpc] [\#78](https://github.com/line/tendermint/pull/78) Add `Voters` rpc | ||
- [consensus] [\#83](https://github.com/line/tendermint/pull/83) Selection voters using random sampling without replacement | ||
- [consensus] [\#92](https://github.com/line/tendermint/pull/92) Apply calculation of voter count | ||
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. Please remove the change that has already added. #78, #83 , #92 (https://github.com/line/tendermint/blob/v0.33.4-0.2/CHANGELOG.md) 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. Okay |
||
- [BLS] [\#81](https://github.com/line/tendermint/issues/81) Modify to generate at the same time as Ed25519 key generation | ||
- [lite] [\#100](https://github.com/line/tendermint/pull/100) Lite calls `Genesis()` rpc when it starts up | ||
|
||
### IMPROVEMENTS: | ||
|
||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,19 +267,20 @@ message Header { | |
BlockID last_block_id = 5 [(gogoproto.nullable) = false]; | ||
|
||
// hashes of block data | ||
bytes last_commit_hash = 6; // commit from validators from the last block | ||
bytes data_hash = 7; // transactions | ||
bytes last_commit_hash = 6; // commit from validators from the last block | ||
bytes data_hash = 7; // transactions | ||
|
||
// hashes from the app output from the prev block | ||
bytes validators_hash = 8; // validators for the current block | ||
bytes next_validators_hash = 9; // validators for the next block | ||
bytes consensus_hash = 10; // consensus params for current block | ||
bytes app_hash = 11; // state after txs from the previous block | ||
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block | ||
bytes voters_hash = 8; // voters for the current block | ||
bytes validators_hash = 9; // validators for the current block | ||
bytes next_validators_hash = 10; // validators for the next block | ||
bytes consensus_hash = 11; // consensus params for current block | ||
bytes app_hash = 12; // state after txs from the previous block | ||
bytes last_results_hash = 13; // root hash of all results from the txs from the previous block | ||
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. 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. Okay, I'll check it after merging |
||
|
||
// consensus info | ||
bytes evidence_hash = 13; // evidence included in the block | ||
bytes proposer_address = 14; // original proposer of the block | ||
bytes evidence_hash = 14; // evidence included in the block | ||
bytes proposer_address = 15; // original proposer of the block | ||
} | ||
|
||
message Version { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package unmarshaler | |
|
||
import ( | ||
"encoding/json" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/tendermint/tendermint/libs/rand" | ||
|
||
dbm "github.com/tendermint/tm-db" | ||
|
||
|
@@ -30,10 +31,13 @@ func initializeValidatorState(valAddr []byte, height int64) dbm.DB { | |
{Address: valAddr, StakingPower: 1}, | ||
} | ||
state := sm.State{ | ||
VoterParams: types.DefaultVoterParams(), | ||
LastBlockHeight: 0, | ||
LastBlockTime: tmtime.Now(), | ||
LastProofHash: rand.Bytes(10), | ||
Validators: types.NewValidatorSet(vals), | ||
NextValidators: types.NewValidatorSet(vals), | ||
Voters: types.ToVoterAll(vals), | ||
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 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. The existing test code used |
||
LastHeightValidatorsChanged: 1, | ||
ConsensusParams: types.ConsensusParams{ | ||
Evidence: types.EvidenceParams{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package lite | |
|
||
import ( | ||
"bytes" | ||
"github.com/tendermint/tendermint/crypto/vrf" | ||
|
||
"github.com/pkg/errors" | ||
|
||
|
@@ -17,21 +18,24 @@ var _ Verifier = (*BaseVerifier)(nil) | |
// use the DynamicVerifier. | ||
// TODO: Handle unbonding time. | ||
type BaseVerifier struct { | ||
chainID string | ||
height int64 | ||
voterSet *types.VoterSet | ||
chainID string | ||
height int64 | ||
valSet *types.ValidatorSet | ||
voterParams *types.VoterParams | ||
} | ||
|
||
// NewBaseVerifier returns a new Verifier initialized with a validator set at | ||
// some height. | ||
func NewBaseVerifier(chainID string, height int64, valset *types.VoterSet) *BaseVerifier { | ||
func NewBaseVerifier(chainID string, height int64, valset *types.ValidatorSet, | ||
voterParams *types.VoterParams) *BaseVerifier { | ||
if valset.IsNilOrEmpty() { | ||
panic("NewBaseVerifier requires a valid voterSet") | ||
} | ||
return &BaseVerifier{ | ||
chainID: chainID, | ||
height: height, | ||
voterSet: valset, | ||
chainID: chainID, | ||
height: height, | ||
valSet: valset, | ||
voterParams: voterParams, | ||
} | ||
} | ||
|
||
|
@@ -56,9 +60,9 @@ func (bv *BaseVerifier) Verify(signedHeader types.SignedHeader) error { | |
} | ||
|
||
// We can't verify with the wrong validator set. | ||
if !bytes.Equal(signedHeader.VotersHash, | ||
bv.voterSet.Hash()) { | ||
return lerr.ErrUnexpectedValidators(signedHeader.VotersHash, bv.voterSet.Hash()) | ||
if !bytes.Equal(signedHeader.ValidatorsHash, | ||
bv.valSet.Hash()) { | ||
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. If possible, I think it's better to read the code if this compare is one-line. |
||
return lerr.ErrUnexpectedValidators(signedHeader.ValidatorsHash, bv.valSet.Hash()) | ||
} | ||
|
||
// Do basic sanity checks. | ||
|
@@ -67,8 +71,17 @@ func (bv *BaseVerifier) Verify(signedHeader types.SignedHeader) error { | |
return errors.Wrap(err, "in verify") | ||
} | ||
|
||
proofHash, err := vrf.ProofToHash(signedHeader.Proof.Bytes()) | ||
if err != nil { | ||
return errors.Wrap(err, "in verify") | ||
} | ||
voters := types.SelectVoter(bv.valSet, proofHash, bv.voterParams) | ||
if !bytes.Equal(signedHeader.VotersHash, voters.Hash()) { | ||
return errors.Errorf("header's voter hash is %X, but voters hash is %X", | ||
signedHeader.VotersHash, voters.Hash()) | ||
} | ||
// Check commit signatures. | ||
err = bv.voterSet.VerifyCommit( | ||
err = voters.VerifyCommit( | ||
bv.chainID, signedHeader.Commit.BlockID, | ||
signedHeader.Height, signedHeader.Commit) | ||
if err != nil { | ||
|
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.
This change log has already been added to 0.33.4-0.2. (https://github.com/line/tendermint/blob/v0.33.4-0.2/CHANGELOG.md)