Sync relayers from RPC

This commit is contained in:
Tornado Contrib 2024-10-04 17:20:50 +00:00
parent 620d46580b
commit d19c062847
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
6 changed files with 3758 additions and 2933 deletions

6642
dist/cli.js vendored

File diff suppressed because it is too large Load Diff

@ -1,12 +1,9 @@
import { AsyncZippable, Unzipped } from 'fflate';
import { BaseEvents, CachedEvents, MinimalEvents } from '@tornado/core';
export declare function existsAsync(fileOrDir: string): Promise<boolean>;
/**
* Supports legacy gz format for legacy UI
*/
export declare function deflateAsync(data: Uint8Array): Promise<Buffer>;
export declare function zipAsync(file: AsyncZippable): Promise<Uint8Array>;
export declare function unzipAsync(data: Uint8Array): Promise<Unzipped>;
export declare function saveLegacyFile({ fileName, userDirectory, dataString, }: {
fileName: string;
userDirectory: string;

@ -51,7 +51,7 @@
"optionalDependencies": {},
"devDependencies": {
"@colors/colors": "^1.6.0",
"@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f73b9ecbff0b106854752388f94c2d0c30e54975",
"@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#58b31101259245dad8ac6152829ca7bc7ac7f091",
"@typechain/ethers-v6": "^0.5.1",
"@types/figlet": "^1.5.8",
"@typescript-eslint/eslint-plugin": "^8.7.0",

@ -1457,7 +1457,7 @@ export function tornadoProgram() {
console.log(`\nConnected with Tovarish Relayer ${tovarishClient.selectedRelayer?.url}\n`);
}
if (governanceContract) {
if (netId === RELAYER_NETWORK && governanceContract) {
const governanceService = new NodeGovernanceService({
netId,
provider,
@ -1474,7 +1474,7 @@ export function tornadoProgram() {
await governanceService.updateEvents();
}
if (registryContract && aggregatorContract) {
if (netId === RELAYER_NETWORK && registryContract && aggregatorContract) {
const registryService = new NodeRegistryService({
netId,
provider,
@ -1485,7 +1485,8 @@ export function tornadoProgram() {
relayerEnsSubdomains: getRelayerEnsSubdomains(),
deployedBlock: REGISTRY_BLOCK,
fetchDataOptions,
tovarishClient,
// Exclude tovarish relayer from updating registry events and use RPC directly
// tovarishClient,
cacheDirectory: EVENTS_DIR,
userDirectory: SAVED_DIR,
});

@ -1,8 +1,7 @@
import path from 'path';
import { deflate, constants } from 'zlib';
import { stat, mkdir, readFile, writeFile } from 'fs/promises';
import { zip, unzip, AsyncZippable, Unzipped } from 'fflate';
import { BaseEvents, CachedEvents, MinimalEvents } from '@tornado/core';
import { BaseEvents, CachedEvents, MinimalEvents, zipAsync, unzipAsync } from '@tornado/core';
export async function existsAsync(fileOrDir: string): Promise<boolean> {
try {
@ -36,30 +35,6 @@ export function deflateAsync(data: Uint8Array): Promise<Buffer> {
});
}
export function zipAsync(file: AsyncZippable): Promise<Uint8Array> {
return new Promise((res, rej) => {
zip(file, { mtime: new Date('1/1/1980') }, (err, data) => {
if (err) {
rej(err);
return;
}
res(data);
});
});
}
export function unzipAsync(data: Uint8Array): Promise<Unzipped> {
return new Promise((res, rej) => {
unzip(data, {}, (err, data) => {
if (err) {
rej(err);
return;
}
res(data);
});
});
}
export async function saveLegacyFile({
fileName,
userDirectory,

@ -786,9 +786,9 @@
"@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0"
ethers "^6.4.0"
"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f73b9ecbff0b106854752388f94c2d0c30e54975":
"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#58b31101259245dad8ac6152829ca7bc7ac7f091":
version "1.0.19"
resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f73b9ecbff0b106854752388f94c2d0c30e54975"
resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#58b31101259245dad8ac6152829ca7bc7ac7f091"
dependencies:
"@metamask/eth-sig-util" "^7.0.3"
"@tornado/contracts" "^1.0.1"
@ -802,6 +802,7 @@
ethers "^6.13.2"
ffjavascript "0.2.48"
fflate "^0.8.2"
idb "^8.0.0"
"@tornado/fixed-merkle-tree@^0.7.3":
version "0.7.3"
@ -2786,6 +2787,11 @@ iconv-lite@^0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"
idb@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/idb/-/idb-8.0.0.tgz#33d7ed894ed36e23bcb542fb701ad579bfaad41f"
integrity sha512-l//qvlAKGmQO31Qn7xdzagVPPaHTxXx199MhrAFuVBTPqydcPYBWjkrbv4Y0ktB+GmWOiwHl237UUOrLmQxLvw==
ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"