-
Notifications
You must be signed in to change notification settings - Fork 451
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 OP Holocene fork #7761
Merged
Merged
Add OP Holocene fork #7761
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6f0395e
Perform single dependency capture
emlautarom1 fda85b9
Add Holocene to ReleaseSpec
emlautarom1 32ee4f7
Decode EIP1559 parameters from BlockHeader
emlautarom1 5a8e70c
Validate ExtraData fields post-Holocene
emlautarom1 c8aa891
Collapse test cases
emlautarom1 e0f5d5e
Test for pre-Holocene ExtraData validation
emlautarom1 d9a5c12
Extract to interface
emlautarom1 35d6ef0
Allow for "zero" EIP1559 parameters
emlautarom1 412fdbc
Add concrete `Eip1559Spec : IEip1559Spec`
emlautarom1 315cc23
Add helper methods
emlautarom1 0ce5908
Add OptimismBaseFeeCalculator
emlautarom1 22fc7ad
Remove unused using
emlautarom1 3d14ce3
Add `EIP1559Params` to `OptimismPayloadAttributes`
emlautarom1 a66b367
Rename file
emlautarom1 defe8f7
Use correct version
emlautarom1 ecabab6
Decode EIP1559 parameters from `OptimismPayloadAttributes`
emlautarom1 b7db888
Include EIP1559 params from attributes into block header
emlautarom1 aef8a7c
Extract required length to constant
emlautarom1 67c6577
Remove unused constructor
emlautarom1 551976c
Test payload validation before Holocene
emlautarom1 53b6f8e
Reintroduce `BaseFeeCalculator` singleton
emlautarom1 ae5c231
Fix wrong test name
emlautarom1 97831af
Mark tests parallelizable
emlautarom1 44bbeeb
Override `BaseFeeCalculator` in OP
emlautarom1 db743b6
Use init only properties
emlautarom1 96675ab
Use `nameof`
emlautarom1 1405f1b
Remove nullability
emlautarom1 6469275
Add Holocene timestamp for Sepolia
emlautarom1 4603248
Add Holocene parameters
emlautarom1 fcd733d
Merge branch 'master' into feat/optimism-holocene
emlautarom1 c7b37b5
Ensure `ExtraData.Length == 9`
emlautarom1 d9fd3e4
Add placeholder timestamp for mainnet
emlautarom1 4013c7a
Merge branch 'master' into feat/optimism-holocene
benaadams 96e57e3
Perform single `IsZero` check
emlautarom1 b1ba8a4
Rename class
emlautarom1 83e2f84
Prefer errors over Exceptions
emlautarom1 1d10135
Make `IBaseFeeCalculator` part of `IEip1559Spec`
emlautarom1 2c77b7b
Use `IEip1559Spec.IBaseFeeCalculator` in singleton
emlautarom1 18444bd
Inject `IBaseFeeCalculator` through `IChainSpecEngineParameters`
emlautarom1 bdf4d23
Make `HoloceneTimestamp` optional
emlautarom1 377829c
Fix substitutes
emlautarom1 0792ec4
Avoid whitespace diff
emlautarom1 9ea6945
Merge branch 'master' into feat/optimism-holocene
emlautarom1 e3ad51c
Extract constant
emlautarom1 5ff8dff
Merge branch 'master' into feat/optimism-holocene
emlautarom1 55e1fb6
Merge branch 'master' into feat/optimism-holocene
emlautarom1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Nethermind/Nethermind.Optimism.Test/EIP1559ParametersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using Nethermind.Core.Extensions; | ||
using Nethermind.Core.Test.Builders; | ||
using NUnit.Framework; | ||
using FluentAssertions; | ||
using System; | ||
|
||
namespace Nethermind.Optimism.Test; | ||
|
||
[Parallelizable(ParallelScope.All)] | ||
public class EIP1559ParametersTests | ||
{ | ||
private static IEnumerable<(string hexString, EIP1559Parameters expected)> DecodeBlockHeaderParametersCases() | ||
{ | ||
yield return ("0x000000000000000000", new(0, 0, 0)); | ||
yield return ("0x000000000100000000", new(0, 1, 0)); | ||
yield return ("0x0000000001000001bc", new(0, 1, 444)); | ||
yield return ("0x0000000001ffffffff", new(0, 1, UInt32.MaxValue)); | ||
yield return ("0x00ffffffff00000000", new(0, UInt32.MaxValue, 0)); | ||
yield return ("0x00ffffffff000001bc", new(0, UInt32.MaxValue, 444)); | ||
yield return ("0x00ffffffffffffffff", new(0, UInt32.MaxValue, UInt32.MaxValue)); | ||
} | ||
[TestCaseSource(nameof(DecodeBlockHeaderParametersCases))] | ||
public void DecodeBlockHeaderParameters((string HexString, EIP1559Parameters Expected) testCase) | ||
{ | ||
var bytes = Bytes.FromHexString(testCase.HexString); | ||
var blockHeader = Build.A.BlockHeader.WithExtraData(bytes).TestObject; | ||
|
||
blockHeader.TryDecodeEIP1559Parameters(out EIP1559Parameters decoded, out _); | ||
|
||
decoded.Should().Be(testCase.Expected); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Nethermind/Nethermind.Optimism.Test/OptimismBaseFeeCalculatorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using FluentAssertions; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Core.Test.Builders; | ||
using Nethermind.Int256; | ||
using Nethermind.Specs; | ||
using NUnit.Framework; | ||
|
||
namespace Nethermind.Optimism.Test; | ||
|
||
public class OptimismBaseFeeCalculatorTests | ||
{ | ||
/// <remarks> | ||
/// Tests sourced from <see href="https://github.com/ethereum-optimism/op-geth/blob/1e60ba82d31bc17111481998100cd948ee06c0ab/consensus/misc/eip1559/eip1559_test.go#L191"/> | ||
/// </remarks> | ||
[TestCase(15_000_000, 10_000_000, 10u, 2u)] // Target | ||
[TestCase(10_000_000, 9_666_667, 10u, 2u)] // Below | ||
[TestCase(20_000_000, 10_333_333, 10u, 2u)] // Above | ||
[TestCase(3_000_000, 10_000_000, 2u, 10u)] // Target | ||
[TestCase(1_000_000, 6_666_667, 2u, 10u)] // Below | ||
[TestCase(30_000_000, 55_000_000, 2u, 10u)] // Above | ||
public void CalculatesBaseFee_AfterHolocene_UsingExtraDataParameters(long gasUsed, long expectedBaseFee, UInt32 denominator, UInt32 elasticity) | ||
{ | ||
const ulong HoloceneTimestamp = 10_000_000; | ||
|
||
IReleaseSpec releaseSpec = new ReleaseSpec | ||
{ | ||
IsEip1559Enabled = true, | ||
IsOpHoloceneEnabled = true, | ||
BaseFeeCalculator = new OptimismBaseFeeCalculator(HoloceneTimestamp, new DefaultBaseFeeCalculator()) | ||
}; | ||
|
||
var extraData = new byte[EIP1559Parameters.ByteLength]; | ||
var parameters = new EIP1559Parameters(0, denominator, elasticity); | ||
parameters.WriteTo(extraData); | ||
|
||
BlockHeader blockHeader = Build.A.BlockHeader | ||
.WithGasLimit(30_000_000) | ||
.WithBaseFee(10_000_000) | ||
.WithTimestamp(HoloceneTimestamp) | ||
.WithGasUsed(gasUsed) | ||
.WithExtraData(extraData) | ||
.TestObject; | ||
|
||
UInt256 actualBaseFee = BaseFeeCalculator.Calculate(blockHeader, releaseSpec); | ||
|
||
actualBaseFee.Should().Be((UInt256)expectedBaseFee); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could remove this static class altogether by leveraging extension methods but for now I'll leave it as it is to avoid more diffs.