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 NextVoters from state #100

Merged
merged 20 commits into from
Jul 8, 2020
Merged
Prev Previous commit
Next Next commit
fix: apply comments
  • Loading branch information
Woosang Son committed Jul 5, 2020
commit 69c1860300eff364d00d4cc1ea3e23a6bafc909c
4 changes: 0 additions & 4 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
### BREAKING CHANGES:

- 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
Expand All @@ -18,9 +17,6 @@
- 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
- [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

Expand Down
4 changes: 2 additions & 2 deletions lite/base_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lite

import (
"bytes"

"github.com/tendermint/tendermint/crypto/vrf"

"github.com/pkg/errors"
Expand Down Expand Up @@ -60,8 +61,7 @@ func (bv *BaseVerifier) Verify(signedHeader types.SignedHeader) error {
}

// We can't verify with the wrong validator set.
if !bytes.Equal(signedHeader.ValidatorsHash,
bv.valSet.Hash()) {
if !bytes.Equal(signedHeader.ValidatorsHash, bv.valSet.Hash()) {
return lerr.ErrUnexpectedValidators(signedHeader.ValidatorsHash, bv.valSet.Hash())
}

Expand Down
18 changes: 14 additions & 4 deletions lite2/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ func VerifyNonAdjacent(
}

// Ensure that +`trustLevel` (default 1/3) or more of last trusted validators signed correctly.
err = trustedVoters.VerifyCommitTrusting(chainID, untrustedHeader.Commit.BlockID, untrustedHeader.Height,
untrustedHeader.Commit, trustLevel)
err = trustedVoters.VerifyCommitTrusting(
chainID,
untrustedHeader.Commit.BlockID,
untrustedHeader.Height,
untrustedHeader.Commit,
trustLevel)
if err != nil {
switch e := err.(type) {
case types.ErrNotEnoughVotingPowerSigned:
Expand All @@ -85,7 +89,10 @@ func VerifyNonAdjacent(
// NOTE: this should always be the last check because untrustedVals can be
// intentionally made very large to DOS the light client. not the case for
// VerifyAdjacent, where validator set is known in advance.
if err := untrustedVoters.VerifyCommit(chainID, untrustedHeader.Commit.BlockID, untrustedHeader.Height,
if err := untrustedVoters.VerifyCommit(
chainID,
untrustedHeader.Commit.BlockID,
untrustedHeader.Height,
untrustedHeader.Commit); err != nil {
return ErrInvalidHeader{err}
}
Expand Down Expand Up @@ -152,7 +159,10 @@ func VerifyAdjacent(
}

// Ensure that +2/3 of new validators signed correctly.
if err := untrustedVoters.VerifyCommit(chainID, untrustedHeader.Commit.BlockID, untrustedHeader.Height,
if err := untrustedVoters.VerifyCommit(
chainID,
untrustedHeader.Commit.BlockID,
untrustedHeader.Height,
untrustedHeader.Commit); err != nil {
return ErrInvalidHeader{err}
}
Expand Down