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

Merge/main into multichain #684

Merged
merged 49 commits into from
Oct 1, 2024
Merged

Conversation

Wodann
Copy link
Member

@Wodann Wodann commented Sep 25, 2024

Merges the latest changes from main into feat/multichain.

github-actions bot and others added 30 commits July 1, 2024 18:12
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix: allow missing nonce in remote blocks

* misc: add changeset
* chore: Explicitly depend on semver and fs-extra in hardhat-tests

Appeases ESLint. These are de facto pulled by other dependencies but
it's implicit.

* refactor: Unify ts-node and use the one currently used by Hardhat

Deduping the hardhat package makes it easier to patch it while working
on the stack trace porting feature branch.

* chore: Use the newest Hardhat 2.22.6

This will make patching the changes easier to review as we will sync
with the upstream as it has some changes already related to the stack
traces that we port.
* feat: upgrade revm dependencies

* Create wild-phones-drum.md
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* feat: add support for RIP-7212

* misc: add changelog

* fix: updated index.d.ts

* fix: revert rename of InvalidFEOpcode

* fix: set enableRip7212 in ProviderConfig

* test: validate that disabling RIP-7212 works

* refactor: use runtime variable instead of const

* Path Hardhat dev dep to work with latest EDR changes

EDR uses Hardhat as a dev dependency to run some javascript tests. The
way this works is that the tests are run using Hardhat, but we use pnpm
to override the EDR dependency in Hardhat with the local one. This works
fine as long as there are no breaking changes in EDR. When there are, we
have a circular dependency problem: we can't publish a new version of
EDR until the tests pass, but for the tests to pass we need a version of
Hardhat that works with the new version of EDR.

A temporary workaround for this is to use `pnpm patch` to temporarily
modify the Hardhat code in a way that works with the breaking change.
In this case, this just means adding the new field when constructing
the provider.

---------

Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* build: upgrade revm to v12

* test: remove invalid test

* misc: add changeset
* fix: use remote chain id for pre-fork simulation

* Fix error message
* chore: Bump hardhat to 2.22.7

* fixup: Don't enable RIP-7212 in our tests

* Adapt for NomicFoundation/hardhat#5411
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix: add json alias property in provider response

* Create empty-bobcats-refuse.md
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* breaking change: rename response.json to response.data

* Create sour-donkeys-draw.md

