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

Add OP Holocene fork #7761

Merged
merged 46 commits into from
Nov 21, 2024
Merged

Add OP Holocene fork #7761

merged 46 commits into from
Nov 21, 2024

Conversation

emlautarom1
Copy link
Contributor

@emlautarom1 emlautarom1 commented Nov 14, 2024

Resolves #7760

Changes

  • Support OP Holocene

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

Added tests that cover all new LOCs. Manual testing is still required.

Documentation

Requires documentation update

  • Yes
  • No

I don't think it's a requirement to update the docs.

Requires explanation in Release Notes

  • Yes
  • No

We should communicate that Nethermind is ready to support the new OP fork.

Remarks

Initially, only Sepolia timestamps are included for both Optimism and Base since those are the only ones currently known at this time.

/// </remarks>
public sealed class OptimismBaseFeeCalculator(
IBaseFeeCalculator baseFeeCalculator,
ISpecProvider specProvider) : IBaseFeeCalculator
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much point in having IOptimismSpecHelper for starters, but could replace this ISpecProvider with IOptimismSpecHelper, and replace releaseSpec.GetSpec(parent).IsOpHoloceneEnabled with helper.IsHolocene(parent).

If we don't use IOptimismSpecHelper then its additions related to Holocene are essentially dead code (no usages).

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't like the hidden dependency and side effect with BaseFeeCalculator.
I would change exceptions handling.

src/Nethermind/Chains/base-mainnet.json Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Core/BaseFeeCalculator.cs Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Core/Specs/IEip1559Spec.cs Outdated Show resolved Hide resolved
var spec = _specProvider.GetSpec(currentBestBlock.Header);
if (spec.IsOpHoloceneEnabled)
{
EIP1559Parameters eip1559Parameters = optimismPayload.DecodeEIP1559Parameters();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could fail and throw exception

Copy link
Contributor Author

@emlautarom1 emlautarom1 Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that at that point we've already validated the attributes so there should not be a risk of exceptions (unless I'm missing something):

  1. We validate attributes in

public async Task<ResultWrapper<ForkchoiceUpdatedV1Result>> Handle(ForkchoiceStateV1 forkchoiceState, PayloadAttributes? payloadAttributes, int version)
{
Block? newHeadBlock = GetBlock(forkchoiceState.HeadBlockHash);
return await ApplyForkchoiceUpdate(newHeadBlock, forkchoiceState, payloadAttributes)
?? ValidateAttributes(payloadAttributes, version)
?? StartBuildingPayload(newHeadBlock!, forkchoiceState, payloadAttributes);
}

  1. Then we use the IPreparationService in StartBuildingPayload

payloadId = _payloadPreparationService.StartPreparingPayload(newHeadBlock.Header, payloadAttributes);

  1. Eventually, OptimismPayloadPreparationService.ImproveBlock is called:

public string StartPreparingPayload(BlockHeader parentHeader, PayloadAttributes payloadAttributes)
{
string payloadId = payloadAttributes.GetPayloadId(parentHeader);
if (!_payloadStorage.ContainsKey(payloadId))
{
Block emptyBlock = ProduceEmptyBlock(payloadId, parentHeader, payloadAttributes);
ImproveBlock(payloadId, parentHeader, payloadAttributes, emptyBlock, DateTimeOffset.UtcNow);
}
else if (_logger.IsInfo) _logger.Info($"Payload with the same parameters has already started. PayloadId: {payloadId}");
return payloadId;
}

protected override void ImproveBlock(string payloadId, BlockHeader parentHeader,
PayloadAttributes payloadAttributes, Block currentBestBlock, DateTimeOffset startDateTime)

}
}

public static class BaseFeeCalculator
Copy link
Contributor Author

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.

@emlautarom1 emlautarom1 merged commit cc96168 into master Nov 21, 2024
79 checks passed
@emlautarom1 emlautarom1 deleted the feat/optimism-holocene branch November 21, 2024 20:20
kamilchodola added a commit that referenced this pull request Nov 22, 2024
@emlautarom1 emlautarom1 restored the feat/optimism-holocene branch November 22, 2024 16:12
@emlautarom1 emlautarom1 mentioned this pull request Nov 22, 2024
16 tasks
asdacap added a commit that referenced this pull request Nov 22, 2024
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.

Add support for OP Holocene fork
3 participants