Skip to content

Commit 8da5bf0

Browse files
authored
core,params: cherry pick upstream PRs needed for Fusaka defence on Sepolia (#690)
2 parents 51614a3 + 5eee1ea commit 8da5bf0

File tree

4 files changed

+372
-9
lines changed

4 files changed

+372
-9
lines changed

core/forkid/forkid_test.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ func TestCreation(t *testing.T) {
9595
{1735372, 1706655071, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 1706655072}}, // Last Shanghai block
9696
{1735372, 1706655072, ID{Hash: checksumToBytes(0x88cf81d9), Next: 1741159776}}, // First Cancun block
9797
{1735372, 1741159775, ID{Hash: checksumToBytes(0x88cf81d9), Next: 1741159776}}, // Last Cancun block
98-
{1735372, 1741159776, ID{Hash: checksumToBytes(0xed88b5fd), Next: 0}}, // First Prague block
99-
{1735372, 2741159776, ID{Hash: checksumToBytes(0xed88b5fd), Next: 0}}, // Future Prague block
98+
{1735372, 1741159776, ID{Hash: checksumToBytes(0xed88b5fd), Next: 1760427360}}, // First Prague block
99+
{1735372, 1760427359, ID{Hash: checksumToBytes(0xed88b5fd), Next: 1760427360}}, // Last Prague block
100+
{1735372, 1760427360, ID{Hash: checksumToBytes(0xe2ae4999), Next: 1761017184}}, // First Osaka block
101+
{1735372, 1761017183, ID{Hash: checksumToBytes(0xe2ae4999), Next: 1761017184}}, // Last Osaka block
102+
{1735372, 1761017184, ID{Hash: checksumToBytes(0x56078a1e), Next: 1761607008}}, // First BPO1 block
103+
{1735372, 1761607007, ID{Hash: checksumToBytes(0x56078a1e), Next: 1761607008}}, // Last BPO1 block
104+
{1735372, 1761607008, ID{Hash: checksumToBytes(0x268956b6), Next: 0}}, // First BPO2 block
105+
{1735372, 2000000000, ID{Hash: checksumToBytes(0x268956b6), Next: 0}}, // Future BPO2 block
100106
},
101107
},
102108
// Holesky test cases
@@ -110,8 +116,14 @@ func TestCreation(t *testing.T) {
110116
{123, 1707305663, ID{Hash: checksumToBytes(0xfd4f016b), Next: 1707305664}}, // Last Shanghai block
111117
{123, 1707305664, ID{Hash: checksumToBytes(0x9b192ad0), Next: 1740434112}}, // First Cancun block
112118
{123, 1740434111, ID{Hash: checksumToBytes(0x9b192ad0), Next: 1740434112}}, // Last Cancun block
113-
{123, 1740434112, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 0}}, // First Prague block
114-
{123, 2740434112, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 0}}, // Future Prague block
119+
{123, 1740434112, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 1759308480}}, // First Prague block
120+
{123, 1759308479, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 1759308480}}, // Last Prague block
121+
{123, 1759308480, ID{Hash: checksumToBytes(0x783def52), Next: 1759800000}}, // First Osaka block
122+
{123, 1759799999, ID{Hash: checksumToBytes(0x783def52), Next: 1759800000}}, // Last Osaka block
123+
{123, 1759800000, ID{Hash: checksumToBytes(0xa280a45c), Next: 1760389824}}, // First BPO1 block
124+
{123, 1760389823, ID{Hash: checksumToBytes(0xa280a45c), Next: 1760389824}}, // Last BPO1 block
125+
{123, 1760389824, ID{Hash: checksumToBytes(0x9bc6cb31), Next: 0}}, // First BPO2 block
126+
{123, 2000000000, ID{Hash: checksumToBytes(0x9bc6cb31), Next: 0}}, // Future BPO1 block
115127
},
116128
},
117129
// Hoodi test cases
@@ -121,8 +133,14 @@ func TestCreation(t *testing.T) {
121133
[]testcase{
122134
{0, 0, ID{Hash: checksumToBytes(0xbef71d30), Next: 1742999832}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris, Shanghai, Cancun block
123135
{123, 1742999831, ID{Hash: checksumToBytes(0xbef71d30), Next: 1742999832}}, // Last Cancun block
124-
{123, 1742999832, ID{Hash: checksumToBytes(0x0929e24e), Next: 0}}, // First Prague block
125-
{123, 2740434112, ID{Hash: checksumToBytes(0x0929e24e), Next: 0}}, // Future Prague block
136+
{123, 1742999832, ID{Hash: checksumToBytes(0x0929e24e), Next: 1761677592}}, // First Prague block
137+
{123, 1761677591, ID{Hash: checksumToBytes(0x0929e24e), Next: 1761677592}}, // Last Prague block
138+
{123, 1761677592, ID{Hash: checksumToBytes(0xe7e0e7ff), Next: 1762365720}}, // First Osaka block
139+
{123, 1762365719, ID{Hash: checksumToBytes(0xe7e0e7ff), Next: 1762365720}}, // Last Osaka block
140+
{123, 1762365720, ID{Hash: checksumToBytes(0x3893353e), Next: 1762955544}}, // First BPO1 block
141+
{123, 1762955543, ID{Hash: checksumToBytes(0x3893353e), Next: 1762955544}}, // Last BPO1 block
142+
{123, 1762955544, ID{Hash: checksumToBytes(0x23aa1351), Next: 0}}, // First BPO2 block
143+
{123, 2000000000, ID{Hash: checksumToBytes(0x23aa1351), Next: 0}}, // Future BPO2 block
126144
},
127145
},
128146
}