* Update sour-donkeys-draw.md
… type in debug trace (#606)

* fix: improve error message and option to skip unsupported tx type in debug trace

* Address code review feedback

* Handle unsupported transaction type requested

* Fix test setup
* Fix pnpm warning

* Add syncpakc

* Add syncpack

* Run syncpack format

* Run syncpack on CI

* Add setup-node action

* Fixes related to upgrading prettier

* Run prettier

* Add setup-rust action

* Run prettier in edr_napi

* Add lint scripts to packages

* Run prettier in crates/tools/js/benchmark

* Port benchmark code to typescript

* Add eslint to all packages

* Upgrade @types/node to v20

* Fix broken build:edr script

* Resolve benchmark output path
* Upgrade Hardhat to v2.22.9

* Add patch for hardhat#5664
* refactor: Port the codebase model construction and EVM decoding from HH

* chore: Add a script that regenerates the pnpm patch for Hardhat

* patch(hardhat): Cherry-pick and adapt for the unreleased Rip7212 PR

See NomicFoundation/hardhat@f944cd5

* patch(hardhat): Cherry-pick a stack trace cleanup PR

See NomicFoundation/hardhat@5739893

* patch(hardhat): Use the rewritten compiler to model logic from EDR

See NomicFoundation/hardhat@49c66b6

* Port `MessageTrace` and `VMTracer` machinery from Hardhat (#531)

* Some small improvements

* Port `MessageTrace` and `VMTracer` machinery from Hardhat

* Move HH-specific ExitCode logic to edr_napi

* Remove unused `ExitCode::STATIC_STATE_CHANGE`

* patch(hardhat): Re-use MessageTrace and VmTracer from EDR now

See NomicFoundation/hardhat@3aeeb56

* chore: Re-run pnpm build

* Address PR feedback

* Address PR feedback

* fixup: Apply formatting

* refactor: Port ContractsIdentifier to Rust (#562)

* chore: Port the BytecodeTrie from ContractsIdentifier

* Migrate some library utils

* Migrate some Opcode helpers

* Finish the ContractsIdentifier port

* Remove unused get_library_address_positions

* Simplify the ContractsIdentifier port

* patch(hardhat): Re-use the ContractsIdentifier from EDR

* fixup: Fix a simple test

* refactor: Port the `VmTraceDecoder` from Hardhat (#568)

* fix: Correctly deserialize BuildInfo with `_format` field

* refactor: Port the VmTraceDecoder from Hardhat

* fix(napi): Correctly encode and decode `MessageTrace` types

* refactor: Remove now unneeded functions

* patch(hardhat): Port the VmTraceDecoder from Hardhat

* Reformat and remove unused imports

* fixup: Use a more correct type for the XYZTrace::bytecode field

* fixup: Adjust test to now optional `deployedContract` property

* refactor: Port `ReturnData` and `StackTraceEntryType` (#589)

* feat: Port solidity-stack-trace.ts

* feat: Port return-data.ts

* patch(hardhat): Port return-data.ts and solidity-stack-trace.ts

* fixup: Reformat files

* fixup: let's see how tests feel about a number instead of a const enum variant

* Make the comment about Rust type alias more clear [skip ci]

* fix: Fully transpile in Mocha tests to correctly inline const enums (#594)

It seems transpile-only transpiles per module, however we need to
perform full "compilation" in order to correctly see and inline values
for const enums.

We use const enums because that's how they are emitted by napi-rs and
there's no option to change that. Rather than invest into supporting
that or working around it, let's just fully compile the test harness
once.

See https://www.typescriptlang.org/tsconfig/#isolatedModules for more
context.

* refactor: Port ErrorInferrer and SolidityTracer from Hardhat (#593)

* Start porting SolidityTracer

* Start porting ErrorInferrer

* WIP: Keep Reference in MessageTraces

* Port 99% of the ErrorInferrer

Except `ErrorInferrer.inferAfterTracing`. I discovered that the original
code creates a shallow copy of the stack trace during select heuristics
and returns the modified one or the *original* one if the heuristic does
not hit.

One could keep track of possible series of changes that would have to be
subsequently applied if the heuristic hits and returns a modified the
stack trace but instead, I want the code to do exactly what the original
code did.

Rather than wrap every entry in a shareable `Rc` (they are not
modified), I decided to make them clonable in the next PR, which means
we need to not keep the `ClassInstance` around to derive the Clone
trait.

* Port mapped-inlined-internal-functions-heuristics.ts

* refactor: Prune StackTraceEntry.message to make it clonable

See previous commit "Port 99% of the ErrorInferrer".

* refactor: Drop unused inner funcs in the ErrorInferrer

* feat: Finish porting `ErrorInferrer`

* feat: Finish porting `SolidityTracer`

* refactor: Remove now unused utils IntoEither/IntoOption

* patch(hardhat): Port ErrorInferrer and SolidityTracer

* fixup! refactor: Prune StackTraceEntry.message to make it clonable

* fixup: Reformat

* Document the unsafety surrounding napi-rs's References

* refactor: Remove some now unused functions

* Address review feedback

* fix a missing period

* fix alphabetical sorting

* refactor: Port stack-traces/debug.ts (#596)

* Port over debugging facilities from debug.ts

* patch(hardhat): Port debug.ts

* fix: Make the depth optional in printMessageTrace

* fixup: Formatting

* Merge `main` into the stack trace port feature branch (#618)

* fix: use remote chain id for pre-fork simulation (#567)

* fix: use remote chain id for pre-fork simulation

* Fix error message

* chore: Bump hardhat to 2.22.7 (#571)

* chore: Bump hardhat to 2.22.7

* fixup: Don't enable RIP-7212 in our tests

* Adapt for NomicFoundation/hardhat#5411

* fix: prevent crash when returning large JSON responses (#569)

* ci: update collaborator check in the benchmarks workflow (#574)

* edr-0.5.1 (#559)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: add json alias property in provider response (#582)

* fix: add json alias property in provider response

* Create empty-bobcats-refuse.md

* edr-0.5.2 (#583)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* breaking change: rename response.json to response.data (#584)

* breaking change: rename response.json to response.data

* Create sour-donkeys-draw.md

* Update sour-donkeys-draw.md

* fix: improve error message and option to skip unsupported transaction type in debug trace (#606)

* fix: improve error message and option to skip unsupported tx type in debug trace

* Address code review feedback

* Handle unsupported transaction type requested

* Fix test setup

* ci: remove review-related slack notifications (#612)

* chore: js tooling improvements (#609)

* Fix pnpm warning

* Add syncpakc

* Add syncpack

* Run syncpack format

* Run syncpack on CI

* Add setup-node action

* Fixes related to upgrading prettier

* Run prettier

* Add setup-rust action

* Run prettier in edr_napi

* Add lint scripts to packages

* Run prettier in crates/tools/js/benchmark

* Port benchmark code to typescript

* Add eslint to all packages

* Upgrade @types/node to v20

* Fix broken build:edr script

* Resolve benchmark output path

* chore: upgrade hardhat and add patch (#613)

* Upgrade Hardhat to v2.22.9

* Add patch for hardhat#5664

* chore: Bump to vanilla Hardhat 2.22.9

* chore: Regenerate the Hardhat patch to use the new EDR internals

* chore: Bump @napi-rs/cli to fix duplicated napi typedefs

See <napi-rs/napi-rs#2088>

* fixup: Prettify test.ts

* Fixes after testing in OZ (#625)

* fix: add bounds checks

* fix: check that steps is not empty before traversing it

* fixup: formatting [skip ci]

---------

Co-authored-by: Igor Matuszewski <xanewok@gmail.com>

---------

Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com>
Co-authored-by: Wodann <Wodann@users.noreply.github.com>
Co-authored-by: Piotr Galar <piotr.galar@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>

* chore: Restore old test.ts and remove some `as any` conversions

* WIP: Benchmark with patched Hardhat to use new EDR internals

* Revert "WIP: Benchmark with patched Hardhat to use new EDR internals"

This reverts commit ac2e012.

* Remove the gen-hardhat-patches script

---------

Co-authored-by: Agost Biro <5764438+agostbiro@users.noreply.github.com>
Co-authored-by: Wodann <Wodann@users.noreply.github.com>
Co-authored-by: Piotr Galar <piotr.galar@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
#614)

* Stop re-exporting SourceMapLocation and other minor types

* Stop re-exporting Instruction and Opcode

* Stop re-exporting JumpType

* Stop re-exporting ContractFunctionVisibility

* Stop re-exporting ContractType

* refactor: Rename ContractType to ContractKind

To better match the name from the solc artifacts and to match what other
libraries use as well.

* Stop re-exporting ImmutableReference

* Stop re-exporting CustomError

* Stop re-exporting SourceFile

* Stop re-exporting SourceLocation

* fixup! Stop re-exporting CustomError

* refactor: Keep Vec<u8> as ContractFunction.selector

* Simplify and don't re-export select functions

* Simplify ContractsIdentifier wrt buffer cloning

* refactor: Remove redundant napi::Result in SourceFile::new

* refactor: Limit interior mutability in ContractFunction to the selector

* refactor: Break Rc cycle between Contract <> ContractFunction

The `contract` field in ContractFunction is only used for the debug
printing anyway.

* refactor: Remove more napi types

* refactor: Always bundle ContractsIdentifier with VmTraceDecoder

* Stop re-exporting Contract

* Stop threading Env through SolidityTracer

* Stop re-exporting Bytecode and prune ClassInstance helpers

* refactor: Don't unnecessarily clone Rcs

* refactor: Clean up ContractsIdentifier some more

* Move the rest of the library_utils

* Remove some useless Results and impl PartialEq for SourceLocation

* refactor: For now settle on panicking borrows for clarity

* Fix an annoying Clippy false positive lint

* refactor: Remove (now) unnecessary custom opcode logic

* refactor: Make sure to catch_unwind in our main napi entry points

* Remove unnecessary napi types from model.rs

* Prune napi Results from the compiler.rs

* refactor: Move build model, AST conv. and source map to edr_solidity

* refactor: Replace ContractsIdentifier with ported impl

While the original port is nicer, I prefer to move over everything that
is already working with the existing source model. We should make this a
lot nicer and document this later on.

* fixup: Formatting

* fix: Separate N-API bindings from the edr_solidity

We can't pull other #[napi]-adorned types when pulling a dependency
because it causes linking failures when building unit test targets.

This is only a minor nuisance, so let's pull the trigger and separate
this entirely.

* Remove now unused anyhow from edr_napi

* refactor: Break the ref cycle by separating sources in the build model

* WIP: Benchmark with patched Hardhat to use new EDR internals

* Add documentation for select types in edr_solidity

* fixup: formatting

* Track future deserialization improvements in an issue

* fixup: formatting

* Revert "WIP: Benchmark with patched Hardhat to use new EDR internals"

This reverts commit 9ca5997.
Xanewok and others added 19 commits September 5, 2024 17:14
This removes the need for us to patch locally, so let's pull
this in to clean up the patching for now.
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix: Prevent contiguous blockchain storage from bitrotting

* fixup: Reformat
Co-authored-by: Igor Matuszewski <Xanewok@gmail.com>
This workflow needs to be added to main as the
schedule trigger only works on the default branch.
* fix: Gracefully handle a call trace with no jump dests

This specifically does what Hardhat did, which is throwing a new Error.

The error can be found in https://github.com/ProjectOpenSea/seaport,
if we execute:
```
npx hardhat test --no-compile --config ./hardhat.config.ts --grep 'Reverts when attempting to execute transfers on a conduit when not called from a channel'
```

* fix: Handle optional settings in solc Standard JSON output

* Add a changeset
* fix: Allow block time offset to be negative

* Add a changeset file

* fix: Use a correct sign for block time offset

* test: Add a regression test for forking blocks with future timestamps
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix: Handle nullptr JS TypedArrays by bumping napi to 2.6.11

* Remove the comment about pinning both napi(-derive) crates

* fixup: Forgot that napi_derive is not re-exported by napi
#676)

* fixup: Re-generate the index.d.ts file

* chore: Bump @napi-rs/cli to 2.18.4

Closes #621
* fix: Use correct bytecode in proxy error propagation check

This was a mistake done when porting; the original code is correct.

* Add a changeset file
* fix: Only add unmapped instructions at the opcode boundary

* Add a changeset file

* Add a unit test for mapping instructions across opcode boundary
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* ci: Drop actions-rs/cargo action in favor of directly running cargo

* ci: Migrate off unmaintained actions-rs/toolchain

* feat: Install Rustup if not found on the self-hosted runner

* feat: Set the CARGO_HOME explicitly

* Use a more maintained action for installing a Rust toolchain

* ci: Streamline nightly Rustfmt installation

* ci: Add toolchain/components inputs to setup-rust
@Wodann Wodann added the no changeset needed This PR doesn't require a changeset label Sep 25, 2024
@Wodann Wodann requested a review from a team September 25, 2024 22:31
@Wodann Wodann self-assigned this Sep 25, 2024
Copy link

changeset-bot bot commented Sep 25, 2024

⚠️ No Changeset found

Latest commit: b87054b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Wodann Wodann temporarily deployed to github-action-benchmark September 25, 2024 22:31 — with GitHub Actions Inactive
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (feat/multichain@d2f663d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/edr_rpc_eth/src/transaction.rs 0.00% 0 Missing and 1 partial ⚠️
crates/edr_solidity/src/source_map.rs 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             feat/multichain     #684   +/-   ##
==================================================
  Coverage                   ?   53.46%           
==================================================
  Files                      ?      236           
  Lines                      ?    27715           
  Branches                   ?    27715           
==================================================
  Hits                       ?    14817           
  Misses                     ?    11979           
  Partials                   ?      919           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@Xanewok Xanewok left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Wodann Wodann merged commit 2eda304 into feat/multichain Oct 1, 2024
41 checks passed
@Wodann Wodann deleted the merge/main-into-multichain branch October 1, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changeset needed This PR doesn't require a changeset
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants