From 1be0c4894afee14c7aae7ebab3074b47cdab9389 Mon Sep 17 00:00:00 2001 From: atvanguard <93arpit@gmail.com> Date: Mon, 18 May 2020 14:17:13 +0530 Subject: [PATCH] dev: provide previous block number to UnauthorizedSignerError --- consensus/bor/bor.go | 6 ++++-- consensus/bor/bor_test/bor_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index a8f90dfe66d6..fac5500b76c8 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 1c6c530e82ed..98331996f92d 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()}) }