-
Notifications
You must be signed in to change notification settings - Fork 505
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
OP Holocene - Proper EIP-1559 parameters handling #7926
Conversation
@@ -142,6 +142,7 @@ bool GetForInnerPathExistence(KeyValuePair<string, JsonElement> o) => | |||
Eip6780TransitionTimestamp = chainSpecJson.Params.Eip6780TransitionTimestamp, | |||
Rip7212TransitionTimestamp = chainSpecJson.Params.Rip7212TransitionTimestamp, | |||
OpGraniteTransitionTimestamp = chainSpecJson.Params.OpGraniteTransitionTimestamp, | |||
OpHoloceneTransitionTimestamp = chainSpecJson.Params.OpHoloceneTransitionTimestamp, |
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.
The first issue was that we missed one of these copies which resulted in a IReleaseSpec
where Holocene was never enabled. I think some parts of the system were working correctly since we were getting this timestamp from a different source.
Either way, this kind of work is repetitive and error prone and it would be great if we could come up with a better solution that does not require such manual work.
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.
Let's remove OpHoloceneTransitionTimestamp from ChainSpecLoader. We have OptimsimChainSpecEngineParameters for that. Also we should remove OpGraniteTransitionTimestamp, but not in this pr proabably
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.
Alright, that sounds good, but I'm having a bit of issues getting an instance of OptimismChainSpecEngineParameters
in certain places like in OptimismPayloadAttributes.Validate
:
nethermind/src/Nethermind/Nethermind.Optimism/Rpc/OptimismPayloadAttributes.cs
Lines 117 to 127 in fbf855b
IReleaseSpec releaseSpec = specProvider.GetSpec(ForkActivation.TimestampOnly(Timestamp)); | |
if (!releaseSpec.IsOpHoloceneEnabled && EIP1559Params is not null) | |
{ | |
error = $"{nameof(EIP1559Params)} should be null before Holocene"; | |
return PayloadAttributesValidationResult.InvalidPayloadAttributes; | |
} | |
if (releaseSpec.IsOpHoloceneEnabled && !this.TryDecodeEIP1559Parameters(out _, out var decodeError)) | |
{ | |
error = decodeError; | |
return PayloadAttributesValidationResult.InvalidPayloadAttributes; | |
} |
foreach (var noTxPool in (bool[])[true, false]) | ||
{ | ||
yield return (new OptimismPayloadAttributes { EIP1559Params = [0, 0, 0, 8, 0, 0, 0, 2], NoTxPool = noTxPool }, new EIP1559Parameters(0, 8, 2)); | ||
yield return (new OptimismPayloadAttributes { EIP1559Params = [0, 0, 0, 2, 0, 0, 0, 2], NoTxPool = noTxPool }, new EIP1559Parameters(0, 2, 2)); | ||
yield return (new OptimismPayloadAttributes { EIP1559Params = [0, 0, 0, 2, 0, 0, 0, 10], NoTxPool = noTxPool }, new EIP1559Parameters(0, 2, 10)); | ||
yield return (new OptimismPayloadAttributes { EIP1559Params = [0, 0, 0, 0, 0, 0, 0, 0], NoTxPool = noTxPool }, new EIP1559Parameters(0, 250, 6)); | ||
} |
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.
We added tests that set the NoTxPool = true
, which showed that the PayloadPreparationService
was not adjusting the BlockHeader.ExtraData
with the EIP-1559 parameters even though this should always be done.
// NOTE: Since we updated the `Header` we need to recalculate the hash. | ||
currentBestBlock.Header.Hash = currentBestBlock.Header.CalculateHash(); |
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.
As the comment highlights, since we're modifying the BlockHeader.ExtraData
we need to recompute the Hash
. This is again error prone and tedious since we can easily forget to update the hash.
It's not clear to me if this is the best place to perform this recalculation or maybe there is a different stage in the processing pipeline where it should be done.
- There is no need since during validation we ensure the value is non-zero - Zero should never be written to `ExtraData`
- Add test for trailing bytes
@@ -35,7 +34,9 @@ public class OptimismHeaderValidatorTests | |||
yield return ("0xffffaaaa", false); | |||
yield return ("0x01ffffffff00000000", false); | |||
yield return ("0xff0000000100000001", false); | |||
yield return ("0x000000000000000000", false); |
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.
In ExtraData
, a 0
EIP-1559 parameters should not be valid, instead defaults should be used (which are non-zero)
ElasticityMultiplier = eip1559Params.Elasticity, | ||
BaseFeeMaxChangeDenominator = eip1559Params.Denominator | ||
}; | ||
spec = new OverridableEip1559Spec(specFor1559) |
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.
There is no need to branch here since 0
EIP-1559 parameters should never get to ExtraData
.
@@ -142,6 +142,7 @@ bool GetForInnerPathExistence(KeyValuePair<string, JsonElement> o) => | |||
Eip6780TransitionTimestamp = chainSpecJson.Params.Eip6780TransitionTimestamp, | |||
Rip7212TransitionTimestamp = chainSpecJson.Params.Rip7212TransitionTimestamp, | |||
OpGraniteTransitionTimestamp = chainSpecJson.Params.OpGraniteTransitionTimestamp, | |||
OpHoloceneTransitionTimestamp = chainSpecJson.Params.OpHoloceneTransitionTimestamp, |
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.
Let's remove OpHoloceneTransitionTimestamp from ChainSpecLoader. We have OptimsimChainSpecEngineParameters for that. Also we should remove OpGraniteTransitionTimestamp, but not in this pr proabably
@deffrian won't it break fork info? |
Using OptimsimChainSpecEngineParameters is blocked by #7886. Let's merge it as is |
Fixes #7903
Changes
ExtraData
, even when dealing with defaults.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Unit tests were extended to include cases where
NoTxPool = true
which were missing from the original PR.Documentation
Requires documentation update
Requires explanation in Release Notes
Remarks
This PR fixes several issues that were found after running some integration tests leveraging Kurtosis and the optimism-package. More details will be provided as discussion comments.