feat(cast): Cast generic Network support (foundry-rs#13624)#396
feat(cast): Cast generic Network support (foundry-rs#13624)#396Dargon789 wants to merge 205 commits intoDargon789:masterfrom
Conversation
* Update standard_json.rs * Update provider.rs * Update sourcify.rs
…send` (#13747) Extract `CastTxSender::print_tx_result()` to share the "print hash or wait for receipt" logic between the normal send flow and the browser wallet flow. Flatten the browser case into its own `else if` branch so `--browser` takes priority over `--unlocked` instead of being silently ignored.
#13736) refactor(anvil): move network-agnostic methods to impl<N> Backend<N> Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
#13752) * refactor(evm): remove unused `snap_tx_env` from `BackendStateSnapshot` The `snap_tx_env` field was stored on every state snapshot but never read back on revert — it was destructured as `_`. Remove it along with the `tx_env` parameter from `DatabaseExt::snapshot_state`, avoiding an unnecessary `TxEnv` clone on every snapshot. * style: fmt snapshot_state signatures * fix: use backend_mut in CowBackend::snapshot_state to preserve initialization Amp-Thread-ID: https://ampcode.com/threads/T-019ce8e6-b2c7-71dd-8f3e-df34110d8a20 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
There was a problem hiding this comment.
Sorry @Dargon789, your pull request is larger than the review limit of 150000 diff characters
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
@Mergifyio refresh |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
✅ Pull request refreshed |
There was a problem hiding this comment.
Code Review
This pull request introduces generic network support for the cast crate, a significant architectural refactoring. The Cast struct and its methods are now generic over the alloy_network::Network trait, allowing them to work with different network types like AnyNetwork and TempoNetwork. This required changes across multiple crates, including anvil, forge, and foundry-evm-core, to adapt to the new generic APIs. Key changes include using generic transaction requests, introducing a TryIntoRlpEncodable trait for headers, and refactoring provider creation to use a generic ProviderBuilder. The changes are well-structured and improve the flexibility of cast.
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
@github-actions[bot] is attempting to deploy a commit to the Foundry development Team on Vercel. A member of the Team first needs to authorize it. |
…0.2.31 (#13763) Co-authored-by: Matthias Seitz <19890894+mattsse@users.noreply.github.com>
fix(cheatcodes): import TxEnv in evm cheatcodes Amp-Thread-ID: https://ampcode.com/threads/T-019d3dc5-6540-72d5-b37c-0dcce6a0c330 Co-authored-by: Amp <amp@ampcode.com>
refactor(anvil): extract per-tx mining loop into generic `execute_pool_transactions` Extract the ~150-line per-tx loop duplicated in `do_mine_block` and `with_pending_block` into a shared `execute_pool_transactions` function. The function is generic over `B: BlockExecutor` — callers pass any executor that satisfies the trait bounds. Also makes `build_tx_env_for_pending` generic over transaction and tx env types, removing the `is_optimism` parameter. Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
…#13959) refactor(anvil): replace EitherEvm with compile-time dispatch Replace runtime EitherEvm dispatch with compile-time branching on is_optimism(). Creates concrete EthEvm/OpEvm instances directly via their respective EvmFactory, eliminating the EitherEvm wrapper.
…`Error intrinsic gas too low` (#13999) add megaeth and megaethtestnet to different gas calc
* Align with alloy-evm 0.29.2 and revm 36 Amp-Thread-ID: https://ampcode.com/threads/T-019d3ea9-358f-76fb-9078-b9228f314b05 Co-authored-by: Amp <amp@ampcode.com> * Fix lint for revm handler upgrade Amp-Thread-ID: https://ampcode.com/threads/T-019d3ea9-358f-76fb-9078-b9228f314b05 Co-authored-by: Amp <amp@ampcode.com> * Use merged fork-db typed cache maps Amp-Thread-ID: https://ampcode.com/threads/T-019d3ea9-358f-76fb-9078-b9228f314b05 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
Add `FromEvmVersion` trait in `foundry-evm-hardforks` with impls for `SpecId`, `OpSpecId`, and `TempoHardfork`. Delete old `evm_spec_id` from `foundry-config` and re-export the generic version.
refactor(anvil): remove EitherEvm from tests and delete either_evm module Replace EitherEvm usage in evm.rs tests with concrete EthEvm/OpEvm types. Each test already knows its network at compile time — the runtime dispatch was unnecessary. With zero consumers remaining, delete `either_evm.rs` entirely.
…generic impl (#14019) refactor(anvil): mk FeeHistoryService generic, mv EthApi mtds to generic impl Co-authored-by: zerosnacks <zerosnacks@protonmail.com>
* fix(evm): use actual block number for fork pinning on Arbitrum On Arbitrum, `block_env.number` is remapped to the L1 (Ethereum mainnet) block number by `apply_chain_and_block_specific_env_changes`. The fork block pinning logic introduced in #13085 read this remapped value, causing the fork to pin to an ancient Arbitrum block where most contracts did not exist yet. This fix threads the actual block number returned by `fork_evm_env` through `env()` and into `get_fork()`, so the fork is always pinned to the correct chain block number regardless of L2 block number remapping. Fixes #13576 Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019cf6ac-e302-742b-92aa-b0b1ee1dd91d * test: add regression tests for Arbitrum fork block pinning Adds two regression tests for #13576: 1. Unit test in opts.rs: verifies that env() returns the L2 block number (not the remapped L1 block number) and that get_fork() pins to it. 2. Integration test in script.rs: runs a forge script that calls WETH on an Arbitrum fork — this would fail with "call to non-contract address" before the fix. Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * test: use USDC instead of WETH in Arbitrum regression test WETH has a non-zero ETH balance so it gets loaded into the fork regardless of the block number bug. USDC has zero balance and is the contract that actually fails without the fix. Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019cf6ac-e302-742b-92aa-b0b1ee1dd91d * test: prefix Arbitrum regression test with flaky_ Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d42e5-a19e-76fa-a81d-1c33d0e5df2d Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: Amp <amp@ampcode.com>
refactor(evm): make `InspectorStackBuilder::build()` generic over `SPEC` and `Network`
Motivation
Solution
PR Checklist
feat(cast):
CastgenericNetworksupport foundry-rs/foundry#13624