@kohaku-eth/tornado-cash 0.0.2-alpha.13 → 0.0.2-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/merkle-tree.browser.js +1 -1
- package/dist/merkle-tree.node.js +1 -1
- package/dist/state-manager.worker.js +28 -7
- package/dist/state-manager.worker.node.js +28 -7
- package/dist/worker-loader.browser.d.ts +4 -1
- package/dist/worker-loader.node.d.ts +4 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -289,6 +289,15 @@ interface ISyncService {
|
|
|
289
289
|
* with the same external-then-chain strategy as {@link getPoolEvents}.
|
|
290
290
|
*/
|
|
291
291
|
getRelayerRegistryEvents(params: IGetEventsParams): Promise<IGetRelayerRegistryEventsResult>;
|
|
292
|
+
/**
|
|
293
|
+
* Resolves a pool's scan-start block. Uses the external provider's first
|
|
294
|
+
* covered block when available (an O(1) lookup), else falls back to the
|
|
295
|
+
* on-chain deployment-block binary search.
|
|
296
|
+
*/
|
|
297
|
+
getPoolDeploymentBlock(params: {
|
|
298
|
+
chainId: bigint;
|
|
299
|
+
address: Address;
|
|
300
|
+
}): Promise<bigint>;
|
|
292
301
|
}
|
|
293
302
|
|
|
294
303
|
type SpecificAssetBalanceFn<isAsync extends boolean = false> = <const Adresses extends Address | Address[] = Address[], ReturnType = Adresses extends unknown[] ? Map<Address, bigint> : bigint>(assetAddress?: Adresses) => isAsync extends true ? Promise<ReturnType> : ReturnType;
|
package/dist/index.js
CHANGED
|
@@ -440,6 +440,7 @@ var TornadoCashProtocol = class {
|
|
|
440
440
|
}
|
|
441
441
|
return events;
|
|
442
442
|
},
|
|
443
|
+
firstCoveredBlock: (params) => externalSyncProvider.firstCoveredBlock(params),
|
|
443
444
|
lastCoveredBlock: (params) => externalSyncProvider.lastCoveredBlock(params)
|
|
444
445
|
};
|
|
445
446
|
await Promise.race([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/utils/merkle-tree/merkle-tree.util.browser.ts
|
|
2
|
-
import { generateMimcMerkleProof, createMimcMerkleTreeParallel } from "mimc-tree";
|
|
2
|
+
import { generateMimcMerkleProof, createMimcMerkleTreeParallel } from "@kohaku-eth/mimc-tree";
|
|
3
3
|
var buildTree = async (leaves) => {
|
|
4
4
|
return createMimcMerkleTreeParallel(leaves, { workerUrl: "./merkle-tree-worker.browser.js" });
|
|
5
5
|
};
|
package/dist/merkle-tree.node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/utils/merkle-tree/merkle-tree.util.node.ts
|
|
2
|
-
import { generateMimcMerkleProof, createMimcMerkleTreeNodejsParallel } from "mimc-tree";
|
|
2
|
+
import { generateMimcMerkleProof, createMimcMerkleTreeNodejsParallel } from "@kohaku-eth/mimc-tree";
|
|
3
3
|
var buildTree = async (leaves) => {
|
|
4
4
|
return createMimcMerkleTreeNodejsParallel(leaves);
|
|
5
5
|
};
|
|
@@ -18009,6 +18009,24 @@ var SyncService = class {
|
|
|
18009
18009
|
toBlock: head
|
|
18010
18010
|
};
|
|
18011
18011
|
}
|
|
18012
|
+
async getPoolDeploymentBlock({
|
|
18013
|
+
chainId,
|
|
18014
|
+
address
|
|
18015
|
+
}) {
|
|
18016
|
+
const provider = this.externalSyncProvider;
|
|
18017
|
+
if (provider) {
|
|
18018
|
+
try {
|
|
18019
|
+
return BigInt(
|
|
18020
|
+
await provider.firstCoveredBlock({
|
|
18021
|
+
chainId: toHex(chainId),
|
|
18022
|
+
address: toHex(address, { size: 20 })
|
|
18023
|
+
})
|
|
18024
|
+
);
|
|
18025
|
+
} catch {
|
|
18026
|
+
}
|
|
18027
|
+
}
|
|
18028
|
+
return this.dataService.getContractDeploymentBlock(address);
|
|
18029
|
+
}
|
|
18012
18030
|
/**
|
|
18013
18031
|
* Decides whether to use the external provider and, if so, streams its raw
|
|
18014
18032
|
* events for `[fromBlock, coverage]`. Event-agnostic: callers parse the raw
|
|
@@ -18028,11 +18046,12 @@ var SyncService = class {
|
|
|
18028
18046
|
}
|
|
18029
18047
|
const chainId = toHex(rawChainId);
|
|
18030
18048
|
const hexAddress = toHex(address, { size: 20 });
|
|
18031
|
-
|
|
18032
|
-
|
|
18049
|
+
let coverage;
|
|
18050
|
+
try {
|
|
18051
|
+
coverage = BigInt(await provider.lastCoveredBlock({ chainId, address: hexAddress }));
|
|
18052
|
+
} catch {
|
|
18033
18053
|
return null;
|
|
18034
18054
|
}
|
|
18035
|
-
const coverage = BigInt(rawCoverage);
|
|
18036
18055
|
if (coverage <= fromBlock) {
|
|
18037
18056
|
return null;
|
|
18038
18057
|
}
|
|
@@ -21290,10 +21309,11 @@ var storeFactory = ({
|
|
|
21290
21309
|
var syncPoolsThunk = createAsyncThunk(
|
|
21291
21310
|
"sync/pools",
|
|
21292
21311
|
async ({
|
|
21293
|
-
dataService
|
|
21312
|
+
dataService,
|
|
21313
|
+
syncService
|
|
21294
21314
|
}, { dispatch, getState }) => {
|
|
21295
21315
|
const state = getState();
|
|
21296
|
-
const { instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
|
|
21316
|
+
const { chainId, instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
|
|
21297
21317
|
const existingPools = poolsSelector(state);
|
|
21298
21318
|
const poolsAddressses = await dataService.getAllPoolsAddresses(instanceRegistryAddress);
|
|
21299
21319
|
const unsyncedPools = poolsAddressses.filter((address) => !existingPools.has(address));
|
|
@@ -21301,7 +21321,7 @@ var syncPoolsThunk = createAsyncThunk(
|
|
|
21301
21321
|
unsyncedPools.map(async (poolAddress) => {
|
|
21302
21322
|
const [config, registeredBlock] = await Promise.all([
|
|
21303
21323
|
dataService.getPoolConfig(instanceRegistryAddress, poolAddress),
|
|
21304
|
-
|
|
21324
|
+
syncService.getPoolDeploymentBlock({ chainId, address: poolAddress })
|
|
21305
21325
|
]);
|
|
21306
21326
|
return { config, registeredBlock };
|
|
21307
21327
|
})
|
|
@@ -22010,7 +22030,8 @@ var syncThunk = createAsyncThunk(
|
|
|
22010
22030
|
"sync/syncEverything",
|
|
22011
22031
|
async ({ dataService, syncService, secretManager, verify = false, ...params }, { dispatch }) => {
|
|
22012
22032
|
unwrapResult(await dispatch(syncPoolsThunk({
|
|
22013
|
-
dataService
|
|
22033
|
+
dataService,
|
|
22034
|
+
syncService
|
|
22014
22035
|
})));
|
|
22015
22036
|
unwrapResult(await dispatch(syncRelayersThunk({ dataService, syncService })));
|
|
22016
22037
|
const syncEventsResult = await dispatch(syncEventsThunk({ syncService }));
|
|
@@ -17581,6 +17581,24 @@ var SyncService = class {
|
|
|
17581
17581
|
toBlock: head
|
|
17582
17582
|
};
|
|
17583
17583
|
}
|
|
17584
|
+
async getPoolDeploymentBlock({
|
|
17585
|
+
chainId,
|
|
17586
|
+
address
|
|
17587
|
+
}) {
|
|
17588
|
+
const provider = this.externalSyncProvider;
|
|
17589
|
+
if (provider) {
|
|
17590
|
+
try {
|
|
17591
|
+
return BigInt(
|
|
17592
|
+
await provider.firstCoveredBlock({
|
|
17593
|
+
chainId: toHex(chainId),
|
|
17594
|
+
address: toHex(address, { size: 20 })
|
|
17595
|
+
})
|
|
17596
|
+
);
|
|
17597
|
+
} catch {
|
|
17598
|
+
}
|
|
17599
|
+
}
|
|
17600
|
+
return this.dataService.getContractDeploymentBlock(address);
|
|
17601
|
+
}
|
|
17584
17602
|
/**
|
|
17585
17603
|
* Decides whether to use the external provider and, if so, streams its raw
|
|
17586
17604
|
* events for `[fromBlock, coverage]`. Event-agnostic: callers parse the raw
|
|
@@ -17600,11 +17618,12 @@ var SyncService = class {
|
|
|
17600
17618
|
}
|
|
17601
17619
|
const chainId = toHex(rawChainId);
|
|
17602
17620
|
const hexAddress = toHex(address, { size: 20 });
|
|
17603
|
-
|
|
17604
|
-
|
|
17621
|
+
let coverage;
|
|
17622
|
+
try {
|
|
17623
|
+
coverage = BigInt(await provider.lastCoveredBlock({ chainId, address: hexAddress }));
|
|
17624
|
+
} catch {
|
|
17605
17625
|
return null;
|
|
17606
17626
|
}
|
|
17607
|
-
const coverage = BigInt(rawCoverage);
|
|
17608
17627
|
if (coverage <= fromBlock) {
|
|
17609
17628
|
return null;
|
|
17610
17629
|
}
|
|
@@ -20868,10 +20887,11 @@ var storeFactory = ({
|
|
|
20868
20887
|
var syncPoolsThunk = createAsyncThunk(
|
|
20869
20888
|
"sync/pools",
|
|
20870
20889
|
async ({
|
|
20871
|
-
dataService
|
|
20890
|
+
dataService,
|
|
20891
|
+
syncService
|
|
20872
20892
|
}, { dispatch, getState }) => {
|
|
20873
20893
|
const state = getState();
|
|
20874
|
-
const { instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
|
|
20894
|
+
const { chainId, instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
|
|
20875
20895
|
const existingPools = poolsSelector(state);
|
|
20876
20896
|
const poolsAddressses = await dataService.getAllPoolsAddresses(instanceRegistryAddress);
|
|
20877
20897
|
const unsyncedPools = poolsAddressses.filter((address) => !existingPools.has(address));
|
|
@@ -20879,7 +20899,7 @@ var syncPoolsThunk = createAsyncThunk(
|
|
|
20879
20899
|
unsyncedPools.map(async (poolAddress) => {
|
|
20880
20900
|
const [config, registeredBlock] = await Promise.all([
|
|
20881
20901
|
dataService.getPoolConfig(instanceRegistryAddress, poolAddress),
|
|
20882
|
-
|
|
20902
|
+
syncService.getPoolDeploymentBlock({ chainId, address: poolAddress })
|
|
20883
20903
|
]);
|
|
20884
20904
|
return { config, registeredBlock };
|
|
20885
20905
|
})
|
|
@@ -21236,7 +21256,8 @@ var syncThunk = createAsyncThunk(
|
|
|
21236
21256
|
"sync/syncEverything",
|
|
21237
21257
|
async ({ dataService, syncService, secretManager, verify = false, ...params }, { dispatch }) => {
|
|
21238
21258
|
unwrapResult(await dispatch(syncPoolsThunk({
|
|
21239
|
-
dataService
|
|
21259
|
+
dataService,
|
|
21260
|
+
syncService
|
|
21240
21261
|
})));
|
|
21241
21262
|
unwrapResult(await dispatch(syncRelayersThunk({ dataService, syncService })));
|
|
21242
21263
|
const syncEventsResult = await dispatch(syncEventsThunk({ syncService }));
|
|
@@ -64,7 +64,10 @@ type ExternalSyncClient = {
|
|
|
64
64
|
fromBlock: Hex;
|
|
65
65
|
toBlock: Hex;
|
|
66
66
|
}): Promise<ExternalRawEvent[]>;
|
|
67
|
-
|
|
67
|
+
/** @throws if the provider has no data for the pool. */
|
|
68
|
+
firstCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
|
|
69
|
+
/** @throws if the provider has no data for the pool. */
|
|
70
|
+
lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
|
|
68
71
|
};
|
|
69
72
|
|
|
70
73
|
interface IRelayerStatusResponse {
|
|
@@ -65,7 +65,10 @@ type ExternalSyncClient = {
|
|
|
65
65
|
fromBlock: Hex;
|
|
66
66
|
toBlock: Hex;
|
|
67
67
|
}): Promise<ExternalRawEvent[]>;
|
|
68
|
-
|
|
68
|
+
/** @throws if the provider has no data for the pool. */
|
|
69
|
+
firstCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
|
|
70
|
+
/** @throws if the provider has no data for the pool. */
|
|
71
|
+
lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
|
|
69
72
|
};
|
|
70
73
|
|
|
71
74
|
interface IRelayerStatusResponse {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kohaku-eth/tornado-cash",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.14",
|
|
4
4
|
"description": "Tornado Cash Shielded Pool Kohaku Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"micro-zk-proofs": "0.3.1",
|
|
75
75
|
"ox": "^0.12.0",
|
|
76
76
|
"viem": "^2.51.3",
|
|
77
|
+
"@kohaku-eth/mimc-tree": "0.0.3",
|
|
77
78
|
"@kohaku-eth/provider": "0.1.0-alpha.8",
|
|
78
|
-
"mimc-tree": "0.1.0",
|
|
79
79
|
"@kohaku-eth/plugins": "0.0.1-alpha.11"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|