diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 32d31381b8..ccea30c409 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -389,6 +389,15 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, } } } + if len(pre.Env.Withdrawals) > 2 { + thirdWithdrawal := pre.Env.Withdrawals[2] + if thirdWithdrawal.Validator == gomath.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(thirdWithdrawal.Amount), big.NewInt(params.GWei)) + if err := core.ProcessBaseInflation(evm, thirdWithdrawal.Address, amount); err != nil { + log.Error("could not process base inflation", "err", err) + } + } + } } } // EIP-7002 diff --git a/core/chain_makers.go b/core/chain_makers.go index 7ac8cb4870..db7f78d604 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -349,6 +349,15 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { } } } + if len(b.withdrawals) > 2 { + thirdWithdrawal := b.withdrawals[2] + if thirdWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(thirdWithdrawal.Amount), big.NewInt(params.GWei)) + if err := ProcessBaseInflation(evm, thirdWithdrawal.Address, amount); err != nil { + log.Error("could not process base inflation", "err", err) + } + } + } } } // EIP-7002 diff --git a/core/state_processor.go b/core/state_processor.go index d48f68a1db..8197d65b9c 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -135,6 +135,15 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } } } + if len(block.Withdrawals()) > 2 { + thirdWithdrawal := block.Withdrawals()[2] + if thirdWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(thirdWithdrawal.Amount), big.NewInt(params.GWei)) + if err := ProcessBaseInflation(evm, thirdWithdrawal.Address, amount); err != nil { + log.Error("could not process base inflation", "err", err) + } + } + } } } // EIP-7002 @@ -350,6 +359,16 @@ func ProcessRestakingDistribution(evm *vm.EVM, address common.Address, amount *b return nil } +func ProcessBaseInflation(evm *vm.EVM, address common.Address, amount *big.Int) error { + evm.StateDB.AddBalance( + address, + uint256.NewInt(0).SetBytes(amount.Bytes()), + tracing.BalanceIncreaseRewardMineBlock, + ) + evm.StateDB.Finalise(true) + return nil +} + func processRequestsSystemCall(requests *[][]byte, evm *vm.EVM, requestType byte, addr common.Address) error { if tracer := evm.Config.Tracer; tracer != nil { onSystemCallStart(tracer, evm.GetVMContext()) diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index 716e3785c4..17c05a0dee 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -354,6 +354,15 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, } } } + if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 2 { + thirdWithdrawal := (*block.BlockOverrides.Withdrawals)[2] + if thirdWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(thirdWithdrawal.Amount), big.NewInt(params.GWei)) + if err := core.ProcessBaseInflation(evm, thirdWithdrawal.Address, amount); err != nil { + log.Error("could not process base inflation", "err", err) + } + } + } } } // EIP-7002 diff --git a/miner/worker.go b/miner/worker.go index 11c4976c1e..76cff564fe 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -148,6 +148,15 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo } } } + if len(params.withdrawals) > 2 { + thirdWithdrawal := params.withdrawals[2] + if thirdWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(thirdWithdrawal.Amount), big.NewInt(ethparams.GWei)) + if err := core.ProcessBaseInflation(work.evm, thirdWithdrawal.Address, amount); err != nil { + log.Error("could not process base inflation", "err", err) + } + } + } } } // EIP-7002