Skip to content

Commit e705f24

Browse files
feat: add support for additional account directories in setup command and related functions
1 parent 6b32ace commit e705f24

5 files changed

Lines changed: 417 additions & 19 deletions

File tree

cli/src/commands/test-validator/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class SetupCommand extends Command {
163163
default: true,
164164
allowNo: true,
165165
}),
166+
"account-dir": Flags.string({
167+
description:
168+
"Additional directory containing account JSON files to preload. Can be specified multiple times.",
169+
required: false,
170+
multiple: true,
171+
summary: "Usage: --account-dir <path/to/accounts/>",
172+
}),
166173
};
167174

168175
validatePrograms(
@@ -299,6 +306,7 @@ class SetupCommand extends Command {
299306
verbose: flags.verbose,
300307
skipReset: flags["skip-reset"],
301308
useSurfpool: flags["use-surfpool"],
309+
additionalAccountDirs: flags["account-dir"],
302310
});
303311
this.log("\nSetup tasks completed successfully \x1b[32m✔\x1b[0m");
304312
}

cli/src/utils/initTestEnv.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export async function initTestEnv({
158158
skipReset,
159159
useSurfpool,
160160
compressiblePdaPrograms,
161+
additionalAccountDirs,
161162
}: {
162163
additionalPrograms?: { address: string; path: string }[];
163164
upgradeablePrograms?: {
@@ -184,6 +185,7 @@ export async function initTestEnv({
184185
skipReset?: boolean;
185186
useSurfpool?: boolean;
186187
compressiblePdaPrograms?: string[];
188+
additionalAccountDirs?: string[];
187189
}) {
188190
if (useSurfpool) {
189191
// For surfpool we can await startTestValidator because spawnBinary returns
@@ -202,6 +204,7 @@ export async function initTestEnv({
202204
verbose,
203205
skipReset,
204206
useSurfpool,
207+
additionalAccountDirs,
205208
});
206209
// Surfpool only supports JSON-RPC POST, not GET /health.
207210
await confirmRpcReadiness(`http://127.0.0.1:${rpcPort}`);
@@ -220,6 +223,7 @@ export async function initTestEnv({
220223
verbose,
221224
skipReset,
222225
useSurfpool,
226+
additionalAccountDirs,
223227
});
224228
await waitForServers([{ port: rpcPort, path: "/health" }]);
225229
await confirmServerStability(`http://127.0.0.1:${rpcPort}/health`);
@@ -503,6 +507,7 @@ export async function getSurfpoolArgs({
503507
rpcPort,
504508
gossipHost,
505509
downloadBinaries = true,
510+
additionalAccountDirs,
506511
}: {
507512
additionalPrograms?: { address: string; path: string }[];
508513
upgradeablePrograms?: {
@@ -514,6 +519,7 @@ export async function getSurfpoolArgs({
514519
rpcPort?: number;
515520
gossipHost?: string;
516521
downloadBinaries?: boolean;
522+
additionalAccountDirs?: string[];
517523
}): Promise<Array<string>> {
518524
const dirPath = programsDirPath();
519525

@@ -563,6 +569,13 @@ export async function getSurfpoolArgs({
563569
args.push("--account-dir", accountsPath);
564570
}
565571

572+
// Load additional account directories
573+
if (additionalAccountDirs) {
574+
for (const accountDir of additionalAccountDirs) {
575+
args.push("--account-dir", path.resolve(accountDir));
576+
}
577+
}
578+
566579
return args;
567580
}
568581

@@ -658,6 +671,7 @@ export async function startTestValidator({
658671
verbose,
659672
skipReset,
660673
useSurfpool,
674+
additionalAccountDirs,
661675
}: {
662676
additionalPrograms?: { address: string; path: string }[];
663677
upgradeablePrograms?: {
@@ -675,6 +689,7 @@ export async function startTestValidator({
675689
verbose?: boolean;
676690
skipReset?: boolean;
677691
useSurfpool?: boolean;
692+
additionalAccountDirs?: string[];
678693
}) {
679694
if (useSurfpool) {
680695
const command = await ensureSurfpoolBinary();
@@ -684,6 +699,7 @@ export async function startTestValidator({
684699
skipSystemAccounts,
685700
rpcPort,
686701
gossipHost,
702+
additionalAccountDirs,
687703
});
688704

689705
await killTestValidator(rpcPort);

forester/src/compressible/pda/compressor.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,6 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
105105
)
106106
})?;
107107

108-
/*
109-
// Verify PDA derivation matches (mirrors LightConfig::load_checked)
110-
let (expected_pda, _) = LightConfig::derive_pda(program_id, config.config_bump);
111-
if expected_pda != config_pda {
112-
return Err(anyhow::anyhow!(
113-
"Config PDA derivation mismatch. Expected: {}. Found: {}",
114-
expected_pda,
115-
config_pda
116-
));
117-
}
118-
*/
119108
let rent_sponsor = config.rent_sponsor;
120109
let compression_authority = config.compression_authority;
121110
let address_tree = *config

program-libs/compressed-account/src/constants.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ pub const ACCOUNT_COMPRESSION_PROGRAM_ID: [u8; 32] =
66
/// ID of the light-system program.
77
pub const LIGHT_SYSTEM_PROGRAM_ID: [u8; 32] =
88
pubkey_array!("SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7");
9+
/// ID of the light-registry program.
10+
pub const LIGHT_REGISTRY_PROGRAM_ID: [u8; 32] =
11+
pubkey_array!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX");
912
#[deprecated(since = "0.9.0", note = "Use LIGHT_SYSTEM_PROGRAM_ID instead")]
1013
pub const SYSTEM_PROGRAM_ID: [u8; 32] = LIGHT_SYSTEM_PROGRAM_ID;
1114
pub const REGISTERED_PROGRAM_PDA: [u8; 32] =

0 commit comments

Comments
 (0)