Skip to content

Commit

Permalink
Merge pull request #2945 from oasislabs/kostko/stable/20.6.x/fix-sani…
Browse files Browse the repository at this point in the history
…ty-check

[20.6.x] go/staking: Relax account identifier sanity check added in 20.6.1
  • Loading branch information
kostko authored May 27, 2020
2 parents ba4ecd6 + 1cdb3e2 commit c8f3cbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changelog/2945.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/staking: Relax account identifier sanity check added in 20.6.1

Version 20.6.1 introduced an additional sanity check for account identifier
validity, but this actually breaks some existing deployments. This revert
makes the checks consistent with 20.6 behavior.
4 changes: 0 additions & 4 deletions go/consensus/tendermint/apps/staking/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ func (s *ImmutableState) Accounts(ctx context.Context) ([]signature.PublicKey, e
}

func (s *ImmutableState) Account(ctx context.Context, id signature.PublicKey) (*staking.Account, error) {
if !id.IsValid() {
return nil, fmt.Errorf("tendermint/staking: invalid account ID")
}

value, err := s.is.Get(ctx, accountKeyFmt.Encode(&id))
if err != nil {
return nil, abciAPI.UnavailableStateError(err)
Expand Down
3 changes: 0 additions & 3 deletions go/staking/api/sanity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ func (p *ConsensusParameters) SanityCheck() error {
// SanityCheckAccount examines an account's balances.
// Adds the balances to a running total `total`.
func SanityCheckAccount(total *quantity.Quantity, parameters *ConsensusParameters, now epochtime.EpochTime, id signature.PublicKey, acct *Account) error {
if !id.IsValid() {
return fmt.Errorf("staking: sanity check failed: account has invalid ID: %s", id)
}
if !acct.General.Balance.IsValid() {
return fmt.Errorf("staking: sanity check failed: general balance is invalid for account with ID: %s", id)
}
Expand Down

0 comments on commit c8f3cbc

Please sign in to comment.