mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-15 20:46:40 +00:00
params: add amsterdam fork config (#32687)
Adds Amsterdam as fork config option. Co-authored-by: lightclient <lightclient@protonmail.com>
This commit is contained in:
parent
c984d9086e
commit
b19452dc11
2 changed files with 48 additions and 28 deletions
|
|
@ -448,16 +448,17 @@ type ChainConfig struct {
|
||||||
|
|
||||||
// Fork scheduling was switched from blocks to timestamps here
|
// Fork scheduling was switched from blocks to timestamps here
|
||||||
|
|
||||||
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
||||||
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
|
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
|
||||||
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
||||||
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
|
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
|
||||||
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
BPO1Time *uint64 `json:"bpo1Time,omitempty"` // BPO1 switch time (nil = no fork, 0 = already on bpo1)
|
||||||
BPO1Time *uint64 `json:"bpo1Time,omitempty"` // BPO1 switch time (nil = no fork, 0 = already on bpo1)
|
BPO2Time *uint64 `json:"bpo2Time,omitempty"` // BPO2 switch time (nil = no fork, 0 = already on bpo2)
|
||||||
BPO2Time *uint64 `json:"bpo2Time,omitempty"` // BPO2 switch time (nil = no fork, 0 = already on bpo2)
|
BPO3Time *uint64 `json:"bpo3Time,omitempty"` // BPO3 switch time (nil = no fork, 0 = already on bpo3)
|
||||||
BPO3Time *uint64 `json:"bpo3Time,omitempty"` // BPO3 switch time (nil = no fork, 0 = already on bpo3)
|
BPO4Time *uint64 `json:"bpo4Time,omitempty"` // BPO4 switch time (nil = no fork, 0 = already on bpo4)
|
||||||
BPO4Time *uint64 `json:"bpo4Time,omitempty"` // BPO4 switch time (nil = no fork, 0 = already on bpo4)
|
BPO5Time *uint64 `json:"bpo5Time,omitempty"` // BPO5 switch time (nil = no fork, 0 = already on bpo5)
|
||||||
BPO5Time *uint64 `json:"bpo5Time,omitempty"` // BPO5 switch time (nil = no fork, 0 = already on bpo5)
|
AmsterdamTime *uint64 `json:"amsterdamTime,omitempty"` // Amsterdam switch time (nil = no fork, 0 = already on amsterdam)
|
||||||
|
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
||||||
|
|
||||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||||
// the network that triggers the consensus upgrade.
|
// the network that triggers the consensus upgrade.
|
||||||
|
|
@ -575,9 +576,6 @@ func (c *ChainConfig) Description() string {
|
||||||
if c.OsakaTime != nil {
|
if c.OsakaTime != nil {
|
||||||
banner += fmt.Sprintf(" - Osaka: @%-10v (https://ethereum.github.io/execution-specs/src/ethereum/forks/osaka/__init__.py.html)\n", *c.OsakaTime)
|
banner += fmt.Sprintf(" - Osaka: @%-10v (https://ethereum.github.io/execution-specs/src/ethereum/forks/osaka/__init__.py.html)\n", *c.OsakaTime)
|
||||||
}
|
}
|
||||||
if c.VerkleTime != nil {
|
|
||||||
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
|
|
||||||
}
|
|
||||||
if c.BPO1Time != nil {
|
if c.BPO1Time != nil {
|
||||||
banner += fmt.Sprintf(" - BPO1: @%-10v\n", *c.BPO1Time)
|
banner += fmt.Sprintf(" - BPO1: @%-10v\n", *c.BPO1Time)
|
||||||
}
|
}
|
||||||
|
|
@ -593,6 +591,12 @@ func (c *ChainConfig) Description() string {
|
||||||
if c.BPO5Time != nil {
|
if c.BPO5Time != nil {
|
||||||
banner += fmt.Sprintf(" - BPO5: @%-10v\n", *c.BPO5Time)
|
banner += fmt.Sprintf(" - BPO5: @%-10v\n", *c.BPO5Time)
|
||||||
}
|
}
|
||||||
|
if c.AmsterdamTime != nil {
|
||||||
|
banner += fmt.Sprintf(" - Amsterdam: @%-10v\n", *c.AmsterdamTime)
|
||||||
|
}
|
||||||
|
if c.VerkleTime != nil {
|
||||||
|
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
|
||||||
|
}
|
||||||
return banner
|
return banner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -605,15 +609,16 @@ type BlobConfig struct {
|
||||||
|
|
||||||
// BlobScheduleConfig determines target and max number of blobs allow per fork.
|
// BlobScheduleConfig determines target and max number of blobs allow per fork.
|
||||||
type BlobScheduleConfig struct {
|
type BlobScheduleConfig struct {
|
||||||
Cancun *BlobConfig `json:"cancun,omitempty"`
|
Cancun *BlobConfig `json:"cancun,omitempty"`
|
||||||
Prague *BlobConfig `json:"prague,omitempty"`
|
Prague *BlobConfig `json:"prague,omitempty"`
|
||||||
Osaka *BlobConfig `json:"osaka,omitempty"`
|
Osaka *BlobConfig `json:"osaka,omitempty"`
|
||||||
Verkle *BlobConfig `json:"verkle,omitempty"`
|
Verkle *BlobConfig `json:"verkle,omitempty"`
|
||||||
BPO1 *BlobConfig `json:"bpo1,omitempty"`
|
BPO1 *BlobConfig `json:"bpo1,omitempty"`
|
||||||
BPO2 *BlobConfig `json:"bpo2,omitempty"`
|
BPO2 *BlobConfig `json:"bpo2,omitempty"`
|
||||||
BPO3 *BlobConfig `json:"bpo3,omitempty"`
|
BPO3 *BlobConfig `json:"bpo3,omitempty"`
|
||||||
BPO4 *BlobConfig `json:"bpo4,omitempty"`
|
BPO4 *BlobConfig `json:"bpo4,omitempty"`
|
||||||
BPO5 *BlobConfig `json:"bpo5,omitempty"`
|
BPO5 *BlobConfig `json:"bpo5,omitempty"`
|
||||||
|
Amsterdam *BlobConfig `json:"amsterdam,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHomestead returns whether num is either equal to the homestead block or greater.
|
// IsHomestead returns whether num is either equal to the homestead block or greater.
|
||||||
|
|
@ -726,11 +731,6 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsVerkle returns whether time is either equal to the Verkle fork time or greater.
|
|
||||||
func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
|
|
||||||
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsBPO1 returns whether time is either equal to the BPO1 fork time or greater.
|
// IsBPO1 returns whether time is either equal to the BPO1 fork time or greater.
|
||||||
func (c *ChainConfig) IsBPO1(num *big.Int, time uint64) bool {
|
func (c *ChainConfig) IsBPO1(num *big.Int, time uint64) bool {
|
||||||
return c.IsLondon(num) && isTimestampForked(c.BPO1Time, time)
|
return c.IsLondon(num) && isTimestampForked(c.BPO1Time, time)
|
||||||
|
|
@ -756,6 +756,16 @@ func (c *ChainConfig) IsBPO5(num *big.Int, time uint64) bool {
|
||||||
return c.IsLondon(num) && isTimestampForked(c.BPO5Time, time)
|
return c.IsLondon(num) && isTimestampForked(c.BPO5Time, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAmsterdam returns whether time is either equal to the Amsterdam fork time or greater.
|
||||||
|
func (c *ChainConfig) IsAmsterdam(num *big.Int, time uint64) bool {
|
||||||
|
return c.IsLondon(num) && isTimestampForked(c.AmsterdamTime, time)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVerkle returns whether time is either equal to the Verkle fork time or greater.
|
||||||
|
func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
|
||||||
|
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
|
||||||
|
}
|
||||||
|
|
||||||
// IsVerkleGenesis checks whether the verkle fork is activated at the genesis block.
|
// IsVerkleGenesis checks whether the verkle fork is activated at the genesis block.
|
||||||
//
|
//
|
||||||
// Verkle mode is considered enabled if the verkle fork time is configured,
|
// Verkle mode is considered enabled if the verkle fork time is configured,
|
||||||
|
|
@ -836,6 +846,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||||
{name: "bpo3", timestamp: c.BPO3Time, optional: true},
|
{name: "bpo3", timestamp: c.BPO3Time, optional: true},
|
||||||
{name: "bpo4", timestamp: c.BPO4Time, optional: true},
|
{name: "bpo4", timestamp: c.BPO4Time, optional: true},
|
||||||
{name: "bpo5", timestamp: c.BPO5Time, optional: true},
|
{name: "bpo5", timestamp: c.BPO5Time, optional: true},
|
||||||
|
{name: "amsterdam", timestamp: c.AmsterdamTime, optional: true},
|
||||||
} {
|
} {
|
||||||
if lastFork.name != "" {
|
if lastFork.name != "" {
|
||||||
switch {
|
switch {
|
||||||
|
|
@ -890,6 +901,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||||
{name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3},
|
{name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3},
|
||||||
{name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4},
|
{name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4},
|
||||||
{name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5},
|
{name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5},
|
||||||
|
{name: "amsterdam", timestamp: c.AmsterdamTime, config: bsc.Amsterdam},
|
||||||
} {
|
} {
|
||||||
if cur.config != nil {
|
if cur.config != nil {
|
||||||
if err := cur.config.validate(); err != nil {
|
if err := cur.config.validate(); err != nil {
|
||||||
|
|
@ -1005,6 +1017,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
|
||||||
if isForkTimestampIncompatible(c.BPO5Time, newcfg.BPO5Time, headTimestamp) {
|
if isForkTimestampIncompatible(c.BPO5Time, newcfg.BPO5Time, headTimestamp) {
|
||||||
return newTimestampCompatError("BPO5 fork timestamp", c.BPO5Time, newcfg.BPO5Time)
|
return newTimestampCompatError("BPO5 fork timestamp", c.BPO5Time, newcfg.BPO5Time)
|
||||||
}
|
}
|
||||||
|
if isForkTimestampIncompatible(c.AmsterdamTime, newcfg.AmsterdamTime, headTimestamp) {
|
||||||
|
return newTimestampCompatError("Amsterdam fork timestamp", c.AmsterdamTime, newcfg.AmsterdamTime)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1024,6 +1039,8 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
|
||||||
london := c.LondonBlock
|
london := c.LondonBlock
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
case c.IsAmsterdam(london, time):
|
||||||
|
return forks.Amsterdam
|
||||||
case c.IsBPO5(london, time):
|
case c.IsBPO5(london, time):
|
||||||
return forks.BPO5
|
return forks.BPO5
|
||||||
case c.IsBPO4(london, time):
|
case c.IsBPO4(london, time):
|
||||||
|
|
@ -1259,7 +1276,7 @@ type Rules struct {
|
||||||
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
||||||
IsBerlin, IsLondon bool
|
IsBerlin, IsLondon bool
|
||||||
IsMerge, IsShanghai, IsCancun, IsPrague, IsOsaka bool
|
IsMerge, IsShanghai, IsCancun, IsPrague, IsOsaka bool
|
||||||
IsVerkle bool
|
IsAmsterdam, IsVerkle bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rules ensures c's ChainID is not nil.
|
// Rules ensures c's ChainID is not nil.
|
||||||
|
|
@ -1289,6 +1306,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
||||||
IsCancun: isMerge && c.IsCancun(num, timestamp),
|
IsCancun: isMerge && c.IsCancun(num, timestamp),
|
||||||
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
IsPrague: isMerge && c.IsPrague(num, timestamp),
|
||||||
IsOsaka: isMerge && c.IsOsaka(num, timestamp),
|
IsOsaka: isMerge && c.IsOsaka(num, timestamp),
|
||||||
|
IsAmsterdam: isMerge && c.IsAmsterdam(num, timestamp),
|
||||||
IsVerkle: isVerkle,
|
IsVerkle: isVerkle,
|
||||||
IsEIP4762: isVerkle,
|
IsEIP4762: isVerkle,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ const (
|
||||||
BPO3
|
BPO3
|
||||||
BPO4
|
BPO4
|
||||||
BPO5
|
BPO5
|
||||||
|
Amsterdam
|
||||||
)
|
)
|
||||||
|
|
||||||
// String implements fmt.Stringer.
|
// String implements fmt.Stringer.
|
||||||
|
|
@ -82,4 +83,5 @@ var forkToString = map[Fork]string{
|
||||||
BPO3: "BPO3",
|
BPO3: "BPO3",
|
||||||
BPO4: "BPO4",
|
BPO4: "BPO4",
|
||||||
BPO5: "BPO5",
|
BPO5: "BPO5",
|
||||||
|
Amsterdam: "Amsterdam",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue