Skip to content

Commit

Permalink
feat: add rpc url to nwaku, persist rln tree in docker and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
adklempner committed May 4, 2024
1 parent 3d92f19 commit 72e5a71
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,50 @@ jobs:
- run: npm run build:esm
- run: npm run test:browser

build_rln_tree:
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
});
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@v3
with:
name: rln_tree.tar.gz
path: /tmp
- uses: ./.github/actions/npm
- name: Sync rln tree and save artifact
run: |
npm run sync-rln-tree
docker cp rln_tree:/rln_tree.db /tmp/rln_tree.db
tar -czf rln_tree.tar.gz -C /tmp/rln_tree.db .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: rln_tree.tar.gz
path: rln_tree.tar.gz

node:
uses: ./.github/workflows/test-node.yml
secrets: inherit
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/tests/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
12 changes: 11 additions & 1 deletion packages/tests/src/lib/dockerode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`]: {},
Expand Down
11 changes: 11 additions & 0 deletions packages/tests/src/lib/service_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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> {
Expand Down
29 changes: 29 additions & 0 deletions packages/tests/src/sync-rln-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SEPOLIA_RPC_URL } from "./constants.js";
import { ServiceNode } from "./lib/service_node.js";

async function syncRlnTree() {
const nwaku = new ServiceNode("rln_tree");
await nwaku.start({
store: false,
lightpush: false,
relay: false,
filter: false,
rest: true,
clusterId: 1,
rlnRelayEthClientAddress: SEPOLIA_RPC_URL
});
let healthy = false;
while (!healthy) {
healthy = await nwaku.healthy();
}
}

syncRlnTree()
.then(() => {
console.log("Synced RLN tree");
process.exit(0);
})
.catch((err) => {
console.error(`Error syncing RLN tree: ${err}`);
process.exit(1);
});
1 change: 1 addition & 0 deletions packages/tests/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Args {
// `legacyFilter` is required to enable filter v1 with go-waku
legacyFilter?: boolean;
clusterId?: number;
rlnRelayEthClientAddress?: string;
}

export interface Ports {
Expand Down
4 changes: 3 additions & 1 deletion packages/tests/tests/sharding/auto_sharding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
beforeEachCustom,
makeLogFileName,
MessageCollector,
SEPOLIA_RPC_URL,
ServiceNode,
tearDownNodes
} from "../../src/index.js";
Expand Down Expand Up @@ -49,7 +50,8 @@ describe("Autosharding: Running Nodes", function () {
lightpush: true,
relay: true,
clusterId: clusterId,
pubsubTopic: pubsubTopics
pubsubTopic: pubsubTopics,
rlnRelayEthClientAddress: SEPOLIA_RPC_URL
});

await nwaku.ensureSubscriptions(pubsubTopics);
Expand Down

0 comments on commit 72e5a71

Please sign in to comment.