feat: add Prague hardfork (#2718)

This commit is contained in:
buddho 2024-09-23 17:53:32 +08:00 committed by GitHub
parent 8c1acb0b22
commit 27f67a5210
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 45 additions and 3 deletions

@ -65,6 +65,7 @@ var (
utils.OverridePassedForkTime,
utils.OverrideBohr,
utils.OverridePascal,
utils.OverridePrague,
utils.OverrideVerkle,
utils.MultiDataBaseFlag,
}, utils.DatabaseFlags),
@ -267,6 +268,10 @@ func initGenesis(ctx *cli.Context) error {
v := ctx.Uint64(utils.OverridePascal.Name)
overrides.OverridePascal = &v
}
if ctx.IsSet(utils.OverridePrague.Name) {
v := ctx.Uint64(utils.OverridePrague.Name)
overrides.OverridePrague = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
overrides.OverrideVerkle = &v

@ -199,6 +199,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
v := ctx.Uint64(utils.OverridePascal.Name)
cfg.Eth.OverridePascal = &v
}
if ctx.IsSet(utils.OverridePrague.Name) {
v := ctx.Uint64(utils.OverridePrague.Name)
cfg.Eth.OverridePrague = &v
}
if ctx.IsSet(utils.OverrideVerkle.Name) {
v := ctx.Uint64(utils.OverrideVerkle.Name)
cfg.Eth.OverrideVerkle = &v

@ -75,6 +75,7 @@ var (
utils.OverridePassedForkTime,
utils.OverrideBohr,
utils.OverridePascal,
utils.OverridePrague,
utils.OverrideVerkle,
utils.OverrideFullImmutabilityThreshold,
utils.OverrideMinBlocksForBlobRequests,

@ -323,6 +323,11 @@ var (
Usage: "Manually specify the Pascal fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverridePrague = &cli.Uint64Flag{
Name: "override.prague",
Usage: "Manually specify the Prague fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideVerkle = &cli.Uint64Flag{
Name: "override.verkle",
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",

@ -219,6 +219,7 @@ type ChainOverrides struct {
OverridePassedForkTime *uint64
OverrideBohr *uint64
OverridePascal *uint64
OverridePrague *uint64
OverrideVerkle *uint64
}
@ -260,6 +261,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
if overrides != nil && overrides.OverridePascal != nil {
config.PascalTime = overrides.OverridePascal
}
if overrides != nil && overrides.OverridePrague != nil {
config.PragueTime = overrides.OverridePrague
}
if overrides != nil && overrides.OverrideVerkle != nil {
config.VerkleTime = overrides.OverrideVerkle
}

@ -203,6 +203,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
chainConfig.PascalTime = config.OverridePascal
overrides.OverridePascal = config.OverridePascal
}
if config.OverridePrague != nil {
chainConfig.PragueTime = config.OverridePrague
overrides.OverridePrague = config.OverridePrague
}
if config.OverrideVerkle != nil {
chainConfig.VerkleTime = config.OverrideVerkle
overrides.OverrideVerkle = config.OverrideVerkle

@ -197,6 +197,9 @@ type Config struct {
// OverridePascal (TODO: remove after the fork)
OverridePascal *uint64 `toml:",omitempty"`
// OverridePrague (TODO: remove after the fork)
OverridePrague *uint64 `toml:",omitempty"`
// OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"`

@ -73,6 +73,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
OverridePassedForkTime *uint64 `toml:",omitempty"`
OverrideBohr *uint64 `toml:",omitempty"`
OverridePascal *uint64 `toml:",omitempty"`
OverridePrague *uint64 `toml:",omitempty"`
OverrideVerkle *uint64 `toml:",omitempty"`
BlobExtraReserve uint64
}
@ -133,6 +134,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.OverridePassedForkTime = c.OverridePassedForkTime
enc.OverrideBohr = c.OverrideBohr
enc.OverridePascal = c.OverridePascal
enc.OverridePrague = c.OverridePrague
enc.OverrideVerkle = c.OverrideVerkle
enc.BlobExtraReserve = c.BlobExtraReserve
return &enc, nil
@ -197,6 +199,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
OverridePassedForkTime *uint64 `toml:",omitempty"`
OverrideBohr *uint64 `toml:",omitempty"`
OverridePascal *uint64 `toml:",omitempty"`
OverridePrague *uint64 `toml:",omitempty"`
OverrideVerkle *uint64 `toml:",omitempty"`
BlobExtraReserve *uint64
}
@ -372,6 +375,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.OverridePascal != nil {
c.OverridePascal = dec.OverridePascal
}
if dec.OverridePrague != nil {
c.OverridePrague = dec.OverridePrague
}
if dec.OverrideVerkle != nil {
c.OverrideVerkle = dec.OverrideVerkle
}

@ -157,6 +157,7 @@ var (
BohrTime: newUint64(1727317200), // 2024-09-26 02:20:00 AM UTC
// TODO
PascalTime: nil,
PragueTime: nil,
Parlia: &ParliaConfig{
Period: 3,
@ -200,6 +201,7 @@ var (
BohrTime: newUint64(1724116996), // 2024-08-20 01:23:16 AM UTC
// TODO
PascalTime: nil,
PragueTime: nil,
Parlia: &ParliaConfig{
Period: 3,
@ -244,6 +246,7 @@ var (
BohrTime: newUint64(0),
// TODO
PascalTime: newUint64(0),
PragueTime: newUint64(0),
Parlia: &ParliaConfig{
Period: 3,
@ -649,7 +652,12 @@ func (c *ChainConfig) String() string {
PascalTime = big.NewInt(0).SetUint64(*c.PascalTime)
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, PascalTime: %v, Engine: %v}",
var PragueTime *big.Int
if c.PragueTime != nil {
PragueTime = big.NewInt(0).SetUint64(*c.PragueTime)
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, PascalTime: %v, PragueTime: %v, Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
@ -690,6 +698,7 @@ func (c *ChainConfig) String() string {
HaberFixTime,
BohrTime,
PascalTime,
PragueTime,
engine,
)
}
@ -1071,7 +1080,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
{name: "haberFixTime", timestamp: c.HaberFixTime},
{name: "bohrTime", timestamp: c.BohrTime},
{name: "pascalTime", timestamp: c.PascalTime},
{name: "pragueTime", timestamp: c.PragueTime, optional: true},
{name: "pragueTime", timestamp: c.PragueTime},
{name: "verkleTime", timestamp: c.VerkleTime, optional: true},
} {
if lastFork.name != "" {
@ -1413,7 +1422,7 @@ type Rules struct {
IsHertz bool
IsHertzfix bool
IsShanghai, IsKepler, IsFeynman, IsCancun, IsHaber bool
IsBohr, IsPrague, IsVerkle bool
IsBohr, IsPascal, IsPrague, IsVerkle bool
}
// Rules ensures c's ChainID is not nil.
@ -1450,6 +1459,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsCancun: c.IsCancun(num, timestamp),
IsHaber: c.IsHaber(num, timestamp),
IsBohr: c.IsBohr(num, timestamp),
IsPascal: c.IsPascal(num, timestamp),
IsPrague: c.IsPrague(num, timestamp),
IsVerkle: c.IsVerkle(num, timestamp),
}