-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add rpc url to nwaku, persist rln tree in docker and ci
- Loading branch information
1 parent
3d92f19
commit e7bef35
Showing
7 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters