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

OP Holocene - Proper EIP-1559 parameters handling #7926

Merged
merged 8 commits into from
Dec 19, 2024

Conversation

emlautarom1
Copy link
Contributor

Fixes #7903

Changes

  • Properly set up the Holocene timestamp.
  • Always store EIP-1559 parameters in ExtraData, even when dealing with defaults.
  • Ensure Block Header hash is recalculated when needed.
  • Use defaults from Chainspec rather than from constants.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Unit tests were extended to include cases where NoTxPool = true which were missing from the original PR.

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

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.

@@ -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,
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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:

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;
}

Comment on lines +35 to +41
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));
}
Copy link
Contributor Author

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.

Comment on lines +67 to +68
// NOTE: Since we updated the `Header` we need to recalculate the hash.
currentBestBlock.Header.Hash = currentBestBlock.Header.CalculateHash();
Copy link
Contributor Author

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);
Copy link
Contributor Author

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)
Copy link
Contributor Author

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,
Copy link
Contributor

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

@flcl42
Copy link
Contributor

flcl42 commented Dec 18, 2024

@deffrian won't it break fork info?

@deffrian
Copy link
Contributor

Using OptimsimChainSpecEngineParameters is blocked by #7886. Let's merge it as is

@emlautarom1 emlautarom1 merged commit 695420e into master Dec 19, 2024
79 checks passed
@emlautarom1 emlautarom1 deleted the fix/op-holocene-integration-tests branch December 19, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OP Holocene (Kurtosis): Incorrect chain config, rejects holocene blocks.
4 participants