Skip to content

Commit

Permalink
Sepolia Shanghai configs (#5280)
Browse files Browse the repository at this point in the history
* sepolia timestamps

* changed SepoliaSpecProvider

* Sepolia

* add ForkInfoTests

* whitespaces in chainspec
  • Loading branch information
MarekM25 authored and kamilchodola committed Feb 13, 2023
1 parent 5ddb742 commit e8155a8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Nethermind/Chains/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
"eip3529Transition": "0x0",
"eip3541Transition": "0x0",
"terminalTotalDifficulty": "3C6568F12E8000",
"mergeForkIdTransition": "0x1A7ACB"
"mergeForkIdTransition": "0x1A7ACB",
"eip4895TransitionTimestamp": "0x63FD7D60",
"eip3855TransitionTimestamp": "0x63FD7D60",
"eip3651TransitionTimestamp": "0x63FD7D60",
"eip3860TransitionTimestamp": "0x63FD7D60"
},
"genesis": {
"seal": {
Expand Down
4 changes: 3 additions & 1 deletion src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public void Fork_id_and_hash_as_expected_on_ropsten(long head, ulong headTimesta

[TestCase(0, 0ul, "0xFE3366E7", 1735371ul, "Sepolia genesis")]
[TestCase(1735370, 0ul, "0xFE3366E7", 1735371ul, "Sepolia Last block before MergeForkIdTranstion")]
[TestCase(1735371, 0ul, "0xb96cbd13", 0ul, "First block - Sepolia MergeForkIdTransition")]
[TestCase(1735371, 0ul, "0xb96cbd13", 1677557088UL, "First block - Sepolia MergeForkIdTransition")]
[TestCase(1735372, 1677557088ul, "0xf7f9bc08", 0ul, "Shanghai")]
[TestCase(1735372, 2677557088ul, "0xf7f9bc08", 0ul, "Future Shanghai")]
public void Fork_id_and_hash_as_expected_on_sepolia(long head, ulong headTimestamp, string forkHashHex, ulong next, string description)
{
Test(head, headTimestamp, KnownHashes.SepoliaGenesis, forkHashHex, next, description, SepoliaSpecProvider.Instance, "sepolia.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ public void Sepolia_loads_properly()

List<ForkActivation> forkActivationsToTest = new()
{
(ForkActivation)120_000_000, // far in the future
new ForkActivation(2, 0),
new ForkActivation(120_000_000, 0),
new ForkActivation(1735372, 3),
new ForkActivation(1735372, 1677557088),
new ForkActivation(1735372, 1677557087)
};

CompareSpecProviders(sepolia, provider, forkActivationsToTest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ public void Can_load_spaceneth()
chainSpec.GrayGlacierBlockNumber.Should().Be(null);
}

[Test]
public void Can_load_sepolia()
{
string path = Path.Combine(TestContext.CurrentContext.WorkDirectory, "../../../../", "Chains/sepolia.json");
ChainSpec chainSpec = LoadChainSpec(path);

Assert.AreEqual(11155111, chainSpec.NetworkId, $"{nameof(chainSpec.NetworkId)}");
Assert.AreEqual("Sepolia Testnet", chainSpec.Name, $"{nameof(chainSpec.Name)}");
Assert.AreEqual("sepolia", chainSpec.DataDir, $"{nameof(chainSpec.Name)}");
Assert.AreEqual("Ethash", chainSpec.SealEngineType, "engine");

chainSpec.LondonBlockNumber.Should().Be(0L);
chainSpec.ShanghaiTimestamp.Should().Be(1677557088);
}

[Test]
public void Can_load_posdao_with_openethereum_pricing_transitions()
{
Expand Down
11 changes: 9 additions & 2 deletions src/Nethermind/Nethermind.Specs/SepoliaSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalD
public UInt256? TerminalTotalDifficulty => _terminalTotalDifficulty;
public IReleaseSpec GenesisSpec => London.Instance;

public IReleaseSpec GetSpec(ForkActivation forkActivation) => London.Instance;
public const ulong ShanghaiBlockTimestamp = 1677557088;

public IReleaseSpec GetSpec(ForkActivation forkActivation) =>
forkActivation switch
{
{ Timestamp: null } or { Timestamp: < ShanghaiBlockTimestamp } => London.Instance,
_ => Shanghai.Instance
};

public long? DaoBlockNumber => null;


public ulong NetworkId => Core.BlockchainIds.Rinkeby;
public ulong ChainId => NetworkId;

public ForkActivation[] TransitionActivations { get; } = { (ForkActivation)1735371 };
public ForkActivation[] TransitionActivations { get; } = { (ForkActivation)1735371, new ForkActivation(1735371, 1677557088) };

private SepoliaSpecProvider() { }

Expand Down

0 comments on commit e8155a8

Please sign in to comment.