From e9d4bfa266b105c911393b28f1607ef20dff6731 Mon Sep 17 00:00:00 2001 From: pinardZ Date: Mon, 26 May 2025 02:12:57 +0800 Subject: [PATCH 1/4] adapt to staking contract --- cmd/evm/internal/t8ntool/execution.go | 14 +++++++- consensus/beacon/consensus.go | 5 ++- core/chain_makers.go | 11 +++++++ core/state_processor.go | 47 +++++++++++++++++++++++++++ internal/ethapi/simulate.go | 11 +++++++ miner/worker.go | 11 +++++++ params/protocol_params.go | 4 +++ 7 files changed, 101 insertions(+), 2 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index b2e5f70714..98b7d9e337 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -18,6 +18,7 @@ package t8ntool import ( "fmt" + gomath "math" "math/big" "github.com/ethereum/go-ethereum/common" @@ -347,7 +348,9 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, for _, w := range pre.Env.Withdrawals { // Amount is in gwei, turn into wei amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal) + if w.Validator != gomath.MaxUint64 { + statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal) + } } // Gather the execution-layer triggered requests. @@ -362,6 +365,15 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, if err := core.ParseDepositLogs(&requests, allLogs, chainConfig); err != nil { return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err)) } + if len(pre.Env.Withdrawals) > 0 { + w := pre.Env.Withdrawals[0] + if w.Validator == gomath.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } + } + } // EIP-7002 if err := core.ProcessWithdrawalQueue(&requests, evm); err != nil { return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not process withdrawal requests: %v", err)) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 01390c40a3..7963b9df17 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -19,6 +19,7 @@ package beacon import ( "errors" "fmt" + "math" "math/big" "github.com/ethereum/go-ethereum/common" @@ -347,7 +348,9 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. // Convert amount from gwei to wei. amount := new(uint256.Int).SetUint64(w.Amount) amount = amount.Mul(amount, uint256.NewInt(params.GWei)) - state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal) + if w.Validator != math.MaxUint64 { + state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal) + } } // No block reward which is issued by consensus layer instead. } diff --git a/core/chain_makers.go b/core/chain_makers.go index 37bddcfda5..90a28cf92c 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -18,6 +18,7 @@ package core import ( "fmt" + "math" "math/big" "github.com/ethereum/go-ethereum/common" @@ -30,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-verkle" @@ -327,6 +329,15 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { // create EVM for system calls blockContext := NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase) evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{}) + if len(b.withdrawals) > 0 { + w := b.withdrawals[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } + } + } // EIP-7002 if err := ProcessWithdrawalQueue(&requests, evm); err != nil { panic(fmt.Sprintf("could not process withdrawal requests: %v", err)) diff --git a/core/state_processor.go b/core/state_processor.go index 322bd24f41..1197559258 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -18,6 +18,7 @@ package core import ( "fmt" + "math" "math/big" "github.com/ethereum/go-ethereum/common" @@ -27,7 +28,9 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) // StateProcessor is a basic Processor, which takes care of transitioning @@ -112,6 +115,15 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg if err := ParseDepositLogs(&requests, allLogs, p.config); err != nil { return nil, err } + if len(block.Withdrawals()) > 0 { + w := block.Withdrawals()[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } + } + } // EIP-7002 if err := ProcessWithdrawalQueue(&requests, evm); err != nil { return nil, err @@ -279,6 +291,41 @@ func ProcessConsolidationQueue(requests *[][]byte, evm *vm.EVM) error { return processRequestsSystemCall(requests, evm, 0x02, params.ConsolidationQueueAddress) } +// ProcessStakingDistribution +func ProcessStakingDistribution(evm *vm.EVM, address common.Address, amount *big.Int) error { + if tracer := evm.Config.Tracer; tracer != nil { + onSystemCallStart(tracer, evm.GetVMContext()) + if tracer.OnSystemCallEnd != nil { + defer tracer.OnSystemCallEnd() + } + } + input := make([]byte, 32) + copy(input[12:], address.Bytes()) + addr := params.StakingContractAddress + msg := &Message{ + From: params.SystemAddress, + GasLimit: 30_000_000, + GasPrice: common.Big0, + GasFeeCap: common.Big0, + GasTipCap: common.Big0, + To: &addr, + Data: append(params.StakingContractCallData, input...), + } + evm.SetTxContext(NewEVMTxContext(msg)) + evm.StateDB.AddAddressToAccessList(addr) + evm.StateDB.AddBalance( + params.StakingContractAddress, + uint256.NewInt(0).SetBytes(amount.Bytes()), + tracing.BalanceIncreaseRewardMineBlock, + ) + _, _, err := evm.Call(msg.From, *msg.To, msg.Data, 30_000_000, common.U2560) + evm.StateDB.Finalise(true) + if err != nil { + return fmt.Errorf("system call failed to execute: %v", err) + } + 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 b997cf297b..cde74747db 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -21,6 +21,7 @@ import ( "encoding/json" "errors" "fmt" + "math" "math/big" "time" @@ -34,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/internal/ethapi/override" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" ) @@ -332,6 +334,15 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil { return nil, nil, nil, err } + if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 { + w := (*block.BlockOverrides.Withdrawals)[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } + } + } // EIP-7002 if err := core.ProcessWithdrawalQueue(&requests, evm); err != nil { return nil, nil, nil, err diff --git a/miner/worker.go b/miner/worker.go index b5db6180cf..d22edc812f 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -19,6 +19,7 @@ package miner import ( "errors" "fmt" + "math" "math/big" "sync/atomic" "time" @@ -34,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + ethparams "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" ) @@ -126,6 +128,15 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo if err := core.ParseDepositLogs(&requests, allLogs, miner.chainConfig); err != nil { return &newPayloadResult{err: err} } + if len(params.withdrawals) > 0 { + w := params.withdrawals[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei)) + if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } + } + } // EIP-7002 if err := core.ProcessWithdrawalQueue(&requests, work.evm); err != nil { return &newPayloadResult{err: err} diff --git a/params/protocol_params.go b/params/protocol_params.go index 6b06dadaef..c5bde58510 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -211,4 +211,8 @@ var ( // EIP-7251 - Increase the MAX_EFFECTIVE_BALANCE ConsolidationQueueAddress = common.HexToAddress("0x0000BBdDc7CE488642fb579F8B00f3a590007251") ConsolidationQueueCode = common.FromHex("3373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd") + + StakingContractAddress = common.HexToAddress("0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512") + // StakingContractCode = common.FromHex("3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500") + StakingContractCallData = common.FromHex("1de9d9b6") ) From ccc130f82f9f473ad6453b48ea7e143466d22c27 Mon Sep 17 00:00:00 2001 From: pinardZ Date: Wed, 28 May 2025 01:10:06 +0800 Subject: [PATCH 2/4] staking contract modified to be upgradeable --- core/state_processor.go | 13 +++++++------ params/protocol_params.go | 4 ---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 1197559258..9090ed60c9 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -299,22 +299,23 @@ func ProcessStakingDistribution(evm *vm.EVM, address common.Address, amount *big defer tracer.OnSystemCallEnd() } } - input := make([]byte, 32) - copy(input[12:], address.Bytes()) - addr := params.StakingContractAddress + data := make([]byte, 32) + amount.FillBytes(data) + addr := address msg := &Message{ - From: params.SystemAddress, + From: params.SystemAddress, + // Value: amount, GasLimit: 30_000_000, GasPrice: common.Big0, GasFeeCap: common.Big0, GasTipCap: common.Big0, To: &addr, - Data: append(params.StakingContractCallData, input...), + Data: data, } evm.SetTxContext(NewEVMTxContext(msg)) evm.StateDB.AddAddressToAccessList(addr) evm.StateDB.AddBalance( - params.StakingContractAddress, + address, uint256.NewInt(0).SetBytes(amount.Bytes()), tracing.BalanceIncreaseRewardMineBlock, ) diff --git a/params/protocol_params.go b/params/protocol_params.go index c5bde58510..6b06dadaef 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -211,8 +211,4 @@ var ( // EIP-7251 - Increase the MAX_EFFECTIVE_BALANCE ConsolidationQueueAddress = common.HexToAddress("0x0000BBdDc7CE488642fb579F8B00f3a590007251") ConsolidationQueueCode = common.FromHex("3373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd") - - StakingContractAddress = common.HexToAddress("0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512") - // StakingContractCode = common.FromHex("3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500") - StakingContractCallData = common.FromHex("1de9d9b6") ) From 21ffa45b6fc5cdc80c1e5cd431376fb2d16b4a62 Mon Sep 17 00:00:00 2001 From: pinardZ Date: Fri, 30 May 2025 17:08:07 +0800 Subject: [PATCH 3/4] chain config add DelegationActivationTime --- cmd/evm/internal/t8ntool/execution.go | 23 +- cmd/geth/chaincmd.go | 5 + cmd/geth/config.go | 4 + cmd/geth/main.go | 1 + cmd/utils/flags.go | 5 + consensus/beacon/consensus.go | 9 +- core/chain_makers.go | 14 +- core/genesis.go | 8 +- core/state_processor.go | 14 +- eth/backend.go | 3 + eth/ethconfig/config.go | 3 + eth/ethconfig/gen_config.go | 6 + internal/ethapi/simulate.go | 14 +- miner/worker.go | 14 +- params/config.go | 488 +++++++++++++------------- 15 files changed, 338 insertions(+), 273 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 98b7d9e337..cbff2184bb 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -346,11 +346,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, } // Apply withdrawals for _, w := range pre.Env.Withdrawals { + if chainConfig.IsDelegationActive(vmContext.BlockNumber, vmContext.Time) { + if w.Validator == gomath.MaxUint64 { + continue + } + } // Amount is in gwei, turn into wei amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if w.Validator != gomath.MaxUint64 { - statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal) - } + statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal) } // Gather the execution-layer triggered requests. @@ -365,12 +368,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, if err := core.ParseDepositLogs(&requests, allLogs, chainConfig); err != nil { return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err)) } - if len(pre.Env.Withdrawals) > 0 { - w := pre.Env.Withdrawals[0] - if w.Validator == gomath.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { - log.Error("could not process staking distribution", "err", err) + if chainConfig.IsDelegationActive(vmContext.BlockNumber, vmContext.Time) { + if len(pre.Env.Withdrawals) > 0 { + w := pre.Env.Withdrawals[0] + if w.Validator == gomath.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } } } } diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index a947f35f2f..cf1933151f 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -55,6 +55,7 @@ var ( utils.CachePreimagesFlag, utils.OverridePrague, utils.OverrideVerkle, + utils.OverrideDelegationActivation, }, utils.DatabaseFlags), Description: ` The init command initializes a new genesis block and definition for the network. @@ -236,6 +237,10 @@ func initGenesis(ctx *cli.Context) error { v := ctx.Uint64(utils.OverrideVerkle.Name) overrides.OverrideVerkle = &v } + if ctx.IsSet(utils.OverrideDelegationActivation.Name) { + v := ctx.Uint64(utils.OverrideDelegationActivation.Name) + overrides.OverrideDelegationActivation = &v + } chaindb, err := stack.OpenDatabaseWithFreezer("chaindata", 0, 0, ctx.String(utils.AncientFlag.Name), "", false) if err != nil { diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 4215403234..5e21540cb8 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -191,6 +191,10 @@ func makeFullNode(ctx *cli.Context) *node.Node { v := ctx.Uint64(utils.OverrideVerkle.Name) cfg.Eth.OverrideVerkle = &v } + if ctx.IsSet(utils.OverrideDelegationActivation.Name) { + v := ctx.Uint64(utils.OverrideDelegationActivation.Name) + cfg.Eth.OverrideDelegationActivation = &v + } // Start metrics export if enabled utils.SetupMetrics(&cfg.Metrics) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 289030ae65..a7ebd0e322 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -64,6 +64,7 @@ var ( utils.SmartCardDaemonPathFlag, utils.OverridePrague, utils.OverrideVerkle, + utils.OverrideDelegationActivation, utils.EnablePersonal, // deprecated utils.TxPoolLocalsFlag, utils.TxPoolNoLocalsFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b26f43b376..0d837e1947 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -248,6 +248,11 @@ var ( Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } + OverrideDelegationActivation = &cli.Uint64Flag{ + Name: "override.delegationActivation", + Usage: "Manually specify the Delegation Activation timestamp, overriding the bundled setting", + Category: flags.EthCategory, + } SyncModeFlag = &cli.StringFlag{ Name: "syncmode", Usage: `Blockchain sync mode ("snap" or "full")`, diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 7963b9df17..a99c76080c 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -345,12 +345,15 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. } // Withdrawals processing. for _, w := range body.Withdrawals { + if chain.Config().IsDelegationActive(header.Number, header.Time) { + if w.Validator == math.MaxUint64 { + continue + } + } // Convert amount from gwei to wei. amount := new(uint256.Int).SetUint64(w.Amount) amount = amount.Mul(amount, uint256.NewInt(params.GWei)) - if w.Validator != math.MaxUint64 { - state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal) - } + state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal) } // No block reward which is issued by consensus layer instead. } diff --git a/core/chain_makers.go b/core/chain_makers.go index 90a28cf92c..fbd85afc89 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -329,12 +329,14 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { // create EVM for system calls blockContext := NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase) evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{}) - if len(b.withdrawals) > 0 { - w := b.withdrawals[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { - log.Error("could not process staking distribution", "err", err) + if b.cm.config.IsDelegationActive(b.header.Number, b.header.Time) { + if len(b.withdrawals) > 0 { + w := b.withdrawals[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } } } } diff --git a/core/genesis.go b/core/genesis.go index 080f8a3c5f..35a62ccc63 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -258,8 +258,9 @@ func (e *GenesisMismatchError) Error() string { // ChainOverrides contains the changes to chain config. type ChainOverrides struct { - OverridePrague *uint64 - OverrideVerkle *uint64 + OverridePrague *uint64 + OverrideVerkle *uint64 + OverrideDelegationActivation *uint64 } // apply applies the chain overrides on the supplied chain config. @@ -273,6 +274,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error { if o.OverrideVerkle != nil { cfg.VerkleTime = o.OverrideVerkle } + if o.OverrideDelegationActivation != nil { + cfg.DelegationActivationTime = o.OverrideDelegationActivation + } return cfg.CheckConfigForkOrder() } diff --git a/core/state_processor.go b/core/state_processor.go index 9090ed60c9..c2b77972a6 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -115,12 +115,14 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg if err := ParseDepositLogs(&requests, allLogs, p.config); err != nil { return nil, err } - if len(block.Withdrawals()) > 0 { - w := block.Withdrawals()[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { - log.Error("could not process staking distribution", "err", err) + if p.config.IsDelegationActive(block.Number(), block.Time()) { + if len(block.Withdrawals()) > 0 { + w := block.Withdrawals()[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } } } } diff --git a/eth/backend.go b/eth/backend.go index 6d1b6bae99..4b5887bd9e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -226,6 +226,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.OverrideVerkle != nil { overrides.OverrideVerkle = config.OverrideVerkle } + if config.OverrideDelegationActivation != nil { + overrides.OverrideDelegationActivation = config.OverrideDelegationActivation + } eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, &config.TransactionHistory) if err != nil { return nil, err diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 5e19824135..5ded6db1cd 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -162,6 +162,9 @@ type Config struct { // OverrideVerkle (TODO: remove after the fork) OverrideVerkle *uint64 `toml:",omitempty"` + + // OverrideDelegationActivation (TODO: remove after the fork) + OverrideDelegationActivation *uint64 `toml:",omitempty"` } // CreateConsensusEngine creates a consensus engine for the given chain config. diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index cdcddcc772..317f1fd277 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -55,6 +55,7 @@ func (c Config) MarshalTOML() (interface{}, error) { RPCTxFeeCap float64 OverridePrague *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` + OverrideDelegationActivation *uint64 `toml:",omitempty"` } var enc Config enc.Genesis = c.Genesis @@ -95,6 +96,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.RPCTxFeeCap = c.RPCTxFeeCap enc.OverridePrague = c.OverridePrague enc.OverrideVerkle = c.OverrideVerkle + enc.OverrideDelegationActivation = c.OverrideDelegationActivation return &enc, nil } @@ -139,6 +141,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { RPCTxFeeCap *float64 OverridePrague *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` + OverrideDelegationActivation *uint64 `toml:",omitempty"` } var dec Config if err := unmarshal(&dec); err != nil { @@ -258,5 +261,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.OverrideVerkle != nil { c.OverrideVerkle = dec.OverrideVerkle } + if dec.OverrideDelegationActivation != nil { + c.OverrideDelegationActivation = dec.OverrideDelegationActivation + } return nil } diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index cde74747db..56fbe4011e 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -334,12 +334,14 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil { return nil, nil, nil, err } - if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 { - w := (*block.BlockOverrides.Withdrawals)[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { - log.Error("could not process staking distribution", "err", err) + if sim.chainConfig.IsDelegationActive(header.Number, header.Time) { + if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 { + w := (*block.BlockOverrides.Withdrawals)[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } } } } diff --git a/miner/worker.go b/miner/worker.go index d22edc812f..22ea492229 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -128,12 +128,14 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo if err := core.ParseDepositLogs(&requests, allLogs, miner.chainConfig); err != nil { return &newPayloadResult{err: err} } - if len(params.withdrawals) > 0 { - w := params.withdrawals[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei)) - if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil { - log.Error("could not process staking distribution", "err", err) + if miner.chainConfig.IsDelegationActive(work.header.Number, work.header.Time) { + if len(params.withdrawals) > 0 { + w := params.withdrawals[0] + if w.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei)) + if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil { + log.Error("could not process staking distribution", "err", err) + } } } } diff --git a/params/config.go b/params/config.go index 2e825ffcd5..3e87daabb6 100644 --- a/params/config.go +++ b/params/config.go @@ -41,28 +41,29 @@ var ( // MainnetChainConfig is the chain parameters to run a node on the main network. MainnetChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(1_150_000), - DAOForkBlock: big.NewInt(1_920_000), - DAOForkSupport: true, - EIP150Block: big.NewInt(2_463_000), - EIP155Block: big.NewInt(2_675_000), - EIP158Block: big.NewInt(2_675_000), - ByzantiumBlock: big.NewInt(4_370_000), - ConstantinopleBlock: big.NewInt(7_280_000), - PetersburgBlock: big.NewInt(7_280_000), - IstanbulBlock: big.NewInt(9_069_000), - MuirGlacierBlock: big.NewInt(9_200_000), - BerlinBlock: big.NewInt(12_244_000), - LondonBlock: big.NewInt(12_965_000), - ArrowGlacierBlock: big.NewInt(13_773_000), - GrayGlacierBlock: big.NewInt(15_050_000), - TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 - ShanghaiTime: newUint64(1681338455), - CancunTime: newUint64(1710338135), - PragueTime: newUint64(1746612311), - DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"), - Ethash: new(EthashConfig), + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(1_150_000), + DAOForkBlock: big.NewInt(1_920_000), + DAOForkSupport: true, + EIP150Block: big.NewInt(2_463_000), + EIP155Block: big.NewInt(2_675_000), + EIP158Block: big.NewInt(2_675_000), + ByzantiumBlock: big.NewInt(4_370_000), + ConstantinopleBlock: big.NewInt(7_280_000), + PetersburgBlock: big.NewInt(7_280_000), + IstanbulBlock: big.NewInt(9_069_000), + MuirGlacierBlock: big.NewInt(9_200_000), + BerlinBlock: big.NewInt(12_244_000), + LondonBlock: big.NewInt(12_965_000), + ArrowGlacierBlock: big.NewInt(13_773_000), + GrayGlacierBlock: big.NewInt(15_050_000), + TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 + ShanghaiTime: newUint64(1681338455), + CancunTime: newUint64(1710338135), + PragueTime: newUint64(1746612311), + DelegationActivationTime: newUint64(1746612311), + DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"), + Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -70,29 +71,30 @@ var ( } // HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network. HoleskyChainConfig = &ChainConfig{ - ChainID: big.NewInt(17000), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: nil, - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(0), - MergeNetsplitBlock: nil, - ShanghaiTime: newUint64(1696000704), - CancunTime: newUint64(1707305664), - PragueTime: newUint64(1740434112), - DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"), - Ethash: new(EthashConfig), + ChainID: big.NewInt(17000), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: nil, + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(0), + MergeNetsplitBlock: nil, + ShanghaiTime: newUint64(1696000704), + CancunTime: newUint64(1707305664), + PragueTime: newUint64(1740434112), + DelegationActivationTime: newUint64(1740434112), + DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"), + Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -100,29 +102,30 @@ var ( } // SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network. SepoliaChainConfig = &ChainConfig{ - ChainID: big.NewInt(11155111), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), - MergeNetsplitBlock: big.NewInt(1735371), - ShanghaiTime: newUint64(1677557088), - CancunTime: newUint64(1706655072), - PragueTime: newUint64(1741159776), - DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"), - Ethash: new(EthashConfig), + ChainID: big.NewInt(11155111), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), + MergeNetsplitBlock: big.NewInt(1735371), + ShanghaiTime: newUint64(1677557088), + CancunTime: newUint64(1706655072), + PragueTime: newUint64(1741159776), + DelegationActivationTime: newUint64(1741159776), + DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"), + Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -130,29 +133,30 @@ var ( } // HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network. HoodiChainConfig = &ChainConfig{ - ChainID: big.NewInt(560048), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - PragueTime: newUint64(1742999832), - DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), - Ethash: new(EthashConfig), + ChainID: big.NewInt(560048), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + PragueTime: newUint64(1742999832), + DelegationActivationTime: newUint64(1742999832), + DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), + Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -161,52 +165,54 @@ var ( // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. AllEthashProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, - OsakaTime: nil, - VerkleTime: nil, - Ethash: new(EthashConfig), - Clique: nil, + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + DelegationActivationTime: nil, + OsakaTime: nil, + VerkleTime: nil, + Ethash: new(EthashConfig), + Clique: nil, } AllDevChainProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - TerminalTotalDifficulty: big.NewInt(0), - PragueTime: newUint64(0), + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + TerminalTotalDifficulty: big.NewInt(0), + PragueTime: newUint64(0), + DelegationActivationTime: newUint64(0), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -216,91 +222,94 @@ var ( // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. AllCliqueProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: nil, - Clique: &CliqueConfig{Period: 0, Epoch: 30000}, + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + DelegationActivationTime: nil, + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: nil, + Clique: &CliqueConfig{Period: 0, Epoch: 30000}, } // TestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. TestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: new(EthashConfig), - Clique: nil, + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + DelegationActivationTime: nil, + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: new(EthashConfig), + Clique: nil, } // MergedTestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. MergedTestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - PragueTime: newUint64(0), - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(0), - Ethash: new(EthashConfig), - Clique: nil, + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + PragueTime: newUint64(0), + DelegationActivationTime: newUint64(0), + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(0), + Ethash: new(EthashConfig), + Clique: nil, BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -310,31 +319,32 @@ var ( // NonActivatedConfig defines the chain configuration without activating // any protocol change (EIPs). NonActivatedConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: nil, - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: nil, - EIP155Block: nil, - EIP158Block: nil, - ByzantiumBlock: nil, - ConstantinopleBlock: nil, - PetersburgBlock: nil, - IstanbulBlock: nil, - MuirGlacierBlock: nil, - BerlinBlock: nil, - LondonBlock: nil, - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: new(EthashConfig), - Clique: nil, + ChainID: big.NewInt(1), + HomesteadBlock: nil, + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: nil, + EIP155Block: nil, + EIP158Block: nil, + ByzantiumBlock: nil, + ConstantinopleBlock: nil, + PetersburgBlock: nil, + IstanbulBlock: nil, + MuirGlacierBlock: nil, + BerlinBlock: nil, + LondonBlock: nil, + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + DelegationActivationTime: newUint64(0), + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: new(EthashConfig), + Clique: nil, } TestRules = TestChainConfig.Rules(new(big.Int), false, 0) ) @@ -415,7 +425,8 @@ type ChainConfig struct { // the network that triggers the consensus upgrade. TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty,omitempty"` - DepositContractAddress common.Address `json:"depositContractAddress,omitempty"` + DepositContractAddress common.Address `json:"depositContractAddress,omitempty"` + DelegationActivationTime *uint64 `json:"delegationActivationTime,omitempty"` // EnableVerkleAtGenesis is a flag that specifies whether the network uses // the Verkle tree starting from the genesis block. If set to true, the @@ -530,6 +541,9 @@ func (c *ChainConfig) Description() string { if c.VerkleTime != nil { banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime) } + if c.DelegationActivationTime != nil { + banner += fmt.Sprintf(" - DelegationActivationTime: @%-10v\n", *c.DelegationActivationTime) + } return banner } @@ -643,6 +657,10 @@ func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool { return c.IsLondon(num) && isTimestampForked(c.PragueTime, time) } +func (c *ChainConfig) IsDelegationActive(num *big.Int, time uint64) bool { + return c.IsPrague(num, time) && (c.DelegationActivationTime != nil) && (time >= *c.DelegationActivationTime) +} + // IsOsaka returns whether time is either equal to the Osaka fork time or greater. func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool { return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time) From c758f7a13fe746462557b0cd9473bd3ca1ade29c Mon Sep 17 00:00:00 2001 From: pinardZ Date: Wed, 4 Jun 2025 00:29:12 +0800 Subject: [PATCH 4/4] rename some variables --- cmd/evm/internal/t8ntool/execution.go | 8 +- core/chain_makers.go | 8 +- core/state_processor.go | 8 +- internal/ethapi/simulate.go | 8 +- miner/worker.go | 8 +- params/config.go | 485 +++++++++++++------------- 6 files changed, 268 insertions(+), 257 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index cbff2184bb..5ff5b07a0c 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -370,10 +370,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, } if chainConfig.IsDelegationActive(vmContext.BlockNumber, vmContext.Time) { if len(pre.Env.Withdrawals) > 0 { - w := pre.Env.Withdrawals[0] - if w.Validator == gomath.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + firstWithdrawal := pre.Env.Withdrawals[0] + if firstWithdrawal.Validator == gomath.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(firstWithdrawal.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, firstWithdrawal.Address, amount); err != nil { log.Error("could not process staking distribution", "err", err) } } diff --git a/core/chain_makers.go b/core/chain_makers.go index fbd85afc89..67d06740d8 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -331,10 +331,10 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{}) if b.cm.config.IsDelegationActive(b.header.Number, b.header.Time) { if len(b.withdrawals) > 0 { - w := b.withdrawals[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + firstWithdrawal := b.withdrawals[0] + if firstWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(firstWithdrawal.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, firstWithdrawal.Address, amount); err != nil { log.Error("could not process staking distribution", "err", err) } } diff --git a/core/state_processor.go b/core/state_processor.go index c2b77972a6..0bd6bfeddf 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -117,10 +117,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } if p.config.IsDelegationActive(block.Number(), block.Time()) { if len(block.Withdrawals()) > 0 { - w := block.Withdrawals()[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { + firstWithdrawal := block.Withdrawals()[0] + if firstWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(firstWithdrawal.Amount), big.NewInt(params.GWei)) + if err := ProcessStakingDistribution(evm, firstWithdrawal.Address, amount); err != nil { log.Error("could not process staking distribution", "err", err) } } diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index 56fbe4011e..6dad0ebff4 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -336,10 +336,10 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, } if sim.chainConfig.IsDelegationActive(header.Number, header.Time) { if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 { - w := (*block.BlockOverrides.Withdrawals)[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) - if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { + firstWithdrawal := (*block.BlockOverrides.Withdrawals)[0] + if firstWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(firstWithdrawal.Amount), big.NewInt(params.GWei)) + if err := core.ProcessStakingDistribution(evm, firstWithdrawal.Address, amount); err != nil { log.Error("could not process staking distribution", "err", err) } } diff --git a/miner/worker.go b/miner/worker.go index 22ea492229..e5db9341c6 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -130,10 +130,10 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo } if miner.chainConfig.IsDelegationActive(work.header.Number, work.header.Time) { if len(params.withdrawals) > 0 { - w := params.withdrawals[0] - if w.Validator == math.MaxUint64 { - amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei)) - if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil { + firstWithdrawal := params.withdrawals[0] + if firstWithdrawal.Validator == math.MaxUint64 { + amount := new(big.Int).Mul(new(big.Int).SetUint64(firstWithdrawal.Amount), big.NewInt(ethparams.GWei)) + if err := core.ProcessStakingDistribution(work.evm, firstWithdrawal.Address, amount); err != nil { log.Error("could not process staking distribution", "err", err) } } diff --git a/params/config.go b/params/config.go index 3e87daabb6..7c55786b77 100644 --- a/params/config.go +++ b/params/config.go @@ -41,29 +41,30 @@ var ( // MainnetChainConfig is the chain parameters to run a node on the main network. MainnetChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(1_150_000), - DAOForkBlock: big.NewInt(1_920_000), - DAOForkSupport: true, - EIP150Block: big.NewInt(2_463_000), - EIP155Block: big.NewInt(2_675_000), - EIP158Block: big.NewInt(2_675_000), - ByzantiumBlock: big.NewInt(4_370_000), - ConstantinopleBlock: big.NewInt(7_280_000), - PetersburgBlock: big.NewInt(7_280_000), - IstanbulBlock: big.NewInt(9_069_000), - MuirGlacierBlock: big.NewInt(9_200_000), - BerlinBlock: big.NewInt(12_244_000), - LondonBlock: big.NewInt(12_965_000), - ArrowGlacierBlock: big.NewInt(13_773_000), - GrayGlacierBlock: big.NewInt(15_050_000), - TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 - ShanghaiTime: newUint64(1681338455), - CancunTime: newUint64(1710338135), - PragueTime: newUint64(1746612311), + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(1_150_000), + DAOForkBlock: big.NewInt(1_920_000), + DAOForkSupport: true, + EIP150Block: big.NewInt(2_463_000), + EIP155Block: big.NewInt(2_675_000), + EIP158Block: big.NewInt(2_675_000), + ByzantiumBlock: big.NewInt(4_370_000), + ConstantinopleBlock: big.NewInt(7_280_000), + PetersburgBlock: big.NewInt(7_280_000), + IstanbulBlock: big.NewInt(9_069_000), + MuirGlacierBlock: big.NewInt(9_200_000), + BerlinBlock: big.NewInt(12_244_000), + LondonBlock: big.NewInt(12_965_000), + ArrowGlacierBlock: big.NewInt(13_773_000), + GrayGlacierBlock: big.NewInt(15_050_000), + TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 + ShanghaiTime: newUint64(1681338455), + CancunTime: newUint64(1710338135), + PragueTime: newUint64(1746612311), + DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"), + Ethash: new(EthashConfig), + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(1746612311), - DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"), - Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -71,30 +72,31 @@ var ( } // HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network. HoleskyChainConfig = &ChainConfig{ - ChainID: big.NewInt(17000), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: nil, - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(0), - MergeNetsplitBlock: nil, - ShanghaiTime: newUint64(1696000704), - CancunTime: newUint64(1707305664), - PragueTime: newUint64(1740434112), + ChainID: big.NewInt(17000), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: nil, + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(0), + MergeNetsplitBlock: nil, + ShanghaiTime: newUint64(1696000704), + CancunTime: newUint64(1707305664), + PragueTime: newUint64(1740434112), + DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"), + Ethash: new(EthashConfig), + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(1740434112), - DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"), - Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -102,30 +104,31 @@ var ( } // SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network. SepoliaChainConfig = &ChainConfig{ - ChainID: big.NewInt(11155111), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), - MergeNetsplitBlock: big.NewInt(1735371), - ShanghaiTime: newUint64(1677557088), - CancunTime: newUint64(1706655072), - PragueTime: newUint64(1741159776), + ChainID: big.NewInt(11155111), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), + MergeNetsplitBlock: big.NewInt(1735371), + ShanghaiTime: newUint64(1677557088), + CancunTime: newUint64(1706655072), + PragueTime: newUint64(1741159776), + DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"), + Ethash: new(EthashConfig), + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(1741159776), - DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"), - Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -133,30 +136,31 @@ var ( } // HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network. HoodiChainConfig = &ChainConfig{ - ChainID: big.NewInt(560048), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - PragueTime: newUint64(1742999832), + ChainID: big.NewInt(560048), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + PragueTime: newUint64(1742999832), + DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), + Ethash: new(EthashConfig), + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(1742999832), - DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), - Ethash: new(EthashConfig), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -165,53 +169,55 @@ var ( // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. AllEthashProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + OsakaTime: nil, + VerkleTime: nil, + Ethash: new(EthashConfig), + Clique: nil, + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: nil, - OsakaTime: nil, - VerkleTime: nil, - Ethash: new(EthashConfig), - Clique: nil, } AllDevChainProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - TerminalTotalDifficulty: big.NewInt(0), - PragueTime: newUint64(0), + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + TerminalTotalDifficulty: big.NewInt(0), + PragueTime: newUint64(0), + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(0), BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, @@ -222,94 +228,97 @@ var ( // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. AllCliqueProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: nil, + Clique: &CliqueConfig{Period: 0, Epoch: 30000}, + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: nil, - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: nil, - Clique: &CliqueConfig{Period: 0, Epoch: 30000}, } // TestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. TestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: new(EthashConfig), + Clique: nil, + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: nil, - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: new(EthashConfig), - Clique: nil, } // MergedTestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. MergedTestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - PragueTime: newUint64(0), + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + PragueTime: newUint64(0), + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(0), + Ethash: new(EthashConfig), + Clique: nil, + // DelegationActivationTime is the activation time of Delegation logic DelegationActivationTime: newUint64(0), - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(0), - Ethash: new(EthashConfig), - Clique: nil, BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfig, @@ -319,32 +328,33 @@ var ( // NonActivatedConfig defines the chain configuration without activating // any protocol change (EIPs). NonActivatedConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: nil, - DAOForkBlock: nil, - DAOForkSupport: false, - EIP150Block: nil, - EIP155Block: nil, - EIP158Block: nil, - ByzantiumBlock: nil, - ConstantinopleBlock: nil, - PetersburgBlock: nil, - IstanbulBlock: nil, - MuirGlacierBlock: nil, - BerlinBlock: nil, - LondonBlock: nil, - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - MergeNetsplitBlock: nil, - ShanghaiTime: nil, - CancunTime: nil, - PragueTime: nil, - DelegationActivationTime: newUint64(0), - OsakaTime: nil, - VerkleTime: nil, - TerminalTotalDifficulty: big.NewInt(math.MaxInt64), - Ethash: new(EthashConfig), - Clique: nil, + ChainID: big.NewInt(1), + HomesteadBlock: nil, + DAOForkBlock: nil, + DAOForkSupport: false, + EIP150Block: nil, + EIP155Block: nil, + EIP158Block: nil, + ByzantiumBlock: nil, + ConstantinopleBlock: nil, + PetersburgBlock: nil, + IstanbulBlock: nil, + MuirGlacierBlock: nil, + BerlinBlock: nil, + LondonBlock: nil, + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + MergeNetsplitBlock: nil, + ShanghaiTime: nil, + CancunTime: nil, + PragueTime: nil, + OsakaTime: nil, + VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(math.MaxInt64), + Ethash: new(EthashConfig), + Clique: nil, + // DelegationActivationTime is the activation time of Delegation logic + DelegationActivationTime: nil, } TestRules = TestChainConfig.Rules(new(big.Int), false, 0) ) @@ -425,8 +435,9 @@ type ChainConfig struct { // the network that triggers the consensus upgrade. TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty,omitempty"` - DepositContractAddress common.Address `json:"depositContractAddress,omitempty"` - DelegationActivationTime *uint64 `json:"delegationActivationTime,omitempty"` + DepositContractAddress common.Address `json:"depositContractAddress,omitempty"` + // DelegationActivationTime is the activation time of Delegation logic + DelegationActivationTime *uint64 `json:"DelegationActivationTime,omitempty"` // EnableVerkleAtGenesis is a flag that specifies whether the network uses // the Verkle tree starting from the genesis block. If set to true, the