fix: validate every wrapper has code before simulating#4442
Open
squadgazzz wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.
d997e33 to
4ea04ef
Compare
jmg-duarte
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #4434 and #4432. The trade verifier sets
settleCallTargetto the first wrapper. Any further wrappers are packed intowrapperDatabytes and called from inside the chain. A low-levelcallto an EOA returns success with empty output, so if any wrapper in the chain has no code, the inner settlement and itsstoreBalanceinteractions silently no-op and the helper returns a shortqueriedBalancesarray.#4432 added a defensive bounds check that prevents the panic but reports a generic shape mismatch. #4434 added a Solidity
requirethat 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_builderbeforeencode_wrapper_settlement. Catches outer and inner EOA wrappers, surfacesBuildError::WrapperHasNoCode { address }, and is intended to replace the Solidity-side fix in #4434.Changes
BuildError::WrapperHasNoCodeandBuildError::WrapperCodeFetchvariantsensure_wrappers_have_codehelper that runs oneeth_getCodeper wrapper in parallelfinish_simulation_builderwhen wrappers are configuredHow to test
New unit tests.