Skip to content

Solana: Add min_validations to Controller#69

Open
GuidoDipietro wants to merge 4 commits intosolana/settlerfrom
solana/controller-min-validations
Open

Solana: Add min_validations to Controller#69
GuidoDipietro wants to merge 4 commits intosolana/settlerfrom
solana/controller-min-validations

Conversation

@GuidoDipietro
Copy link
Member

@GuidoDipietro GuidoDipietro commented Mar 19, 2026

Adds min_validations to Controller's global state, following EVM implementation.
This implied a change in the Controller's state PDAs, two new instructions, and a small logic change in the Settler.

Note: Tests will fail until SDK version is bumped.


Changes

Controller

State

Adds min_validations: u16 to controller_settings.
This field is added after all existing fields to not break the already deployed program. Eventually, if we take down this program and deploy another one, we can rearrange the fields to have bump be the last one.

Instructions

initialize

Adds min_validations: u16 as a required parameter to set it upon initialization, with a > 0 constraint.

New instruction: set_min_validations

This is an admin-only instruction that lets admins update the min_validations field on ControllerSettings, with a > 0 constraint.

New instruction: resize_settings

This is an admin-only instruction that lets admins resize existing ControllerSettings PDAs.
As the settings PDA is created using the minimum INIT_SPACE on initialization (when calling initialize), adding new fields requires a reallocation.

A note on live programs and existing PDAs:
Typically, it is best to just allocate the PDA once with _reserved: [u8; 500] as its last field to allocate more space than needed and not need reallocations when extending the struct, if we expect to extend the struct on later program upgrades. Another approach for live programs is to deprecate the PDA and use another one such as ControllerSettings2, or rather, extend the state in yet another complementary PDA such as ControllerMinValidations only with the extra fields. However, the approach used here is not only sensible too but also more reasonable given that we are in a development stage yet.

Other notes about this instruction:
Admins should note that this instruction is expected to be called together (same transaction) with another instruction writing to the newly added settings field (in this case, set_min_validations).
If this instruction is called alone, the extra bytes added to the ControllerSettings PDA will be zeroed, meaning there might be inconsistent state. In this case, calling resize_settings on its own creates a min_validation field equal to 0, which is otherwise impossible through program logic.

Settler

Instructions

create_intent

Intent's min_validations are now set to the maximum of intent.min_validations and controller.min_validations, following EVM logic.

Tests

Tests were updated and new cases added accordingly.
Naming was adjusted a bit in settler.spec.ts as it differed slightly from the other test file.

@GuidoDipietro GuidoDipietro self-assigned this Mar 19, 2026
@GuidoDipietro GuidoDipietro marked this pull request as ready for review March 19, 2026 20:35
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.

1 participant