chain config add DelegationActivationTime

This commit is contained in:
pinardZ 2025-05-30 17:08:07 +08:00
parent ccc130f82f
commit 21ffa45b6f
15 changed files with 338 additions and 273 deletions

View file

@ -346,11 +346,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
} }
// Apply withdrawals // Apply withdrawals
for _, w := range pre.Env.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 is in gwei, turn into wei
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) 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. // 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 { if err := core.ParseDepositLogs(&requests, allLogs, chainConfig); err != nil {
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err)) return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err))
} }
if len(pre.Env.Withdrawals) > 0 { if chainConfig.IsDelegationActive(vmContext.BlockNumber, vmContext.Time) {
w := pre.Env.Withdrawals[0] if len(pre.Env.Withdrawals) > 0 {
if w.Validator == gomath.MaxUint64 { w := pre.Env.Withdrawals[0]
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) if w.Validator == gomath.MaxUint64 {
if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
log.Error("could not process staking distribution", "err", err) if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil {
log.Error("could not process staking distribution", "err", err)
}
} }
} }
} }

View file

@ -55,6 +55,7 @@ var (
utils.CachePreimagesFlag, utils.CachePreimagesFlag,
utils.OverridePrague, utils.OverridePrague,
utils.OverrideVerkle, utils.OverrideVerkle,
utils.OverrideDelegationActivation,
}, utils.DatabaseFlags), }, utils.DatabaseFlags),
Description: ` Description: `
The init command initializes a new genesis block and definition for the network. 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) v := ctx.Uint64(utils.OverrideVerkle.Name)
overrides.OverrideVerkle = &v 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) chaindb, err := stack.OpenDatabaseWithFreezer("chaindata", 0, 0, ctx.String(utils.AncientFlag.Name), "", false)
if err != nil { if err != nil {

View file

@ -191,6 +191,10 @@ func makeFullNode(ctx *cli.Context) *node.Node {
v := ctx.Uint64(utils.OverrideVerkle.Name) v := ctx.Uint64(utils.OverrideVerkle.Name)
cfg.Eth.OverrideVerkle = &v 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 // Start metrics export if enabled
utils.SetupMetrics(&cfg.Metrics) utils.SetupMetrics(&cfg.Metrics)

View file

@ -64,6 +64,7 @@ var (
utils.SmartCardDaemonPathFlag, utils.SmartCardDaemonPathFlag,
utils.OverridePrague, utils.OverridePrague,
utils.OverrideVerkle, utils.OverrideVerkle,
utils.OverrideDelegationActivation,
utils.EnablePersonal, // deprecated utils.EnablePersonal, // deprecated
utils.TxPoolLocalsFlag, utils.TxPoolLocalsFlag,
utils.TxPoolNoLocalsFlag, utils.TxPoolNoLocalsFlag,

View file

@ -248,6 +248,11 @@ var (
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting", Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
Category: flags.EthCategory, 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{ SyncModeFlag = &cli.StringFlag{
Name: "syncmode", Name: "syncmode",
Usage: `Blockchain sync mode ("snap" or "full")`, Usage: `Blockchain sync mode ("snap" or "full")`,

View file

@ -345,12 +345,15 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
} }
// Withdrawals processing. // Withdrawals processing.
for _, w := range body.Withdrawals { 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. // Convert amount from gwei to wei.
amount := new(uint256.Int).SetUint64(w.Amount) amount := new(uint256.Int).SetUint64(w.Amount)
amount = amount.Mul(amount, uint256.NewInt(params.GWei)) 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. // No block reward which is issued by consensus layer instead.
} }

View file

@ -329,12 +329,14 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) {
// create EVM for system calls // create EVM for system calls
blockContext := NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase) blockContext := NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase)
evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{}) evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{})
if len(b.withdrawals) > 0 { if b.cm.config.IsDelegationActive(b.header.Number, b.header.Time) {
w := b.withdrawals[0] if len(b.withdrawals) > 0 {
if w.Validator == math.MaxUint64 { w := b.withdrawals[0]
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) if w.Validator == math.MaxUint64 {
if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
log.Error("could not process staking distribution", "err", err) if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil {
log.Error("could not process staking distribution", "err", err)
}
} }
} }
} }

