Skip to content

Commit aa3a110

Browse files
authored
feat: remove unecessary top-up and improve tests (#155)
## Summary Optional change to simplify some of the logic of the treasurer. I noticed that the "top_up" instruction is relatively useless, it only increments a "funded_collateral_amount" counter which itself is already a duplicate of the "run_collateral.amount" ## Details This PR simply remove the "funded_collateral_amount" field and the "top_up" IX Removing this IX reduce the complexity of the program this PR also includes more tests to increase reliability
2 parents 77ab0d7 + 53193b6 commit aa3a110

File tree

11 files changed

+706
-194
lines changed

11 files changed

+706
-194
lines changed

architectures/decentralized/solana-tooling/src/process_treasurer_instructions.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ use psyche_solana_coordinator::find_coordinator_instance;
66
use psyche_solana_treasurer::accounts::ParticipantClaimAccounts;
77
use psyche_solana_treasurer::accounts::ParticipantCreateAccounts;
88
use psyche_solana_treasurer::accounts::RunCreateAccounts;
9-
use psyche_solana_treasurer::accounts::RunTopUpAccounts;
109
use psyche_solana_treasurer::accounts::RunUpdateAccounts;
1110
use psyche_solana_treasurer::find_participant;
1211
use psyche_solana_treasurer::find_run;
1312
use psyche_solana_treasurer::instruction::ParticipantClaim;
1413
use psyche_solana_treasurer::instruction::ParticipantCreate;
1514
use psyche_solana_treasurer::instruction::RunCreate;
16-
use psyche_solana_treasurer::instruction::RunTopUp;
1715
use psyche_solana_treasurer::instruction::RunUpdate;
1816
use psyche_solana_treasurer::logic::ParticipantClaimParams;
1917
use psyche_solana_treasurer::logic::ParticipantCreateParams;
2018
use psyche_solana_treasurer::logic::RunCreateParams;
21-
use psyche_solana_treasurer::logic::RunTopUpParams;
2219
use psyche_solana_treasurer::logic::RunUpdateParams;
2320
use solana_sdk::instruction::Instruction;
2421
use solana_sdk::pubkey::Pubkey;
@@ -63,40 +60,6 @@ pub async fn process_treasurer_run_create(
6360
Ok((run, coordinator_instance))
6461
}
6562

66-
pub async fn process_treasurer_run_top_up(
67-
endpoint: &mut ToolboxEndpoint,
68-
payer: &Keypair,
69-
authority: &Keypair,
70-
authority_collateral: &Pubkey,
71-
collateral_mint: &Pubkey,
72-
run: &Pubkey,
73-
collateral_amount: u64,
74-
) -> Result<Signature, ToolboxEndpointError> {
75-
let run_collateral = ToolboxEndpoint::find_spl_associated_token_account(
76-
run,
77-
collateral_mint,
78-
);
79-
let accounts = RunTopUpAccounts {
80-
authority: authority.pubkey(),
81-
authority_collateral: *authority_collateral,
82-
collateral_mint: *collateral_mint,
83-
run: *run,
84-
run_collateral,
85-
token_program: token::ID,
86-
};
87-
let instruction = Instruction {
88-
accounts: accounts.to_account_metas(None),
89-
data: RunTopUp {
90-
params: RunTopUpParams { collateral_amount },
91-
}
92-
.data(),
93-
program_id: psyche_solana_treasurer::ID,
94-
};
95-
endpoint
96-
.process_instruction_with_signers(instruction, payer, &[authority])
97-
.await
98-
}
99-
10063
pub async fn process_treasurer_run_update(
10164
endpoint: &mut ToolboxEndpoint,
10265
payer: &Keypair,

architectures/decentralized/solana-tooling/tests/suites/memnet_coordinator_full_round.rs

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,17 @@ pub async fn run() {
165165
.unwrap();
166166

167167
// Whitelisted with the wrong account, can't join
168-
assert!(
169-
process_coordinator_join_run(
170-
&mut endpoint,
171-
&payer,
172-
&payer,
173-
&authorization,
174-
&coordinator_instance,
175-
&coordinator_account,
176-
client_id
177-
)
178-
.await
179-
.is_err()
180-
);
168+
process_coordinator_join_run(
169+
&mut endpoint,
170+
&payer,
171+
&payer,
172+
&authorization,
173+
&coordinator_instance,
174+
&coordinator_account,
175+
client_id,
176+
)
177+
.await
178+
.unwrap_err();
181179

182180
// Whitelisted, can join
183181
process_coordinator_join_run(
@@ -204,17 +202,15 @@ pub async fn run() {
204202
);
205203

206204
// Can't tick yet because paused
207-
assert!(
208-
process_coordinator_tick(
209-
&mut endpoint,
210-
&payer,
211-
&ticker,
212-
&coordinator_instance,
213-
&coordinator_account,
214-
)
215-
.await
216-
.is_err()
217-
);
205+
process_coordinator_tick(
206+
&mut endpoint,
207+
&payer,
208+
&ticker,
209+
&coordinator_instance,
210+
&coordinator_account,
211+
)
212+
.await
213+
.unwrap_err();
218214

219215
// Unpause
220216
process_coordinator_set_paused(
@@ -305,18 +301,16 @@ pub async fn run() {
305301
broadcast_merkle: Default::default(),
306302
metadata: Default::default(),
307303
};
308-
assert!(
309-
process_coordinator_witness(
310-
&mut endpoint,
311-
&payer,
312-
&ticker,
313-
&coordinator_instance,
314-
&coordinator_account,
315-
&witness,
316-
)
317-
.await
318-
.is_err()
319-
);
304+
process_coordinator_witness(
305+
&mut endpoint,
306+
&payer,
307+
&ticker,
308+
&coordinator_instance,
309+
&coordinator_account,
310+
&witness,
311+
)
312+
.await
313+
.unwrap_err();
320314
process_coordinator_witness(
321315
&mut endpoint,
322316
&payer,

0 commit comments

Comments
 (0)