Skip to content

Commit b19452d

Browse files
params: add amsterdam fork config (#32687)
Adds Amsterdam as fork config option. Co-authored-by: lightclient <[email protected]>
1 parent c984d90 commit b19452d

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

params/config.go

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,17 @@ type ChainConfig struct {
448448

449449
// Fork scheduling was switched from blocks to timestamps here
450450

451-
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
452-
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
453-
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
454-
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
455-
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
456-
BPO1Time *uint64 `json:"bpo1Time,omitempty"` // BPO1 switch time (nil = no fork, 0 = already on bpo1)
457-
BPO2Time *uint64 `json:"bpo2Time,omitempty"` // BPO2 switch time (nil = no fork, 0 = already on bpo2)
458-
BPO3Time *uint64 `json:"bpo3Time,omitempty"` // BPO3 switch time (nil = no fork, 0 = already on bpo3)
459-
BPO4Time *uint64 `json:"bpo4Time,omitempty"` // BPO4 switch time (nil = no fork, 0 = already on bpo4)
460-
BPO5Time *uint64 `json:"bpo5Time,omitempty"` // BPO5 switch time (nil = no fork, 0 = already on bpo5)
451+
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
452+
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
453+
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
454+
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
455+
BPO1Time *uint64 `json:"bpo1Time,omitempty"` // BPO1 switch time (nil = no fork, 0 = already on bpo1)
456+
BPO2Time *uint64 `json:"bpo2Time,omitempty"` // BPO2 switch time (nil = no fork, 0 = already on bpo2)
457+
BPO3Time *uint64 `json:"bpo3Time,omitempty"` // BPO3 switch time (nil = no fork, 0 = already on bpo3)
458+
BPO4Time *uint64 `json:"bpo4Time,omitempty"` // BPO4 switch time (nil = no fork, 0 = already on bpo4)
459+
BPO5Time *uint64 `json:"bpo5Time,omitempty"` // BPO5 switch time (nil = no fork, 0 = already on bpo5)
460+
AmsterdamTime *uint64 `json:"amsterdamTime,omitempty"` // Amsterdam switch time (nil = no fork, 0 = already on amsterdam)
461+
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
461462

462463
// TerminalTotalDifficulty is the amount of total difficulty reached by
463464
// the network that triggers the consensus upgrade.
@@ -575,9 +576,6 @@ func (c *ChainConfig) Description() string {
575576
if c.OsakaTime != nil {
576577
banner += fmt.Sprintf(" - Osaka: @%-10v (https://ethereum.github.io/execution-specs/src/ethereum/forks/osaka/__init__.py.html)\n", *c.OsakaTime)
577578
}
578-
if c.VerkleTime != nil {
579-
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
580-
}
581579
if c.BPO1Time != nil {
582580
banner += fmt.Sprintf(" - BPO1: @%-10v\n", *c.BPO1Time)
583581
}
@@ -593,6 +591,12 @@ func (c *ChainConfig) Description() string {
593591
if c.BPO5Time != nil {
594592
banner += fmt.Sprintf(" - BPO5: @%-10v\n", *c.BPO5Time)
595593
}
594+
if c.AmsterdamTime != nil {
595+
banner += fmt.Sprintf(" - Amsterdam: @%-10v\n", *c.AmsterdamTime)
596+
}
597+
if c.VerkleTime != nil {
598+
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
599+
}
596600
return banner
597601
}
598602

@@ -605,15 +609,16 @@ type BlobConfig struct {
605609

606610
// BlobScheduleConfig determines target and max number of blobs allow per fork.
607611
type BlobScheduleConfig struct {
608-
Cancun *BlobConfig `json:"cancun,omitempty"`
609-
Prague *BlobConfig `json:"prague,omitempty"`
610-
Osaka *BlobConfig `json:"osaka,omitempty"`
611-
Verkle *BlobConfig `json:"verkle,omitempty"`
612-
BPO1 *BlobConfig `json:"bpo1,omitempty"`
613-
BPO2 *BlobConfig `json:"bpo2,omitempty"`
614-
BPO3 *BlobConfig `json:"bpo3,omitempty"`
615-
BPO4 *BlobConfig `json:"bpo4,omitempty"`
616-
BPO5 *BlobConfig `json:"bpo5,omitempty"`
612+
Cancun *BlobConfig `json:"cancun,omitempty"`
613+
Prague *BlobConfig `json:"prague,omitempty"`
614+
Osaka *BlobConfig `json:"osaka,omitempty"`
615+
Verkle *BlobConfig `json:"verkle,omitempty"`
616+
BPO1 *BlobConfig `json:"bpo1,omitempty"`
617+
BPO2 *BlobConfig `json:"bpo2,omitempty"`
618+
BPO3 *BlobConfig `json:"bpo3,omitempty"`
619+
BPO4 *BlobConfig `json:"bpo4,omitempty"`
620+
BPO5 *BlobConfig `json:"bpo5,omitempty"`
621+
Amsterdam *BlobConfig `json:"amsterdam,omitempty"`
617622
}
618623

619624
// 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 {
726731
return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time)
727732
}
728733

729-
// IsVerkle returns whether time is either equal to the Verkle fork time or greater.
730-
func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
731-
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
732-
}
733-
734734
// IsBPO1 returns whether time is either equal to the BPO1 fork time or greater.
735735
func (c *ChainConfig) IsBPO1(num *big.Int, time uint64) bool {
736736
return c.IsLondon(num) && isTimestampForked(c.BPO1Time, time)
@@ -756,6 +756,16 @@ func (c *ChainConfig) IsBPO5(num *big.Int, time uint64) bool {
756756
return c.IsLondon(num) && isTimestampForked(c.BPO5Time, time)
757757
}
758758

759+
// IsAmsterdam returns whether time is either equal to the Amsterdam fork time or greater.
760+
func (c *ChainConfig) IsAmsterdam(num *big.Int, time uint64) bool {
761+
return c.IsLondon(num) && isTimestampForked(c.AmsterdamTime, time)
762+
}
763+
764+
// IsVerkle returns whether time is either equal to the Verkle fork time or greater.
765+
func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
766+
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
767+
}
768+
759769
// IsVerkleGenesis checks whether the verkle fork is activated at the genesis block.
760770
//
761771
// Verkle mode is considered enabled if the verkle fork time is configured,
@@ -836,6 +846,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
836846
{name: "bpo3", timestamp: c.BPO3Time, optional: true},
837847
{name: "bpo4", timestamp: c.BPO4Time, optional: true},
838848
{name: "bpo5", timestamp: c.BPO5Time, optional: true},
849+
{name: "amsterdam", timestamp: c.AmsterdamTime, optional: true},
839850
} {
840851
if lastFork.name != "" {
841852
switch {
@@ -890,6 +901,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
890901
{name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3},
891902
{name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4},
892903
{name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5},
904+
{name: "amsterdam", timestamp: c.AmsterdamTime, config: bsc.Amsterdam},
893905
} {
894906
if cur.config != nil {
895907
if err := cur.config.validate(); err != nil {
@@ -1005,6 +1017,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
10051017
if isForkTimestampIncompatible(c.BPO5Time, newcfg.BPO5Time, headTimestamp) {
10061018
return newTimestampCompatError("BPO5 fork timestamp", c.BPO5Time, newcfg.BPO5Time)
10071019
}
1020+
if isForkTimestampIncompatible(c.AmsterdamTime, newcfg.AmsterdamTime, headTimestamp) {
1021+
return newTimestampCompatError("Amsterdam fork timestamp", c.AmsterdamTime, newcfg.AmsterdamTime)
1022+
}
10081023
return nil
10091024
}
10101025

@@ -1024,6 +1039,8 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
10241039
london := c.LondonBlock
10251040

10261041
switch {
1042+
case c.IsAmsterdam(london, time):
1043+
return forks.Amsterdam
10271044
case c.IsBPO5(london, time):
10281045
return forks.BPO5
10291046
case c.IsBPO4(london, time):
@@ -1259,7 +1276,7 @@ type Rules struct {
12591276
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
12601277
IsBerlin, IsLondon bool
12611278
IsMerge, IsShanghai, IsCancun, IsPrague, IsOsaka bool
1262-
IsVerkle bool
1279+
IsAmsterdam, IsVerkle bool
12631280
}
12641281

12651282
// Rules ensures c's ChainID is not nil.
@@ -1289,6 +1306,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
12891306
IsCancun: isMerge && c.IsCancun(num, timestamp),
12901307
IsPrague: isMerge && c.IsPrague(num, timestamp),
12911308
IsOsaka: isMerge && c.IsOsaka(num, timestamp),
1309+
IsAmsterdam: isMerge && c.IsAmsterdam(num, timestamp),
12921310
IsVerkle: isVerkle,
12931311
IsEIP4762: isVerkle,
12941312
}

params/forks/forks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const (
4545
BPO3
4646
BPO4
4747
BPO5
48+
Amsterdam
4849
)
4950

5051
// String implements fmt.Stringer.
@@ -82,4 +83,5 @@ var forkToString = map[Fork]string{
8283
BPO3: "BPO3",
8384
BPO4: "BPO4",
8485
BPO5: "BPO5",
86+
Amsterdam: "Amsterdam",
8587
}

0 commit comments

Comments
 (0)