Skip to content

Commit 2732fb1

Browse files
authored
params, core/forkid: add mainnet timestamp for Cancun (#28958)
* params: add cancun timestamp for mainnet * core/forkid: add test for mainnet cancun forkid * core/forkid: update todo tests for cancun
1 parent 8a76a81 commit 2732fb1

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

core/forkid/forkid_test.go

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ func TestCreation(t *testing.T) {
7474
{15049999, 0, ID{Hash: checksumToBytes(0x20c327fc), Next: 15050000}}, // Last Arrow Glacier block
7575
{15050000, 0, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 1681338455}}, // First Gray Glacier block
7676
{20000000, 1681338454, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 1681338455}}, // Last Gray Glacier block
77-
{20000000, 1681338455, ID{Hash: checksumToBytes(0xdce96c2d), Next: 0}}, // First Shanghai block
78-
{30000000, 2000000000, ID{Hash: checksumToBytes(0xdce96c2d), Next: 0}}, // Future Shanghai block
77+
{20000000, 1681338455, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // First Shanghai block
78+
{30000000, 1710338134, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // Last Shanghai block
79+
{40000000, 1710338135, ID{Hash: checksumToBytes(0x9f3d2254), Next: 0}}, // First Cancun block
80+
{50000000, 2000000000, ID{Hash: checksumToBytes(0x9f3d2254), Next: 0}}, // Future Cancun block
7981
},
8082
},
8183
// Goerli test cases
@@ -141,6 +143,7 @@ func TestValidation(t *testing.T) {
141143
// Config that has not timestamp enabled
142144
legacyConfig := *params.MainnetChainConfig
143145
legacyConfig.ShanghaiTime = nil
146+
legacyConfig.CancunTime = nil
144147

145148
tests := []struct {
146149
config *params.ChainConfig
@@ -213,14 +216,10 @@ func TestValidation(t *testing.T) {
213216
// at some future block 88888888, for itself, but past block for local. Local is incompatible.
214217
//
215218
// This case detects non-upgraded nodes with majority hash power (typical Ropsten mess).
216-
//
217-
// TODO(karalabe): This testcase will fail once mainnet gets timestamped forks, make legacy chain config
218219
{&legacyConfig, 88888888, 0, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 88888888}, ErrLocalIncompatibleOrStale},
219220

220221
// Local is mainnet Byzantium. Remote is also in Byzantium, but announces Gopherium (non existing
221222
// fork) at block 7279999, before Petersburg. Local is incompatible.
222-
//
223-
// TODO(karalabe): This testcase will fail once mainnet gets timestamped forks, make legacy chain config
224223
{&legacyConfig, 7279999, 0, ID{Hash: checksumToBytes(0xa00bc324), Next: 7279999}, ErrLocalIncompatibleOrStale},
225224

226225
//------------------------------------
@@ -297,34 +296,25 @@ func TestValidation(t *testing.T) {
297296
// Local is mainnet currently in Shanghai only (so it's aware of Cancun), remote announces
298297
// also Shanghai, but it's not yet aware of Cancun (e.g. non updated node before the fork).
299298
// In this case we don't know if Cancun passed yet or not.
300-
//
301-
// TODO(karalabe): Enable this when Cancun is specced
302-
//{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, nil},
299+
{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0xdce96c2d), Next: 0}, nil},
303300

304301
// Local is mainnet currently in Shanghai only (so it's aware of Cancun), remote announces
305302
// also Shanghai, and it's also aware of Cancun (e.g. updated node before the fork). We
306303
// don't know if Cancun passed yet (will pass) or not.
307-
//
308-
// TODO(karalabe): Enable this when Cancun is specced and update next timestamp
309-
//{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil},
304+
{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}, nil},
310305

311306
// Local is mainnet currently in Shanghai only (so it's aware of Cancun), remote announces
312307
// also Shanghai, and it's also aware of some random fork (e.g. misconfigured Cancun). As
313308
// neither forks passed at neither nodes, they may mismatch, but we still connect for now.
314-
//
315-
// TODO(karalabe): Enable this when Cancun is specced
316-
//{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: math.MaxUint64}, nil},
309+
{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0xdce96c2d), Next: math.MaxUint64}, nil},
317310

318311
// Local is mainnet exactly on Cancun, remote announces Shanghai + knowledge about Cancun. Remote
319312
// is simply out of sync, accept.
320-
//
321-
// TODO(karalabe): Enable this when Cancun is specced, update local head and time, next timestamp
322-
// {params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil},
313+
{params.MainnetChainConfig, 21000000, 1710338135, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}, nil},
323314

