From 2209cb486a6e89e305eedb027b8f356a2d0cc8b4 Mon Sep 17 00:00:00 2001 From: Rez Date: Thu, 20 Mar 2025 07:16:07 +1100 Subject: [PATCH] Add withdrawals to sanitizeChain --- internal/ethapi/simulate.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index 2d8a078c87..49a5901a4e 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -319,13 +319,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, reqHash := types.CalcRequestsHash(requests) header.RequestsHash = &reqHash } - var withdrawals []*types.Withdrawal - if block.BlockOverrides.Withdrawals != nil { - withdrawals = *block.BlockOverrides.Withdrawals - } else { - withdrawals = []*types.Withdrawal{} - } - blockBody := &types.Body{Transactions: txes, Withdrawals: withdrawals} + blockBody := &types.Body{Transactions: txes, Withdrawals: *block.BlockOverrides.Withdrawals} chainHeadReader := &simChainHeadReader{ctx, sim.b} b, err := sim.b.Engine().FinalizeAndAssemble(chainHeadReader, header, sim.state, blockBody, receipts) if err != nil { @@ -392,6 +386,10 @@ func (sim *simulator) sanitizeChain(blocks []simBlock) ([]simBlock, error) { n := new(big.Int).Add(prevNumber, big.NewInt(1)) block.BlockOverrides.Number = (*hexutil.Big)(n) } + if block.BlockOverrides.Withdrawals == nil { + var withdrawals types.Withdrawals + block.BlockOverrides.Withdrawals = &withdrawals + } diff := new(big.Int).Sub(block.BlockOverrides.Number.ToInt(), prevNumber) if diff.Cmp(common.Big0) <= 0 { return nil, &invalidBlockNumberError{fmt.Sprintf("block numbers must be in order: %d <= %d", block.BlockOverrides.Number.ToInt().Uint64(), prevNumber)}