Skip to content

Reject EOA target in Solver helper to surface as simulation failure#4434

Open
squadgazzz wants to merge 2 commits into
mainfrom
fix/solver-helper-rejects-eoa-target
Open

Reject EOA target in Solver helper to surface as simulation failure#4434
squadgazzz wants to merge 2 commits into
mainfrom
fix/solver-helper-rejects-eoa-target

Conversation

@squadgazzz
Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz commented May 22, 2026

Description

The Solver simulation helper (contracts/solidity/Solver.sol) calls the settle target via low-level call. EVM call to an address with no code returns success with empty output, so when an order's metadata.wrappers[0].address points at an EOA (or any address without code), _executeAndMeasure silently no-ops: the inner settle never runs, the pre/post storeBalance interactions that record trader balances never execute, and the helper returns a queriedBalances array with only the settlement-contract pre/post balances (length 2N instead of the expected 2N + 2).

On the Rust side, SettleOutput::from_swap blindly indexes that array and panics on the missing trader balance entries. PR #4432 adds the defensive bounds check on the Rust side. This PR addresses the root cause: reject EOA targets up front so the verifier produces a normal Error::SimulationFailed (unverified quote) rather than a malformed response that downstream code has to defend against.

Production wrappers (AAVE FlashLoanRouter, Euler open/close-position, etc.) always have code, so this check only fires for malformed or test-crafted appData.

Changes

  • Added require(settleCallTarget.code.length > 0, "settle target has no code") to Solver._executeAndMeasure.
  • Regenerated artifacts/Solver.json and the cow-contract-solver Rust bindings via just generate-contracts.

How to test

Existing tests.

Related issues

Companion to #4432.

@squadgazzz squadgazzz marked this pull request as ready for review May 22, 2026 13:54
@squadgazzz squadgazzz requested a review from a team as a code owner May 22, 2026 13:54
Copy link
Copy Markdown
Contributor

@jmg-duarte jmg-duarte left a comment

Choose a reason for hiding this comment

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

Doesn't this require a re-deploy for the solver contract?

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 validation check in the Solver contract to ensure that the settleCallTarget contains code. This change prevents silent no-ops during EVM calls to Externally Owned Accounts (EOAs), which would otherwise break the expected balance array layout and simulation logic. The contract artifacts and generated Rust bindings have been updated accordingly. No critical issues were found.

@squadgazzz
Copy link
Copy Markdown
Contributor Author

Doesn't this require a re-deploy for the solver contract?

nope

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