feat: setup#2
Conversation
There was a problem hiding this comment.
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.
| "func-visibility": ["error", { "ignoreConstructors": true }], | ||
| "no-complex-fallback": "off", | ||
| "no-inline-assembly": "off" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I'd sit on that as it might not be required by other repos.
| /// @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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
kaze-cow
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
As per cowprotocol/contracts-template#20 and legal recommendations, CoW Foundation is the name we should use going forward.
| 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). |
There was a problem hiding this comment.
linking to a private notion on a public repo's readme seems a bit wierd. not sure if we want this here or not.
There was a problem hiding this comment.
Good point, I feel like it should be there for any internal integrators.
| /// @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) { |
There was a problem hiding this comment.
why not using this for validation during the deployment?
There was a problem hiding this comment.
Validation/assumptions should now be done manually if --broadcast is not supplied, for simplicity.
* 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
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
Solver7702Delegate.Solver7702Delegate.Countercontract, script, and test.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: