Skip to content

Commit ab91cd4

Browse files
authored
fix(svm): L-09 close instruction_params account after execute_relayer_refund_leaf (#840)
* fix(svm): L-09 close instruction_params account after execute_relayer_refund_leaf Signed-off-by: Reinis Martinsons <reinis@umaproject.org> * test: instruction params account is closed Signed-off-by: Reinis Martinsons <reinis@umaproject.org> --------- Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
1 parent 580ef11 commit ab91cd4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

programs/svm-spoke/src/instructions/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct ExecuteRelayerRefundLeaf<'info> {
1818
#[account(mut)]
1919
pub signer: Signer<'info>,
2020

21-
#[account(seeds = [b"instruction_params", signer.key().as_ref()], bump)]
21+
#[account(mut, seeds = [b"instruction_params", signer.key().as_ref()], bump, close = signer)]
2222
pub instruction_params: Account<'info, ExecuteRelayerRefundLeafParams>, // Contains all leaf & proof information.
2323

2424
#[account(seeds = [b"state", state.seed.to_le_bytes().as_ref()], bump)]

test/svm/SvmSpoke.Bundle.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,23 @@ describe("svm_spoke.bundle", () => {
241241
program: program.programId,
242242
};
243243
const proofAsNumbers = proof.map((p) => Array.from(p));
244-
await loadExecuteRelayerRefundLeafParams(program, owner, stateAccountData.rootBundleId, leaf, proofAsNumbers);
244+
const instructionParams = await loadExecuteRelayerRefundLeafParams(
245+
program,
246+
owner,
247+
stateAccountData.rootBundleId,
248+
leaf,
249+
proofAsNumbers
250+
);
245251
const tx = await program.methods
246252
.executeRelayerRefundLeaf()
247253
.accounts(executeRelayerRefundLeafAccounts)
248254
.remainingAccounts(remainingAccounts)
249255
.rpc();
250256

257+
// Verify the instruction params account has been automatically closed.
258+
const instructionParamsInfo = await program.provider.connection.getAccountInfo(instructionParams);
259+
assert.isNull(instructionParamsInfo, "Instruction params account should be closed");
260+
251261
// Verify the ExecutedRelayerRefundRoot event
252262
let events = await readEventsUntilFound(connection, tx, [program]);
253263
let event = events.find((event) => event.name === "executedRelayerRefundRoot")?.data;

0 commit comments

Comments
 (0)