Optional tree generation

This commit is contained in:
Tornado Contrib 2024-10-21 23:11:07 +00:00
parent 53e60da285
commit 48774c321e
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
6 changed files with 162 additions and 60 deletions

201
dist/cli.js vendored

@ -181016,7 +181016,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", routerContract: "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b",
echoContract: "0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42", echoContract: "0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornContract: "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C", tornContract: "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C",
governanceContract: "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce", governanceContract: "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce",
stakingRewardsContract: "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29", stakingRewardsContract: "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29",
@ -181130,7 +181130,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornadoSubgraph: "tornadocash/bsc-tornado-subgraph", tornadoSubgraph: "tornadocash/bsc-tornado-subgraph",
subgraphs: {}, subgraphs: {},
rpcUrls: { rpcUrls: {
@ -181193,7 +181193,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornadoSubgraph: "tornadocash/matic-tornado-subgraph", tornadoSubgraph: "tornadocash/matic-tornado-subgraph",
subgraphs: {}, subgraphs: {},
rpcUrls: { rpcUrls: {
@ -181244,7 +181244,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
ovmGasPriceOracleContract: "0x420000000000000000000000000000000000000F", ovmGasPriceOracleContract: "0x420000000000000000000000000000000000000F",
tornadoSubgraph: "tornadocash/optimism-tornado-subgraph", tornadoSubgraph: "tornadocash/optimism-tornado-subgraph",
subgraphs: {}, subgraphs: {},
@ -181296,7 +181296,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornadoSubgraph: "tornadocash/arbitrum-tornado-subgraph", tornadoSubgraph: "tornadocash/arbitrum-tornado-subgraph",
subgraphs: {}, subgraphs: {},
rpcUrls: { rpcUrls: {
@ -181351,7 +181351,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornadoSubgraph: "tornadocash/xdai-tornado-subgraph", tornadoSubgraph: "tornadocash/xdai-tornado-subgraph",
subgraphs: {}, subgraphs: {},
rpcUrls: { rpcUrls: {
@ -181402,7 +181402,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8", offchainOracleContract: "0x00000000000D6FFc74A8feb35aF5827bf57f6786",
tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph", tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph",
subgraphs: {}, subgraphs: {},
rpcUrls: { rpcUrls: {
@ -181452,6 +181452,7 @@ const defaultConfig = {
multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11", multicallContract: "0xcA11bde05977b3631167028862bE2a173976CA11",
routerContract: "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee", routerContract: "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee",
echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4",
offchainOracleContract: "0x1f89EAF03E5b260Bc6D4Ae3c3334b1B750F3e127",
tornContract: "0x3AE6667167C0f44394106E197904519D808323cA", tornContract: "0x3AE6667167C0f44394106E197904519D808323cA",
governanceContract: "0xe5324cD7602eeb387418e594B87aCADee08aeCAD", governanceContract: "0xe5324cD7602eeb387418e594B87aCADee08aeCAD",
stakingRewardsContract: "0x6d0018890751Efd31feb8166711B16732E2b496b", stakingRewardsContract: "0x6d0018890751Efd31feb8166711B16732E2b496b",
@ -182299,10 +182300,15 @@ class BaseEventsService {
lastBlock: rpcEvents.lastBlock lastBlock: rpcEvents.lastBlock
}; };
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars /* eslint-disable @typescript-eslint/no-unused-vars */
async validateEvents({ events, lastBlock }) { async validateEvents({
events,
lastBlock,
hasNewEvents
}) {
return void 0; return void 0;
} }
/* eslint-enable @typescript-eslint/no-unused-vars */
/** /**
* Handle saving events * Handle saving events
*/ */
@ -182332,7 +182338,11 @@ class BaseEventsService {
return !hasEvent; return !hasEvent;
}); });
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber; const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
const validateResult = await this.validateEvents({ events: allEvents, lastBlock }); const validateResult = await this.validateEvents({
events: allEvents,
lastBlock,
hasNewEvents: Boolean(newEvents.events.length)
});
if (savedEvents.fromCache || newEvents.events.length) { if (savedEvents.fromCache || newEvents.events.length) {
await this.saveEvents({ events: allEvents, lastBlock }); await this.saveEvents({ events: allEvents, lastBlock });
} }
@ -182346,17 +182356,19 @@ class BaseEventsService {
class BaseTornadoService extends BaseEventsService { class BaseTornadoService extends BaseEventsService {
amount; amount;
currency; currency;
optionalTree;
merkleTreeService; merkleTreeService;
batchTransactionService; batchTransactionService;
batchBlockService; batchBlockService;
constructor(serviceConstructor) { constructor(serviceConstructor) {
const { Tornado: contract, amount, currency, provider, merkleTreeService } = serviceConstructor; const { Tornado: contract, amount, currency, provider, optionalTree, merkleTreeService } = serviceConstructor;
super({ super({
...serviceConstructor, ...serviceConstructor,
contract contract
}); });
this.amount = amount; this.amount = amount;
this.currency = currency; this.currency = currency;
this.optionalTree = optionalTree;
this.merkleTreeService = merkleTreeService; this.merkleTreeService = merkleTreeService;
this.batchTransactionService = new BatchTransactionService({ this.batchTransactionService = new BatchTransactionService({
provider, provider,
@ -182431,7 +182443,10 @@ class BaseTornadoService extends BaseEventsService {
}); });
} }
} }
async validateEvents({ events }) { async validateEvents({
events,
hasNewEvents
}) {
if (events.length && this.getType().toLowerCase() === DEPOSIT) { if (events.length && this.getType().toLowerCase() === DEPOSIT) {
const depositEvents = events; const depositEvents = events;
const lastEvent = depositEvents[depositEvents.length - 1]; const lastEvent = depositEvents[depositEvents.length - 1];
@ -182439,7 +182454,7 @@ class BaseTornadoService extends BaseEventsService {
const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`; const errMsg = `Deposit events invalid wants ${depositEvents.length - 1} leafIndex have ${lastEvent.leafIndex}`;
throw new Error(errMsg); throw new Error(errMsg);
} }
if (this.merkleTreeService) { if (this.merkleTreeService && (!this.optionalTree || hasNewEvents)) {
return await this.merkleTreeService.verifyTree(depositEvents); return await this.merkleTreeService.verifyTree(depositEvents);
} }
} }
@ -183043,8 +183058,14 @@ async function saveDBEvents({
lastBlock lastBlock
}) { }) {
try { try {
const formattedEvents = events.map((e) => {
return {
eid: `${e.transactionHash}_${e.logIndex}`,
...e
};
});
await idb.createMultipleTransactions({ await idb.createMultipleTransactions({
data: events, data: formattedEvents,
storeName: instanceName storeName: instanceName
}); });
await idb.putItem({ await idb.putItem({
@ -183074,8 +183095,12 @@ async function loadDBEvents({
lastBlock: 0 lastBlock: 0
}; };
} }
const events = (await idb.getAll({ storeName: instanceName })).map((e) => {
delete e.eid;
return e;
});
return { return {
events: await idb.getAll({ storeName: instanceName }), events,
lastBlock: lastBlockStore.blockNumber lastBlock: lastBlockStore.blockNumber
}; };
} catch (err) { } catch (err) {
@ -189131,7 +189156,7 @@ class IndexedDB {
} }
}; };
this.dbName = dbName; this.dbName = dbName;
this.dbVersion = 34; this.dbVersion = 35;
} }
async initDB() { async initDB() {
try { try {
@ -189325,24 +189350,42 @@ async function getIndexedDB(netId) {
await idb2.initDB(); await idb2.initDB();
return idb2; return idb2;
} }
const DEPOSIT_INDEXES = [ const minimalIndexes = [
{ name: "transactionHash", unique: false }, {
{ name: "commitment", unique: true } name: "blockNumber",
unique: false
},
{
name: "transactionHash",
unique: false
}
]; ];
const WITHDRAWAL_INDEXES = [
{ name: "nullifierHash", unique: true }
// keys on which the index is created
];
const LAST_EVENT_INDEXES = [{ name: "name", unique: false }];
const defaultState = [ const defaultState = [
{ {
name: "encrypted_events", name: `echo_${netId}`,
keyPath: "transactionHash" keyPath: "eid",
indexes: [
...minimalIndexes,
{
name: "address",
unique: false
}
]
},
{
name: `encrypted_notes_${netId}`,
keyPath: "eid",
indexes: minimalIndexes
}, },
{ {
name: "lastEvents", name: "lastEvents",
keyPath: "name", keyPath: "name",
indexes: LAST_EVENT_INDEXES indexes: [
{
name: "name",
unique: false
}
]
} }
]; ];
const config = getConfig(netId); const config = getConfig(netId);
@ -189350,33 +189393,68 @@ async function getIndexedDB(netId) {
const stores = [...defaultState]; const stores = [...defaultState];
if (netId === NetId.MAINNET) { if (netId === NetId.MAINNET) {
stores.push({ stores.push({
name: "register_events", name: `registered_${netId}`,
keyPath: "ensName" keyPath: "ensName",
indexes: [
...minimalIndexes,
{
name: "relayerAddress",
unique: false
}
]
});
stores.push({
name: `governance_${netId}`,
keyPath: "eid",
indexes: [
...minimalIndexes,
{
name: "event",
unique: false
}
]
}); });
} }
Object.entries(tokens).forEach(([token, { instanceAddress }]) => { Object.entries(tokens).forEach(([token, { instanceAddress }]) => {
Object.keys(instanceAddress).forEach((amount) => { Object.keys(instanceAddress).forEach((amount) => {
if (nativeCurrency === token) { if (nativeCurrency === token) {
stores.push({ stores.push(
name: `stringify_bloom_${netId}_${token}_${amount}`, {
keyPath: "hashBloom" name: `stringify_bloom_${netId}_${token}_${amount}`,
}); keyPath: "hashBloom",
indexes: []
},
{
name: `stringify_tree_${netId}_${token}_${amount}`,
keyPath: "hashTree",
indexes: []
}
);
} }
stores.push( stores.push(
{ {
name: `deposits_${netId}_${token}_${amount}`, name: `deposits_${netId}_${token}_${amount}`,
keyPath: "leafIndex", keyPath: "leafIndex",
// the key by which it refers to the object must be in all instances of the storage // the key by which it refers to the object must be in all instances of the storage
indexes: DEPOSIT_INDEXES indexes: [
...minimalIndexes,
{
name: "commitment",
unique: true
}
]
}, },
{ {
name: `withdrawals_${netId}_${token}_${amount}`, name: `withdrawals_${netId}_${token}_${amount}`,
keyPath: "blockNumber", keyPath: "eid",
indexes: WITHDRAWAL_INDEXES indexes: [
}, ...minimalIndexes,
{ {
name: `stringify_tree_${netId}_${token}_${amount}`, name: "nullifierHash",
keyPath: "hashTree" unique: true
}
// keys on which the index is created
]
} }
); );
}); });
@ -189589,16 +189667,19 @@ class TokenPriceOracle {
oracle; oracle;
multicall; multicall;
provider; provider;
fallbackPrice;
constructor(provider, multicall2, oracle) { constructor(provider, multicall2, oracle) {
this.provider = provider; this.provider = provider;
this.multicall = multicall2; this.multicall = multicall2;
this.oracle = oracle; this.oracle = oracle;
this.fallbackPrice = parseEther("0.0001");
} }
buildCalls(tokens) { buildCalls(tokens) {
return tokens.map(({ tokenAddress }) => ({ return tokens.map(({ tokenAddress }) => ({
contract: this.oracle, contract: this.oracle,
name: "getRateToEth", name: "getRateToEth",
params: [tokenAddress, true] params: [tokenAddress, true],
allowFailure: true
})); }));
} }
buildStable(stablecoinAddress) { buildStable(stablecoinAddress) {
@ -189611,32 +189692,42 @@ class TokenPriceOracle {
{ {
contract: this.oracle, contract: this.oracle,
name: "getRateToEth", name: "getRateToEth",
params: [stablecoin.target, true] params: [stablecoin.target, true],
allowFailure: true
} }
]; ];
} }
async fetchPrice(tokenAddress, decimals) { async fetchPrice(tokenAddress, decimals) {
if (!this.oracle) { if (!this.oracle) {
return new Promise((resolve) => resolve(parseEther("0.0001"))); return new Promise((resolve) => resolve(this.fallbackPrice));
}
try {
const price = await this.oracle.getRateToEth(tokenAddress, true);
return price * BigInt(10 ** decimals) / BigInt(10 ** 18);
} catch (err) {
console.log(`Failed to fetch oracle price for ${tokenAddress}, will use fallback price ${this.fallbackPrice}`);
console.log(err);
return this.fallbackPrice;
} }
const price = await this.oracle.getRateToEth(tokenAddress, true);
return price * BigInt(10 ** decimals) / BigInt(10 ** 18);
} }
async fetchPrices(tokens) { async fetchPrices(tokens) {
if (!this.oracle) { if (!this.oracle) {
return new Promise((resolve) => resolve(tokens.map(() => parseEther("0.0001")))); return new Promise((resolve) => resolve(tokens.map(() => this.fallbackPrice)));
} }
const prices = await multicall(this.multicall, this.buildCalls(tokens)); const prices = await multicall(this.multicall, this.buildCalls(tokens));
return prices.map((price, index) => { return prices.map((price, index) => {
if (!price) {
price = this.fallbackPrice;
}
return price * BigInt(10 ** tokens[index].decimals) / BigInt(10 ** 18); return price * BigInt(10 ** tokens[index].decimals) / BigInt(10 ** 18);
}); });
} }
async fetchEthUSD(stablecoinAddress) { async fetchEthUSD(stablecoinAddress) {
if (!this.oracle) { if (!this.oracle) {
return new Promise((resolve) => resolve(1e4)); return new Promise((resolve) => resolve(10 ** 18 / Number(this.fallbackPrice)));
} }
const [decimals, price] = await multicall(this.multicall, this.buildStable(stablecoinAddress)); const [decimals, price] = await multicall(this.multicall, this.buildStable(stablecoinAddress));
const ethPrice = price * BigInt(10n ** decimals) / BigInt(10 ** 18); const ethPrice = (price || this.fallbackPrice) * BigInt(10n ** decimals) / BigInt(10 ** 18);
return 1 / Number(formatEther(ethPrice)); return 1 / Number(formatEther(ethPrice));
} }
} }
@ -190237,8 +190328,12 @@ class NodeTornadoService extends BaseTornadoService {
async getEventsFromCache() { async getEventsFromCache() {
return await getEventsFromCache(this); return await getEventsFromCache(this);
} }
async validateEvents({ events }) { async validateEvents({
const tree = await super.validateEvents({ events }); events,
lastBlock,
hasNewEvents
}) {
const tree = await super.validateEvents({ events, lastBlock, hasNewEvents });
if (tree && this.currency === this.nativeCurrency && this.treeCache) { if (tree && this.currency === this.nativeCurrency && this.treeCache) {
const merkleTree = tree; const merkleTree = tree;
await this.treeCache.createTree(events, merkleTree); await this.treeCache.createTree(events, merkleTree);
@ -191592,7 +191687,8 @@ Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url}
currency, currency,
Tornado, Tornado,
merkleWorkerPath merkleWorkerPath
}) }),
optionalTree: true
}); });
const withdrawalsService = new NodeTornadoService({ const withdrawalsService = new NodeTornadoService({
...TornadoServiceConstructor, ...TornadoServiceConstructor,
@ -191755,7 +191851,8 @@ Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url}
amount, amount,
currency, currency,
userDirectory: SAVED_TREE_DIR userDirectory: SAVED_TREE_DIR
}) }),
optionalTree: true
}); });
const withdrawalsService = new NodeTornadoService({ const withdrawalsService = new NodeTornadoService({
...TornadoServiceConstructor, ...TornadoServiceConstructor,

@ -21,8 +21,8 @@ export declare class NodeTornadoService extends BaseTornadoService {
updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void; updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
getEventsFromDB(): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>; getEventsFromDB(): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
getEventsFromCache(): Promise<import("@tornado/core").CachedEvents<DepositsEvents | WithdrawalsEvents>>; getEventsFromCache(): Promise<import("@tornado/core").CachedEvents<DepositsEvents | WithdrawalsEvents>>;
validateEvents<S>({ events }: { validateEvents<S>({ events, lastBlock, hasNewEvents, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
events: (DepositsEvents | WithdrawalsEvents)[]; hasNewEvents?: boolean;
}): Promise<S>; }): Promise<S>;
saveEvents({ events, lastBlock }: BaseEvents<DepositsEvents | WithdrawalsEvents>): Promise<void>; saveEvents({ events, lastBlock }: BaseEvents<DepositsEvents | WithdrawalsEvents>): Promise<void>;
} }

@ -51,7 +51,7 @@
"optionalDependencies": {}, "optionalDependencies": {},
"devDependencies": { "devDependencies": {
"@colors/colors": "^1.6.0", "@colors/colors": "^1.6.0",
"@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#dfb20aa61753c4f29ab144517ff48959e1b33c40", "@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#9f4044d11033e99e0a863989864d1578a93de531",
"@typechain/ethers-v6": "^0.5.1", "@typechain/ethers-v6": "^0.5.1",
"@types/figlet": "^1.7.0", "@types/figlet": "^1.7.0",
"@typescript-eslint/eslint-plugin": "^8.9.0", "@typescript-eslint/eslint-plugin": "^8.9.0",

@ -1305,6 +1305,7 @@ export function tornadoProgram() {
Tornado, Tornado,
merkleWorkerPath, merkleWorkerPath,
}), }),
optionalTree: true,
}); });
const withdrawalsService = new NodeTornadoService({ const withdrawalsService = new NodeTornadoService({
@ -1506,6 +1507,7 @@ export function tornadoProgram() {
currency, currency,
userDirectory: SAVED_TREE_DIR, userDirectory: SAVED_TREE_DIR,
}), }),
optionalTree: true,
}); });
const withdrawalsService = new NodeTornadoService({ const withdrawalsService = new NodeTornadoService({

@ -17,7 +17,6 @@ import {
BaseEchoService, BaseEchoService,
CachedRelayers, CachedRelayers,
toFixedHex, toFixedHex,
DEPOSIT,
} from '@tornado/core'; } from '@tornado/core';
import type { import type {
BaseEvents, BaseEvents,
@ -183,8 +182,12 @@ export class NodeTornadoService extends BaseTornadoService {
return await getEventsFromCache<DepositsEvents | WithdrawalsEvents>(this); return await getEventsFromCache<DepositsEvents | WithdrawalsEvents>(this);
} }
async validateEvents<S>({ events }: { events: (DepositsEvents | WithdrawalsEvents)[] }): Promise<S> { async validateEvents<S>({
const tree = await super.validateEvents<S>({ events }); events,
lastBlock,
hasNewEvents,
}: BaseEvents<DepositsEvents | WithdrawalsEvents> & { hasNewEvents?: boolean }): Promise<S> {
const tree = await super.validateEvents<S>({ events, lastBlock, hasNewEvents });
if (tree && this.currency === this.nativeCurrency && this.treeCache) { if (tree && this.currency === this.nativeCurrency && this.treeCache) {
const merkleTree = tree as unknown as MerkleTree; const merkleTree = tree as unknown as MerkleTree;

@ -785,9 +785,9 @@
"@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0" "@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0"
ethers "^6.13.4" ethers "^6.13.4"
"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#dfb20aa61753c4f29ab144517ff48959e1b33c40": "@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#9f4044d11033e99e0a863989864d1578a93de531":
version "1.0.19" version "1.0.19"
resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#dfb20aa61753c4f29ab144517ff48959e1b33c40" resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#9f4044d11033e99e0a863989864d1578a93de531"
dependencies: dependencies:
"@metamask/eth-sig-util" "^7.0.3" "@metamask/eth-sig-util" "^7.0.3"
"@tornado/contracts" "git+https://git.tornado.ws/tornadocontrib/tornado-contracts.git#ece511f424dc811c3aec149a4bf0e3731c0598a4" "@tornado/contracts" "git+https://git.tornado.ws/tornadocontrib/tornado-contracts.git#ece511f424dc811c3aec149a4bf0e3731c0598a4"