trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

Support Paris hardfork #3864

Closed robmcl4 closed 1 year ago

robmcl4 commented 1 year ago

Current Situation

ganache only supports up to the grayGlacier ethereum hardfork (see src/chains/ethereum/options/src/chain-options.ts:5).

However, the Paris hardfork (aka 'The Merge') has been active for several weeks now. Critically, this makes for odd behavior regarding EIP-4399 "Supplant DIFFICULTY opcode with PREVRANDAO".

Proposal

I propose the following changes.

  1. All blocks produced by ganache set the prevRandao header field to 0b100...00, with an option in evm_mine to set the value manually. The first bit is set to 1 so that EVM applications may test for Paris hardfork activation by checking that the PREVRANDAO value is greater than 2**64, as suggested in EIP-4399 (ctrl+f "The probability of RANDAO value").
  2. Update the @ethereumjs/vm dependency to support Block.prevRandao, and update all invocations of the EVM to use the prevRandao value as appropriate, if the Paris hardfork is active. Note that this will require a major version bump from v5 to v6 -- I am not sure how much work this would be.

Caveat: although @ethereumjs/evm does advertise support for EIP-4399, it is currently marked as experimental (see their README)

davidmurdoch commented 1 year ago

We do have a release for support under the alpha tag: https://github.com/trufflesuite/ganache/releases/tag/v7.4.4-alpha.0

You can track our progress getting it to stable here: https://github.com/trufflesuite/ganache/issues/3693#issuecomment-1284540912