mirror of https://github.com/waku-org/js-waku.git
feat: add rpc url to nwaku, persist rln tree in docker and ci
This commit is contained in:
parent
4eb06c64eb
commit
aad819bb1f
|
@ -68,6 +68,53 @@ jobs:
|
|||
- run: npm run build:esm
|
||||
- run: npm run test:browser
|
||||
|
||||
build_rln_tree:
|
||||
if: false # This condition disables the job
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: waku-org/js-waku
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_JS }}
|
||||
- name: Check for existing RLN tree artifact
|
||||
id: check-artifact
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const artifact = await github.rest.actions.listWorkflowRunArtifacts({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
run_id: context.runId
|
||||
});
|
||||
console.log(artifact);
|
||||
const foundArtifact = artifact.data.artifacts.find(art => art.name === 'rln_tree.tar.gz');
|
||||
if (foundArtifact) {
|
||||
core.setOutput('artifact_id', foundArtifact.id);
|
||||
core.setOutput('artifact_found', 'true');
|
||||
} else {
|
||||
core.setOutput('artifact_found', 'false');
|
||||
}
|
||||
- name: Download RLN tree artifact
|
||||
if: steps.check-artifact.outputs.artifact_found == 'true'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: rln_tree.tar.gz
|
||||
path: /tmp
|
||||
- uses: ./.github/actions/npm
|
||||
- name: Sync rln tree and save artifact
|
||||
run: |
|
||||
mkdir -p /tmp/rln_tree.db
|
||||
npm run build:esm
|
||||
npm run sync-rln-tree
|
||||
tar -czf rln_tree.tar.gz -C /tmp/rln_tree.db .
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rln_tree.tar.gz
|
||||
path: rln_tree.tar.gz
|
||||
|
||||
node:
|
||||
uses: ./.github/workflows/test-node.yml
|
||||
secrets: inherit
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
"doc": "run-s doc:*",
|
||||
"doc:html": "typedoc --options typedoc.cjs",
|
||||
"doc:cname": "echo 'js.waku.org' > docs/CNAME",
|
||||
"publish": "node ./ci/publish.js"
|
||||
"publish": "node ./ci/publish.js",
|
||||
"sync-rln-tree": "node ./packages/tests/src/sync-rln-tree.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@size-limit/preset-big-lib": "^11.0.2",
|
||||
|
|
|
@ -62,3 +62,6 @@ export const TEST_TIMESTAMPS = [
|
|||
];
|
||||
|
||||
export const MOCHA_HOOK_MAX_TIMEOUT = 50_000;
|
||||
|
||||
export const SEPOLIA_RPC_URL =
|
||||
process.env.SEPOLIA_RPC_URL || "https://sepolia.gateway.tenderly.co";
|
||||
|
|
|
@ -115,7 +115,17 @@ export default class Dockerode {
|
|||
...(args?.peerExchange && {
|
||||
[`${discv5UdpPort}/udp`]: [{ HostPort: discv5UdpPort.toString() }]
|
||||
})
|
||||
}
|
||||
},
|
||||
Mounts: args.rlnRelayEthClientAddress
|
||||
? [
|
||||
{
|
||||
Type: "bind",
|
||||
ReadOnly: false,
|
||||
Source: "/tmp/rln_tree.db",
|
||||
Target: "/rln_tree.db"
|
||||
}
|
||||
]
|
||||
: []
|
||||
},
|
||||
ExposedPorts: {
|
||||
[`${restPort}/tcp`]: {},
|
||||
|
|
|
@ -87,6 +87,10 @@ export class ServiceNode {
|
|||
return isGoWaku ? "go-waku" : "nwaku";
|
||||
}
|
||||
|
||||
get containerName(): string | undefined {
|
||||
return this.docker?.container?.id;
|
||||
}
|
||||
|
||||
async start(
|
||||
args: Args = {},
|
||||
options: {
|
||||
|
@ -229,6 +233,17 @@ export class ServiceNode {
|
|||
);
|
||||
}
|
||||
|
||||
async healthy(): Promise<boolean> {
|
||||
this.checkProcess();
|
||||
|
||||
return this.restCall<boolean>(
|
||||
"/health",
|
||||
"GET",
|
||||
undefined,
|
||||
async (response) => response.status === 200
|
||||
);
|
||||
}
|
||||
|
||||
async ensureSubscriptions(
|
||||
pubsubTopics: string[] = [DefaultPubsubTopic]
|
||||
): Promise<boolean> {
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import { exec } from "child_process";
|
||||
import { setTimeout } from "timers";
|
||||
import { promisify } from "util";
|
||||
|
||||
import { SEPOLIA_RPC_URL } from "../dist/constants.js";
|
||||
import { ServiceNode } from "../dist/lib/service_node.js";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.27.0";
|
||||
const containerName = "rln_tree";
|
||||
|
||||
async function syncRlnTree() {
|
||||
try {
|
||||
await execAsync(`docker inspect ${WAKUNODE_IMAGE}`);
|
||||
console.log(`Using local image ${WAKUNODE_IMAGE}`);
|
||||
} catch (error) {
|
||||
console.log(`Pulling image ${WAKUNODE_IMAGE}`);
|
||||
await execAsync(`docker pull ${WAKUNODE_IMAGE}`);
|
||||
console.log("Image pulled");
|
||||
}
|
||||
|
||||
const nwaku = new ServiceNode(containerName);
|
||||
await nwaku.start(
|
||||
{
|
||||
store: false,
|
||||
lightpush: false,
|
||||
relay: true,
|
||||
filter: false,
|
||||
rest: true,
|
||||
clusterId: 1,
|
||||
rlnRelayEthClientAddress: SEPOLIA_RPC_URL
|
||||
},
|
||||
{ retries: 3 }
|
||||
);
|
||||
let healthy = false;
|
||||
while (!healthy) {
|
||||
healthy = await nwaku.healthy();
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
|
||||
await execAsync(
|
||||
`docker cp ${nwaku.containerName}:/rln_tree.db /tmp/rln_tree.db`
|
||||
);
|
||||
await nwaku.stop();
|
||||
}
|
||||
|
||||
syncRlnTree()
|
||||
.then(() => {
|
||||
console.log("Synced RLN tree");
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(`Error syncing RLN tree: ${err}`);
|
||||
process.exit(1);
|
||||
});
|
|
@ -26,6 +26,7 @@ export interface Args {
|
|||
legacyFilter?: boolean;
|
||||
clusterId?: number;
|
||||
shard?: Array<number>;
|
||||
rlnRelayEthClientAddress?: string;
|
||||
}
|
||||
|
||||
export interface Ports {
|
||||
|
|
Loading…
Reference in New Issue