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 Eof Execution EIP-7692 (EIP-663, EIP-3540, EIP-3670, EIP-4200, EIP-4750, EIP-5450, EIP-6206, EIP-7069, EIP-7480, EIP-7620, EIP-7698, EIP-7756) #8176

Open
wants to merge 317 commits into
base: master
Choose a base branch
from

Conversation

benaadams
Copy link
Member

Closes #4584
Closes #4586
Closes #4906
Closes #4907
Closes #4956

Changes

  • Refactor Evm to make it less unwieldy to opcode changes & optimizations

Types of changes

What types of changes does your code introduce?

  • New feature (a non-breaking change that adds functionality)

Testing

Requires testing

  • Yes

If yes, did you write tests?

  • Yes

Notes on testing

Optional. Remove if not applicable.

Documentation

Requires documentation update

  • Yes

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes

If yes, fill in the details here. Remove if not applicable.

Remarks

Optional. Remove if not applicable.

@@ -13,6 +13,7 @@
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
<PackageVersion Include="Ckzg.Bindings" Version="2.0.1.1258" />
<PackageVersion Include="Colorful.Console" Version="1.2.15" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
Copy link
Contributor

Choose a reason for hiding this comment

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

This is redundant. We already use the same CLI parser for everything else.

Copy link
Contributor

@Scooletz Scooletz left a comment

Choose a reason for hiding this comment

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

A few remarks. I love both, the direction and the execution. Long live the delegate* calls!

@@ -431,5 +437,9 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec
bool IsAuthorizationListEnabled => IsEip7702Enabled;

public bool RequestsEnabled => ConsolidationRequestsEnabled || WithdrawalRequestsEnabled || DepositsEnabled;

public object? EvmInstructions { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have some comments here? What kind of object is it etc?


public object? EvmInstructions { get; set; }

public object? EvmTracedInstructions { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above? Maybe refer to Trace, NoTrace?

@@ -20,6 +20,7 @@ namespace Nethermind.Core
[DebuggerDisplay("{Hash}, Value: {Value}, To: {To}, Gas: {GasLimit}")]
public class Transaction
{
public byte[] EofMagic = [0xEF, 0x00];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public byte[] EofMagic = [0xEF, 0x00];
public static ReadOnlyMemory<byte> EofMagic => [0xEF, 0x00];

stuff?

deployingAddress.Bytes.CopyTo(bytes.Slice(1, 20));
salt.CopyTo(bytes.Slice(21, salt.Length));
ValueKeccak.Compute(initCode).BytesAsSpan.CopyTo(bytes.Slice(21 + salt.Length, 32));
deployingAddress.Bytes.CopyTo(bytes.Slice(1, Address.Size));
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for removing magic 🙇

}
private static void WaitForAnalysisToComplete(ManualResetEventSlim resetEvent)
{
Thread thread = Thread.CurrentThread;
Copy link
Contributor

Choose a reason for hiding this comment

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

There was the scoping mechanism elsewhere. Can't we do using var priority = ... here?


for (int i = 0; i < lookup.Length; i++)
{
lookup[i] = &InstructionBadInstruction;
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome!

lookup[(int)Instruction.BYTE] = &InstructionByte;

// Conditional: enable shift opcodes if the spec allows.
if (spec.ShiftOpcodesEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you saying you extracted all spec checks? ❤️

_codeInfoRepository.InsertCode(WorldState, code, env.ExecutingAccount, spec);

unspentGas -= codeDepositGasCost;
}
}

if (tx.IsEofContractCreation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract method? Gets really big.


namespace Nethermind.Evm;

public interface IFlag
Copy link
Contributor

Choose a reason for hiding this comment

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

As you generalized on/off using generic parameter trick, should it be commented for future generations how and why to use it?

debugger?.TryWait(ref _vmState, ref programCounter, ref gasAvailable, ref stack.Head);
#endif
// Fetch the current instruction from the code section.
Instruction instruction = codeSection[programCounter];
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this can be trusted. You removed so much of the beautiful code that was here and all we're left is an array lookup... On a serious note: beautiful 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants