From d026655f192823010cc2effd22d6aa9331e0b7bf Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 6 Aug 2023 13:09:40 -0700 Subject: [PATCH] Use hashed tries --- packages/client/src/sync/fetcher/accountfetcher.ts | 5 +++-- packages/client/src/sync/fetcher/bytecodefetcher.ts | 2 +- packages/client/src/sync/fetcher/storagefetcher.ts | 2 +- packages/client/src/sync/fetcher/trienodefetcher.ts | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/client/src/sync/fetcher/accountfetcher.ts b/packages/client/src/sync/fetcher/accountfetcher.ts index 5a10b4cedb..c3834d15ea 100644 --- a/packages/client/src/sync/fetcher/accountfetcher.ts +++ b/packages/client/src/sync/fetcher/accountfetcher.ts @@ -141,9 +141,10 @@ export class AccountFetcher extends Fetcher this.root = options.root this.first = options.first this.count = options.count ?? BigInt(2) ** BigInt(256) - this.first - this.codeTrie = new Trie({ useKeyHashing: true }) - this.accountTrie = new Trie({ useKeyHashing: true }) + this.codeTrie = new Trie({ useKeyHashing: false }) + this.accountTrie = new Trie({ useKeyHashing: false }) this.accountToStorageTrie = new Map() + this.debug = createDebugLogger('client:AccountFetcher') this.storageFetcher = new StorageFetcher({ config: this.config, diff --git a/packages/client/src/sync/fetcher/bytecodefetcher.ts b/packages/client/src/sync/fetcher/bytecodefetcher.ts index 682e4a984a..c5fab14fca 100644 --- a/packages/client/src/sync/fetcher/bytecodefetcher.ts +++ b/packages/client/src/sync/fetcher/bytecodefetcher.ts @@ -45,7 +45,7 @@ export class ByteCodeFetcher extends Fetcher constructor(options: ByteCodeFetcherOptions) { super(options) this.hashes = options.hashes ?? [] - this.trie = options.trie ?? new Trie({ useKeyHashing: true }) + this.trie = options.trie ?? new Trie({ useKeyHashing: false }) this.debug = createDebugLogger('client:ByteCodeFetcher') if (this.hashes.length > 0) { const fullJob = { task: { hashes: this.hashes } } as Job diff --git a/packages/client/src/sync/fetcher/storagefetcher.ts b/packages/client/src/sync/fetcher/storagefetcher.ts index 8ed712d9c7..d43bf10253 100644 --- a/packages/client/src/sync/fetcher/storagefetcher.ts +++ b/packages/client/src/sync/fetcher/storagefetcher.ts @@ -398,7 +398,7 @@ export class StorageFetcher extends Fetcher this.pathToNodeRequestData = new OrderedMap() this.requestedNodeToPath = new Map() this.fetchedAccountNodes = new Map() - this.accountTrie = options.accountTrie ?? new Trie({ useKeyHashing: true }) - this.codeTrie = options.codeTrie ?? new Trie({ useKeyHashing: true }) + this.accountTrie = options.accountTrie ?? new Trie({ useKeyHashing: false }) + this.codeTrie = options.codeTrie ?? new Trie({ useKeyHashing: false }) this.accountToStorageTrie = options.accountToStorageTrie ?? new Map() this.nodeCount = 0 this.debug = createDebugLogger('client:TrieNodeFetcher') @@ -323,7 +323,7 @@ export class TrieNodeFetcher extends Fetcher // add storage data for account if it has fetched nodes // TODO figure out what the key should be for mapping accounts to storage tries - const storageTrie = new Trie({ useKeyHashing: true }) + const storageTrie = new Trie({ useKeyHashing: false }) const storageTrieOps: BatchDBOp[] = [] if (pathToStorageNode !== undefined && pathToStorageNode.size > 0) { for (const [path, data] of pathToStorageNode) {