Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chopsticks to version 0.16.1 and fix issue when detecting port on running process #432

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"prepublish": "pnpm run build && pnpm run generate-types"
},
"dependencies": {
"@acala-network/chopsticks": "0.15.0",
"@acala-network/chopsticks": "0.16.1",
"@moonbeam-network/api-augment": "0.2902.0",
"@moonwall/types": "workspace:*",
"@moonwall/util": "workspace:*",
Expand All @@ -71,7 +71,7 @@
"@polkadot/util": "13.1.1",
"@polkadot/util-crypto": "13.1.1",
"@vitest/ui": "2.1.1",
"@zombienet/orchestrator": "0.0.87",
"@zombienet/orchestrator": "0.0.91",
"@zombienet/utils": "0.0.25",
"bottleneck": "2.19.5",
"cfonts": "^3.3.0",
Expand All @@ -97,7 +97,7 @@
"yargs": "17.7.2"
},
"peerDependencies": {
"@acala-network/chopsticks": "^0.15.0",
"@acala-network/chopsticks": "^0.16.1",
"@polkadot/api": "^10.11.2",
"@vitest/ui": "^1.2.2",
"vitest": "^2.1.1"
Expand Down
11 changes: 1 addition & 10 deletions packages/cli/src/internal/commandParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function parseChopsticksRunCmd(launchSpecs: ChopsticksLaunchSpec[]): {
const chopsticksArgs = [
"node_modules/@acala-network/chopsticks/chopsticks.cjs",
`--config=${launchSpecs[0].configPath}`,
`--addr=${launchSpecs[0].address ?? "127.0.0.1"}`, // use old behaviour by default
];

const mode = launchSpecs[0].buildBlockMode ? launchSpecs[0].buildBlockMode : "manual";
Expand Down Expand Up @@ -124,16 +125,6 @@ export function parseChopsticksRunCmd(launchSpecs: ChopsticksLaunchSpec[]): {
chopsticksArgs.push(`--relaychain=${spec.configPath}`);
}
}
// launchSpecs.forEach((spec) => {
// const type = spec.type ? spec.type : "parachain";
// switch (type) {
// case "parachain":
// chopsticksArgs.push(`--parachain=${spec.configPath}`);
// break;
// case "relaychain":
// chopsticksArgs.push(`--relaychain=${spec.configPath}`);
// }
// });

return {
cmd: chopsticksCmd,
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/internal/localNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,14 @@ async function checkWebSocketJSONRPC(port: number): Promise<boolean> {
async function findPortsByPid(pid: number, retryCount = 600, retryDelay = 100): Promise<number[]> {
for (let i = 0; i < retryCount; i++) {
try {
const { stdout } = await execAsync(`lsof -i -n -P | grep LISTEN | grep ${pid}`);
const { stdout } = await execAsync(`lsof -p ${pid} -n -P | grep LISTEN`);
const ports: number[] = [];
const lines = stdout.split("\n");
for (const line of lines) {
const regex = /(?:\*|127\.0\.0\.1):(\d+)/;
// Example outputs:
// - lsof node 97796 romarq 26u IPv6 0xb6c3e894a2247189 0t0 TCP *:8000 (LISTEN)
// - lsof node 97242 romarq 26u IPv6 0x330c461cca8d2b63 0t0 TCP [::1]:8000 (LISTEN)
const regex = /(?:.+):(\d+)/;
const match = line.match(regex);
if (match) {
ports.push(Number(match[1]));
Expand All @@ -179,6 +182,7 @@ async function findPortsByPid(pid: number, retryCount = 600, retryDelay = 100):
if (ports.length) {
return ports;
}
throw new Error("Could not find any ports");
} catch (error) {
if (i === retryCount - 1) {
throw error;
Expand Down
4 changes: 4 additions & 0 deletions packages/types/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"ChopsticksLaunchSpec": {
"description": "A launch specification object for the \"chopsticks\" foundation type.",
"properties": {
"address": {
"description": "Server listening interface\nAdded in: https://github.com/AcalaNetwork/chopsticks/pull/826",
"type": "string"
},
"allowUnresolvedImports": {
"description": "An optional flag to NOT throw when the host fails to export a function expected by the runtime.",
"type": "boolean"
Expand Down
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@polkadot/api": "13.2.1",
"@polkadot/api-base": "13.2.1",
"@polkadot/keyring": "13.1.1",
"@polkadot/util-crypto": "13.1.1",
"@polkadot/types": "13.2.1",
"@polkadot/util": "13.1.1",
"@types/node": "20.14.10",
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ export interface ChopsticksLaunchSpec extends GenericLaunchSpec {
* An optional flag to retain node logs from previous runs.
*/
retainAllLogs?: boolean;

/**
* Server listening interface
* Added in: https://github.com/AcalaNetwork/chopsticks/pull/826
*/
address?: string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@polkadot/api": "13.2.1",
"@polkadot/api-derive": "13.2.1",
"@polkadot/keyring": "13.1.1",
"@polkadot/util-crypto": "13.1.1",
"@polkadot/rpc-provider": "13.2.1",
"@polkadot/types": "13.2.1",
"@polkadot/types-codec": "13.2.1",
Expand Down
Loading