Skip to content

fix: validate every wrapper has code before simulating#4442

Open
squadgazzz wants to merge 2 commits into
mainfrom
fix/wrapper-code-check
Open

fix: validate every wrapper has code before simulating#4442
squadgazzz wants to merge 2 commits into
mainfrom
fix/wrapper-code-check

Conversation

@squadgazzz
Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz commented May 26, 2026

Description

Follow-up to #4434 and #4432. The trade verifier sets settleCallTarget to the first wrapper. Any further wrappers are packed into wrapperData bytes and called from inside the chain. A low-level call to an EOA returns success with empty output, so if any wrapper in the chain has no code, the inner settlement and its storeBalance interactions silently no-op and the helper returns a short queriedBalances array.

#4432 added a defensive bounds check that prevents the panic but reports a generic shape mismatch. #4434 added a Solidity require that only catches the outermost wrapper, as @MartinquaXD pointed out in this comment.

This PR moves the check to Rust and validates every wrapper address in finish_simulation_builder before encode_wrapper_settlement. Catches outer and inner EOA wrappers, surfaces BuildError::WrapperHasNoCode { address }, and is intended to replace the Solidity-side fix in #4434.

Changes

  • BuildError::WrapperHasNoCode and BuildError::WrapperCodeFetch variants
  • ensure_wrappers_have_code helper that runs one eth_getCode per wrapper in parallel
  • Called from finish_simulation_builder when wrappers are configured

How to test

New unit tests.

@squadgazzz squadgazzz requested a review from a team as a code owner May 26, 2026 08:32
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a check (ensure_wrappers_have_code) to verify that all wrapper addresses in a simulation have code deployed on-chain, preventing silent failures during execution. It also adds corresponding unit tests and error definitions. The feedback suggests querying the wrapper code at the specific simulated block number rather than the latest block to ensure correctness for historical simulations, which requires updating the helper function, its call site, and the associated tests.

Comment thread crates/simulator/src/encoding.rs
Comment thread crates/simulator/src/encoding.rs
Comment thread crates/simulator/src/encoding.rs Outdated
Comment thread crates/simulator/src/encoding.rs Outdated
Comment thread crates/simulator/src/encoding.rs Outdated
@squadgazzz squadgazzz force-pushed the fix/wrapper-code-check branch from d997e33 to 4ea04ef Compare May 26, 2026 08:37
@squadgazzz squadgazzz requested a review from MartinquaXD May 26, 2026 13:38
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.

2 participants