From dc320a1cfa42303a2163d8baec3d3bfb9e1b9590 Mon Sep 17 00:00:00 2001 From: Ruben Buniatyan Date: Tue, 13 Feb 2024 14:37:28 +0100 Subject: [PATCH] Add Cancun hard-fork settings for Gnosis (#6709) --- src/Nethermind/Chains/gnosis.json | 5 +++++ .../Nethermind.Network.Test/ForkInfoTests.cs | 5 +++-- .../ChainSpecBasedSpecProviderTests.cs | 14 +++++++------- .../Nethermind.Specs/GnosisSpecProvider.cs | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Nethermind/Chains/gnosis.json b/src/Nethermind/Chains/gnosis.json index 4a43af2e159..ca9066ebbf9 100644 --- a/src/Nethermind/Chains/gnosis.json +++ b/src/Nethermind/Chains/gnosis.json @@ -74,6 +74,11 @@ "eip3855TransitionTimestamp": "0x64c8edbc", "eip3860TransitionTimestamp": "0x64c8edbc", "eip4895TransitionTimestamp": "0x64c8edbc", + "eip1153TransitionTimestamp": "0x65ef4dbc", + "eip4788TransitionTimestamp": "0x65ef4dbc", + "eip4844TransitionTimestamp": "0x65ef4dbc", + "eip5656TransitionTimestamp": "0x65ef4dbc", + "eip6780TransitionTimestamp": "0x65ef4dbc", "eip1559BaseFeeMaxChangeDenominator": "0x8", "eip1559ElasticityMultiplier": "0x2", "eip1559BaseFeeInitialValue": "0x3b9aca00", diff --git a/src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs b/src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs index 135b8d7733e..329fb2d7b47 100644 --- a/src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs +++ b/src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs @@ -155,8 +155,9 @@ public void Fork_id_and_hash_as_expected_on_sepolia(long head, ulong headTimesta [TestCase(19039999, 0ul, "0x069a83d9", 19040000ul, "Last Berlin block")] [TestCase(19040000, 0ul, "0x018479d3", GnosisSpecProvider.ShanghaiTimestamp, "First London block")] [TestCase(21735000, 0ul, "0x018479d3", GnosisSpecProvider.ShanghaiTimestamp, "First GIP-31 block")] - [TestCase(31735000, GnosisSpecProvider.ShanghaiTimestamp, "0x2efe91ba", 0ul, "First Shanghai timestamp")] - [TestCase(91735000, GnosisSpecProvider.ShanghaiTimestamp, "0x2efe91ba", 0ul, "Future Shanghai timestamp")] + [TestCase(31735000, GnosisSpecProvider.ShanghaiTimestamp, "0x2efe91ba", GnosisSpecProvider.CancunTimestamp, "First Shanghai timestamp")] + [TestCase(41735000, GnosisSpecProvider.CancunTimestamp, "0x1384dfc1", 0ul, "First Cancun timestamp")] + [TestCase(91735000, GnosisSpecProvider.CancunTimestamp, "0x1384dfc1", 0ul, "Future Cancun timestamp")] public void Fork_id_and_hash_as_expected_on_gnosis(long head, ulong headTimestamp, string forkHashHex, ulong next, string description) { ChainSpecLoader loader = new ChainSpecLoader(new EthereumJsonSerializer()); diff --git a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs index e49b17f721c..5d2eb0fdb87 100644 --- a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs +++ b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs @@ -272,9 +272,11 @@ public static IEnumerable GnosisActivations yield return new TestCaseData((ForkActivation)GnosisSpecProvider.BerlinBlockNumber) { TestName = "Berlin" }; yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber - 1)) { TestName = "Before London" }; yield return new TestCaseData((ForkActivation)GnosisSpecProvider.LondonBlockNumber) { TestName = "London" }; - yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber, GnosisSpecProvider.ShanghaiTimestamp - 1)) { TestName = "Before Shanghai" }; - yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber, GnosisSpecProvider.ShanghaiTimestamp)) { TestName = "Shanghai" }; - yield return new TestCaseData((ForkActivation)(999_999_999, 999_999_999)) { TestName = "Future" }; + yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 1, GnosisSpecProvider.ShanghaiTimestamp - 1)) { TestName = "Before Shanghai" }; + yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 1, GnosisSpecProvider.ShanghaiTimestamp)) { TestName = "Shanghai" }; + yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.CancunTimestamp - 1)) { TestName = "Before Cancun" }; + yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.CancunTimestamp)) { TestName = "Cancun" }; + yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.CancunTimestamp + 100000000)) { TestName = "Future" }; } } @@ -292,10 +294,8 @@ public void Gnosis_loads_properly(ForkActivation forkActivation) VerifyGnosisPreShanghaiSpecifics(provider); - IReleaseSpec? preShanghaiSpec = provider.GetSpec((GnosisSpecProvider.LondonBlockNumber + 1, - GnosisSpecProvider.ShanghaiTimestamp - 1)); - IReleaseSpec? postShanghaiSpec = provider.GetSpec((GnosisSpecProvider.LondonBlockNumber + 1, - GnosisSpecProvider.ShanghaiTimestamp)); + IReleaseSpec? preShanghaiSpec = provider.GetSpec((1, GnosisSpecProvider.ShanghaiTimestamp - 1)); + IReleaseSpec? postShanghaiSpec = provider.GetSpec((1, GnosisSpecProvider.ShanghaiTimestamp)); VerifyGnosisShanghaiSpecifics(preShanghaiSpec, postShanghaiSpec); VerifyGnosisCancunSpecifics(); diff --git a/src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs b/src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs index a3fccaffb44..e79bf4fe228 100644 --- a/src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs +++ b/src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs @@ -17,6 +17,7 @@ public class GnosisSpecProvider : ISpecProvider public const long LondonBlockNumber = 19_040_000; public const ulong BeaconChainGenesisTimestamp = 0x61b10dbc; public const ulong ShanghaiTimestamp = 0x64c8edbc; + public const ulong CancunTimestamp = 0x65ef4dbc; private GnosisSpecProvider() { } @@ -32,7 +33,8 @@ public IReleaseSpec GetSpec(ForkActivation forkActivation) _ => forkActivation.Timestamp switch { null or < ShanghaiTimestamp => London.Instance, - _ => Shanghai.Instance + < CancunTimestamp => Shanghai.Instance, + _ => Cancun.Instance } }; }