Skip to content

Commit

Permalink
dev: provide previous block number to UnauthorizedSignerError
Browse files Browse the repository at this point in the history
  • Loading branch information
atvanguard committed May 18, 2020
1 parent c7ea09a commit 1be0c48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ func (c *Bor) verifySeal(chain consensus.ChainReader, header *types.Header, pare
return err
}
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
return &UnauthorizedSignerError{number, signer.Bytes()}
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}

succession, err := snap.GetSignerSuccessionNumber(signer)
Expand Down Expand Up @@ -741,7 +742,8 @@ func (c *Bor) Seal(chain consensus.ChainReader, block *types.Block, results chan

// Bail out if we're unauthorized to sign a block
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
return &UnauthorizedSignerError{number, signer.Bytes()}
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}

successionNumber, err := snap.GetSignerSuccessionNumber(signer)
Expand Down
2 changes: 1 addition & 1 deletion consensus/bor/bor_test/bor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ func TestSignerNotFound(t *testing.T) {
_, err := chain.InsertChain([]*types.Block{block})
assert.Equal(t,
*err.(*bor.UnauthorizedSignerError),
bor.UnauthorizedSignerError{Number: 1, Signer: addr.Bytes()})
bor.UnauthorizedSignerError{Number: 0, Signer: addr.Bytes()})
}

0 comments on commit 1be0c48

Please sign in to comment.