Skip to content

Commit

Permalink
bor: make withdrawals nil
Browse files Browse the repository at this point in the history
  • Loading branch information
anshalshukla committed Oct 20, 2023
1 parent d104b38 commit 9f44579
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
16 changes: 8 additions & 8 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,14 +816,14 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,

headerNumber := header.Number.Uint64()

if len(withdrawals) > 0 {
if withdrawals != nil {
withdrawals = nil
log.Error("Bor does not support withdrawals", "number", headerNumber)
return
}

if header.WithdrawalsHash != nil {
header.WithdrawalsHash = nil
log.Error("Bor does not support withdrawalHash", "number", headerNumber)
return
}

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
Expand Down Expand Up @@ -898,18 +898,18 @@ func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHead
finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble")
defer tracing.EndSpan(finalizeSpan)

if len(withdrawals) > 0 {
return nil, errors.New("Bor does not support withdrawals")
headerNumber := header.Number.Uint64()

if withdrawals != nil {
log.Error("Bor does not support withdrawals", "number", headerNumber)
}

if header.WithdrawalsHash != nil {
return nil, errors.New("Bor does not support withdrawalHash")
log.Error("Bor does not support withdrawalHash", "number", headerNumber)
}

stateSyncData := []*types.StateSyncData{}

headerNumber := header.Number.Uint64()

var err error

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
Expand Down
4 changes: 2 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ func (g *Genesis) ToBlock() *types.Block {
var withdrawals []*types.Withdrawal

if g.Config != nil && g.Config.IsShanghai(new(big.Int).SetUint64(g.Number)) {
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
withdrawals = make([]*types.Withdrawal, 0)
head.WithdrawalsHash = nil
withdrawals = nil
}

return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
Expand Down
6 changes: 5 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}
// Fail if Shanghai not enabled and len(withdrawals) is non-zero.
withdrawals := block.Withdrawals()
if len(withdrawals) > 0 && !p.config.IsShanghai(block.Number()) {
if !p.config.IsShanghai(block.Number()) && withdrawals != nil {
return nil, nil, 0, fmt.Errorf("withdrawals before shanghai")
}
// Bor does not support withdrawals
if withdrawals != nil {
withdrawals = nil
}
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), withdrawals)

Expand Down

0 comments on commit 9f44579

Please sign in to comment.