View file

@ -258,8 +258,9 @@ func (e *GenesisMismatchError) Error() string {
// ChainOverrides contains the changes to chain config. // ChainOverrides contains the changes to chain config.
type ChainOverrides struct { type ChainOverrides struct {
OverridePrague *uint64 OverridePrague *uint64
OverrideVerkle *uint64 OverrideVerkle *uint64
OverrideDelegationActivation *uint64
} }
// apply applies the chain overrides on the supplied chain config. // 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 { if o.OverrideVerkle != nil {
cfg.VerkleTime = o.OverrideVerkle cfg.VerkleTime = o.OverrideVerkle
} }
if o.OverrideDelegationActivation != nil {
cfg.DelegationActivationTime = o.OverrideDelegationActivation
}
return cfg.CheckConfigForkOrder() return cfg.CheckConfigForkOrder()
} }

View file

@ -115,12 +115,14 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
if err := ParseDepositLogs(&requests, allLogs, p.config); err != nil { if err := ParseDepositLogs(&requests, allLogs, p.config); err != nil {
return nil, err return nil, err
} }
if len(block.Withdrawals()) > 0 { if p.config.IsDelegationActive(block.Number(), block.Time()) {
w := block.Withdrawals()[0] if len(block.Withdrawals()) > 0 {
if w.Validator == math.MaxUint64 { w := block.Withdrawals()[0]
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) if w.Validator == math.MaxUint64 {
if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil { amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
log.Error("could not process staking distribution", "err", err) if err := ProcessStakingDistribution(evm, w.Address, amount); err != nil {
log.Error("could not process staking distribution", "err", err)
}
} }
} }
} }

View file

@ -226,6 +226,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.OverrideVerkle != nil { if config.OverrideVerkle != nil {
overrides.OverrideVerkle = config.OverrideVerkle 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) eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, &config.TransactionHistory)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -162,6 +162,9 @@ type Config struct {
// OverrideVerkle (TODO: remove after the fork) // OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"`
// OverrideDelegationActivation (TODO: remove after the fork)
OverrideDelegationActivation *uint64 `toml:",omitempty"`
} }
// CreateConsensusEngine creates a consensus engine for the given chain config. // CreateConsensusEngine creates a consensus engine for the given chain config.

View file

@ -55,6 +55,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
RPCTxFeeCap float64 RPCTxFeeCap float64
OverridePrague *uint64 `toml:",omitempty"` OverridePrague *uint64 `toml:",omitempty"`
OverrideVerkle *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"`
OverrideDelegationActivation *uint64 `toml:",omitempty"`
} }
var enc Config var enc Config
enc.Genesis = c.Genesis enc.Genesis = c.Genesis
@ -95,6 +96,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.RPCTxFeeCap = c.RPCTxFeeCap enc.RPCTxFeeCap = c.RPCTxFeeCap
enc.OverridePrague = c.OverridePrague enc.OverridePrague = c.OverridePrague
enc.OverrideVerkle = c.OverrideVerkle enc.OverrideVerkle = c.OverrideVerkle
enc.OverrideDelegationActivation = c.OverrideDelegationActivation
return &enc, nil return &enc, nil
} }
@ -139,6 +141,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
RPCTxFeeCap *float64 RPCTxFeeCap *float64
OverridePrague *uint64 `toml:",omitempty"` OverridePrague *uint64 `toml:",omitempty"`
OverrideVerkle *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"`
OverrideDelegationActivation *uint64 `toml:",omitempty"`
} }
var dec Config var dec Config
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
@ -258,5 +261,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.OverrideVerkle != nil { if dec.OverrideVerkle != nil {
c.OverrideVerkle = dec.OverrideVerkle c.OverrideVerkle = dec.OverrideVerkle
} }
if dec.OverrideDelegationActivation != nil {
c.OverrideDelegationActivation = dec.OverrideDelegationActivation
}
return nil return nil
} }

View file

