diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index a8f90dfe66..fac5500b76 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -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) @@ -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) diff --git a/consensus/bor/bor_test/bor_test.go b/consensus/bor/bor_test/bor_test.go index 1c6c530e82..98331996f9 100644 --- a/consensus/bor/bor_test/bor_test.go +++ b/consensus/bor/bor_test/bor_test.go @@ -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()}) }