Skip to content

Add solver authentication to the settlement - #127

Merged
fedgiac merged 29 commits into
mainfrom
federico/sc-300-gate-settlement-on-a-solver-caller
Aug 28, 2026
Merged

Add solver authentication to the settlement#127
fedgiac merged 29 commits into
mainfrom
federico/sc-300-gate-settlement-on-a-solver-caller

Conversation

@fedgiac

@fedgiac fedgiac commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Gate BeginSettle on a solver that both signs the transaction and is in the state PDA's solver list, so only approved solvers can settle.

Design

Only BeginSettle is gated. FinalizeSettle can't run without a paired BeginSettle earlier in the same atomic transaction (enforced by the counterpart/ordering checks). Considering that the solver signs an instruction that points to another one, it's fair to assume the solver agrees to the finalize as well.

Cost: ~100/200 CU on a settlement.

Out of scope

The CLI payer for settle needs to be a solver now. This is poorly documented right now, but it should be easy to add a check.

Tests

This is where most of the changes in this PR happen, and they are very boring. Only notable things: now all settlement test need to register a solver. Some tests have a dedicated transaction payer, some other are paid directly by the solver, based on how relevant the fee payment appeared to be.

Every time there was some metering test, I decided to have the solver be the payer to make it more realistic.

How to test

CI.

@fedgiac
fedgiac requested a review from a team as a code owner August 27, 2026 14:42
@linear-code

linear-code Bot commented Aug 27, 2026

Copy link
Copy Markdown

SC-300

@kaze-cow kaze-cow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as I mentioned privately this PR turned out quite a lot more complicated than I would have expected

I think in a future PR the setup functions for the integration test suite should be revisited. IMNSHO what is currently called setup_settle_ready should be the new setup as most tests want a reasonably functional setup function as a starting point, and only specific tests that need special circumstances (ex. uninitialized, explicitly not wanting a solver registered for whatever reason) should be more elaborately named variants.

(random note from the token2022 side: we are looking at probably adding a 5th static account as a result of the token2022 token account being added to allow for both token accounts to be used at the same time. just want to put this on the radar)

Comment thread programs/settlement/src/processor.rs Outdated
Comment thread programs/settlement/src/processor.rs
Comment thread programs/settlement/src/processor.rs
Comment thread interface/src/instruction/settle/begin.rs Outdated
Comment thread interface/src/instruction/settle/begin.rs Outdated
Comment thread interface/src/instruction/settle/begin.rs Outdated
Comment thread programs/settlement/tests/settle_solver_auth.rs
Comment thread programs/settlement/tests/settle_solver_auth.rs Outdated
Base automatically changed from federico/sc-299-add-functions-to-add-solver to main August 28, 2026 08:38
@fedgiac
fedgiac requested a review from kaze-cow August 28, 2026 09:37

@kaze-cow kaze-cow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no further comments

@fedgiac
fedgiac merged commit f9b67db into main Aug 28, 2026
14 checks passed
@fedgiac
fedgiac deleted the federico/sc-300-gate-settlement-on-a-solver-caller branch August 28, 2026 10:14
fedgiac added a commit that referenced this pull request Aug 28, 2026
I addressed a
[comment](#127 (comment))
in a previous PR but it wasn't pushed. So I'm adding it as a new PR.
Just a small change.

## How to test

CI.
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