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

Revert "Add OP Holocene fork (#7761)" #7791

Merged
merged 1 commit into from
Nov 22, 2024
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
4 changes: 1 addition & 3 deletions src/Nethermind/Chains/base-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"ecotoneTimestamp": "0x65d62c10",
"fjordTimestamp": "0x66575100",
"graniteTimestamp": "0x66ba3180",
"holoceneTimestamp": "0x6745e270",
"l1FeeRecipient": "0x420000000000000000000000000000000000001A",
"l1BlockAddress": "0x4200000000000000000000000000000000000015",
"canyonBaseFeeChangeDenominator": "250",
Expand Down Expand Up @@ -65,10 +64,9 @@
"eip4844TransitionTimestamp": "0x65D62C10",
"eip5656TransitionTimestamp": "0x65D62C10",
"eip6780TransitionTimestamp": "0x65D62C10",

"rip7212TransitionTimestamp": "0x66575100",
"opGraniteTransitionTimestamp": "0x66ba3180",
"opHoloceneTransitionTimestamp": "0x6745e270",

"terminalTotalDifficulty": "0"
},
Expand Down
2 changes: 0 additions & 2 deletions src/Nethermind/Chains/op-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"ecotoneTimestamp": "0x65D62C10",
"fjordTimestamp": "0x66575100",
"graniteTimestamp": "0x66ba3180",
"holoceneTimestamp": "0x6745e270",
"l1FeeRecipient": "0x420000000000000000000000000000000000001A",
"l1BlockAddress": "0x4200000000000000000000000000000000000015",
"canyonBaseFeeChangeDenominator": "250",
Expand Down Expand Up @@ -65,7 +64,6 @@
"eip6780TransitionTimestamp": "0x65D62C10",
"rip7212TransitionTimestamp": "0x66575100",
"opGraniteTransitionTimestamp": "0x66ba3180",
"opHoloceneTransitionTimestamp": "0x6745e270",
"terminalTotalDifficulty": "0"
},
"genesis": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HeaderValidator : IHeaderValidator
private static readonly byte[] DaoExtraData = Bytes.FromHexString("0x64616f2d686172642d666f726b");