params/config.go

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,17 @@ var (
9898
ShanghaiTime: newUint64(1696000704),
9999
CancunTime: newUint64(1707305664),
100100
PragueTime: newUint64(1740434112),
101+
OsakaTime: newUint64(1759308480),
102+
BPO1Time: newUint64(1759800000),
103+
BPO2Time: newUint64(1760389824),
101104
DepositContractAddress: common.HexToAddress("0x4242424242424242424242424242424242424242"),
102105
Ethash: new(EthashConfig),
103106
BlobScheduleConfig: &BlobScheduleConfig{
104107
Cancun: DefaultCancunBlobConfig,
105108
Prague: DefaultPragueBlobConfig,
109+
Osaka: DefaultOsakaBlobConfig,
110+
BPO1: DefaultBPO1BlobConfig,
111+
BPO2: DefaultBPO2BlobConfig,
106112
},
107113
}
108114
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
@@ -128,11 +134,17 @@ var (
128134
ShanghaiTime: newUint64(1677557088),
129135
CancunTime: newUint64(1706655072),
130136
PragueTime: newUint64(1741159776),
137+
OsakaTime: newUint64(1760427360),
138+
BPO1Time: newUint64(1761017184),
139+
BPO2Time: newUint64(1761607008),
131140
DepositContractAddress: common.HexToAddress("0x7f02c3e3c98b133055b8b348b2ac625669ed295d"),
132141
Ethash: new(EthashConfig),
133142
BlobScheduleConfig: &BlobScheduleConfig{
134143
Cancun: DefaultCancunBlobConfig,
135144
Prague: DefaultPragueBlobConfig,
145+
Osaka: DefaultOsakaBlobConfig,
146+
BPO1: DefaultBPO1BlobConfig,
147+
BPO2: DefaultBPO2BlobConfig,
136148
},
137149
}
138150
// HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network.
@@ -158,11 +170,17 @@ var (
158170
ShanghaiTime: newUint64(0),
159171
CancunTime: newUint64(0),
160172
PragueTime: newUint64(1742999832),
173+
OsakaTime: newUint64(1761677592),
174+
BPO1Time: newUint64(1762365720),
175+
BPO2Time: newUint64(1762955544),
161176
DepositContractAddress: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"),
162177
Ethash: new(EthashConfig),
163178
BlobScheduleConfig: &BlobScheduleConfig{
164179
Cancun: DefaultCancunBlobConfig,
165180
Prague: DefaultPragueBlobConfig,
181+
Osaka: DefaultOsakaBlobConfig,
182+
BPO1: DefaultBPO1BlobConfig,
183+
BPO2: DefaultBPO2BlobConfig,
166184
},
167185
}
168186
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
@@ -394,6 +412,30 @@ var (
394412
Max: 9,
395413
UpdateFraction: 5007716,
396414
}
415+
// DefaultBPO1BlobConfig is the default blob configuration for the Osaka fork.
416+
DefaultBPO1BlobConfig = &BlobConfig{
417+
Target: 10,
418+
Max: 15,
419+
UpdateFraction: 8346193,
420+
}
421+
// DefaultBPO1BlobConfig is the default blob configuration for the Osaka fork.
422+
DefaultBPO2BlobConfig = &BlobConfig{
423+
Target: 14,
424+
Max: 21,
425+
UpdateFraction: 11684671,
426+
}
427+
// DefaultBPO1BlobConfig is the default blob configuration for the Osaka fork.
428+
DefaultBPO3BlobConfig = &BlobConfig{
429+
Target: 21,
430+
Max: 32,
431+
UpdateFraction: 20609697,
432+
}
433+
// DefaultBPO1BlobConfig is the default blob configuration for the Osaka fork.
434+
DefaultBPO4BlobConfig = &BlobConfig{
435+
Target: 14,
436+
Max: 21,
437+
UpdateFraction: 13739630,
438+
}
397439
// DefaultBlobSchedule is the latest configured blob schedule for Ethereum mainnet.
398440
DefaultBlobSchedule = &BlobScheduleConfig{
399441
Cancun: DefaultCancunBlobConfig,
@@ -1205,6 +1247,16 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
12051247
london := c.LondonBlock
12061248

12071249
switch {
1250+
case c.IsBPO5(london, time):
1251+
return forks.BPO5
1252+
case c.IsBPO4(london, time):
1253+
return forks.BPO4
1254+
case c.IsBPO3(london, time):
1255+
return forks.BPO3
1256+
case c.IsBPO2(london, time):
1257+
return forks.BPO2
1258+
case c.IsBPO1(london, time):
1259+
return forks.BPO1
12081260
case c.IsOsaka(london, time):
12091261
return forks.Osaka
12101262
case c.IsPrague(london, time):
@@ -1223,12 +1275,22 @@ func (c *ChainConfig) BlobConfig(fork forks.Fork) *BlobConfig {
12231275
// TODO: https://github.com/ethereum-optimism/op-geth/issues/685
12241276
// This function has a bug.
12251277
switch fork {
1278+
case forks.BPO5:
1279+
return c.BlobScheduleConfig.BPO5
1280+
case forks.BPO4:
1281+
return c.BlobScheduleConfig.BPO4
1282+
case forks.BPO3:
1283+
return c.BlobScheduleConfig.BPO3
1284+
case forks.BPO2:
1285+
return c.BlobScheduleConfig.BPO2
1286+
case forks.BPO1:
1287+
return c.BlobScheduleConfig.BPO1
12261288
case forks.Osaka:
1227-
return DefaultOsakaBlobConfig
1289+
return c.BlobScheduleConfig.Osaka
12281290
case forks.Prague:
1229-
return DefaultPragueBlobConfig
1291+
return c.BlobScheduleConfig.Prague
12301292
case forks.Cancun:
1231-
return DefaultCancunBlobConfig
1293+
return c.BlobScheduleConfig.Cancun
12321294
default:
12331295
return nil
12341296
}
@@ -1258,6 +1320,16 @@ func (c *ChainConfig) ActiveSystemContracts(time uint64) map[string]common.Addre
12581320
// the fork isn't defined or isn't a time-based fork.
12591321
func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 {
12601322
switch {
1323+
case fork == forks.BPO5:
1324+
return c.BPO5Time
1325+
case fork == forks.BPO4:
1326+
return c.BPO4Time
1327+
case fork == forks.BPO3:
1328+
return c.BPO3Time
1329+
case fork == forks.BPO2:
1330+
return c.BPO2Time
1331+
case fork == forks.BPO1:
1332+
return c.BPO1Time
12611333
case fork == forks.Osaka:
12621334
return c.OsakaTime
12631335
case fork == forks.Prague:

params/forks/forks.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ const (
4040
Cancun
4141
Prague
4242
Osaka
43+
BPO1
44+
BPO2
45+
BPO3
46+
BPO4
47+
BPO5
4348
)
4449

4550
// String implements fmt.Stringer.

0 commit comments

Comments
 (0)