Skip to content

Commit

Permalink
Merge pull request #1056 from maticnetwork/shaghai-fixes
Browse files Browse the repository at this point in the history
Shanghai fixes
  • Loading branch information
anshalshukla authored Oct 23, 2023
2 parents 95cee33 + d0abdcb commit 0133e32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
21 changes: 6 additions & 15 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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{}
Expand Down
3 changes: 3 additions & 0 deletions consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit 0133e32

Please sign in to comment.