private readonly ISealValidator _sealValidator;
protected readonly ISpecProvider _specProvider;
private readonly ISpecProvider _specProvider;
private readonly long? _daoBlockNumber;
protected readonly ILogger _logger;
private readonly IBlockTree _blockTree;
Expand Down
1 change: 0 additions & 1 deletion src/Nethermind/Nethermind.Core.Test/BlockHeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public void Eip_1559_CalculateBaseFee_should_returns_zero_when_eip1559_not_enabl
public void Eip_1559_CalculateBaseFee(long gasTarget, long baseFee, long expectedBaseFee, long gasUsed, long? minimalBaseFee = null)
{
IReleaseSpec releaseSpec = Substitute.For<IReleaseSpec>();
releaseSpec.BaseFeeCalculator.Returns(new DefaultBaseFeeCalculator());
releaseSpec.IsEip1559Enabled.Returns(true);
releaseSpec.Eip1559BaseFeeMinValue.Returns((UInt256?)minimalBaseFee);
releaseSpec.ForkBaseFee.Returns(Eip1559Constants.DefaultForkBaseFee);
Expand Down
98 changes: 43 additions & 55 deletions src/Nethermind/Nethermind.Core/BaseFeeCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,55 @@
using Nethermind.Core.Specs;
using Nethermind.Int256;

namespace Nethermind.Core;

public interface IBaseFeeCalculator
namespace Nethermind.Core
{
UInt256 Calculate(BlockHeader parent, IEip1559Spec specFor1559);
}

/// <summary>
/// Calculate <c>BaseFee</c> based on parent <see cref="BlockHeader"/> and <see cref="IEip1559Spec"/>.
/// </summary>
public sealed class DefaultBaseFeeCalculator : IBaseFeeCalculator
{
public UInt256 Calculate(BlockHeader parent, IEip1559Spec specFor1559)
/// <summary>Calculate BaseFee based on block parent and release spec.</summary>
public static class BaseFeeCalculator
{
UInt256 expectedBaseFee = parent.BaseFeePerGas;
if (specFor1559.IsEip1559Enabled)
public static UInt256 Calculate(BlockHeader parent, IEip1559Spec specFor1559)
{
UInt256 parentBaseFee = parent.BaseFeePerGas;
long gasDelta;
UInt256 feeDelta;
bool isForkBlockNumber = specFor1559.Eip1559TransitionBlock == parent.Number + 1;
long parentGasTarget = parent.GasLimit / specFor1559.ElasticityMultiplier;
if (isForkBlockNumber)
parentGasTarget = parent.GasLimit;

if (parent.GasUsed == parentGasTarget)
{
expectedBaseFee = parent.BaseFeePerGas;
}
else if (parent.GasUsed > parentGasTarget)
{
gasDelta = parent.GasUsed - parentGasTarget;
feeDelta = UInt256.Max(
parentBaseFee * (UInt256)gasDelta / (UInt256)parentGasTarget / specFor1559.BaseFeeMaxChangeDenominator,
UInt256.One);
expectedBaseFee = parentBaseFee + feeDelta;
}
else
UInt256 expectedBaseFee = parent.BaseFeePerGas;
if (specFor1559.IsEip1559Enabled)
{
gasDelta = parentGasTarget - parent.GasUsed;
feeDelta = parentBaseFee * (UInt256)gasDelta / (UInt256)parentGasTarget / specFor1559.BaseFeeMaxChangeDenominator;
expectedBaseFee = UInt256.Max(parentBaseFee - feeDelta, 0);
UInt256 parentBaseFee = parent.BaseFeePerGas;
long gasDelta;
UInt256 feeDelta;
bool isForkBlockNumber = specFor1559.Eip1559TransitionBlock == parent.Number + 1;
long parentGasTarget = parent.GasLimit / specFor1559.ElasticityMultiplier;
if (isForkBlockNumber)
parentGasTarget = parent.GasLimit;

if (parent.GasUsed == parentGasTarget)
{
expectedBaseFee = parent.BaseFeePerGas;
}
else if (parent.GasUsed > parentGasTarget)
{
gasDelta = parent.GasUsed - parentGasTarget;
feeDelta = UInt256.Max(
parentBaseFee * (UInt256)gasDelta / (UInt256)parentGasTarget / specFor1559.BaseFeeMaxChangeDenominator,
UInt256.One);
expectedBaseFee = parentBaseFee + feeDelta;
}
else
{
gasDelta = parentGasTarget - parent.GasUsed;
feeDelta = parentBaseFee * (UInt256)gasDelta / (UInt256)parentGasTarget / specFor1559.BaseFeeMaxChangeDenominator;
expectedBaseFee = UInt256.Max(parentBaseFee - feeDelta, 0);
}

if (isForkBlockNumber)
{
expectedBaseFee = specFor1559.ForkBaseFee;
}

if (specFor1559.Eip1559BaseFeeMinValue.HasValue)
{
expectedBaseFee = UInt256.Max(expectedBaseFee, specFor1559.Eip1559BaseFeeMinValue.Value);
}
}

if (isForkBlockNumber)
{
expectedBaseFee = specFor1559.ForkBaseFee;
}

if (specFor1559.Eip1559BaseFeeMinValue.HasValue)
{
expectedBaseFee = UInt256.Max(expectedBaseFee, specFor1559.Eip1559BaseFeeMinValue.Value);
}
return expectedBaseFee;
}

return expectedBaseFee;
}
}

public static class BaseFeeCalculator
{
public static UInt256 Calculate(BlockHeader parent, IEip1559Spec specFor1559) =>
specFor1559.BaseFeeCalculator.Calculate(parent, specFor1559);
}
25 changes: 0 additions & 25 deletions src/Nethermind/Nethermind.Core/Specs/IEip1559Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,5 @@ public interface IEip1559Spec
public UInt256 ForkBaseFee { get; }
public UInt256 BaseFeeMaxChangeDenominator { get; }
public long ElasticityMultiplier { get; }
public IBaseFeeCalculator BaseFeeCalculator { get; }
}

public sealed class OverridableEip1559Spec : IEip1559Spec
{
public bool IsEip1559Enabled { get; init; }
public long Eip1559TransitionBlock { get; init; }
public Address? FeeCollector { get; init; }
public UInt256? Eip1559BaseFeeMinValue { get; init; }
public UInt256 ForkBaseFee { get; init; }
public UInt256 BaseFeeMaxChangeDenominator { get; init; }
public long ElasticityMultiplier { get; init; }
public IBaseFeeCalculator BaseFeeCalculator { get; init; }

public OverridableEip1559Spec(IEip1559Spec spec)
{
IsEip1559Enabled = spec.IsEip1559Enabled;
Eip1559TransitionBlock = spec.Eip1559TransitionBlock;
FeeCollector = spec.FeeCollector;
Eip1559BaseFeeMinValue = spec.Eip1559BaseFeeMinValue;
ForkBaseFee = spec.ForkBaseFee;
BaseFeeMaxChangeDenominator = spec.BaseFeeMaxChangeDenominator;
ElasticityMultiplier = spec.ElasticityMultiplier;
BaseFeeCalculator = spec.BaseFeeCalculator;
}
}
}
3 changes: 0 additions & 3 deletions src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,6 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec
/// OP Granite
bool IsOpGraniteEnabled { get; }

