Add withdrawals to sanitizeChain

This commit is contained in:
Rez 2025-03-20 07:16:07 +11:00
parent 6d443ca1d2
commit 2209cb486a
No known key found for this signature in database

View file

@ -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)}