From 43ccaba4b870d62c3a5ba7e5424601249b1359e5 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Wed, 24 Jul 2024 18:50:46 +0800 Subject: [PATCH] process withdrawals --- pkg/validator/validator.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 1a201a9..9c6bf2d 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -334,7 +334,7 @@ func applyTransactions(block *types.Block, backend *ipldeth.Backend) (*ipldstate evm.Reset(core.NewEVMTxContext(msg), statedb) // Apply the transaction to the current state (included in the env). if _, err := core.ApplyMessage(evm, msg, &gp); err != nil { - return nil, fmt.Errorf("transaction %#x failed: %w", tx.Hash(), err) + return nil, fmt.Errorf("error applying tx %#x: %w", tx.Hash(), err) } if config.IsByzantium(block.Number()) { @@ -344,6 +344,14 @@ func applyTransactions(block *types.Block, backend *ipldeth.Backend) (*ipldstate } } + // Withdrawals processing. + for _, w := range block.Withdrawals() { + // Convert amount from gwei to wei. + amount := new(uint256.Int).SetUint64(w.Amount) + amount = amount.Mul(amount, uint256.NewInt(params.GWei)) + statedb.AddBalance(w.Address, amount) + } + if config.Ethash != nil { accumulateRewards(config, statedb, block.Header(), block.Uncles()) }