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

Cancun fixes + EIP 4788 #6009

Merged
merged 90 commits into from
Aug 18, 2023
Merged

Cancun fixes + EIP 4788 #6009

merged 90 commits into from
Aug 18, 2023

Conversation

MarekM25
Copy link
Contributor

Changes

PR for current Cancun branch and last minute fixes + EIP 4788

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

src/Nethermind/Chains/genesis.json Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated Show resolved Hide resolved

state.RecalculateStateRoot();
blockRequestV3.StateRoot = state.StateRoot;
TryCalculateHash(blockRequestV3, out Keccak? hash);
Copy link
Contributor

Choose a reason for hiding this comment

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

We recalculate it below CreateBlockRequestInternal<T> btw. What is interesting is that we do not execute transactions that may affect the state. Maybe state hash root was already calculated before( _beaconBlockRootHandler can be placed there if so)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure tbh, I'll have to take a look into it

/// Parent Beacon Block precompile
/// </summary>
bool IsEip4788Enabled { get; }
Address Eip4788ContractAddress { get; }
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 need test that this address is being loaded correctly from chainspec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Demuirgos :) please do it in next PR

Copy link
Contributor Author

@MarekM25 MarekM25 left a comment

Choose a reason for hiding this comment

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

2 small comments

@MarekM25 MarekM25 marked this pull request as ready for review August 18, 2023 13:36
Comment on lines 92 to +106
public static int GetVersion(this PayloadAttributes executionPayload) =>
executionPayload.Withdrawals is null ? 1 : 2;
executionPayload switch
{
{ ParentBeaconBlockRoot: not null, Withdrawals: not null } => EngineApiVersions.Cancun,
{ Withdrawals: not null } => EngineApiVersions.Shanghai,
_ => EngineApiVersions.Paris
};

public static int ExpectedEngineSpecVersion(this IReleaseSpec spec) =>
spec switch
{
{ WithdrawalsEnabled: true, IsEip4844Enabled: true } => EngineApiVersions.Cancun,
{ WithdrawalsEnabled: true } => EngineApiVersions.Shanghai,
_ => EngineApiVersions.Paris
};
Copy link
Contributor

Choose a reason for hiding this comment

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

execution payload is treated based on a specific fork instead of what EIPs are enabled. This could result in conflicts with supporting other chains where, for example, gnosis would want to adopt 4788 but not 4844 (just an example). Ill post the same thing on the PR. but i dont want to block it. so ill probably post it as an issue to be looked at in a later PR.
designing a solution to this problem is not easy so i completely understand if it is not considered before cancun.

@@ -17,6 +18,8 @@ protected Cancun()
IsEip5656Enabled = true;
IsEip4844Enabled = true;
IsEip6780Enabled = true;
IsEip4788Enabled = true;
Eip4788ContractAddress = Address.FromNumber(0x0b);
Copy link
Contributor

Choose a reason for hiding this comment

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

This might differ from one network to another (hopefully not)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will

@MarekM25 MarekM25 merged commit 055c64b into master Aug 18, 2023
62 of 63 checks passed
@MarekM25 MarekM25 deleted the cancun branch August 18, 2023 15:38
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.

None yet

6 participants