@lightprotocol/zk-compression-cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/accounts/address_merkle_tree_C83cpRN6oaafjNgMQJvaYgAz592EP5wunKvbokeTKPLn.json +1 -1
- package/accounts/address_merkle_tree_queue_HNjtNrjt6irUPYEgxhx2Vcs42koK9fxzm3aFLHVaaRWz.json +1 -1
- package/accounts/cpi_context_Bvux5m7rMGXJfjNCKUXHaRMcVJCiDe6iWu8ANj8kpwu5.json +1 -0
- package/accounts/governance_authority_pda_8KEKiyAMugpKq9XCGzx81UtTBuytByW8arm9EaBVpD5k.json +1 -0
- package/accounts/group_pda_5e3BWAnQAgpNdANLnMQp45MgUy7gQtZcwYkWv3MwgdZR.json +1 -0
- package/accounts/merkle_tree_pubkey_5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W.json +1 -1
- package/accounts/nullifier_queue_pubkey_44J4oDXpjPAbzHCSc24q7NEiPekss4sAbLd8ka4gd9CZ.json +1 -1
- package/accounts/registered_forester_epoch_pda_DFiGEbaz75wSdqy9bpeWacqLWrqAwWBfqh4iSYtejiwK.json +1 -0
- package/accounts/registered_program_pda_ApB3ASTFzS1RrccrB1cnNDPAAWrm1X4KSeNh2G3qSaxx.json +1 -0
- package/accounts/registered_registry_program_pda_CYAHAD4k1MExp219NfV9scN9GWzrMLhLpWqouwbvbVNo.json +1 -0
- package/bin/account_compression.so +0 -0
- package/bin/forester +0 -0
- package/bin/forester.toml +10 -0
- package/bin/light_compressed_token.so +0 -0
- package/bin/light_registry.so +0 -0
- package/bin/light_system_program.so +0 -0
- package/bin/prover-darwin-arm64 +0 -0
- package/bin/prover-darwin-x64 +0 -0
- package/bin/prover-linux-arm64 +0 -0
- package/bin/prover-linux-x64 +0 -0
- package/bin/prover-windows-arm64.exe +0 -0
- package/bin/prover-windows-x64.exe +0 -0
- package/dist/commands/approve-and-mint-to/index.js +1 -5
- package/dist/commands/balance/index.js +1 -5
- package/dist/commands/compress-sol/index.js +1 -4
- package/dist/commands/compress-spl/index.js +1 -5
- package/dist/commands/config/config.d.ts +2 -0
- package/dist/commands/config/config.js +34 -6
- package/dist/commands/create-mint/index.d.ts +2 -2
- package/dist/commands/create-mint/index.js +8 -12
- package/dist/commands/decompress-sol/index.js +1 -4
- package/dist/commands/decompress-spl/index.js +2 -6
- package/dist/commands/mint-to/index.js +1 -5
- package/dist/commands/register-mint/index.d.ts +0 -3
- package/dist/commands/register-mint/index.js +1 -16
- package/dist/commands/start-prover/index.d.ts +1 -0
- package/dist/commands/start-prover/index.js +6 -1
- package/dist/commands/test-validator/index.d.ts +6 -0
- package/dist/commands/test-validator/index.js +42 -5
- package/dist/commands/transfer/index.js +1 -5
- package/dist/utils/constants.d.ts +6 -1
- package/dist/utils/constants.js +7 -2
- package/dist/utils/initTestEnv.d.ts +17 -4
- package/dist/utils/initTestEnv.js +40 -19
- package/dist/utils/process.d.ts +1 -1
- package/dist/utils/process.js +11 -5
- package/dist/utils/processForester.d.ts +3 -0
- package/dist/utils/processForester.js +25 -0
- package/dist/utils/processPhotonIndexer.d.ts +1 -1
- package/dist/utils/processPhotonIndexer.js +10 -3
- package/dist/utils/processProverServer.d.ts +1 -1
- package/dist/utils/processProverServer.js +4 -3
- package/dist/utils/utils.d.ts +6 -0
- package/dist/utils/utils.js +20 -1
- package/oclif.manifest.json +190 -108
- package/package.json +27 -8
- package/accounts/governance_authority_pda_3MtrKu5Mjgh3JqeE5PeRzw2Ld28XjFgbbph67E6UERSx.json +0 -1
- package/accounts/group_pda_Edo2YjXU5eE17CejPBkupPgFLcYuAX47pGZmM7s2hAkj.json +0 -1
- package/accounts/registered_program_pda_ytwwVWhQUMoTKdirKmvEW5xCRVr4B2dJZnToiHtE2L2.json +0 -1
- package/bin/light_compressed_pda.so +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer, prover, proveCompressedAccounts, proveNewAddresses, checkPhotonVersion, photonDatabaseUrl, }: {
|
|
1
|
+
export declare function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer, prover, forester, rpcPort, indexerPort, proverPort, gossipHost, proveCompressedAccounts, proveNewAddresses, checkPhotonVersion, photonDatabaseUrl, limitLedgerSize, }: {
|
|
2
2
|
additionalPrograms?: {
|
|
3
3
|
address: string;
|
|
4
4
|
path: string;
|
|
@@ -6,12 +6,18 @@ export declare function initTestEnv({ additionalPrograms, skipSystemAccounts, in
|
|
|
6
6
|
skipSystemAccounts?: boolean;
|
|
7
7
|
indexer: boolean;
|
|
8
8
|
prover: boolean;
|
|
9
|
+
forester: boolean;
|
|
10
|
+
rpcPort?: number;
|
|
11
|
+
indexerPort?: number;
|
|
12
|
+
proverPort?: number;
|
|
13
|
+
gossipHost?: string;
|
|
9
14
|
proveCompressedAccounts?: boolean;
|
|
10
15
|
proveNewAddresses?: boolean;
|
|
11
16
|
checkPhotonVersion?: boolean;
|
|
12
17
|
photonDatabaseUrl?: string;
|
|
18
|
+
limitLedgerSize?: number;
|
|
13
19
|
}): Promise<void>;
|
|
14
|
-
export declare function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, indexer, prover, }?: {
|
|
20
|
+
export declare function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, indexer, prover, forester, }?: {
|
|
15
21
|
additionalPrograms?: {
|
|
16
22
|
address: string;
|
|
17
23
|
path: string;
|
|
@@ -19,20 +25,27 @@ export declare function initTestEnvIfNeeded({ additionalPrograms, skipSystemAcco
|
|
|
19
25
|
skipSystemAccounts?: boolean;
|
|
20
26
|
indexer?: boolean;
|
|
21
27
|
prover?: boolean;
|
|
28
|
+
forester?: boolean;
|
|
22
29
|
}): Promise<void>;
|
|
23
|
-
export declare function getSolanaArgs({ additionalPrograms, skipSystemAccounts, downloadBinaries, }: {
|
|
30
|
+
export declare function getSolanaArgs({ additionalPrograms, skipSystemAccounts, limitLedgerSize, rpcPort, gossipHost, downloadBinaries, }: {
|
|
24
31
|
additionalPrograms?: {
|
|
25
32
|
address: string;
|
|
26
33
|
path: string;
|
|
27
34
|
}[];
|
|
28
35
|
skipSystemAccounts?: boolean;
|
|
36
|
+
limitLedgerSize?: number;
|
|
37
|
+
rpcPort?: number;
|
|
38
|
+
gossipHost?: string;
|
|
29
39
|
downloadBinaries?: boolean;
|
|
30
40
|
}): Promise<Array<string>>;
|
|
31
|
-
export declare function startTestValidator({ additionalPrograms, skipSystemAccounts, }: {
|
|
41
|
+
export declare function startTestValidator({ additionalPrograms, skipSystemAccounts, limitLedgerSize, rpcPort, gossipHost, }: {
|
|
32
42
|
additionalPrograms?: {
|
|
33
43
|
address: string;
|
|
34
44
|
path: string;
|
|
35
45
|
}[];
|
|
36
46
|
skipSystemAccounts?: boolean;
|
|
47
|
+
limitLedgerSize?: number;
|
|
48
|
+
rpcPort?: number;
|
|
49
|
+
gossipHost?: string;
|
|
37
50
|
}): Promise<void>;
|
|
38
51
|
export declare function killTestValidator(): Promise<void>;
|
|
@@ -10,7 +10,8 @@ const psp_utils_1 = require("../psp-utils");
|
|
|
10
10
|
const process_1 = require("./process");
|
|
11
11
|
const processProverServer_1 = require("./processProverServer");
|
|
12
12
|
const processPhotonIndexer_1 = require("./processPhotonIndexer");
|
|
13
|
-
|
|
13
|
+
const processForester_1 = require("./processForester");
|
|
14
|
+
async function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer = true, prover = true, forester = true, rpcPort = 8899, indexerPort = 8784, proverPort = 3001, gossipHost = "127.0.0.1", proveCompressedAccounts = true, proveNewAddresses = false, checkPhotonVersion = true, photonDatabaseUrl, limitLedgerSize, }) {
|
|
14
15
|
console.log("Performing setup tasks...\n");
|
|
15
16
|
const initAccounts = async () => {
|
|
16
17
|
const anchorProvider = await (0, utils_1.setAnchorProvider)();
|
|
@@ -22,19 +23,34 @@ async function initTestEnv({ additionalPrograms, skipSystemAccounts, indexer = t
|
|
|
22
23
|
});
|
|
23
24
|
};
|
|
24
25
|
// We cannot await this promise directly because it will hang the process
|
|
25
|
-
startTestValidator({
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
startTestValidator({
|
|
27
|
+
additionalPrograms,
|
|
28
|
+
skipSystemAccounts,
|
|
29
|
+
limitLedgerSize,
|
|
30
|
+
rpcPort,
|
|
31
|
+
gossipHost,
|
|
32
|
+
});
|
|
33
|
+
await (0, process_1.waitForServers)([{ port: rpcPort, path: "/health" }]);
|
|
34
|
+
await (0, process_1.confirmServerStability)(`http://127.0.0.1:${rpcPort}/health`);
|
|
28
35
|
await initAccounts();
|
|
29
36
|
if (indexer) {
|
|
30
|
-
|
|
37
|
+
const config = (0, utils_1.getConfig)();
|
|
38
|
+
config.indexerUrl = `http://127.0.0.1:${indexerPort}`;
|
|
39
|
+
(0, utils_1.setConfig)(config);
|
|
40
|
+
await (0, processPhotonIndexer_1.startIndexer)(`http://127.0.0.1:${rpcPort}`, indexerPort, checkPhotonVersion, photonDatabaseUrl);
|
|
31
41
|
}
|
|
32
42
|
if (prover) {
|
|
33
|
-
|
|
43
|
+
const config = (0, utils_1.getConfig)();
|
|
44
|
+
config.proverUrl = `http://127.0.0.1:${proverPort}`;
|
|
45
|
+
(0, utils_1.setConfig)(config);
|
|
46
|
+
await (0, processProverServer_1.startProver)(proverPort, proveCompressedAccounts, proveNewAddresses);
|
|
47
|
+
}
|
|
48
|
+
if (forester) {
|
|
49
|
+
await (0, processForester_1.startForester)();
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
exports.initTestEnv = initTestEnv;
|
|
37
|
-
async function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, indexer = false, prover = false, } = {}) {
|
|
53
|
+
async function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, indexer = false, prover = false, forester = false, } = {}) {
|
|
38
54
|
try {
|
|
39
55
|
const anchorProvider = await (0, utils_1.setAnchorProvider)();
|
|
40
56
|
// this request will fail if there is no local test validator running
|
|
@@ -48,6 +64,7 @@ async function initTestEnvIfNeeded({ additionalPrograms, skipSystemAccounts, ind
|
|
|
48
64
|
skipSystemAccounts,
|
|
49
65
|
indexer,
|
|
50
66
|
prover,
|
|
67
|
+
forester,
|
|
51
68
|
});
|
|
52
69
|
}
|
|
53
70
|
}
|
|
@@ -83,8 +100,7 @@ function programFilePath(programName) {
|
|
|
83
100
|
}
|
|
84
101
|
return path_1.default.resolve(__dirname, path_1.default.join(constants_1.BASE_PATH, programName));
|
|
85
102
|
}
|
|
86
|
-
async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, downloadBinaries = true, }) {
|
|
87
|
-
const LIMIT_LEDGER_SIZE = "500000000";
|
|
103
|
+
async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, limitLedgerSize, rpcPort, gossipHost, downloadBinaries = true, }) {
|
|
88
104
|
// TODO: adjust program tags
|
|
89
105
|
const programs = [
|
|
90
106
|
{
|
|
@@ -93,24 +109,24 @@ async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, downloadB
|
|
|
93
109
|
tag: constants_1.SPL_NOOP_PROGRAM_TAG,
|
|
94
110
|
},
|
|
95
111
|
{
|
|
96
|
-
id: "
|
|
112
|
+
id: "H5sFv8VwWmjxHYS2GB4fTDsK7uTtnRT4WiixtHrET3bN",
|
|
97
113
|
name: "light_system_program.so",
|
|
98
|
-
tag: constants_1.
|
|
114
|
+
tag: constants_1.LIGHT_SYSTEM_PROGRAM_TAG,
|
|
99
115
|
},
|
|
100
116
|
{
|
|
101
|
-
id: "
|
|
117
|
+
id: "HXVfQ44ATEi9WBKLSCCwM54KokdkzqXci9xCQ7ST9SYN",
|
|
102
118
|
name: "light_compressed_token.so",
|
|
103
|
-
tag: constants_1.
|
|
119
|
+
tag: constants_1.LIGHT_COMPRESSED_TOKEN_TAG,
|
|
104
120
|
},
|
|
105
121
|
{
|
|
106
|
-
id: "
|
|
122
|
+
id: "CbjvJc1SNx1aav8tU49dJGHu8EUdzQJSMtkjDmV8miqK",
|
|
107
123
|
name: "account_compression.so",
|
|
108
|
-
tag: constants_1.
|
|
124
|
+
tag: constants_1.LIGHT_ACCOUNT_COMPRESSION_TAG,
|
|
109
125
|
},
|
|
110
126
|
{
|
|
111
|
-
id: "
|
|
127
|
+
id: "7Z9Yuy3HkBCc2Wf3xzMGnz6qpV4n7ciwcoEMGKqhAnj1",
|
|
112
128
|
name: "light_registry.so",
|
|
113
|
-
tag: constants_1.
|
|
129
|
+
tag: constants_1.LIGHT_REGISTRY_TAG,
|
|
114
130
|
},
|
|
115
131
|
];
|
|
116
132
|
if (additionalPrograms)
|
|
@@ -120,7 +136,9 @@ async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, downloadB
|
|
|
120
136
|
const dirPath = programsDirPath();
|
|
121
137
|
const solanaArgs = [
|
|
122
138
|
"--reset",
|
|
123
|
-
`--limit-ledger-size=${
|
|
139
|
+
`--limit-ledger-size=${limitLedgerSize}`,
|
|
140
|
+
`--rpc-port=${rpcPort}`,
|
|
141
|
+
`--gossip-host=${gossipHost}`,
|
|
124
142
|
"--quiet",
|
|
125
143
|
];
|
|
126
144
|
for (const program of programs) {
|
|
@@ -150,11 +168,14 @@ async function getSolanaArgs({ additionalPrograms, skipSystemAccounts, downloadB
|
|
|
150
168
|
return solanaArgs;
|
|
151
169
|
}
|
|
152
170
|
exports.getSolanaArgs = getSolanaArgs;
|
|
153
|
-
async function startTestValidator({ additionalPrograms, skipSystemAccounts, }) {
|
|
171
|
+
async function startTestValidator({ additionalPrograms, skipSystemAccounts, limitLedgerSize, rpcPort, gossipHost, }) {
|
|
154
172
|
const command = "solana-test-validator";
|
|
155
173
|
const solanaArgs = await getSolanaArgs({
|
|
156
174
|
additionalPrograms,
|
|
157
175
|
skipSystemAccounts,
|
|
176
|
+
limitLedgerSize,
|
|
177
|
+
rpcPort,
|
|
178
|
+
gossipHost,
|
|
158
179
|
});
|
|
159
180
|
await killTestValidator();
|
|
160
181
|
await new Promise((r) => setTimeout(r, 1000));
|
package/dist/utils/process.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function killProcess(processName: string): Promise<void>;
|
|
2
|
-
export declare function killProcessByPort(port:
|
|
2
|
+
export declare function killProcessByPort(port: number): Promise<void>;
|
|
3
3
|
/**
|
|
4
4
|
* Executes a command and logs the output to the console.
|
|
5
5
|
* @param command - Path to the command to be executed.
|
package/dist/utils/process.js
CHANGED
|
@@ -19,7 +19,7 @@ async function killProcess(processName) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.killProcess = killProcess;
|
|
21
21
|
async function killProcessByPort(port) {
|
|
22
|
-
await execute(
|
|
22
|
+
await execute(`lsof -t -i:${port} | while read line; do kill -9 $line; done`);
|
|
23
23
|
}
|
|
24
24
|
exports.killProcessByPort = killProcessByPort;
|
|
25
25
|
/**
|
|
@@ -40,17 +40,16 @@ async function executeCommand({ command, args, additionalPath, logFile = true, }
|
|
|
40
40
|
env: childPathEnv ? { ...process.env, PATH: childPathEnv } : process.env,
|
|
41
41
|
detached: true,
|
|
42
42
|
};
|
|
43
|
+
let logStream = null;
|
|
43
44
|
if (logFile) {
|
|
44
45
|
const folderName = "test-ledger";
|
|
45
46
|
const file = `./${folderName}/${commandBase}.log`;
|
|
46
47
|
if (!fs_1.default.existsSync(folderName)) {
|
|
47
48
|
fs_1.default.mkdirSync(folderName);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
logStream = fs_1.default.createWriteStream(file, {
|
|
50
51
|
flags: "a",
|
|
51
52
|
});
|
|
52
|
-
process.stdout.pipe(logStream);
|
|
53
|
-
process.stderr.pipe(logStream);
|
|
54
53
|
}
|
|
55
54
|
console.log(`Executing command ${commandBase} ${args}...`);
|
|
56
55
|
let childProcess;
|
|
@@ -60,6 +59,10 @@ async function executeCommand({ command, args, additionalPath, logFile = true, }
|
|
|
60
59
|
catch (e) {
|
|
61
60
|
throw new Error(`Failed to execute command ${commandBase}: ${e}`);
|
|
62
61
|
}
|
|
62
|
+
if (logStream) {
|
|
63
|
+
childProcess.stdout.pipe(logStream);
|
|
64
|
+
childProcess.stderr.pipe(logStream);
|
|
65
|
+
}
|
|
63
66
|
childProcess.stdout.on("data", (data) => {
|
|
64
67
|
stdoutData += data.toString();
|
|
65
68
|
process.stdout.write(data);
|
|
@@ -68,6 +71,9 @@ async function executeCommand({ command, args, additionalPath, logFile = true, }
|
|
|
68
71
|
process.stderr.write(data);
|
|
69
72
|
});
|
|
70
73
|
childProcess.on("close", (code) => {
|
|
74
|
+
if (logStream) {
|
|
75
|
+
logStream.end();
|
|
76
|
+
}
|
|
71
77
|
if (code !== 0) {
|
|
72
78
|
console.log(`${commandBase} exited with code ${code}`);
|
|
73
79
|
reject(new Error(`${commandBase} exited with code ${code}`));
|
|
@@ -123,7 +129,7 @@ async function waitForServers(servers) {
|
|
|
123
129
|
const opts = {
|
|
124
130
|
resources: servers.map(({ port, path }) => `http-get://127.0.0.1:${port}${path}`),
|
|
125
131
|
delay: 1000,
|
|
126
|
-
timeout:
|
|
132
|
+
timeout: 25000,
|
|
127
133
|
interval: 300,
|
|
128
134
|
simultaneous: 2,
|
|
129
135
|
validateStatus: function (status) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getForesterBinaryName = exports.startForester = exports.killForester = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const process_1 = require("./process");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
async function killForester() {
|
|
9
|
+
await (0, process_1.killProcess)(constants_1.FORESTER_PROCESS_NAME);
|
|
10
|
+
}
|
|
11
|
+
exports.killForester = killForester;
|
|
12
|
+
async function startForester() {
|
|
13
|
+
console.log("Killing existing forester process...");
|
|
14
|
+
await killForester();
|
|
15
|
+
console.log("Starting forester...");
|
|
16
|
+
(0, process_1.spawnBinary)(getForesterBinaryName(), ["subscribe"]);
|
|
17
|
+
console.log("Forester started successfully!");
|
|
18
|
+
}
|
|
19
|
+
exports.startForester = startForester;
|
|
20
|
+
function getForesterBinaryName() {
|
|
21
|
+
const binDir = path_1.default.join(__dirname, "../..", "bin");
|
|
22
|
+
const binaryName = path_1.default.join(binDir, "forester");
|
|
23
|
+
return binaryName;
|
|
24
|
+
}
|
|
25
|
+
exports.getForesterBinaryName = getForesterBinaryName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function startIndexer(checkPhotonVersion?: boolean, photonDatabaseUrl?: string): Promise<void>;
|
|
1
|
+
export declare function startIndexer(rpcUrl: string, indexerPort: number, checkPhotonVersion?: boolean, photonDatabaseUrl?: string): Promise<void>;
|
|
@@ -7,7 +7,7 @@ const process_1 = require("./process");
|
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
8
|
const node_child_process_1 = require("node:child_process");
|
|
9
9
|
const util = tslib_1.__importStar(require("node:util"));
|
|
10
|
-
async function startIndexer(checkPhotonVersion = true, photonDatabaseUrl) {
|
|
10
|
+
async function startIndexer(rpcUrl, indexerPort, checkPhotonVersion = true, photonDatabaseUrl) {
|
|
11
11
|
await killIndexer();
|
|
12
12
|
const resolvedOrNull = which_1.default.sync("photon", { nothrow: true });
|
|
13
13
|
if (resolvedOrNull === null ||
|
|
@@ -20,10 +20,17 @@ async function startIndexer(checkPhotonVersion = true, photonDatabaseUrl) {
|
|
|
20
20
|
console.log("Starting indexer...");
|
|
21
21
|
let args = [];
|
|
22
22
|
if (photonDatabaseUrl) {
|
|
23
|
-
args = [
|
|
23
|
+
args = [
|
|
24
|
+
"--db-url",
|
|
25
|
+
photonDatabaseUrl,
|
|
26
|
+
"--port",
|
|
27
|
+
indexerPort.toString(),
|
|
28
|
+
"--rpc-url",
|
|
29
|
+
rpcUrl,
|
|
30
|
+
];
|
|
24
31
|
}
|
|
25
32
|
(0, process_1.spawnBinary)(constants_1.INDEXER_PROCESS_NAME, args);
|
|
26
|
-
await (0, process_1.waitForServers)([{ port:
|
|
33
|
+
await (0, process_1.waitForServers)([{ port: indexerPort, path: "/getIndexerHealth" }]);
|
|
27
34
|
console.log("Indexer started successfully!");
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function killProver(): Promise<void>;
|
|
2
|
-
export declare function startProver(proveCompressedAccounts: boolean, proveNewAddresses: boolean): Promise<void>;
|
|
2
|
+
export declare function startProver(proverPort: number, proveCompressedAccounts: boolean, proveNewAddresses: boolean): Promise<void>;
|
|
3
3
|
export declare function getProverNameByArch(): string;
|
|
@@ -12,22 +12,23 @@ async function killProver() {
|
|
|
12
12
|
await (0, process_1.killProcess)(constants_1.LIGHT_PROVER_PROCESS_NAME);
|
|
13
13
|
}
|
|
14
14
|
exports.killProver = killProver;
|
|
15
|
-
async function startProver(proveCompressedAccounts, proveNewAddresses) {
|
|
15
|
+
async function startProver(proverPort, proveCompressedAccounts, proveNewAddresses) {
|
|
16
16
|
if (!proveCompressedAccounts && !proveNewAddresses) {
|
|
17
17
|
console.log("No flags provided. Please provide at least one flag to start the prover.");
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
20
|
console.log("Kill existing prover process...");
|
|
21
21
|
await killProver();
|
|
22
|
-
await (0, process_1.killProcessByPort)(
|
|
22
|
+
await (0, process_1.killProcessByPort)(proverPort);
|
|
23
23
|
const keysDir = path_1.default.join(__dirname, "../..", "bin", KEYS_DIR);
|
|
24
24
|
const args = ["start"];
|
|
25
25
|
args.push(`--inclusion=${proveCompressedAccounts ? "true" : "false"}`);
|
|
26
26
|
args.push(`--non-inclusion=${proveNewAddresses ? "true" : "false"}`);
|
|
27
27
|
args.push("--keys-dir", keysDir);
|
|
28
|
+
args.push("--prover-address", `0.0.0.0:${proverPort}`);
|
|
28
29
|
console.log("Starting prover...");
|
|
29
30
|
(0, process_1.spawnBinary)(getProverNameByArch(), args);
|
|
30
|
-
await (0, process_1.waitForServers)([{ port:
|
|
31
|
+
await (0, process_1.waitForServers)([{ port: proverPort, path: "/" }]);
|
|
31
32
|
console.log("Prover started successfully!");
|
|
32
33
|
}
|
|
33
34
|
exports.startProver = startProver;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import * as anchor from "@coral-xyz/anchor";
|
|
2
2
|
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
import { Rpc } from "@lightprotocol/stateless.js";
|
|
3
4
|
export declare const defaultSolanaWalletKeypair: () => Keypair;
|
|
4
5
|
export declare const setAnchorProvider: () => Promise<anchor.AnchorProvider>;
|
|
6
|
+
export declare function rpc(): Rpc;
|
|
5
7
|
export declare function getPayer(): Promise<anchor.web3.Keypair>;
|
|
6
8
|
export declare function generateSolanaTransactionURL(transactionType: "tx" | "address", transactionHash: string, cluster: string): string;
|
|
7
9
|
type Config = {
|
|
8
10
|
solanaRpcUrl: string;
|
|
11
|
+
indexerUrl: string;
|
|
12
|
+
proverUrl: string;
|
|
9
13
|
};
|
|
10
14
|
export declare const getSolanaRpcUrl: () => string;
|
|
15
|
+
export declare const getIndexerUrl: () => string;
|
|
16
|
+
export declare const getProverUrl: () => string;
|
|
11
17
|
export declare const getConfig: (filePath?: string) => Config;
|
|
12
18
|
export declare function ensureDirectoryExists(dirPath: string): void;
|
|
13
19
|
export declare const setConfig: (config: Partial<Config>, filePath?: string) => void;
|
package/dist/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidBase58SecretKey = exports.isValidURL = exports.CustomLoader = exports.setConfig = exports.ensureDirectoryExists = exports.getConfig = exports.getSolanaRpcUrl = exports.generateSolanaTransactionURL = exports.getPayer = exports.setAnchorProvider = exports.defaultSolanaWalletKeypair = void 0;
|
|
3
|
+
exports.isValidBase58SecretKey = exports.isValidURL = exports.CustomLoader = exports.setConfig = exports.ensureDirectoryExists = exports.getConfig = exports.getProverUrl = exports.getIndexerUrl = exports.getSolanaRpcUrl = exports.generateSolanaTransactionURL = exports.getPayer = exports.rpc = exports.setAnchorProvider = exports.defaultSolanaWalletKeypair = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const fs_1 = require("fs");
|
|
@@ -34,6 +34,15 @@ const setAnchorProvider = async () => {
|
|
|
34
34
|
return anchorProvider;
|
|
35
35
|
};
|
|
36
36
|
exports.setAnchorProvider = setAnchorProvider;
|
|
37
|
+
function rpc() {
|
|
38
|
+
if ((0, exports.getSolanaRpcUrl)() === "" ||
|
|
39
|
+
(0, exports.getIndexerUrl)() === "" ||
|
|
40
|
+
(0, exports.getProverUrl)() === "") {
|
|
41
|
+
throw new Error("Please set the Solana RPC URL, Indexer URL, and Prover URL in the config file");
|
|
42
|
+
}
|
|
43
|
+
return (0, stateless_js_1.createRpc)((0, exports.getSolanaRpcUrl)(), (0, exports.getIndexerUrl)(), (0, exports.getProverUrl)());
|
|
44
|
+
}
|
|
45
|
+
exports.rpc = rpc;
|
|
37
46
|
function getWalletPath() {
|
|
38
47
|
return process.env.HOME + "/.config/solana/id.json";
|
|
39
48
|
}
|
|
@@ -50,6 +59,16 @@ const getSolanaRpcUrl = () => {
|
|
|
50
59
|
return config.solanaRpcUrl;
|
|
51
60
|
};
|
|
52
61
|
exports.getSolanaRpcUrl = getSolanaRpcUrl;
|
|
62
|
+
const getIndexerUrl = () => {
|
|
63
|
+
const config = (0, exports.getConfig)();
|
|
64
|
+
return config.indexerUrl;
|
|
65
|
+
};
|
|
66
|
+
exports.getIndexerUrl = getIndexerUrl;
|
|
67
|
+
const getProverUrl = () => {
|
|
68
|
+
const config = (0, exports.getConfig)();
|
|
69
|
+
return config.proverUrl;
|
|
70
|
+
};
|
|
71
|
+
exports.getProverUrl = getProverUrl;
|
|
53
72
|
function getConfigPath() {
|
|
54
73
|
// Check for the environment variable
|
|
55
74
|
const envConfigPath = process.env.LIGHT_PROTOCOL_CONFIG;
|