Skip to content

Commit

Permalink
Add Gnosis Shanghai hard-fork timestamp (#5848)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo authored and kamilchodola committed Jun 26, 2023
1 parent 8f9172c commit e8ac1da
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/Nethermind/Chains/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
}
},
"params": {
"networkID": "100",
"gasLimitBoundDivisor": "0x400",
"maximumExtraDataSize": "0x20",
"maxCodeSize": "0x6000",
"maxCodeSizeTransitionTimestamp": "0x64c8edbc",
"minGasLimit": "0x1388",
"networkID": "100",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
Expand All @@ -68,6 +70,10 @@
"eip3529Transition": 19040000,
"eip3541Transition": 19040000,
"eip1559Transition": 19040000,
"eip3651TransitionTimestamp": "0x64c8edbc",
"eip3855TransitionTimestamp": "0x64c8edbc",
"eip3860TransitionTimestamp": "0x64c8edbc",
"eip4895TransitionTimestamp": "0x64c8edbc",
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2",
"eip1559BaseFeeInitialValue": "0x3b9aca00",
Expand Down
6 changes: 4 additions & 2 deletions src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ public void Fork_id_and_hash_as_expected_on_sepolia(long head, ulong headTimesta
[TestCase(16101499, 0ul, "0xb6e6cd81", 16101500ul, "Last POSDAO Activation block")]
[TestCase(16101500, 0ul, "0x069a83d9", 19040000ul, "First Berlin block")]
[TestCase(19039999, 0ul, "0x069a83d9", 19040000ul, "Last Berlin block")]
[TestCase(19040000, 0ul, "0x018479d3", 0ul, "First London block")]
[TestCase(21735000, 0ul, "0x018479d3", 0ul, "First GIP-31 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")]
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Nethermind.Specs.Test.ChainSpecStyle;
[TestFixture]
public class ChainSpecBasedSpecProviderTests
{
private const ulong GnosisBlockTime = 5;
private const double GnosisBlockTime = 5;

[TestCase(0, null, false)]
[TestCase(0, 0ul, false)]
Expand Down Expand Up @@ -265,15 +265,14 @@ public void Gnosis_loads_properly()

VerifyGnosisPreShanghaiExceptions(provider);

/* ToDo uncomment with Gnosis fork specified
IReleaseSpec? preShanghaiSpec = provider.GetSpec((GnosisSpecProvider.LondonBlockNumber + 1,
GnosisSpecProvider.ShanghaiTimestamp - 1));
IReleaseSpec? postShanghaiSpec = provider.GetSpec((GnosisSpecProvider.LondonBlockNumber + 1,
GnosisSpecProvider.ShanghaiTimestamp));

VerifyGnosisPreShanghaiExceptions(preShanghaiSpec, postShanghaiSpec);
VerifyGnosisShanghaiExceptions(preShanghaiSpec, postShanghaiSpec);
GetTransitionTimestamps(chainSpec.Parameters).Should().AllSatisfy(
t => ValidateSlotByTimestamp(t, GnosisSpecProvider.BeaconChainGenesisTimestamp, GnosisBlockTime).Should().BeTrue()); */
t => ValidateSlotByTimestamp(t, GnosisSpecProvider.BeaconChainGenesisTimestamp, GnosisBlockTime).Should().BeTrue());
}

private void VerifyGnosisShanghaiExceptions(IReleaseSpec preShanghaiSpec, IReleaseSpec postShanghaiSpec)
Expand Down Expand Up @@ -830,6 +829,8 @@ private static IEnumerable<ulong> GetTransitionTimestamps(ChainParameters parame
/// <param name="genesisTimestamp">The network's genesis timestamp</param>
/// <param name="blockTime">The network's block time in seconds</param>
/// <returns><c>true</c> if the timestamp is valid; otherwise, <c>false</c>.</returns>
private static bool ValidateSlotByTimestamp(ulong timestamp, ulong genesisTimestamp, ulong blockTime = 12) =>
timestamp > genesisTimestamp && (timestamp - genesisTimestamp) / blockTime % 0x2000 == 0;
private static bool ValidateSlotByTimestamp(ulong timestamp, ulong genesisTimestamp, double blockTime = 12) =>
timestamp > genesisTimestamp &&
Math.Round((timestamp - genesisTimestamp) / blockTime) % 0x2000 == 0 &&
Math.Ceiling((timestamp - genesisTimestamp) / blockTime) % 0x2000 == 0;
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GnosisSpecProvider : ISpecProvider
public const long BerlinBlockNumber = 16_101_500;
public const long LondonBlockNumber = 19_040_000;
public const ulong BeaconChainGenesisTimestamp = 0x61b10dbc;
public const ulong ShanghaiTimestamp = long.MaxValue;
public const ulong ShanghaiTimestamp = 0x64c8edbc;

private GnosisSpecProvider() { }

Expand Down

0 comments on commit e8ac1da

Please sign in to comment.