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 support #2795

Merged
merged 21 commits into from
May 24, 2024
Merged

Cancun support #2795

merged 21 commits into from
May 24, 2024

Conversation

RomarQ
Copy link
Contributor

@RomarQ RomarQ commented May 3, 2024

What does it do?

Adds support for a few EIP's included in CANCUN hard-fork.

  • Adds 2 new opcodes (TLOAD and TSTORE) for manipulating state that behaves almost identically to storage but is discarded after every transaction.

    • These new instructions were introduced by EIP-1153 and included in Cancun fork.
  • Adds a new opcode (MCOPY) for copying memory. Implementing this change will be important in ensuring that the same solidity/vyper contract compiles down to the same bytecode.´

    • This new instruction was introduced by EIP-5656 and included in Cancun fork.
  • Changes the behaviour of the self destruct opcode.

Are there relevant PRs or issues in other repositories (Polkadot-SDK, Frontier)?

rust-ethereum/evm#278
rust-ethereum/evm#279
rust-ethereum/evm#281
moonbeam-foundation/evm#3
moonbeam-foundation/frontier#205

@RomarQ RomarQ changed the title test transient storage (eip-1153) Cancun support May 3, 2024
@RomarQ RomarQ added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited dependencies Pull requests that update a dependency file breaking Needs to be mentioned in breaking changes labels May 3, 2024
Copy link
Contributor

github-actions bot commented May 3, 2024

Coverage Report

@@                Coverage Diff                 @@
##           master   cancun-support      +/-   ##
==================================================
- Coverage   72.87%           72.83%   -0.04%     
  Files         229              229              
+ Lines       70028            70073      +45     
==================================================
  Hits        51031            51031              
+ Misses      18997            19042      +45     
Files Changed Coverage

Coverage generated Fri May 24 10:50:10 UTC 2024

@RomarQ
Copy link
Contributor Author

RomarQ commented May 7, 2024

Reason for the gas cost decreases in this PR:

The new opcode MCOPY has optimised memory copying.

As example use case, copying 256 bytes costs:

  • at least 757 gas pre-EIP-2929 using the identity precompile
  • at least 157 gas post-EIP-2929 using the identity precompile
  • at least 96 gas using unrolled MLOAD/MSTORE instructions
  • 27 gas using EIP-5656 (The changes included in this PR)

According to an analysis of blocks 10537502 to 10538702 on ethereum, roughly 10.5% of memory copies would have had improved performance with the availability of an MCOPY instruction.

Memory copying is used by languages like Solidity and Vyper, where we expect this improvement to provide efficient means of building data structures, including efficient sliced access and copies of memory objects. Having a dedicated MCOPY instruction would also add forward protection against future gas cost changes to CALL instructions in general.

@RomarQ RomarQ requested review from librelois, ahmadkaouk, Agusrodri, timbrinded, a team and noandrea and removed request for a team May 23, 2024 08:01
Agusrodri
Agusrodri previously approved these changes May 23, 2024
ahmadkaouk
ahmadkaouk previously approved these changes May 24, 2024
@librelois librelois dismissed stale reviews from ahmadkaouk and Agusrodri via fb2cd75 May 24, 2024 08:37
librelois
librelois previously approved these changes May 24, 2024
@RomarQ RomarQ merged commit f63af52 into master May 24, 2024
27 checks passed
@RomarQ RomarQ deleted the cancun-support branch May 24, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants