consensus, core, internal, miner: remove FinalizeAndAssemble

This commit is contained in:
Gary Rong 2026-04-17 09:28:25 +08:00
parent 91e4122aa4
commit afaa572600
3 changed files with 15 additions and 3 deletions

View file

@ -416,7 +416,15 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
Uncles: b.uncles,
Withdrawals: b.withdrawals,
}
if !config.IsShanghai(b.header.Number, b.header.Time) {
if body.Withdrawals != nil {
panic("unexpected withdrawal before shanghai")
}
} else {
if body.Withdrawals == nil {
body.Withdrawals = make([]*types.Withdrawal, 0)
}
}
// Finalize the state transition by applying operations such as withdrawals,
// uncle rewards, and related processing.
b.engine.Finalize(cm, b.header, statedb, &body)

View file

@ -417,7 +417,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
blockBody := &types.Body{
Transactions: txes,
Withdrawals: *block.BlockOverrides.Withdrawals,
Withdrawals: *block.BlockOverrides.Withdrawals, // Withdrawal is also sanitized as non-nil
}
chainHeadReader := &simChainHeadReader{ctx, sim.b}

View file

@ -190,7 +190,11 @@ func (miner *Miner) generateWork(ctx context.Context, genParam *generateParams,
Transactions: work.txs,
Withdrawals: genParam.withdrawals,
}
if miner.chainConfig.IsShanghai(work.header.Number, work.header.Time) {
if !miner.chainConfig.IsShanghai(work.header.Number, work.header.Time) {
if body.Withdrawals != nil {
return &newPayloadResult{err: errors.New("unexpected withdrawals before shanghai")}
}
} else {
if body.Withdrawals == nil {
body.Withdrawals = make([]*types.Withdrawal, 0)
}