Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cab3e70
Refactor state PDA accessors
fedgiac Aug 25, 2026
e4ec645
Add instruction to add a solver
fedgiac Aug 26, 2026
8e5d0dc
Merge branch 'main' into refactor-state-account-decoder
fedgiac Aug 26, 2026
7813e83
state_header -> state_account_bytes
fedgiac Aug 26, 2026
515547f
Simplify tests for `Role::ALL`
fedgiac Aug 26, 2026
3e79073
Implement StateAccount::from_account
fedgiac Aug 26, 2026
85c2fd5
StateAccount::new -> StateAccount::attach
fedgiac Aug 26, 2026
1379c01
Merge branch 'refactor-state-account-decoder' into federico/sc-299-ad…
fedgiac Aug 26, 2026
3e2393f
Add comment about saturating_sub
fedgiac Aug 26, 2026
5d0ea61
Move rejects_adding_solver_if_manager_is_not_signer next to rejects_a…
fedgiac Aug 26, 2026
a18f331
Clarify strict invariant check
fedgiac Aug 26, 2026
9dcc7b6
Add proptest verifying duplicate rejection
fedgiac Aug 26, 2026
7d19c0d
Move most resizing operations to interface
fedgiac Aug 26, 2026
8b489e4
cargo fmt & ambiguous import
fedgiac Aug 26, 2026
c6844b4
Simplify binary search
fedgiac Aug 26, 2026
5286c3a
`Header` -> `StateInitArgs`
fedgiac Aug 27, 2026
d189143
Merge branch 'main' into refactor-state-account-decoder
fedgiac Aug 27, 2026
01c2b79
Merge branch 'refactor-state-account-decoder' into federico/sc-299-ad…
fedgiac Aug 27, 2026
c2311fe
Merge branch 'main' into federico/sc-299-add-functions-to-add-solver
fedgiac Aug 27, 2026
c468453
Fix merge issue
fedgiac Aug 27, 2026
641c07a
Reduce number of solvers created in test
fedgiac Aug 27, 2026
f4964e7
Move binary search into solver insertion
fedgiac Aug 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions bench-report.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"accounts": {
"add_solver/add_with_many_existing_solvers": 5,
"add_solver/adds_a_solver": 5,
"create_buffers/happy_path_creates_initialized_buffer_token_account": 6,
"create_buffers/happy_path_creates_multiple_buffers_in_one_instruction": 10,
"create_buffers/max_buffers_in_one_instruction": 64,
Expand All @@ -24,30 +26,34 @@
"transfer_authority/reclaim_authority_can_transfer_itself": 4
},
"compute_units": {
"create_buffers/happy_path_creates_initialized_buffer_token_account": 10340,
"create_buffers/happy_path_creates_multiple_buffers_in_one_instruction": 21731,
"create_buffers/max_buffers_in_one_instruction": 176947,
"create_order/happy_path_creates_order_pda_with_expected_body": 4976,
"initialize/happy_path_initializes_state_pda_with_expected_data": 4526,
"reclaim_buffer/funded_buffer_is_skipped": 6324,
"reclaim_buffer/happy_path_reclaims_empty_buffer_to_the_authority_itself": 7472,
"reclaim_buffer/max_buffers_in_one_instruction": 136526,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 18068,
"add_solver/add_with_many_existing_solvers": 5074,
"add_solver/adds_a_solver": 4622,
"create_buffers/happy_path_creates_initialized_buffer_token_account": 10345,
"create_buffers/happy_path_creates_multiple_buffers_in_one_instruction": 21743,
"create_buffers/max_buffers_in_one_instruction": 177040,
"create_order/happy_path_creates_order_pda_with_expected_body": 4978,
"initialize/happy_path_initializes_state_pda_with_expected_data": 4529,
"reclaim_buffer/funded_buffer_is_skipped": 6333,
"reclaim_buffer/happy_path_reclaims_empty_buffer_to_the_authority_itself": 7481,
"reclaim_buffer/max_buffers_in_one_instruction": 136650,
"reclaim_buffer/reclaims_multiple_buffers_skipping_funded": 18080,
"reclaim_order/happy_path_returns_lamports_and_closes_pda": 2183,
"settle/finalizes_with_no_pushes": 7062,
"settle/pulls_from_multiple_orders": 19921,
"settle/pulls_funds_to_destination": 13524,
"settle/pulls_to_multiple_destinations": 14675,
"settle/pushes_a_single_order": 12366,
"settle/pushes_several_orders_from_different_buffers": 17608,
"settle/pushes_several_orders_from_one_buffer": 17609,
"settle/settles_a_single_order": 12384,
"settle/settles_multiple_orders": 22894,
"transfer_authority/manager_can_transfer_manager": 3174,
"transfer_authority/manager_can_transfer_reclaim_authority": 3176,
"transfer_authority/reclaim_authority_can_transfer_itself": 3180
"settle/finalizes_with_no_pushes": 7070,
"settle/pulls_from_multiple_orders": 19949,
"settle/pulls_funds_to_destination": 13542,
"settle/pulls_to_multiple_destinations": 14694,
"settle/pushes_a_single_order": 12380,
"settle/pushes_several_orders_from_different_buffers": 17632,
"settle/pushes_several_orders_from_one_buffer": 17631,
"settle/settles_a_single_order": 12398,
"settle/settles_multiple_orders": 22926,
"transfer_authority/manager_can_transfer_manager": 3175,
"transfer_authority/manager_can_transfer_reclaim_authority": 3177,
"transfer_authority/reclaim_authority_can_transfer_itself": 3181
},
"transaction_bytes": {
"add_solver/add_with_many_existing_solvers": 366,
"add_solver/adds_a_solver": 366,
"create_buffers/happy_path_creates_initialized_buffer_token_account": 303,
"create_buffers/happy_path_creates_multiple_buffers_in_one_instruction": 435,
"create_buffers/max_buffers_in_one_instruction": 331,
Expand Down
24 changes: 24 additions & 0 deletions client/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,30 @@ impl From<TransferAuthority> for Instruction {
}
}

