Add instruction to add a solver - #119
Conversation
kaze-cow
left a comment
There was a problem hiding this comment.
it may be worthwhile, similar to the pattern taken with ReclaimBuffers, to allow for multiple solvers to be added in a single instruction. It doesn't seem like it would be that hard, as it could be resize once by the number of new addresses being added and then call add_solver on StatePda in a loop (see comment)
HOWEVER, in the name of accelerating for the deadline, feel free to ignore this change if its going to take longer than maybe 30 minutes to an hour.
Single-instruction tests were calling assert_settlement_error(0, …), whose instruction-index argument is only meaningful for the multi-instruction settlement tests. I moved that helper out of the shared common scaffolding into settle_limit_prices.rs (the one file that has a reason to care about the index). No behaviour change.
I thought we introduced a new assert_settlement_error_at to remove the index for most cases? or was that in an unmerged PR...
I later saw that the function was not the one I thought I added. assert_setltement_error should have basically been a wrapper for assert_settlement_error_at with 0 index.
…d-functions-to-add-solver
…dding_solver_by_non_manager
Co-authored-by: Kaze <230549489+kaze-cow@users.noreply.github.com>
|
About adding multiple solvers at once: I want to do it but I won't because it would take more than 1h to do it properly. I created an issue to remember about this. Even if we do this, I'd do that in another PR to prevent the scope from growing. |
kaze-cow
left a comment
There was a problem hiding this comment.
couple of minor it appears unaddressed comments. overall would be ok with merging this otherwise.
Drives the new `AddSolver` instruction (#119) from the dev CLI: ``` cow solver add <address> [--manager <keypair-path>] ``` - New `test-cli/src/cmd/solver.rs`: a `solver` command group whose `add` subcommand builds `cow_settlement_client::instructions::AddSolver` against the derived state PDA, sends it, and prints a summary (signature, solver, manager, statePda). - `AddSolver` needs both the manager's and the payer's signature, so `--manager` takes a *keypair path*, not an address. It defaults to by the same as `--keypair`, which is the payer. ## Verification I deployed a testing program for this base branch for the change at `7hwEhpgqZy1qRNMdFvVh4YjerBrZnMR7qGZUbLJTFSxg` To test adding a solver: ``` ➜ solana-programs git:(kaze/sc-299-add-functions-to-addremove-solvers) ./target/debug/cow solver add B6acm3swJK9pJ7fe4i4GQgP7x5A3RndvsdV2bKhcA1i5 --program-id 7hwEhpgqZy1qRNMdFvVh4YjerBrZnMR7qGZUbLJTFSxg signature = 2dsTvWAGvxL2w9MVWTHiMn76oKM73XH29GWh5eaKAGfh739A3CrB4ZRhh1hF72HppJdJyRHSmCTUY1gKi6DzwcXE solver = B6acm3swJK9pJ7fe4i4GQgP7x5A3RndvsdV2bKhcA1i5 manager = B6acm3swJK9pJ7fe4i4GQgP7x5A3RndvsdV2bKhcA1i5 statePda = HkqW1CPzMddJzZm5eFfFBK3wH6uUasLLQ5TczrM2o5VQ ``` The specified solver account can now be used for a settlement as in #98 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
Add the first of the manager's solver-management instructions:
AddSolverinserts a solver into the allowlist stored in the state PDA.Moreover, it encodes this list into the state PDA and includes the minimum accessors needed to it.
Scope is deliberately add only: removing solvers and the solver gate on settling are separate follow-ups. Right now, solvers are unused, can only be appended to.
Solver storage
Solvers live packed and sorted by address immediately after the header, one 32-byte entry each. Sorted storage keeps the list binary-searchable, which is what the manager gate and the future settle gate rely on.
The instruction
The manager authorizes: it signs but doesn't pay. Someone needs to pay for the extra rent from the account's growth, and that's the dedicated
payer.Test-helper cleanup (incidental)
Single-instruction tests were calling
assert_settlement_error(0, …), whose instruction-index argument is only meaningful for the multi-instruction settlement tests. I moved that helper out of the sharedcommonscaffolding intosettle_limit_prices.rs(the one file that has a reason to care about the index). No behaviour change.How to test
New tests.