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

Enable Gnosis Pectra #8095

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions src/Nethermind/Chains/chiado.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@
"eip4844MaxBlobGasPerBlock": "0x40000",
"eip4844MinBlobGasPrice": "0x3b9aca00",
"eip4844TargetBlobGasPerBlock": "0x20000",
"eip4844FeeCollectorTransitionTimestamp": "0x56343EE4C",
"eip2537TransitionTimestamp": "0x56343EE4C",
"eip2935TransitionTimestamp": "0x56343EE4C",
"eip6110TransitionTimestamp": "0x56343EE4C",
"eip7002TransitionTimestamp": "0x56343EE4C",
"eip7251TransitionTimestamp": "0x56343EE4C",
"eip7549TransitionTimestamp": "0x56343EE4C",
"eip7594TransitionTimestamp": "0x56343EE4C",
"eip7623TransitionTimestamp": "0x56343EE4C",
"eip7685TransitionTimestamp": "0x56343EE4C",
"eip7702TransitionTimestamp": "0x56343EE4C",
"registrar": "0x6000000000000000000000000000000000000000",
"transactionPermissionContract": "0x4000000000000000000000000000000000000001",
"transactionPermissionContractTransition": "0x0",
Expand Down
11 changes: 11 additions & 0 deletions src/Nethermind/Chains/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
"eip4844MaxBlobGasPerBlock": "0x40000",
"eip4844MinBlobGasPrice": "0x3b9aca00",
"eip4844TargetBlobGasPerBlock": "0x20000",
"eip4844FeeCollectorTransitionTimestamp": "0x561B10DBC",
"eip2537TransitionTimestamp": "0x561B10DBC",
"eip2935TransitionTimestamp": "0x561B10DBC",
"eip6110TransitionTimestamp": "0x561B10DBC",
"eip7002TransitionTimestamp": "0x561B10DBC",
"eip7251TransitionTimestamp": "0x561B10DBC",
"eip7549TransitionTimestamp": "0x561B10DBC",
"eip7594TransitionTimestamp": "0x561B10DBC",
"eip7623TransitionTimestamp": "0x561B10DBC",
"eip7685TransitionTimestamp": "0x561B10DBC",
"eip7702TransitionTimestamp": "0x561B10DBC",
"registrar": "0x6B53721D4f2Fb9514B85f5C49b197D857e36Cf03",
"transactionPermissionContract": "0x7Dd7032AA75A37ea0b150f57F899119C7379A78b",
"transactionPermissionContractTransition": 9186425,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ public static IEnumerable<TestCaseData> ChiadoActivations
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.ShanghaiTimestamp)) { TestName = "Shanghai" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.CancunTimestamp - 1)) { TestName = "Before Cancun" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.CancunTimestamp)) { TestName = "Cancun" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.CancunTimestamp + 100000000)) { TestName = "Future" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.PragueTimestamp - 1)) { TestName = "Before Prague" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.PragueTimestamp)) { TestName = "Prague" };
yield return new TestCaseData((ForkActivation)(1, ChiadoSpecProvider.PragueTimestamp + 100000000)) { TestName = "Future" };
}
}

Expand All @@ -209,15 +211,21 @@ public void Chiado_loads_properly(ForkActivation forkActivation)
ChiadoSpecProvider chiado = ChiadoSpecProvider.Instance;

CompareSpecs(chiado, provider, forkActivation, CompareSpecsOptions.IsGnosis);
Assert.That(provider.TerminalTotalDifficulty, Is.EqualTo(ChiadoSpecProvider.Instance.TerminalTotalDifficulty));
Assert.That(provider.ChainId, Is.EqualTo(BlockchainIds.Chiado));
Assert.That(provider.NetworkId, Is.EqualTo(BlockchainIds.Chiado));
Assert.Multiple(() =>
{
Assert.That(provider.TerminalTotalDifficulty, Is.EqualTo(ChiadoSpecProvider.Instance.TerminalTotalDifficulty));
Assert.That(provider.ChainId, Is.EqualTo(BlockchainIds.Chiado));
Assert.That(provider.NetworkId, Is.EqualTo(BlockchainIds.Chiado));
});

IReleaseSpec? preShanghaiSpec = provider.GetSpec((1, ChiadoSpecProvider.ShanghaiTimestamp - 1));
IReleaseSpec? postShanghaiSpec = provider.GetSpec((1, ChiadoSpecProvider.ShanghaiTimestamp));
IReleaseSpec? prePragueSpec = provider.GetSpec((1, ChiadoSpecProvider.PragueTimestamp - 1));
IReleaseSpec? postPragueSpec = provider.GetSpec((1, ChiadoSpecProvider.PragueTimestamp));

VerifyGnosisShanghaiSpecifics(preShanghaiSpec, postShanghaiSpec);
VerifyGnosisCancunSpecifics();
VerifyGnosisPragueSpecifics(prePragueSpec, postPragueSpec, ChiadoSpecProvider.FeeCollector);
GetTransitionTimestamps(chainSpec.Parameters).Should().AllSatisfy(
static t => ValidateSlotByTimestamp(t, ChiadoSpecProvider.BeaconChainGenesisTimestampConst, GnosisBlockTime).Should().BeTrue());
}
Expand Down Expand Up @@ -246,7 +254,11 @@ public static IEnumerable<TestCaseData> GnosisActivations
{ 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))
yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.PragueTimestamp - 1))
{ TestName = "Before Prague" };
yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.PragueTimestamp))
{ TestName = "Prague" };
yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.PragueTimestamp + 100000000))
{ TestName = "Future" };
}
}
Expand All @@ -259,21 +271,38 @@ public void Gnosis_loads_properly(ForkActivation forkActivation)
GnosisSpecProvider gnosisSpecProvider = GnosisSpecProvider.Instance;

CompareSpecs(gnosisSpecProvider, provider, forkActivation, CompareSpecsOptions.IsGnosis);
Assert.That(provider.TerminalTotalDifficulty, Is.EqualTo(GnosisSpecProvider.Instance.TerminalTotalDifficulty));
Assert.That(provider.ChainId, Is.EqualTo(BlockchainIds.Gnosis));
Assert.That(provider.NetworkId, Is.EqualTo(BlockchainIds.Gnosis));
Assert.Multiple(() =>
{
Assert.That(provider.TerminalTotalDifficulty, Is.EqualTo(GnosisSpecProvider.Instance.TerminalTotalDifficulty));
Assert.That(provider.ChainId, Is.EqualTo(BlockchainIds.Gnosis));
Assert.That(provider.NetworkId, Is.EqualTo(BlockchainIds.Gnosis));
});

VerifyGnosisPreShanghaiSpecifics(provider);

IReleaseSpec? preShanghaiSpec = provider.GetSpec((1, GnosisSpecProvider.ShanghaiTimestamp - 1));
IReleaseSpec? postShanghaiSpec = provider.GetSpec((1, GnosisSpecProvider.ShanghaiTimestamp));
IReleaseSpec? prePragueSpec = provider.GetSpec((1, GnosisSpecProvider.PragueTimestamp - 1));
IReleaseSpec? postPragueSpec = provider.GetSpec((1, GnosisSpecProvider.PragueTimestamp));

VerifyGnosisShanghaiSpecifics(preShanghaiSpec, postShanghaiSpec);
VerifyGnosisCancunSpecifics();
VerifyGnosisPragueSpecifics(prePragueSpec, postPragueSpec, GnosisSpecProvider.FeeCollector);
GetTransitionTimestamps(chainSpec.Parameters).Should().AllSatisfy(
static t => ValidateSlotByTimestamp(t, GnosisSpecProvider.BeaconChainGenesisTimestampConst, GnosisBlockTime).Should().BeTrue());
}

private static void VerifyGnosisPragueSpecifics(IReleaseSpec prePragueSpec, IReleaseSpec postPragueSpec, Address feeCollector)
{
Assert.Multiple(() =>
{
Assert.That(prePragueSpec.FeeCollector, Is.EqualTo(feeCollector));
Assert.That(postPragueSpec.FeeCollector, Is.EqualTo(feeCollector));
Assert.That(prePragueSpec.IsEip4844FeeCollectorEnabled, Is.EqualTo(false));
Assert.That(postPragueSpec.IsEip4844FeeCollectorEnabled, Is.EqualTo(true));
});
}

private static void VerifyGnosisCancunSpecifics()
{
Assert.Multiple(static () =>
Expand Down Expand Up @@ -318,7 +347,6 @@ public static IEnumerable<TestCaseData> MainnetActivations
get
{
yield return new TestCaseData((ForkActivation)0) { TestName = "Genesis" };
yield return new TestCaseData((ForkActivation)(0, null)) { TestName = "Genesis null" };
yield return new TestCaseData((ForkActivation)(0, 0)) { TestName = "Genesis timestamp" };
yield return new TestCaseData((ForkActivation)1) { TestName = "Genesis + 1" };
yield return new TestCaseData((ForkActivation)(MainnetSpecProvider.HomesteadBlockNumber - 1)) { TestName = "Before Homestead" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ private ReleaseSpec CreateReleaseSpec(ChainSpec chainSpec, long releaseStartBloc
releaseSpec.ValidateChainId = (chainSpec.Parameters.ValidateChainIdTransition ?? 0) <= releaseStartBlock;
releaseSpec.ValidateReceipts = ((chainSpec.Parameters.ValidateReceiptsTransition > 0) ? Math.Max(chainSpec.Parameters.ValidateReceiptsTransition ?? 0, chainSpec.Parameters.Eip658Transition ?? 0) : 0) <= releaseStartBlock;

bool eip1559FeeCollector = releaseSpec.IsEip1559Enabled && (chainSpec.Parameters.Eip1559FeeCollectorTransition ?? long.MaxValue) <= releaseStartBlock;
bool eip4844FeeCollector = releaseSpec.IsEip4844Enabled && (chainSpec.Parameters.Eip4844FeeCollectorTransitionTimestamp ?? long.MaxValue) <= releaseStartTimestamp;
releaseSpec.FeeCollector = (eip1559FeeCollector || eip4844FeeCollector) ? chainSpec.Parameters.FeeCollector : null;

releaseSpec.Eip1559BaseFeeMinValue = releaseSpec.IsEip1559Enabled && (chainSpec.Parameters.Eip1559BaseFeeMinValueTransition ?? long.MaxValue) <= releaseStartBlock ? chainSpec.Parameters.Eip1559BaseFeeMinValue : null;
releaseSpec.ElasticityMultiplier = chainSpec.Parameters.Eip1559ElasticityMultiplier ?? Eip1559Constants.DefaultElasticityMultiplier;
releaseSpec.ForkBaseFee = chainSpec.Parameters.Eip1559BaseFeeInitialValue ?? Eip1559Constants.DefaultForkBaseFee;
Expand Down Expand Up @@ -237,6 +233,11 @@ private ReleaseSpec CreateReleaseSpec(ChainSpec chainSpec, long releaseStartBloc

releaseSpec.IsOntakeEnabled = (chainSpec.Parameters.OntakeTransition ?? long.MaxValue) <= releaseStartBlock;

bool eip1559FeeCollector = releaseSpec.IsEip1559Enabled && (chainSpec.Parameters.Eip1559FeeCollectorTransition ?? long.MaxValue) <= releaseStartBlock;
bool eip4844FeeCollector = releaseSpec.IsEip4844Enabled && (chainSpec.Parameters.Eip4844FeeCollectorTransitionTimestamp ?? long.MaxValue) <= releaseStartTimestamp;
releaseSpec.FeeCollector = (eip1559FeeCollector || eip4844FeeCollector) ? chainSpec.Parameters.FeeCollector : null;
releaseSpec.IsEip4844FeeCollectorEnabled = eip4844FeeCollector;

foreach (IChainSpecEngineParameters item in _chainSpec.EngineChainSpecParametersProvider
.AllChainSpecParameters)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Specs/ChiadoSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class ChiadoSpecProvider : ISpecProvider
public const ulong BeaconChainGenesisTimestampConst = 0x6343ee4c;
public const ulong ShanghaiTimestamp = 0x646e0e4c;
public const ulong CancunTimestamp = 0x65ba8e4c;
//TODO correct this timestamp!
public const ulong PragueTimestamp = ulong.MaxValue - 2;
public const ulong PragueTimestamp = 0x56343EE4C;
public static readonly Address FeeCollector = new("0x1559000000000000000000000000000000000000");

private ChiadoSpecProvider() { }

Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class GnosisSpecProvider : ISpecProvider
public const ulong BeaconChainGenesisTimestampConst = 0x61b10dbc;
public const ulong ShanghaiTimestamp = 0x64c8edbc;
public const ulong CancunTimestamp = 0x65ef4dbc;
//TODO correct this timestamp!
public const ulong PragueTimestamp = ulong.MaxValue - 2;
public const ulong PragueTimestamp = 0x561B10DBC;
public static readonly Address FeeCollector = new("0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92");

private GnosisSpecProvider() { }

Expand Down
Loading