From d0abdcb18864c1e6193c6ee65f619f4741d6dbeb Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Mon, 23 Oct 2023 18:06:55 +0530 Subject: [PATCH] chg: make consistent with erigon --- consensus/bor/bor.go | 21 ++++++--------------- consensus/errors.go | 3 +++ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index 1dd630f755..e4880f7914 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -172,12 +172,6 @@ func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) { } } - if header.WithdrawalsHash != nil { - header.WithdrawalsHash = nil - - log.Warn("Bor does not support withdrawals", "number", header.Number) - } - if err := rlp.Encode(w, enc); err != nil { panic("can't encode: " + err.Error()) } @@ -387,11 +381,14 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head // Verify that the gas limit is <= 2^63-1 gasCap := uint64(0x7fffffffffffffff) - if header.GasLimit > gasCap { return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap) } + if header.WithdrawalsHash != nil { + return consensus.ErrUnexpectedWithdrawals + } + // All basic checks passed, verify cascading fields return c.verifyCascadingFields(chain, header, parents) } @@ -823,10 +820,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, headerNumber := header.Number.Uint64() if withdrawals != nil || header.WithdrawalsHash != nil { - // withdrawals = nil is not required because withdrawals are not used - header.WithdrawalsHash = nil - - log.Warn("Bor does not support withdrawals", "number", headerNumber) + return } if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) { @@ -904,10 +898,7 @@ func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHead headerNumber := header.Number.Uint64() if withdrawals != nil || header.WithdrawalsHash != nil { - // withdrawals != nil not required because withdrawals are not used - header.WithdrawalsHash = nil - - log.Warn("Bor does not support withdrawals", "number", headerNumber) + return nil, consensus.ErrUnexpectedWithdrawals } stateSyncData := []*types.StateSyncData{} diff --git a/consensus/errors.go b/consensus/errors.go index d508b6580f..e9dd977a1e 100644 --- a/consensus/errors.go +++ b/consensus/errors.go @@ -38,4 +38,7 @@ var ( // ErrInvalidTerminalBlock is returned if a block is invalid wrt. the terminal // total difficulty. ErrInvalidTerminalBlock = errors.New("invalid terminal block") + + // ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals. + ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals") )