Skip to content

Commit 3bb9b00

Browse files
authored
Update chopsticks to version 0.16.1 and fix issue when detecting port on running process (#432)
* Update chopsticks to version 0.16.1 and fix issue when detecting port on running process * use old chopsticks behaviour by default * fix chopsticks tests
1 parent a2914ad commit 3bb9b00

File tree

10 files changed

+4526
-6485
lines changed

10 files changed

+4526
-6485
lines changed

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"prepublish": "pnpm run build && pnpm run generate-types"
5959
},
6060
"dependencies": {
61-
"@acala-network/chopsticks": "0.15.0",
61+
"@acala-network/chopsticks": "0.16.1",
6262
"@moonbeam-network/api-augment": "0.2902.0",
6363
"@moonwall/types": "workspace:*",
6464
"@moonwall/util": "workspace:*",
@@ -71,7 +71,7 @@
7171
"@polkadot/util": "13.1.1",
7272
"@polkadot/util-crypto": "13.1.1",
7373
"@vitest/ui": "2.1.1",
74-
"@zombienet/orchestrator": "0.0.87",
74+
"@zombienet/orchestrator": "0.0.91",
7575
"@zombienet/utils": "0.0.25",
7676
"bottleneck": "2.19.5",
7777
"cfonts": "^3.3.0",
@@ -97,7 +97,7 @@
9797
"yargs": "17.7.2"
9898
},
9999
"peerDependencies": {
100-
"@acala-network/chopsticks": "^0.15.0",
100+
"@acala-network/chopsticks": "^0.16.1",
101101
"@polkadot/api": "^10.11.2",
102102
"@vitest/ui": "^1.2.2",
103103
"vitest": "^2.1.1"

packages/cli/src/internal/commandParsers.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function parseChopsticksRunCmd(launchSpecs: ChopsticksLaunchSpec[]): {
8686
const chopsticksArgs = [
8787
"node_modules/@acala-network/chopsticks/chopsticks.cjs",
8888
`--config=${launchSpecs[0].configPath}`,
89+
`--addr=${launchSpecs[0].address ?? "127.0.0.1"}`, // use old behaviour by default
8990
];
9091

9192
const mode = launchSpecs[0].buildBlockMode ? launchSpecs[0].buildBlockMode : "manual";
@@ -124,16 +125,6 @@ export function parseChopsticksRunCmd(launchSpecs: ChopsticksLaunchSpec[]): {
124125
chopsticksArgs.push(`--relaychain=${spec.configPath}`);
125126
}
126127
}
127-
// launchSpecs.forEach((spec) => {
128-
// const type = spec.type ? spec.type : "parachain";
129-
// switch (type) {
130-
// case "parachain":
131-
// chopsticksArgs.push(`--parachain=${spec.configPath}`);
132-
// break;
133-
// case "relaychain":
134-
// chopsticksArgs.push(`--relaychain=${spec.configPath}`);
135-
// }
136-
// });
137128

138129
return {
139130
cmd: chopsticksCmd,

packages/cli/src/internal/localNode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,14 @@ async function checkWebSocketJSONRPC(port: number): Promise<boolean> {
165165
async function findPortsByPid(pid: number, retryCount = 600, retryDelay = 100): Promise<number[]> {
166166
for (let i = 0; i < retryCount; i++) {
167167
try {
168-
const { stdout } = await execAsync(`lsof -i -n -P | grep LISTEN | grep ${pid}`);
168+
const { stdout } = await execAsync(`lsof -p ${pid} -n -P | grep LISTEN`);
169169
const ports: number[] = [];
170170
const lines = stdout.split("\n");
171171
for (const line of lines) {
172-
const regex = /(?:\*|127\.0\.0\.1):(\d+)/;
172+
// Example outputs:
173+
// - lsof node 97796 romarq 26u IPv6 0xb6c3e894a2247189 0t0 TCP *:8000 (LISTEN)
174+
// - lsof node 97242 romarq 26u IPv6 0x330c461cca8d2b63 0t0 TCP [::1]:8000 (LISTEN)
175+
const regex = /(?:.+):(\d+)/;
173176
const match = line.match(regex);
174177
if (match) {
175178
ports.push(Number(match[1]));
@@ -179,6 +182,7 @@ async function findPortsByPid(pid: number, retryCount = 600, retryDelay = 100):
179182
if (ports.length) {
180183
return ports;
181184
}
185+
throw new Error("Could not find any ports");
182186
} catch (error) {
183187
if (i === retryCount - 1) {
184188
throw error;

packages/types/config_schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"ChopsticksLaunchSpec": {
1414
"description": "A launch specification object for the \"chopsticks\" foundation type.",
1515
"properties": {
16+
"address": {
17+
"description": "Server listening interface\nAdded in: https://github.com/AcalaNetwork/chopsticks/pull/826",
18+
"type": "string"
19+
},
1620
"allowUnresolvedImports": {
1721
"description": "An optional flag to NOT throw when the host fails to export a function expected by the runtime.",
1822
"type": "boolean"

packages/types/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@polkadot/api": "13.2.1",
5757
"@polkadot/api-base": "13.2.1",
5858
"@polkadot/keyring": "13.1.1",
59+
"@polkadot/util-crypto": "13.1.1",
5960
"@polkadot/types": "13.2.1",
6061
"@polkadot/util": "13.1.1",
6162
"@types/node": "20.14.10",

packages/types/src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ export interface ChopsticksLaunchSpec extends GenericLaunchSpec {
314314
* An optional flag to retain node logs from previous runs.
315315
*/
316316
retainAllLogs?: boolean;
317+
318+
/**
319+
* Server listening interface
320+
* Added in: https://github.com/AcalaNetwork/chopsticks/pull/826
321+
*/
322+
address?: string;
317323
}
318324

319325
/**

packages/util/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@polkadot/api": "13.2.1",
5959
"@polkadot/api-derive": "13.2.1",
6060
"@polkadot/keyring": "13.1.1",
61+
"@polkadot/util-crypto": "13.1.1",
6162
"@polkadot/rpc-provider": "13.2.1",
6263
"@polkadot/types": "13.2.1",
6364
"@polkadot/types-codec": "13.2.1",

0 commit comments

Comments
 (0)