Skip to content

Commit eee8682

Browse files
params: start osaka fork (#31125)
This PR defines the Osaka fork. An easy first step to start our work on the next hardfork (This is needed for EOF testing as well) --------- Co-authored-by: lightclient <[email protected]>
1 parent 665c851 commit eee8682

File tree

6 files changed

+75
-2
lines changed

6 files changed

+75
-2
lines changed

core/genesis_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func TestVerkleGenesisCommit(t *testing.T) {
272272
ShanghaiTime: &verkleTime,
273273
CancunTime: &verkleTime,
274274
PragueTime: &verkleTime,
275+
OsakaTime: &verkleTime,
275276
VerkleTime: &verkleTime,
276277
TerminalTotalDifficulty: big.NewInt(0),
277278
EnableVerkleAtGenesis: true,

core/vm/jump_table_export.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
2828
switch {
2929
case rules.IsVerkle:
3030
return newCancunInstructionSet(), errors.New("verkle-fork not defined yet")
31+
case rules.IsOsaka:
32+
return newPragueInstructionSet(), errors.New("osaka-fork not defined yet")
3133
case rules.IsPrague:
32-
return newCancunInstructionSet(), errors.New("prague-fork not defined yet")
34+
return newPragueInstructionSet(), nil
3335
case rules.IsCancun:
3436
return newCancunInstructionSet(), nil
3537
case rules.IsShanghai:

eth/tracers/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
10881088
copy.PragueTime = timestamp
10891089
canon = false
10901090
}
1091+
if timestamp := override.OsakaTime; timestamp != nil {
1092+
copy.OsakaTime = timestamp
1093+
canon = false
1094+
}
10911095
if timestamp := override.VerkleTime; timestamp != nil {
10921096
copy.VerkleTime = timestamp
10931097
canon = false

params/config.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ var (
133133
ShanghaiTime: nil,
134134
CancunTime: nil,
135135
PragueTime: nil,
136+
OsakaTime: nil,
136137
VerkleTime: nil,
137138
Ethash: new(EthashConfig),
138139
Clique: nil,
@@ -182,6 +183,7 @@ var (
182183
ShanghaiTime: nil,
183184
CancunTime: nil,
184185
PragueTime: nil,
186+
OsakaTime: nil,
185187
VerkleTime: nil,
186188
TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
187189
Ethash: nil,
@@ -211,6 +213,7 @@ var (
211213
ShanghaiTime: nil,
212214
CancunTime: nil,
213215
PragueTime: nil,
216+
OsakaTime: nil,
214217
VerkleTime: nil,
215218
TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
216219
Ethash: new(EthashConfig),
@@ -240,6 +243,7 @@ var (
240243
ShanghaiTime: newUint64(0),
241244
CancunTime: newUint64(0),
242245
PragueTime: newUint64(0),
246+
OsakaTime: nil,
243247
VerkleTime: nil,
244248
TerminalTotalDifficulty: big.NewInt(0),
245249
Ethash: new(EthashConfig),
@@ -269,6 +273,7 @@ var (
269273
ShanghaiTime: nil,
270274
CancunTime: nil,
271275
PragueTime: nil,
276+
OsakaTime: nil,
272277
VerkleTime: nil,
273278
TerminalTotalDifficulty: big.NewInt(math.MaxInt64),
274279
Ethash: new(EthashConfig),
@@ -318,6 +323,7 @@ type ChainConfig struct {
318323
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
319324
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
320325
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
326+
OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka)
321327
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
322328

323329
// TerminalTotalDifficulty is the amount of total difficulty reached by
@@ -432,6 +438,9 @@ func (c *ChainConfig) Description() string {
432438
if c.PragueTime != nil {
433439
banner += fmt.Sprintf(" - Prague: @%-10v\n", *c.PragueTime)
434440
}
441+
if c.OsakaTime != nil {
442+
banner += fmt.Sprintf(" - Osaka: @%-10v\n", *c.OsakaTime)
443+
}
435444
if c.VerkleTime != nil {
436445
banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
437446
}
@@ -533,6 +542,11 @@ func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool {
533542
return c.IsLondon(num) && isTimestampForked(c.PragueTime, time)
534543
}
535544

545+
// IsOsaka returns whether time is either equal to the Osaka fork time or greater.
546+
func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool {
547+
return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time)
548+
}
549+
536550
// IsVerkle returns whether time is either equal to the Verkle fork time or greater.
537551
func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
538552
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
@@ -611,6 +625,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
611625
{name: "shanghaiTime", timestamp: c.ShanghaiTime},
612626
{name: "cancunTime", timestamp: c.CancunTime, optional: true},
613627
{name: "pragueTime", timestamp: c.PragueTime, optional: true},
628+
{name: "osakaTime", timestamp: c.OsakaTime, optional: true},
614629
{name: "verkleTime", timestamp: c.VerkleTime, optional: true},
615630
} {
616631
if lastFork.name != "" {
@@ -715,6 +730,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
715730
if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) {
716731
return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime)
717732
}
733+
if isForkTimestampIncompatible(c.OsakaTime, newcfg.OsakaTime, headTimestamp) {
734+
return newTimestampCompatError("Osaka fork timestamp", c.OsakaTime, newcfg.OsakaTime)
735+
}
718736
if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) {
719737
return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime)
720738
}
@@ -737,6 +755,8 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
737755
london := c.LondonBlock
738756

739757
switch {
758+
case c.IsOsaka(london, time):
759+
return forks.Osaka
740760
case c.IsPrague(london, time):
741761
return forks.Prague
742762
case c.IsCancun(london, time):
@@ -888,7 +908,7 @@ type Rules struct {
888908
IsEIP2929, IsEIP4762 bool
889909
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
890910
IsBerlin, IsLondon bool
891-
IsMerge, IsShanghai, IsCancun, IsPrague bool
911+
IsMerge, IsShanghai, IsCancun, IsPrague, IsOsaka bool
892912
IsVerkle bool
893913
}
894914

@@ -918,6 +938,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
918938
IsShanghai: isMerge && c.IsShanghai(num, timestamp),
919939
IsCancun: isMerge && c.IsCancun(num, timestamp),
920940
IsPrague: isMerge && c.IsPrague(num, timestamp),
941+
IsOsaka: isMerge && c.IsOsaka(num, timestamp),
921942
IsVerkle: isVerkle,
922943
IsEIP4762: isVerkle,
923944
}

params/forks/forks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ const (
3939
Shanghai
4040
Cancun
4141
Prague
42+
Osaka
4243
)

tests/init.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,50 @@ var Forks = map[string]*params.ChainConfig{
396396
PragueTime: u64(15_000),
397397
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
398398
},
399+
"Osaka": {
400+
ChainID: big.NewInt(1),
401+
HomesteadBlock: big.NewInt(0),
402+
EIP150Block: big.NewInt(0),
403+
EIP155Block: big.NewInt(0),
404+
EIP158Block: big.NewInt(0),
405+
ByzantiumBlock: big.NewInt(0),
406+
ConstantinopleBlock: big.NewInt(0),
407+
PetersburgBlock: big.NewInt(0),
408+
IstanbulBlock: big.NewInt(0),
409+
MuirGlacierBlock: big.NewInt(0),
410+
BerlinBlock: big.NewInt(0),
411+
LondonBlock: big.NewInt(0),
412+
ArrowGlacierBlock: big.NewInt(0),
413+
MergeNetsplitBlock: big.NewInt(0),
414+
TerminalTotalDifficulty: big.NewInt(0),
415+
ShanghaiTime: u64(0),
416+
CancunTime: u64(0),
417+
PragueTime: u64(0),
418+
OsakaTime: u64(0),
419+
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
420+
},
421+
"PragueToOsakaAtTime15k": {
422+
ChainID: big.NewInt(1),
423+
HomesteadBlock: big.NewInt(0),
424+
EIP150Block: big.NewInt(0),
425+
EIP155Block: big.NewInt(0),
426+
EIP158Block: big.NewInt(0),
427+
ByzantiumBlock: big.NewInt(0),
428+
ConstantinopleBlock: big.NewInt(0),
429+
PetersburgBlock: big.NewInt(0),
430+
IstanbulBlock: big.NewInt(0),
431+
MuirGlacierBlock: big.NewInt(0),
432+
BerlinBlock: big.NewInt(0),
433+
LondonBlock: big.NewInt(0),
434+
ArrowGlacierBlock: big.NewInt(0),
435+
MergeNetsplitBlock: big.NewInt(0),
436+
TerminalTotalDifficulty: big.NewInt(0),
437+
ShanghaiTime: u64(0),
438+
CancunTime: u64(0),
439+
PragueTime: u64(0),
440+
OsakaTime: u64(15_000),
441+
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
442+
},
399443
}
400444

401445
// AvailableForks returns the set of defined fork names

0 commit comments

Comments
 (0)