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

"Small" Ethereum Object Format (EIP-3540 + EIP-3670) #4644

Merged
merged 34 commits into from
Nov 16, 2022

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Nov 10, 2022

PR description

Implement "Small" EOF - EIP-3540 (container) and EIP-3670 (validation).

Make code an interface so EOF specific features are compartmentalized,
including an 'invalid' code type representing a code block that didn't
pass validation, CodeV1 for EOF1, and CodeV0 which represents pre-EOF
code. EVMs track a maximum supported EOF version (where 0 is pre-eof)and
code is generated from a CodeFactory taking in context (is it a CREATE
operation and max code size) for the validation.

Includes spec versions for "Shanghai" and transient testnet "Shandong".

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

EOF parses

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Enable the "Merge" network targeting the "paris" fork.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Add a flag to MainnetTransactionProcessor to add the miningBeneficiary
to the list of pre-warmed addresses.
Have shandong fork set this flag to true by default.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
There was a change in error codes in Java DER decoding between Java 17
and Java 11.  Tests depend on Java 11 error.  Use JUnit5 facilities to
ensure the test works proeprly on both with the same codebase.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java
#	ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
# Conflicts:
#	ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
# Conflicts:
#	ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@shemnon
Copy link
Contributor Author

shemnon commented Nov 10, 2022

#warning

Pay no attention to the green reference tests. EOF tests have not been merged into official refrerence tests nor combined into a useful branch.

We're all good. Test that are legit work on my machine.

shemnon and others added 3 commits November 10, 2022 22:53
The trick was an invalid contract being executed from a "return"
initcode should not leave an account behind.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@shemnon shemnon marked this pull request as ready for review November 12, 2022 02:50
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@shemnon shemnon added the doc-change-required Indicates an issue or PR that requires doc to be updated label Nov 12, 2022
@shemnon
Copy link
Contributor Author

shemnon commented Nov 12, 2022

doc change notes -

  • adds SHANGHAI and SHANDONG to the list of --network targets.
  • SHANDONG will be a temporary fork and will be removed in a future version.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@garyschulte garyschulte mentioned this pull request Nov 12, 2022
2 tasks
Copy link
Contributor

@diega diega left a comment

Choose a reason for hiding this comment

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

I really like this PR. I just added a few non blocking comments.

gasCalculator,
evm,
true,
List.of(MaxCodeSizeRule.of(contractSizeLimit), CachedInvalidCodeRule.of()),
Copy link
Contributor

Choose a reason for hiding this comment

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

If the Code of the frame is being created through the CodeFactory, can the o.h.b.e.c.PrefixCodeRule used in the londonDefinition be replaced by o.h.b.e.c.CachedInvalidCodeRule too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. London rejects all 0xEF code for all of London and Paris. The EOF rule relaxes it and accepts EOF formatted code that starts with 0xEF. It could be a configuration of the rule, but I read it cleaner to make it two rules.


public EVM(
final OperationRegistry operations,
final GasCalculator gasCalculator,
final EvmConfiguration evmConfiguration) {
final EvmConfiguration evmConfiguration,
final EvmSpecVersion evmSpecVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about passing a o.h.b.e.c.CodeFactory instance here, created with the corresponding maxEofVersion for each protocol spec. This would keep the EVM runtime agnostic of the upgrade (there would be neccesary some refactor around PUSH0 to resolve it purely from the registry though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CodeFactory holds only pure functions at this point. So we are just moving where the max eof version would be held.

}

@SuppressWarnings("AlreadyChecked") // false positive
public void maybeWarnVersion() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the plan to keep this method after shandong? I would prefer to not keep mutable state in an enum and we should explore if it's not possible to solve this filtering through the logging framework (e.g. DuplicateMessageFilter if we used Logback)

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 idea is that this is only used for transient forks. Perhaps if we had a static enum set and checked that? And we could pre-populate it with "final" forks so there will be no warnings?

Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

Looks great so far.

case MESSAGE_CALL:
mcp.process(messageFrame, tracer);
break;
if (messageFrame.getType() == MessageFrame.Type.CONTRACT_CREATION) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the switch away from previous method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sonar rule S1301 - "switch" statements should have at least 3 "case" clauses

Seemed reasonable with an auto-refactor.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@shemnon shemnon enabled auto-merge (squash) November 15, 2022 23:50
@shemnon shemnon merged commit f20b4b3 into hyperledger:main Nov 16, 2022
wcgcyx pushed a commit to wcgcyx/besu that referenced this pull request Nov 16, 2022
Implement "Small" EOF - EIP-3540 (container) and EIP-3670 (validation).

Make code an interface so EOF specific features are compartmentalized,
including an 'invalid' code type representing a code block that didn't
pass validation, CodeV1 for EOF1, and CodeV0 which represents pre-EOF
code. EVMs track a maximum supported EOF version (where 0 is pre-eof)and
code is generated from a CodeFactory taking in context (is it a CREATE
operation and max code size) for the validation.

Includes spec versions for "Shanghai" and transient testnet "Shandong".
"Small" EOF is only activated in Shandong.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: wcgcyx <wcgcyx@gmail.com>
@rolandtyler rolandtyler removed the doc-change-required Indicates an issue or PR that requires doc to be updated label Nov 17, 2022
@shemnon shemnon mentioned this pull request Dec 12, 2022
2 tasks
@shemnon shemnon mentioned this pull request Dec 19, 2022
macfarla pushed a commit to macfarla/besu that referenced this pull request Jan 10, 2023
Implement "Small" EOF - EIP-3540 (container) and EIP-3670 (validation).

Make code an interface so EOF specific features are compartmentalized,
including an 'invalid' code type representing a code block that didn't
pass validation, CodeV1 for EOF1, and CodeV0 which represents pre-EOF
code. EVMs track a maximum supported EOF version (where 0 is pre-eof)and
code is generated from a CodeFactory taking in context (is it a CREATE
operation and max code size) for the validation.

Includes spec versions for "Shanghai" and transient testnet "Shandong".
"Small" EOF is only activated in Shandong.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Implement "Small" EOF - EIP-3540 (container) and EIP-3670 (validation).

Make code an interface so EOF specific features are compartmentalized,
including an 'invalid' code type representing a code block that didn't
pass validation, CodeV1 for EOF1, and CodeV0 which represents pre-EOF
code. EVMs track a maximum supported EOF version (where 0 is pre-eof)and
code is generated from a CodeFactory taking in context (is it a CREATE
operation and max code size) for the validation.

Includes spec versions for "Shanghai" and transient testnet "Shandong".
"Small" EOF is only activated in Shandong.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
@shemnon shemnon deleted the EOF branch April 4, 2024 17: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.

None yet

4 participants