Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Shanghai hard-fork settings for Chiado testnet #5688

Merged
merged 7 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Nethermind/Chains/chiado.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"networkID": 10200,
"gasLimitBoundDivisor": "0x400",
"maximumExtraDataSize": "0x20",
"maxCodeSize": "0x6000",
"maxCodeSizeTransitionTimestamp": "0x646dff10",
"minGasLimit": "0x1388",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
Expand All @@ -62,6 +64,10 @@
"eip3529Transition": "0x0",
"eip3541Transition": "0x0",
"eip1559Transition": "0x0",
"eip3651TransitionTimestamp": "0x646dff10",
"eip3855TransitionTimestamp": "0x646dff10",
"eip3860TransitionTimestamp": "0x646dff10",
"eip4895TransitionTimestamp": "0x646dff10",
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2",
"eip1559FeeCollector": "0x1559000000000000000000000000000000000000",
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Network.Test/ForkInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void Fork_id_and_hash_as_expected_on_gnosis(long head, ulong headTimestam
Test(head, headTimestamp, KnownHashes.GnosisGenesis, forkHashHex, next, description, provider);
}

[TestCase(0, 0ul, "0x50d39d7b", 0ul, "Chiado genesis")]
[TestCase(0L, 0UL, "0x50d39d7b", ChiadoSpecProvider.ShanghaiTimestamp, "Chiado genesis")]
public void Fork_id_and_hash_as_expected_on_chiado(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 @@ -216,8 +216,10 @@ public void Chiado_loads_properly()
List<ForkActivation> forkActivationsToTest = new()
{
(ForkActivation)0,
(ForkActivation)1,
(ForkActivation)999_999_999, // far in the future
//(ForkActivation)1,
(1, ChiadoSpecProvider.ShanghaiTimestamp - 1),
(1, ChiadoSpecProvider.ShanghaiTimestamp),
(999_999_999, 999_999_999) // far in the future
};

CompareSpecProviders(chiado, provider, forkActivationsToTest, CompareSpecsOptions.IsGnosis);
Expand Down Expand Up @@ -322,7 +324,7 @@ enum CompareSpecsOptions
}
}

private static void CompareSpecs(IReleaseSpec expectedSpec, IReleaseSpec ActualSpec, ForkActivation activation, CompareSpecsOptions compareSpecsOptions)
private static void CompareSpecs(IReleaseSpec expectedSpec, IReleaseSpec actualSpec, ForkActivation activation, CompareSpecsOptions compareSpecsOptions)
{
bool isMainnet = (compareSpecsOptions & CompareSpecsOptions.IsMainnet) != 0;
bool checkDifficultyBomb = (compareSpecsOptions & CompareSpecsOptions.CheckDifficultyBomb) != 0;
Expand Down Expand Up @@ -355,7 +357,7 @@ private static void CompareSpecs(IReleaseSpec expectedSpec, IReleaseSpec ActualS
.Where(p => !isGnosis || p.Name != nameof(IReleaseSpec.LimitCodeSize))
.Where(p => !isGnosis || p.Name != nameof(IReleaseSpec.UseConstantinopleNetGasMetering)))
{
Assert.That(propertyInfo.GetValue(ActualSpec), Is.EqualTo(propertyInfo.GetValue(expectedSpec)),
Assert.That(propertyInfo.GetValue(actualSpec), Is.EqualTo(propertyInfo.GetValue(expectedSpec)),
activation + "." + propertyInfo.Name);
}
}
Expand Down
35 changes: 16 additions & 19 deletions src/Nethermind/Nethermind.Specs/ChiadoSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,36 @@ namespace Nethermind.Specs;

public class ChiadoSpecProvider : ISpecProvider
{
public static readonly ChiadoSpecProvider Instance = new();
public const ulong ShanghaiTimestamp = 0x646dff10UL;

private ChiadoSpecProvider() { }

private ForkActivation? _theMergeBlock = null;
private UInt256? _terminalTotalDifficulty = UInt256.Parse("231707791542740786049188744689299064356246512");
public IReleaseSpec GetSpec(ForkActivation forkActivation) => forkActivation.BlockNumber switch
{
_ => forkActivation.Timestamp switch
{
null or < ShanghaiTimestamp => GenesisSpec,
_ => Shanghai.Instance
}
};

public void UpdateMergeTransitionInfo(long? blockNumber, UInt256? terminalTotalDifficulty = null)
{
if (blockNumber is not null)
_theMergeBlock = (ForkActivation)blockNumber;
MergeBlockNumber = (ForkActivation)blockNumber;

if (terminalTotalDifficulty is not null)
_terminalTotalDifficulty = terminalTotalDifficulty;
TerminalTotalDifficulty = terminalTotalDifficulty;
}

public ForkActivation? MergeBlockNumber => _theMergeBlock;
public ForkActivation? MergeBlockNumber { get; private set; }
public ulong TimestampFork => ShanghaiTimestamp;
public UInt256? TerminalTotalDifficulty => _terminalTotalDifficulty;
public UInt256? TerminalTotalDifficulty { get; private set; } = UInt256.Parse("231707791542740786049188744689299064356246512");
public IReleaseSpec GenesisSpec => London.Instance;
public long? DaoBlockNumber => null;
public ulong NetworkId => BlockchainIds.Chiado;
public ulong ChainId => BlockchainIds.Chiado;
public ForkActivation[] TransitionActivations { get; }
public IReleaseSpec GetSpec(ForkActivation forkActivation)
{
return forkActivation.BlockNumber switch
{
_ => forkActivation.Timestamp switch
{
null or < ShanghaiTimestamp => GenesisSpec,
_ => Shanghai.Instance
}
};
}

public const ulong ShanghaiTimestamp = long.MaxValue;
public static ChiadoSpecProvider Instance { get; } = new();
}
Loading