/// Inserts `solver` into the state PDA's solver list. `manager` authorizes the
/// change and must be the current manager; `payer` funds the account's growth.
/// Both sign.
pub struct AddSolver {
pub program_id: Pubkey,
pub manager: Pubkey,
pub payer: Pubkey,
pub solver: Pubkey,
}

impl From<AddSolver> for Instruction {
fn from(builder: AddSolver) -> Self {
let (state_pda, _bump) = find_state_pda(&builder.program_id);
cow_settlement_interface::instruction::add_solver::AddSolver {
program_id: builder.program_id,
manager: builder.manager,
payer: builder.payer,
state_pda,
solver: builder.solver,
}
.into()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
17 changes: 16 additions & 1 deletion client/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use cow_settlement_interface::{
instruction::{
add_solver::AddSolverInput,
create_buffer::CreateBufferInput,
create_order::CreateOrderInput,
initialize::InitializeInput,
Expand All @@ -28,6 +29,7 @@ pub enum ParsedInstruction<'a, A> {
ReclaimOrder(ReclaimOrderInput<'a, A>),
ReclaimBuffer(ReclaimBufferInput<'a, A>),
TransferAuthority(TransferAuthorityInput<'a, A>),
AddSolver(AddSolverInput<'a, A>),
}

/// Parses any settlement instruction by its discriminator.
Expand Down Expand Up @@ -61,14 +63,18 @@ pub fn parse_instruction<'a, A>(
SettlementInstruction::TransferAuthority => ParsedInstruction::TransferAuthority(
TransferAuthorityInput::parse_body(remaining_data, accounts)?,
),
SettlementInstruction::AddSolver => {
ParsedInstruction::AddSolver(AddSolverInput::parse_body(remaining_data, accounts)?)
}
Comment thread
kaze-cow marked this conversation as resolved.
})
}

#[cfg(test)]
mod tests {
use super::*;
use crate::instructions::{
BeginSettle, CreateBuffers, CreateOrder, FinalizeSettle, Initialize, InitializedIntent,
AddSolver, BeginSettle, CreateBuffers, CreateOrder, FinalizeSettle, Initialize,
InitializedIntent,
};
use cow_settlement_interface::{
data::intent::fixtures::sample_intent,
Expand Down Expand Up @@ -145,6 +151,13 @@ mod tests {
new_authority: payer,
}
.into(),
SettlementInstruction::AddSolver => AddSolver {
program_id,
manager: payer,
payer,
solver: pubkey_from_seed("solver"),
}
.into(),
}
}

Expand All @@ -162,6 +175,7 @@ mod tests {
SettlementInstruction::ReclaimOrder,
SettlementInstruction::ReclaimBuffer,
SettlementInstruction::TransferAuthority,
SettlementInstruction::AddSolver,
] {
let ix = build(expected);
let accounts: Vec<_> = ix
Expand All @@ -180,6 +194,7 @@ mod tests {
ParsedInstruction::ReclaimOrder(_) => SettlementInstruction::ReclaimOrder,
ParsedInstruction::ReclaimBuffer(_) => SettlementInstruction::ReclaimBuffer,
ParsedInstruction::TransferAuthority(_) => SettlementInstruction::TransferAuthority,
ParsedInstruction::AddSolver(_) => SettlementInstruction::AddSolver,
};
assert_eq!(actual, expected);
}
Expand Down
Loading