Skip to content

feat: setup#2

Merged
igorroncevic merged 8 commits into
mainfrom
feat/setup
May 21, 2026
Merged

feat: setup#2
igorroncevic merged 8 commits into
mainfrom
feat/setup

Conversation

@igorroncevic
Copy link
Copy Markdown
Collaborator

@igorroncevic igorroncevic commented May 14, 2026

Description

This PR sets up the first version of Solver7702Delegate, an ERC-7702 delegation target for solver EOAs.

The contract lets approved auxiliary EOAs submit calls through the solver EOA. This gives solvers more nonce lanes for settlement submission while keeping the solver EOA as the address seen by downstream contracts.

What changed

  • Added Solver7702Delegate.
  • Added five immutable approved caller addresses set at deployment time.
  • Added fallback-based call forwarding.
  • Uses packed calldata: the first 20 bytes are the target address, and the rest is forwarded as calldata.
  • Forwards ETH and bubbles up target return data or revert data.
  • Rejects callers that are not in the approved caller list.
  • Added a deploy script for Solver7702Delegate.
  • Removed the starter Counter contract, script, and test.
  • Updated README, Foundry, Slither, Solhint, and editor config for this contract.

Why

A solver EOA has one nonce lane, so transactions from that EOA must land in order. With ERC-7702, auxiliary EOAs can send transactions to the solver EOA and use their own nonce lanes, while calls still execute as the solver EOA.

This keeps the existing solver identity and avoids having to allowlist several EOAs or require every solver to use a smart contract account.

Out of scope

Testing

Run:

just build
just lint
just slither

Copy link
Copy Markdown

@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 replaces the example Counter contract with Solver7702Delegate, an ERC-7702 delegation target that forwards calls from authorized addresses. It also updates tool configurations for Solhint, Slither, and Foundry. Feedback identifies a compilation error in the target address extraction logic and suggests using granular Slither suppressions instead of global detector exclusions to preserve security analysis depth.

Comment thread src/Solver7702Delegate.sol
Comment thread slither.config.json
@igorroncevic igorroncevic marked this pull request as ready for review May 14, 2026 11:26
@igorroncevic igorroncevic requested a review from a team as a code owner May 14, 2026 11:26
Comment thread .solhint.json
Comment on lines +7 to +9
"func-visibility": ["error", { "ignoreConstructors": true }],
"no-complex-fallback": "off",
"no-inline-assembly": "off"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

All of these are necessary:

  • "func-visibility": ["error", { "ignoreConstructors": true }] -> constructor doesn't require explicit visibility modifier since Solidity 0.7
  • "no-complex-fallback": "off" -> we explicitly need our fallback to be complex
  • "no-inline-assembly": "off" -> we explicitly need assembly for gas efficiency

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

id almost say that no-inline-assembly should be added to the template repo because we almost end up using it for one reason or another.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd sit on that as it might not be required by other repos.

Comment thread foundry.toml
Comment thread slither.config.json
Comment thread .vscode/settings.json Outdated
Comment on lines +11 to +24
/// @notice Address of the first approved caller
address private immutable APPROVED_CALLER_0;

/// @notice Address of the second approved caller
address private immutable APPROVED_CALLER_1;

/// @notice Address of the third approved caller
address private immutable APPROVED_CALLER_2;

/// @notice Address of the fourth approved caller
address private immutable APPROVED_CALLER_3;

/// @notice Address of the fifth approved caller
address private immutable APPROVED_CALLER_4;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I left these as private as to not increase the bytecode of the contract unnecessarily.

However, there would need to be some additional assumptions in services about this, because now we can no longer check if the caller is approved with isApprovedCaller (first iteration), but through some other means, e.g. simulating a transaction with a sender being e.g. Bob, and see if it would revert with Unauthorized.

Copy link
Copy Markdown

@kaze-cow kaze-cow May 19, 2026

Choose a reason for hiding this comment

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

I don't think this is a major issue because if the contract is deployed with CREATE2, then the correct list of callers can be validated by checking the existance of the code at the expected address.

Most ethereum libraries provide some sort of a function to predict the create2 address, such as get_create2_address_from_hash. No relying on simulation/revert on creation check needed.

To then know which addresses are authorized, the list can be read from the driver instance that created it.

Copy link
Copy Markdown

@kaze-cow kaze-cow left a comment

Choose a reason for hiding this comment

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

I just feel like the deploy script is a bit more complicated than it needs to be...

import {Solver7702Delegate} from "../src/Solver7702Delegate.sol";

/// @title DeploySolver7702Delegate
/// @author CoW Foundation
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

in the past we have used CoW DAO developers most frequently ex.

https://github.com/cowprotocol/euler-integration-contracts/blob/master/src/CowWrapper.sol#L16
https://github.com/cowprotocol/flash-loan-router/blob/main/src/FlashLoanRouter.sol#L13

(Other contracts have used "CoW Swap Developers" or CoW Developers, so at the very least lets not add a whole nother author to the mix)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As per cowprotocol/contracts-template#20 and legal recommendations, CoW Foundation is the name we should use going forward.

Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread src/Solver7702Delegate.sol
Comment thread src/Solver7702Delegate.sol Outdated
Comment thread README.md
This project is meant to be used as a templated during the creation of new Github repositories (will show in the `Create a new repository > Configuration > Start with a template` selector).

It will contain some useful configuration files and scripts, that can be used also with existing projects (manually copied).
Read more about the initiative [here](https://www.notion.so/cownation/Solver7702Delegate-Design-Doc-3588da5f04ca80a1b521c436abf17724).
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

linking to a private notion on a public repo's readme seems a bit wierd. not sure if we want this here or not.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I feel like it should be there for any internal integrators.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Overall looks great.

Comment thread .vscode/settings.json Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread script/DeploySolver7702Delegate.s.sol Outdated
/// @notice Predicts the CREATE2 address using environment variables.
/// @dev Reads `SALT`, approved callers, and optional `CREATE2_DEPLOYER`.
/// @return The predicted Solver7702Delegate address.
function predictAddress() external view returns (address) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why not using this for validation during the deployment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Validation/assumptions should now be done manually if --broadcast is not supplied, for simplicity.

Comment thread script/DeploySolver7702Delegate.s.sol Outdated
Comment thread src/Solver7702Delegate.sol Outdated
Comment thread src/Solver7702Delegate.sol Outdated
Copy link
Copy Markdown

@kaze-cow kaze-cow left a comment

Choose a reason for hiding this comment

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

great!

* tests: wip

* better tests

* unit tests

* refactor

* integration tests

* fork tests

* check snapshots in CI

* add other networks

* more precise snapshot

* test: address PR review comments

* add rpc urls to env

* fix tests

* simplify tests

* pr feedback

* remove OZ, update tests

* apply copilot recommendation to use msg.value appropriately in historical txs

* update snapshots

* pr feedback

* add swap and bridge tx
@igorroncevic igorroncevic merged commit acde4b0 into main May 21, 2026
6 checks passed
@igorroncevic igorroncevic deleted the feat/setup branch May 21, 2026 11:34
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.

3 participants