/// OP Holocene
bool IsOpHoloceneEnabled { get; }

/// Taiko Ontake
bool IsOntakeEnabled { get; }

Expand Down
2 changes: 0 additions & 2 deletions src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class ReleaseSpecDecorator(IReleaseSpec spec) : IReleaseSpec
public virtual UInt256 ForkBaseFee => spec.ForkBaseFee;
public virtual UInt256 BaseFeeMaxChangeDenominator => spec.BaseFeeMaxChangeDenominator;
public virtual long ElasticityMultiplier => spec.ElasticityMultiplier;
public virtual IBaseFeeCalculator BaseFeeCalculator => spec.BaseFeeCalculator;
public virtual bool IsEip658Enabled => spec.IsEip658Enabled;
public virtual string Name => spec.Name;
public virtual long MaximumExtraDataSize => spec.MaximumExtraDataSize;
Expand Down Expand Up @@ -81,7 +80,6 @@ public class ReleaseSpecDecorator(IReleaseSpec spec) : IReleaseSpec
public bool IsEip7702Enabled => spec.IsEip7702Enabled;
public virtual bool IsRip7212Enabled => spec.IsRip7212Enabled;
public virtual bool IsOpGraniteEnabled => spec.IsOpGraniteEnabled;
public virtual bool IsOpHoloceneEnabled => spec.IsOpHoloceneEnabled;
public virtual bool IsOntakeEnabled => spec.IsOntakeEnabled;
public virtual ulong WithdrawalTimestamp => spec.WithdrawalTimestamp;
public virtual ulong Eip4844TransitionTimestamp => spec.Eip4844TransitionTimestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,10 @@ private static FeeHistoryOracle GetSubstitutedFeeHistoryOracle(
int? cacheSize = null,
int? maxDistFromHead = null)
{
ISpecProvider provider;
if (specProvider is not null)
{
provider = specProvider;
}
else
{
provider = Substitute.For<ISpecProvider>();
provider.GetSpec(Arg.Any<ForkActivation>()).BaseFeeCalculator.Returns(new DefaultBaseFeeCalculator());
}

return new(
blockTree ?? Substitute.For<IBlockTree>(),
receiptStorage ?? Substitute.For<IReceiptStorage>(),
provider,
specProvider ?? Substitute.For<ISpecProvider>(),
maxDistFromHead);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MergeHeaderValidator : HeaderValidator
private readonly IPoSSwitcher _poSSwitcher;
private readonly IHeaderValidator _preMergeHeaderValidator;
private readonly IBlockTree _blockTree;
private readonly ISpecProvider _specProvider;

public MergeHeaderValidator(
IPoSSwitcher poSSwitcher,
Expand All @@ -35,6 +36,7 @@ public MergeHeaderValidator(
_poSSwitcher = poSSwitcher;
_preMergeHeaderValidator = preMergeHeaderValidator;
_blockTree = blockTree;
_specProvider = specProvider;
}

public override bool Validate(BlockHeader header, BlockHeader? parent, bool isUncle = false)
Expand Down
1 change: 0 additions & 1 deletion src/Nethermind/Nethermind.Mining.Test/MinGasPriceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void Test1559(long minimum, long maxFeePerGas, long maxPriorityFeePerGas,
{
ISpecProvider specProvider = Substitute.For<ISpecProvider>();
specProvider.GetSpec(Arg.Any<ForkActivation>()).IsEip1559Enabled.Returns(true);
specProvider.GetSpec(Arg.Any<ForkActivation>()).BaseFeeCalculator.Returns(new DefaultBaseFeeCalculator());

specProvider.GetSpec(Arg.Any<ForkActivation>()).ForkBaseFee.Returns(Eip1559Constants.DefaultForkBaseFee);
specProvider.GetSpec(Arg.Any<ForkActivation>()).BaseFeeMaxChangeDenominator.Returns(Eip1559Constants.DefaultBaseFeeMaxChangeDenominator);
Expand Down
36 changes: 0 additions & 36 deletions src/Nethermind/Nethermind.Optimism.Test/EIP1559ParametersTests.cs

This file was deleted.

This file was deleted.

Loading
Loading