@ -334,12 +334,14 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil { if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 { if sim.chainConfig.IsDelegationActive(header.Number, header.Time) {
w := (*block.BlockOverrides.Withdrawals)[0] if block.BlockOverrides.Withdrawals != nil && len(*block.BlockOverrides.Withdrawals) > 0 {
if w.Validator == math.MaxUint64 { w := (*block.BlockOverrides.Withdrawals)[0]
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei)) if w.Validator == math.MaxUint64 {
if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil { amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
log.Error("could not process staking distribution", "err", err) if err := core.ProcessStakingDistribution(evm, w.Address, amount); err != nil {
log.Error("could not process staking distribution", "err", err)
}
} }
} }
} }

View file

@ -128,12 +128,14 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
if err := core.ParseDepositLogs(&requests, allLogs, miner.chainConfig); err != nil { if err := core.ParseDepositLogs(&requests, allLogs, miner.chainConfig); err != nil {
return &newPayloadResult{err: err} return &newPayloadResult{err: err}
} }
if len(params.withdrawals) > 0 { if miner.chainConfig.IsDelegationActive(work.header.Number, work.header.Time) {
w := params.withdrawals[0] if len(params.withdrawals) > 0 {
if w.Validator == math.MaxUint64 { w := params.withdrawals[0]
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei)) if w.Validator == math.MaxUint64 {
if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil { amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(ethparams.GWei))
log.Error("could not process staking distribution", "err", err) if err := core.ProcessStakingDistribution(work.evm, w.Address, amount); err != nil {
log.Error("could not process staking distribution", "err", err)
}
} }
} }
} }

View file

