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

Fix Gnosis blob fee collection #8091

Merged
merged 4 commits into from
Jan 23, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public static IEnumerable<TestCaseData> ChiadoActivations
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 +212,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 @@ -248,6 +257,12 @@ public static IEnumerable<TestCaseData> GnosisActivations
{ TestName = "Cancun" };
yield return new TestCaseData((ForkActivation)(GnosisSpecProvider.LondonBlockNumber + 2, GnosisSpecProvider.CancunTimestamp + 100000000))
{ TestName = "Future" };
// 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 +274,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
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
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Specs/ChiadoSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ChiadoSpecProvider : ISpecProvider
public const ulong CancunTimestamp = 0x65ba8e4c;
//TODO correct this timestamp!
public const ulong PragueTimestamp = ulong.MaxValue - 2;
public static readonly Address FeeCollector = new("0x1559000000000000000000000000000000000000");

private ChiadoSpecProvider() { }

Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Specs/GnosisSpecProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class GnosisSpecProvider : ISpecProvider
public const ulong CancunTimestamp = 0x65ef4dbc;
//TODO correct this timestamp!
public const ulong PragueTimestamp = ulong.MaxValue - 2;
public static readonly Address FeeCollector = new("0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92");

private GnosisSpecProvider() { }

Expand Down
Loading