324315
// Local is mainnet Cancun, remote announces Shanghai + knowledge about Cancun. Remote
325316
// is simply out of sync, accept.
326-
// TODO(karalabe): Enable this when Cancun is specced, update local head and time, next timestamp
327-
//{params.MainnetChainConfig, 21123456, 1678123456, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil},
317+
{params.MainnetChainConfig, 21123456, 1710338136, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}, nil},
328318

329319
// Local is mainnet Prague, remote announces Shanghai + knowledge about Cancun. Remote
330320
// is definitely out of sync. It may or may not need the Prague update, we don't know yet.
@@ -333,9 +323,7 @@ func TestValidation(t *testing.T) {
333323
//{params.MainnetChainConfig, 0, 0, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}, nil},
334324

335325
// Local is mainnet Shanghai, remote announces Cancun. Local is out of sync, accept.
336-
//
337-
// TODO(karalabe): Enable this when Cancun is specced, update remote checksum
338-
//{params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x00000000), Next: 0}, nil},
326+
{params.MainnetChainConfig, 21000000, 1700000000, ID{Hash: checksumToBytes(0x9f3d2254), Next: 0}, nil},
339327

340328
// Local is mainnet Shanghai, remote announces Cancun, but is not aware of Prague. Local
341329
// out of sync. Local also knows about a future fork, but that is uncertain yet.
@@ -345,34 +333,28 @@ func TestValidation(t *testing.T) {
345333

346334
// Local is mainnet Cancun. remote announces Shanghai but is not aware of further forks.
347335
// Remote needs software update.
348-
//
349-
// TODO(karalabe): Enable this when Cancun is specced, update local head and time
350-
//{params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, ErrRemoteStale},
336+
{params.MainnetChainConfig, 21000000, 1710338135, ID{Hash: checksumToBytes(0xdce96c2d), Next: 0}, ErrRemoteStale},
351337

352338
// Local is mainnet Shanghai, and isn't aware of more forks. Remote announces Shanghai +
353339
// 0xffffffff. Local needs software update, reject.
354340
{params.MainnetChainConfig, 20000000, 1681338455, ID{Hash: checksumToBytes(checksumUpdate(0xdce96c2d, math.MaxUint64)), Next: 0}, ErrLocalIncompatibleOrStale},
355341

356342
// Local is mainnet Shanghai, and is aware of Cancun. Remote announces Cancun +
357343
// 0xffffffff. Local needs software update, reject.
358-
//
359-
// TODO(karalabe): Enable this when Cancun is specced, update remote checksum
360-
//{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(checksumUpdate(0x00000000, math.MaxUint64)), Next: 0}, ErrLocalIncompatibleOrStale},
344+
{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(checksumUpdate(0x9f3d2254, math.MaxUint64)), Next: 0}, ErrLocalIncompatibleOrStale},
361345

362346
// Local is mainnet Shanghai, remote is random Shanghai.
363347
{params.MainnetChainConfig, 20000000, 1681338455, ID{Hash: checksumToBytes(0x12345678), Next: 0}, ErrLocalIncompatibleOrStale},
364348

365-
// Local is mainnet Shanghai, far in the future. Remote announces Gopherium (non existing fork)
349+
// Local is mainnet Cancun, far in the future. Remote announces Gopherium (non existing fork)
366350
// at some future timestamp 8888888888, for itself, but past block for local. Local is incompatible.
367351
//
368352
// This case detects non-upgraded nodes with majority hash power (typical Ropsten mess).
369-
{params.MainnetChainConfig, 88888888, 8888888888, ID{Hash: checksumToBytes(0xdce96c2d), Next: 8888888888}, ErrLocalIncompatibleOrStale},
353+
{params.MainnetChainConfig, 88888888, 8888888888, ID{Hash: checksumToBytes(0x9f3d2254), Next: 8888888888}, ErrLocalIncompatibleOrStale},
370354

371355
// Local is mainnet Shanghai. Remote is also in Shanghai, but announces Gopherium (non existing
372356
// fork) at timestamp 1668000000, before Cancun. Local is incompatible.
373-
//
374-
// TODO(karalabe): Enable this when Cancun is specced
375-
//{params.MainnetChainConfig, 20999999, 1677999999, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, ErrLocalIncompatibleOrStale},
357+
{params.MainnetChainConfig, 20999999, 1699999999, ID{Hash: checksumToBytes(0x71147644), Next: 1700000000}, ErrLocalIncompatibleOrStale},
376358
}
377359
genesis := core.DefaultGenesisBlock().ToBlock()
378360
for i, tt := range tests {

params/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
TerminalTotalDifficulty: MainnetTerminalTotalDifficulty, // 58_750_000_000_000_000_000_000
5959
TerminalTotalDifficultyPassed: true,
6060
ShanghaiTime: newUint64(1681338455),
61+
CancunTime: newUint64(1710338135),
6162
Ethash: new(EthashConfig),
6263
}
6364
// HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network.

0 commit comments

Comments
 (0)