@ -41,28 +41,29 @@ var (
// MainnetChainConfig is the chain parameters to run a node on the main network. // MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &ChainConfig{ MainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(1_150_000), HomesteadBlock: big.NewInt(1_150_000),
DAOForkBlock: big.NewInt(1_920_000), DAOForkBlock: big.NewInt(1_920_000),
DAOForkSupport: true, DAOForkSupport: true,
EIP150Block: big.NewInt(2_463_000), EIP150Block: big.NewInt(2_463_000),
EIP155Block: big.NewInt(2_675_000), EIP155Block: big.NewInt(2_675_000),
EIP158Block: big.NewInt(2_675_000), EIP158Block: big.NewInt(2_675_000),
ByzantiumBlock: big.NewInt(4_370_000), ByzantiumBlock: big.NewInt(4_370_000),
ConstantinopleBlock: big.NewInt(7_280_000), ConstantinopleBlock: big.NewInt(7_280_000),
PetersburgBlock: big.NewInt(7_280_000), PetersburgBlock: big.NewInt(7_280_000),
IstanbulBlock: big.NewInt(9_069_000), IstanbulBlock: big.NewInt(9_069_000),
MuirGlacierBlock: big.NewInt(9_200_000), MuirGlacierBlock: big.NewInt(9_200_000),
BerlinBlock: big.NewInt(12_244_000), BerlinBlock: big.NewInt(12_244_000),
LondonBlock: big.NewInt(12_965_000), LondonBlock: big.NewInt(12_965_000),
ArrowGlacierBlock: big.NewInt(13_773_000), ArrowGlacierBlock: big.NewInt(13_773_000),
GrayGlacierBlock: big.NewInt(15_050_000), GrayGlacierBlock: big.NewInt(15_050_000),
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000 TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000
ShanghaiTime: newUint64(1681338455), ShanghaiTime: newUint64(1681338455),
CancunTime: newUint64(1710338135), CancunTime: newUint64(1710338135),
PragueTime: newUint64(1746612311), PragueTime: newUint64(1746612311),
DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"), DelegationActivationTime: newUint64(1746612311),
Ethash: new(EthashConfig), DepositContractAddress: common.HexToAddress("0x00000000219ab540356cbb839cbe05303d7705fa"),
Ethash: new(EthashConfig),
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -70,29 +71,30 @@ var (
} }
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network. // HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.
HoleskyChainConfig = &ChainConfig{ HoleskyChainConfig = &ChainConfig{
ChainID: big.NewInt(17000), ChainID: big.NewInt(17000),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: true, DAOForkSupport: true,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: nil, MuirGlacierBlock: nil,
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: newUint64(1696000704), ShanghaiTime: newUint64(1696000704),
CancunTime: newUint64(1707305664), CancunTime: newUint64(1707305664),
PragueTime: newUint64(1740434112), PragueTime: newUint64(1740434112),
DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"), DelegationActivationTime: newUint64(1740434112),
Ethash: new(EthashConfig), DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"),
Ethash: new(EthashConfig),
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -100,29 +102,30 @@ var (
} }
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network. // SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
SepoliaChainConfig = &ChainConfig{ SepoliaChainConfig = &ChainConfig{
ChainID: big.NewInt(11155111), ChainID: big.NewInt(11155111),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: true, DAOForkSupport: true,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000), TerminalTotalDifficulty: big.NewInt(17_000_000_000_000_000),
MergeNetsplitBlock: big.NewInt(1735371), MergeNetsplitBlock: big.NewInt(1735371),
ShanghaiTime: newUint64(1677557088), ShanghaiTime: newUint64(1677557088),
CancunTime: newUint64(1706655072), CancunTime: newUint64(1706655072),
PragueTime: newUint64(1741159776), PragueTime: newUint64(1741159776),
DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"), DelegationActivationTime: newUint64(1741159776),
Ethash: new(EthashConfig), DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"),
Ethash: new(EthashConfig),
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -130,29 +133,30 @@ var (
} }
// HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network. // HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network.
HoodiChainConfig = &ChainConfig{ HoodiChainConfig = &ChainConfig{
ChainID: big.NewInt(560048), ChainID: big.NewInt(560048),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: true, DAOForkSupport: true,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
ShanghaiTime: newUint64(0), ShanghaiTime: newUint64(0),
CancunTime: newUint64(0), CancunTime: newUint64(0),
PragueTime: newUint64(1742999832), PragueTime: newUint64(1742999832),
DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), DelegationActivationTime: newUint64(1742999832),
Ethash: new(EthashConfig), DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"),
Ethash: new(EthashConfig),
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -161,52 +165,54 @@ var (
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced // AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus. // and accepted by the Ethereum core developers into the Ethash consensus.
AllEthashProtocolChanges = &ChainConfig{ AllEthashProtocolChanges = &ChainConfig{
ChainID: big.NewInt(1337), ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(math.MaxInt64), TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiTime: nil,
CancunTime: nil, CancunTime: nil,
PragueTime: nil, PragueTime: nil,
OsakaTime: nil, DelegationActivationTime: nil,
VerkleTime: nil, OsakaTime: nil,
Ethash: new(EthashConfig), VerkleTime: nil,
Clique: nil, Ethash: new(EthashConfig),
Clique: nil,
} }
AllDevChainProtocolChanges = &ChainConfig{ AllDevChainProtocolChanges = &ChainConfig{
ChainID: big.NewInt(1337), ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
ShanghaiTime: newUint64(0), ShanghaiTime: newUint64(0),
CancunTime: newUint64(0), CancunTime: newUint64(0),
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
PragueTime: newUint64(0), PragueTime: newUint64(0),
DelegationActivationTime: newUint64(0),
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -216,91 +222,94 @@ var (
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus. // and accepted by the Ethereum core developers into the Clique consensus.
AllCliqueProtocolChanges = &ChainConfig{ AllCliqueProtocolChanges = &ChainConfig{
ChainID: big.NewInt(1337), ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiTime: nil,
CancunTime: nil, CancunTime: nil,
PragueTime: nil, PragueTime: nil,
OsakaTime: nil, DelegationActivationTime: nil,
VerkleTime: nil, OsakaTime: nil,
TerminalTotalDifficulty: big.NewInt(math.MaxInt64), VerkleTime: nil,
Ethash: nil, TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
Clique: &CliqueConfig{Period: 0, Epoch: 30000}, Ethash: nil,
Clique: &CliqueConfig{Period: 0, Epoch: 30000},
} }
// TestChainConfig contains every protocol change (EIPs) introduced // TestChainConfig contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers for testing purposes. // and accepted by the Ethereum core developers for testing purposes.
TestChainConfig = &ChainConfig{ TestChainConfig = &ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiTime: nil,
CancunTime: nil, CancunTime: nil,
PragueTime: nil, PragueTime: nil,
OsakaTime: nil, DelegationActivationTime: nil,
VerkleTime: nil, OsakaTime: nil,
TerminalTotalDifficulty: big.NewInt(math.MaxInt64), VerkleTime: nil,
Ethash: new(EthashConfig), TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
Clique: nil, Ethash: new(EthashConfig),
Clique: nil,
} }
// MergedTestChainConfig contains every protocol change (EIPs) introduced // MergedTestChainConfig contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers for testing purposes. // and accepted by the Ethereum core developers for testing purposes.
MergedTestChainConfig = &ChainConfig{ MergedTestChainConfig = &ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0), HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: big.NewInt(0), EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0), EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0), EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
ShanghaiTime: newUint64(0), ShanghaiTime: newUint64(0),
CancunTime: newUint64(0), CancunTime: newUint64(0),
PragueTime: newUint64(0), PragueTime: newUint64(0),
OsakaTime: nil, DelegationActivationTime: newUint64(0),
VerkleTime: nil, OsakaTime: nil,
TerminalTotalDifficulty: big.NewInt(0), VerkleTime: nil,
Ethash: new(EthashConfig), TerminalTotalDifficulty: big.NewInt(0),
Clique: nil, Ethash: new(EthashConfig),
Clique: nil,
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
@ -310,31 +319,32 @@ var (
// NonActivatedConfig defines the chain configuration without activating // NonActivatedConfig defines the chain configuration without activating
// any protocol change (EIPs). // any protocol change (EIPs).
NonActivatedConfig = &ChainConfig{ NonActivatedConfig = &ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: nil, HomesteadBlock: nil,
DAOForkBlock: nil, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: nil, EIP150Block: nil,
EIP155Block: nil, EIP155Block: nil,
EIP158Block: nil, EIP158Block: nil,
ByzantiumBlock: nil, ByzantiumBlock: nil,
ConstantinopleBlock: nil, ConstantinopleBlock: nil,
PetersburgBlock: nil, PetersburgBlock: nil,
IstanbulBlock: nil, IstanbulBlock: nil,
MuirGlacierBlock: nil, MuirGlacierBlock: nil,
BerlinBlock: nil, BerlinBlock: nil,
LondonBlock: nil, LondonBlock: nil,
ArrowGlacierBlock: nil, ArrowGlacierBlock: nil,
GrayGlacierBlock: nil, GrayGlacierBlock: nil,
MergeNetsplitBlock: nil, MergeNetsplitBlock: nil,
ShanghaiTime: nil, ShanghaiTime: nil,
CancunTime: nil, CancunTime: nil,
PragueTime: nil, PragueTime: nil,
OsakaTime: nil, DelegationActivationTime: newUint64(0),
VerkleTime: nil, OsakaTime: nil,
TerminalTotalDifficulty: big.NewInt(math.MaxInt64), VerkleTime: nil,
Ethash: new(EthashConfig), TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
Clique: nil, Ethash: new(EthashConfig),
Clique: nil,
} }
TestRules = TestChainConfig.Rules(new(big.Int), false, 0) TestRules = TestChainConfig.Rules(new(big.Int), false, 0)
) )
@ -415,7 +425,8 @@ type ChainConfig struct {
// the network that triggers the consensus upgrade. // the network that triggers the consensus upgrade.
TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty,omitempty"` 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 // EnableVerkleAtGenesis is a flag that specifies whether the network uses
// the Verkle tree starting from the genesis block. If set to true, the // 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 { if c.VerkleTime != nil {
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime) banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
} }
if c.DelegationActivationTime != nil {
banner += fmt.Sprintf(" - DelegationActivationTime: @%-10v\n", *c.DelegationActivationTime)
}
return banner return banner
} }
@ -643,6 +657,10 @@ func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.PragueTime, time) 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. // IsOsaka returns whether time is either equal to the Osaka fork time or greater.
func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool { func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time) return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time)