mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
add base inflation
This commit is contained in:
parent
b0069fddd1
commit
21b9295729
5 changed files with 55 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue