Skip to content

Commit

Permalink
Fix Gnosis blob fee collection (#8091)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchhill authored Jan 23, 2025
1 parent 60f18fa commit 2d8b87e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
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

0 comments on commit 2d8b87e

Please sign in to comment.