From 61d88eda1edaa64a2f7f88f6b5bbf1bbbe7cb8bd Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 15:20:33 -0600 Subject: [PATCH 01/14] StateNetwork: naive implement routingTableInfo --- packages/portalnetwork/src/subprotocols/state/state.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/portalnetwork/src/subprotocols/state/state.ts b/packages/portalnetwork/src/subprotocols/state/state.ts index 33bfde504..2aa9f23f8 100644 --- a/packages/portalnetwork/src/subprotocols/state/state.ts +++ b/packages/portalnetwork/src/subprotocols/state/state.ts @@ -116,6 +116,14 @@ export class StateProtocol extends BaseProtocol { } } + + public routingTableInfo = async () => { + return { + nodeId: this.enr.nodeId, + buckets: [['']], + } + } + public stateStore = async (contentKey: string, content: string) => { this.put(ProtocolId.StateNetwork, contentKey, content) this.logger(`content added for: ${contentKey}`) From 6d50876ca8a57c8cf4893dffcbba4ef2c11d1e9a Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 15:21:23 -0600 Subject: [PATCH 02/14] StateNetwork: naive implement stateLocalContent --- packages/portalnetwork/src/subprotocols/state/state.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/portalnetwork/src/subprotocols/state/state.ts b/packages/portalnetwork/src/subprotocols/state/state.ts index 2aa9f23f8..e7fa093ad 100644 --- a/packages/portalnetwork/src/subprotocols/state/state.ts +++ b/packages/portalnetwork/src/subprotocols/state/state.ts @@ -116,7 +116,6 @@ export class StateProtocol extends BaseProtocol { } } - public routingTableInfo = async () => { return { nodeId: this.enr.nodeId, From 906986d3b6a2512ba4c56f18aa56e156eb7b5945 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 17:59:29 -0600 Subject: [PATCH 03/14] StateNetwork: implement findContent and Offer methods --- packages/portalnetwork/src/subprotocols/state/state.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/portalnetwork/src/subprotocols/state/state.ts b/packages/portalnetwork/src/subprotocols/state/state.ts index e7fa093ad..33bfde504 100644 --- a/packages/portalnetwork/src/subprotocols/state/state.ts +++ b/packages/portalnetwork/src/subprotocols/state/state.ts @@ -116,13 +116,6 @@ export class StateProtocol extends BaseProtocol { } } - public routingTableInfo = async () => { - return { - nodeId: this.enr.nodeId, - buckets: [['']], - } - } - public stateStore = async (contentKey: string, content: string) => { this.put(ProtocolId.StateNetwork, contentKey, content) this.logger(`content added for: ${contentKey}`) From 2c7019b034e0f3bed22361fb5f779e79b9b7ff10 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 04:08:20 -0600 Subject: [PATCH 04/14] import alchemy-sdk --- packages/cli/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cli/package.json b/packages/cli/package.json index 50a30852d..682d9cd72 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -22,11 +22,13 @@ "vitest": "^0.34.1" }, "dependencies": { + "alchemy-sdk": "v3-beta", "@chainsafe/discv5": "5.1.1", "@chainsafe/ssz": "^0.11.1", "@ethereumjs/block": "5.0.0", "@ethereumjs/rlp": "5.0.0", "@ethereumjs/tx": "5.0.0", + "@ethereumjs/trie": "^6.0.0", "@ethereumjs/util": "9.0.0", "@ethereumjs/vm": "7.0.0", "@libp2p/interface-peer-id": "^2.0.1", From 5710e3628d23f060a90e8bbb4968745e32b41bd0 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 04:09:09 -0600 Subject: [PATCH 05/14] debug contentID function --- packages/portalnetwork/src/subprotocols/state/util.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/portalnetwork/src/subprotocols/state/util.ts b/packages/portalnetwork/src/subprotocols/state/util.ts index d49d7776b..00896268f 100644 --- a/packages/portalnetwork/src/subprotocols/state/util.ts +++ b/packages/portalnetwork/src/subprotocols/state/util.ts @@ -92,7 +92,7 @@ export const decodeStateNetworkContentKey = (key: Uint8Array) => { } } -export const getStateNetworkContentId = (opts: Omit) => { +export const getStateNetworkContentId = (opts: Partial) => { if (!opts.address) { throw new Error('address is required') } @@ -101,8 +101,8 @@ export const getStateNetworkContentId = (opts: Omit return sha256(opts.address.toBytes()) } case StateNetworkContentType.ContractStorageTrieProof: { - if (!opts.slot) { - throw new Error('slot value required') + if (opts.slot === undefined) { + throw new Error(`slot value required: ${opts}`) } return Uint8Array.from( bigIntToBytes( From a8b7e52dac296202b9866942477f85bad6fe240e Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 04:11:16 -0600 Subject: [PATCH 06/14] state bridge cli script --- packages/cli/src/stateBridge.ts | 222 ++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 packages/cli/src/stateBridge.ts diff --git a/packages/cli/src/stateBridge.ts b/packages/cli/src/stateBridge.ts new file mode 100644 index 000000000..4199843f9 --- /dev/null +++ b/packages/cli/src/stateBridge.ts @@ -0,0 +1,222 @@ +import jayson from 'jayson/promise/index.js' +import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' +import { Alchemy, Network, TransactionResponse } from 'alchemy-sdk' +import { Trie } from '@ethereumjs/trie' +import { fromHexString, toHexString } from '@chainsafe/ssz' +import { + getStateNetworkContentKey, + getStateNetworkContentId, + StateNetworkContentType, + AccountTrieProofType, + ContractStorageTrieProofType, + ContractStorageTrieKeyType, + ContractByteCodeType, + ContractByteCodeKeyType, +} from 'portalnetwork' +import { Address } from '@ethereumjs/util' +import { AccessList } from '@ethereumjs/tx' + +const config = { + apiKey: workerData.KEY, + network: Network.ETH_MAINNET, + url: `https://eth-mainnet.alchemyapi.io/v2/${workerData.KEY}`, +} +const alchemy = new Alchemy({ + ...config, +}) + +const db = new Map() + +const remember = async (contentKey: Uint8Array, content: Uint8Array) => { + db.set(toHexString(contentKey), content) +} + +const store = async (contentKey: Uint8Array, content: Uint8Array) => { + const client = jayson.Client.http({ + host: workerData.host, + port: workerData.port, + }) + const stored = await client.request('portal_stateStore', [ + toHexString(contentKey), + toHexString(content), + ]) + parentPort?.postMessage(`stored: ${stored.result}`) +} + +const gossip = async (contentKey: Uint8Array, content: Uint8Array) => { + const client = jayson.Client.http({ + host: workerData.host ?? 'localhost', + port: workerData.port ?? 8545, + }) + const stored = await client.request('portal_stateGossip', [ + toHexString(contentKey), + toHexString(content), + ]) + parentPort?.postMessage(`gossiped to: ${stored.result} nodes`) +} + +const to_storage = { + store, + gossip, + remember, +} + +const toStorage = async (contentKey: Uint8Array, content: Uint8Array) => { + const memory: 'store' | 'gossip' | 'remember' = workerData.memory ?? 'remember' + const memoryFn = to_storage[memory] + await memoryFn(contentKey, content) +} + +const generateStateNetworkContent = async () => { + const latest = workerData.latest + const number = latest.result.number + const stateroot = latest.result.stateRoot + const receipts = await alchemy.core.getTransactionReceipts({ blockNumber: number }) + const block = await alchemy.core.getBlockWithTransactions(number) + let totalCSP = 0 + let totalBytes_storage = 0 + const accessLists: AccessList[] = block.transactions + .filter((x) => x.accessList && x.accessList.length > 0) + .map((t) => t.accessList) as AccessList[] + + for (const accessList of accessLists) { + for (const contract of accessList) { + const { storageProof } = await alchemy.core.send('eth_getProof', [ + contract.address, + contract.storageKeys, + number, + ]) + for (const p of storageProof) { + const contentkey = ContractStorageTrieKeyType.serialize({ + address: fromHexString( + contract.address.length % 2 === 0 + ? contract.address + : '0x0' + contract.address.slice(2), + ), + slot: BigInt(p.key), + stateRoot: fromHexString(stateroot), + }) + const data = { + data: + p.value.length % 2 === 0 + ? fromHexString(p.value) + : fromHexString('0x0' + p.value.slice(2)), + witnesses: p.proof.map((x: string) => { + return x.length % 2 === 0 ? fromHexString(x) : fromHexString('0x0' + x.slice(2)) + }), + } + const csp = ContractStorageTrieProofType.serialize(data) + totalBytes_storage += csp.length + totalCSP++ + toStorage(contentkey, csp) + } + } + } + + const tos: any = [] + const froms = receipts.receipts!.map((x) => x.from) + const total = [...new Set([...tos, ...froms])] + const contracts = receipts.receipts!.filter((x) => x.contractAddress) + let totalBytecode = 0 + let totalBytes_code = 0 + if (contracts.length > 0) { + for (const c of contracts) { + const accountProof = await alchemy.core.send('eth_getProof', [c.contractAddress, [], number]) + const accountProofContent = AccountTrieProofType.serialize({ + witnesses: accountProof.accountProof.map(fromHexString), + nonce: BigInt(accountProof.nonce), + balance: BigInt(accountProof.balance), + storageRoot: fromHexString(accountProof.storageHash), + codeHash: fromHexString(accountProof.codeHash), + }) + const accountProofContentKey = getStateNetworkContentKey({ + contentType: StateNetworkContentType.AccountTrieProof, + address: Address.fromString(c.contractAddress), + stateRoot: fromHexString(stateroot), + }) + toStorage(accountProofContentKey, accountProofContent) + const codeHash = accountProof.codeHash + const bytecode = await alchemy.core.getCode(c.contractAddress, number) + const bytecodeContentkey = ContractByteCodeKeyType.serialize({ + address: fromHexString(c.contractAddress), + codeHash: fromHexString(codeHash), + }) + const contractBytecode = ContractByteCodeType.serialize(fromHexString(bytecode)) + totalBytes_code += contractBytecode.length + totalBytecode++ + toStorage(bytecodeContentkey, contractBytecode) + } + } + + const proofs: any[] = [] + + for (const [idx, add] of total.entries()) { + if (add === null) { + continue + } + parentPort?.postMessage(['getProof', idx + 1, total.length].join('/') + '\r') + const proof = await alchemy.core.send('eth_getProof', [add, [], number]) + proofs.push(proof) + } + + const accountsData: any = Object.fromEntries( + proofs.map((x) => { + return [ + x.address, + { + witnesses: x.accountProof.map(fromHexString), + nonce: BigInt(x.nonce), + balance: BigInt(x.balance), + storageRoot: fromHexString(x.storageHash), + codeHash: fromHexString(x.codeHash), + }, + ] + }), + ) + let totalBytes_account = 0 + let totalATP = 0 + + for (const add of Object.keys(accountsData)) { + const content = AccountTrieProofType.serialize(accountsData[add]) + totalBytes_account += content.length + totalATP++ + const contentKey = getStateNetworkContentKey({ + address: Address.fromString(add), + stateRoot: fromHexString(stateroot), + contentType: StateNetworkContentType.AccountTrieProof, + }) + const contentId = getStateNetworkContentId({ + address: Address.fromString(add), + contentType: StateNetworkContentType.AccountTrieProof, + }) + return [add, { contentKey, contentId, content }] + } + + const resultMsg2 = [ + 'results', + ...Object.entries({ + hash: latest.result.hash, + stateroot, + accountTrieProofs: totalATP, + accountTrieProofs_bytes: `total: ${totalBytes_account} -- avg: ${ + totalBytes_account / totalATP + }`, + contractStorageProofs: totalCSP, + contractStorageProofs_bytes: `total: ${totalBytes_storage} -- avg: ${ + totalBytes_storage / totalCSP + }`, + bytecode: totalBytes_code, + bytecode_bytes: `total: ${totalBytes_code}, avg: ${totalBytes_code / totalBytecode}`, + total_contents: totalATP + totalCSP + totalBytecode, + total_bytes: totalBytes_account + totalBytes_storage + totalBytes_code, + }), + ].join('/') + + parentPort?.postMessage(resultMsg2 + '\r') + + return number +} + +const blockNum = await generateStateNetworkContent() +parentPort?.postMessage(`Block ${blockNum} processed.`) +process.exit(0) From 12a5d6ebd353e142a2ca890fa5c5843e2b86a199 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 04:11:28 -0600 Subject: [PATCH 07/14] state bridge worker threads script --- packages/cli/scripts/bridgeThread.ts | 189 +++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 packages/cli/scripts/bridgeThread.ts diff --git a/packages/cli/scripts/bridgeThread.ts b/packages/cli/scripts/bridgeThread.ts new file mode 100644 index 000000000..c84657c92 --- /dev/null +++ b/packages/cli/scripts/bridgeThread.ts @@ -0,0 +1,189 @@ +import { hideBin } from 'yargs/helpers' +import yargs from 'yargs' +import { Alchemy, Network } from 'alchemy-sdk' +import EventEmitter from 'events' +import jayson from 'jayson/promise/index.js' +import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' +import { execSync } from 'child_process' + +const bridgeThread = async () => { + const args = await yargs(hideBin(process.argv)) + .option('KEY', { + describe: 'alchemy api key', + string: true, + default: 'JY46MOVpzcwZYEln86fa44MHIks4OoSl', + optional: true, + }) + .option('devnet', { + describe: 'running portal state network devnet', + boolean: true, + default: false, + optional: true, + }) + .option('numNodes', { + description: 'number of nodes in devnet', + number: true, + default: 1, + optional: true, + }) + .option('host', { + description: 'ip address of devnet', + string: true, + optional: true, + }) + .option('port', { + description: 'starting port number', + number: true, + default: 8545, + optional: true, + }) + .strict().argv + + const alchemyHTTP = jayson.Client.https({ + host: 'eth-mainnet.g.alchemy.com', + path: '/v2/JY46MOVpzcwZYEln86fa44MHIks4OoSl', + }) + + const cmd = 'hostname -I' + const pubIp = execSync(cmd).toString().split(' ') + args.host = args.host ?? pubIp[0] + + const config = { + apiKey: 'JY46MOVpzcwZYEln86fa44MHIks4OoSl', + network: Network.ETH_MAINNET, + url: 'https://eth-mainnet.alchemyapi.io/v2/JY46MOVpzcwZYEln86fa44MHIks4OoSl', + } + const alchemy = new Alchemy({ + ...config, + }) + + const processing: Set = new Set() + const processed: Set = new Set() + const started: Map = new Map() + const progress: Map = new Map() + const results: Map = new Map() + + const getMissed = new EventEmitter() + + const numbers: boolean[] = [] + let starting: string + const begin = process.hrtime() + + const memory = !args.devnet ? 'remember' : args.numNodes > 2 ? 'gossip' : 'store' + const ports = Array.from({ length: args.numNodes }, (_, i) => args.port + i) + let current = 0 + const currentPort = () => { + switch (memory) { + case 'remember': + return undefined + case 'store': + return ports[0] + case 'gossip': + const port = ports[current] + current++ + if (current >= ports.length) { + current = 0 + } + return port + } + } + + const workerTask = async (blockTag: string | number = 'latest') => { + const start = process.hrtime() + const latest = await alchemyHTTP.request('eth_getBlockByNumber', [blockTag, true]) + if (progress.has(latest.result.number)) { + return + } + progress.set(latest.result.number, ['']) + results.set(latest.result.number, ['']) + started.set(latest.result.number, [start[0] - begin[0], start[1] - begin[1]]) + const idx = parseInt(latest.result.number, 16) - parseInt(starting, 16) + if (!starting) { + numbers[0] = true + starting = latest.result.number + } else if (!numbers[idx]) { + numbers[idx] = true + if (!numbers[idx - 1]) { + process.stdout.cursorTo(0, 7) + console.log(`getting missed block`, idx - 1 + parseInt(starting, 16)) + getMissed.emit('getMissed', idx - 1 + parseInt(starting, 16)) + } + } + processing.add(latest.result.number) + const worker = new Worker('./dist/stateBridge.js', { + workerData: { latest, KEY: args.KEY, host: args.host, port: currentPort(), memory }, + }) + worker.on('message', async (msg) => { + if (msg.startsWith('getProof')) { + const p = msg.split('/') + const percent = (p[1] / p[2]) * 100 + progress.set(latest.result.number, [ + `|${'/'.repeat(Math.floor(percent / 4))}${'_'.repeat(25 - Math.floor(percent / 4))}|`, + percent.toFixed(2), + `% `, + ]) + } else if (msg.startsWith('results')) { + const r = msg.split('/') + results.set(latest.result.number, r.slice(1)) + } else { + } + let row = 6 + for (let i = started.size - Math.min(started.size, 4); i < started.size; i++) { + let key = [...started.keys()][i] + if (!key) { + break + } + process.stdout.cursorTo(0, row) + process.stdout.clearScreenDown() + process.stdout.cursorTo(0, row) + console.log('\n') + row++ + process.stdout.cursorTo(0, row) + process.stdout.clearScreenDown() + process.stdout.cursorTo(0, row) + console.log(BigInt(key), ...progress.get(key)!) + row++ + for (const line of results.get(key)!) { + process.stdout.cursorTo(0, row) + process.stdout.clearScreenDown() + process.stdout.cursorTo(0, row) + console.log(' '.repeat(BigInt(key).toString().length - 3), line) + row++ + } + } + }) + worker.on('error', (err) => console.error(err.message)) + worker.on('exit', (code) => { + const finished = process.hrtime(start) + processing.delete(latest.result.number) + processed.add(latest.result.number) + progress.set(latest.result.number, [`Finished in`, finished[0], 's']) + }) + } + + if (isMainThread) { + process.stdout.cursorTo(0, 0) + process.stdout.clearScreenDown() + console.log('-'.repeat(process.stdout.columns)) + console.log(''.repeat(process.stdout.columns)) + console.log('State Network Content Bridge') + console.log(''.repeat(process.stdout.columns)) + console.log('-'.repeat(process.stdout.columns)) + workerTask() + getMissed.on('getMissed', (idx) => { + workerTask('0x' + parseInt(idx).toString(16)) + }) + setInterval(() => { + workerTask() + }, 12000) + process.on('SIGINT', () => { + console.log('\nshutting down...') + process.exit(0) + }) + } else { + const data = workerData + parentPort?.postMessage(`You said \"${data}\".`) + } +} + +bridgeThread() From 16096e8a99d0ae307a383c388b516207fce69f58 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Wed, 25 Oct 2023 04:12:30 -0600 Subject: [PATCH 08/14] commit packagelock --- package-lock.json | 176 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index e98b4d932..099b6a02d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8635,6 +8635,27 @@ "ajv": "^6.9.1" } }, + "node_modules/alchemy-sdk": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/alchemy-sdk/-/alchemy-sdk-2.10.1.tgz", + "integrity": "sha512-zV6rBS2K0H3ickE28N7YiPvKPP9EQV+ZAiv9Zi3+aSzhcm0D1bkK+OS/+Tc7mU6EflSpZcDNC1fsLWlRqJOX4Q==", + "dependencies": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/providers": "^5.7.0", + "@ethersproject/units": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "axios": "^0.26.1", + "sturdy-websocket": "^0.2.1", + "websocket": "^1.0.34" + } + }, "node_modules/ansi-html-community": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz", @@ -8864,6 +8885,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, "node_modules/babel-loader": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.3.0.tgz", @@ -9488,6 +9517,18 @@ "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", "dev": true }, + "node_modules/bufferutil": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", + "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/bufio": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/bufio/-/bufio-1.0.7.tgz", @@ -10546,6 +10587,15 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -11307,6 +11357,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/es6-error": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", @@ -11314,6 +11378,16 @@ "dev": true, "optional": true }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, "node_modules/es6-object-assign": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", @@ -11333,6 +11407,15 @@ "es6-promise": "^4.0.3" } }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, "node_modules/esbuild": { "version": "0.18.20", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz", @@ -12100,6 +12183,19 @@ } ] }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, "node_modules/extract-zip": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", @@ -12428,7 +12524,6 @@ "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "dev": true, "funding": [ { "type": "individual", @@ -14073,6 +14168,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, "node_modules/is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -15321,6 +15421,11 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, "node_modules/no-case": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", @@ -18211,6 +18316,11 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/sturdy-websocket": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/sturdy-websocket/-/sturdy-websocket-0.2.1.tgz", + "integrity": "sha512-NnzSOEKyv4I83qbuKw9ROtJrrT6Z/Xt7I0HiP/e6H6GnpeTDvzwGIGeJ8slai+VwODSHQDooW2CAilJwT9SpRg==" + }, "node_modules/style-loader": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.3.tgz", @@ -18830,6 +18940,11 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -18944,6 +19059,14 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, + "node_modules/typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dependencies": { + "is-typedarray": "^1.0.0" + } + }, "node_modules/typedoc": { "version": "0.24.8", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.8.tgz", @@ -19317,6 +19440,18 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -19964,6 +20099,22 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/websocket": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", + "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "dependencies": { + "bufferutil": "^4.0.1", + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "typedarray-to-buffer": "^3.1.5", + "utf-8-validate": "^5.0.2", + "yaeti": "^0.0.6" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/websocket-as-promised": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/websocket-as-promised/-/websocket-as-promised-2.0.1.tgz", @@ -20001,6 +20152,19 @@ "node": ">=0.8.0" } }, + "node_modules/websocket/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/websocket/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", @@ -20214,6 +20378,14 @@ "node": ">=10" } }, + "node_modules/yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==", + "engines": { + "node": ">=0.10.32" + } + }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -20417,6 +20589,7 @@ "@chainsafe/ssz": "^0.11.1", "@ethereumjs/block": "5.0.0", "@ethereumjs/rlp": "5.0.0", + "@ethereumjs/trie": "^6.0.0", "@ethereumjs/tx": "5.0.0", "@ethereumjs/util": "9.0.0", "@ethereumjs/vm": "7.0.0", @@ -20428,6 +20601,7 @@ "@lodestar/params": "^1.9.2", "@lodestar/types": "^1.9.2", "@multiformats/multiaddr": "^11.0.0", + "alchemy-sdk": "v3-beta", "debug": "^4.3.3", "jayson": "^4.0.0", "level": "^8.0.0", From 37c901a788a8006615101fd42a84faf43f551c6b Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:31:48 -0400 Subject: [PATCH 09/14] package.json cleanup --- package-lock.json | 114 +++++++++---------- packages/cli/package.json | 13 ++- packages/cli/{src => scripts}/stateBridge.ts | 0 packages/portalnetwork/package.json | 2 +- packages/proxy/package.json | 2 +- 5 files changed, 69 insertions(+), 62 deletions(-) rename packages/cli/{src => scripts}/stateBridge.ts (100%) diff --git a/package-lock.json b/package-lock.json index 099b6a02d..b23f5569e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8639,6 +8639,8 @@ "version": "2.10.1", "resolved": "https://registry.npmjs.org/alchemy-sdk/-/alchemy-sdk-2.10.1.tgz", "integrity": "sha512-zV6rBS2K0H3ickE28N7YiPvKPP9EQV+ZAiv9Zi3+aSzhcm0D1bkK+OS/+Tc7mU6EflSpZcDNC1fsLWlRqJOX4Q==", + "optional": true, + "peer": true, "dependencies": { "@ethersproject/abi": "^5.7.0", "@ethersproject/abstract-provider": "^5.7.0", @@ -8889,6 +8891,8 @@ "version": "0.26.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "optional": true, + "peer": true, "dependencies": { "follow-redirects": "^1.14.8" } @@ -9522,6 +9526,8 @@ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==", "hasInstallScript": true, + "optional": true, + "peer": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -10591,6 +10597,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "optional": true, + "peer": true, "dependencies": { "es5-ext": "^0.10.50", "type": "^1.0.1" @@ -11362,6 +11370,8 @@ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", "hasInstallScript": true, + "optional": true, + "peer": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", @@ -11382,6 +11392,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "optional": true, + "peer": true, "dependencies": { "d": "1", "es5-ext": "^0.10.35", @@ -11411,6 +11423,8 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "optional": true, + "peer": true, "dependencies": { "d": "^1.0.1", "ext": "^1.1.2" @@ -12187,6 +12201,8 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "optional": true, + "peer": true, "dependencies": { "type": "^2.7.2" } @@ -12194,7 +12210,9 @@ "node_modules/ext/node_modules/type": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", - "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==", + "optional": true, + "peer": true }, "node_modules/extract-zip": { "version": "1.7.0", @@ -12524,6 +12542,7 @@ "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "devOptional": true, "funding": [ { "type": "individual", @@ -14171,7 +14190,9 @@ "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", + "optional": true, + "peer": true }, "node_modules/is-weakref": { "version": "1.0.2", @@ -15424,7 +15445,9 @@ "node_modules/next-tick": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", + "optional": true, + "peer": true }, "node_modules/no-case": { "version": "3.0.4", @@ -16434,11 +16457,10 @@ } }, "node_modules/prettier": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz", - "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -18319,7 +18341,9 @@ "node_modules/sturdy-websocket": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/sturdy-websocket/-/sturdy-websocket-0.2.1.tgz", - "integrity": "sha512-NnzSOEKyv4I83qbuKw9ROtJrrT6Z/Xt7I0HiP/e6H6GnpeTDvzwGIGeJ8slai+VwODSHQDooW2CAilJwT9SpRg==" + "integrity": "sha512-NnzSOEKyv4I83qbuKw9ROtJrrT6Z/Xt7I0HiP/e6H6GnpeTDvzwGIGeJ8slai+VwODSHQDooW2CAilJwT9SpRg==", + "optional": true, + "peer": true }, "node_modules/style-loader": { "version": "3.3.3", @@ -18943,7 +18967,9 @@ "node_modules/type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", + "optional": true, + "peer": true }, "node_modules/type-check": { "version": "0.4.0", @@ -19063,6 +19089,8 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "optional": true, + "peer": true, "dependencies": { "is-typedarray": "^1.0.0" } @@ -19445,6 +19473,8 @@ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", "hasInstallScript": true, + "optional": true, + "peer": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -20103,6 +20133,8 @@ "version": "1.0.34", "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "optional": true, + "peer": true, "dependencies": { "bufferutil": "^4.0.1", "debug": "^2.2.0", @@ -20156,6 +20188,8 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "peer": true, "dependencies": { "ms": "2.0.0" } @@ -20163,7 +20197,9 @@ "node_modules/websocket/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "optional": true, + "peer": true }, "node_modules/whatwg-url": { "version": "5.0.0", @@ -20382,6 +20418,8 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==", + "optional": true, + "peer": true, "engines": { "node": ">=0.10.32" } @@ -20601,7 +20639,6 @@ "@lodestar/params": "^1.9.2", "@lodestar/types": "^1.9.2", "@multiformats/multiaddr": "^11.0.0", - "alchemy-sdk": "v3-beta", "debug": "^4.3.3", "jayson": "^4.0.0", "level": "^8.0.0", @@ -20616,7 +20653,7 @@ "@types/yargs": "^17.0.7", "eslint": "^8.6.0", "nodemon": "^2.0.19", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "ts-node": "^10.4.0", "tslib": "^2.3.1", "tsx": "^3.12.7", @@ -20625,21 +20662,14 @@ }, "engines": { "node": "^18" - } - }, - "packages/cli/node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" }, - "engines": { - "node": ">=10.13.0" + "peerDependencies": { + "alchemy-sdk": "v3-beta" }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" + "peerDependenciesMeta": { + "alchemy-sdk": { + "optional": true + } } }, "packages/client": { @@ -20727,7 +20757,7 @@ "@vitest/ui": "^0.34.1", "c8": "^7.12.0", "eslint": "^8.6.0", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "testdouble": "^3.16.3", "ts-node": "^10.4.0", "tslib": "^2.3.1", @@ -20740,21 +20770,6 @@ "node": ">=18" } }, - "packages/portalnetwork/node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "packages/proxy": { "dependencies": { "debug": "^4.3.3", @@ -20766,26 +20781,11 @@ "@types/ws": "^7.4.7", "@types/yargs": "^17.0.8", "eslint": "^8.6.0", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "ts-node": "^10.2.1", "typescript": "^4.4.3" } }, - "packages/proxy/node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "packages/ui": { "version": "10.38.2", "dependencies": { diff --git a/packages/cli/package.json b/packages/cli/package.json index 682d9cd72..cddd3f5f5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -14,7 +14,7 @@ "@types/yargs": "^17.0.7", "eslint": "^8.6.0", "nodemon": "^2.0.19", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "ts-node": "^10.4.0", "tslib": "^2.3.1", "tsx": "^3.12.7", @@ -22,7 +22,6 @@ "vitest": "^0.34.1" }, "dependencies": { - "alchemy-sdk": "v3-beta", "@chainsafe/discv5": "5.1.1", "@chainsafe/ssz": "^0.11.1", "@ethereumjs/block": "5.0.0", @@ -46,6 +45,14 @@ "@lodestar/params": "^1.9.2", "@lodestar/types": "^1.9.2" }, + "peerDependencies": { + "alchemy-sdk": "v3-beta" + }, + "peerDependenciesMeta": { + "alchemy-sdk": { + "optional": true + } + }, "scripts": { "start": "ts-node --esm src/index.ts", "server:dev": "tsx watch src/server/server.ts", @@ -65,4 +72,4 @@ "../portalnetwork/dist" ] } -} +} \ No newline at end of file diff --git a/packages/cli/src/stateBridge.ts b/packages/cli/scripts/stateBridge.ts similarity index 100% rename from packages/cli/src/stateBridge.ts rename to packages/cli/scripts/stateBridge.ts diff --git a/packages/portalnetwork/package.json b/packages/portalnetwork/package.json index d338b6bbc..5fd7db4dc 100644 --- a/packages/portalnetwork/package.json +++ b/packages/portalnetwork/package.json @@ -63,7 +63,7 @@ "@vitest/ui": "^0.34.1", "c8": "^7.12.0", "eslint": "^8.6.0", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "testdouble": "^3.16.3", "ts-node": "^10.4.0", "tslib": "^2.3.1", diff --git a/packages/proxy/package.json b/packages/proxy/package.json index 1d349449a..349209ace 100644 --- a/packages/proxy/package.json +++ b/packages/proxy/package.json @@ -5,7 +5,7 @@ "@types/ws": "^7.4.7", "@types/yargs": "^17.0.8", "eslint": "^8.6.0", - "prettier": "^2.5.1", + "prettier": "^3.0.2", "ts-node": "^10.2.1", "typescript": "^4.4.3" }, From d55414f3ec07ad31e8287d8ec690866a6acb44d5 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:15:03 -0400 Subject: [PATCH 10/14] Move bridge back for now --- packages/cli/src/stateBridge.ts | 222 ++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 packages/cli/src/stateBridge.ts diff --git a/packages/cli/src/stateBridge.ts b/packages/cli/src/stateBridge.ts new file mode 100644 index 000000000..4199843f9 --- /dev/null +++ b/packages/cli/src/stateBridge.ts @@ -0,0 +1,222 @@ +import jayson from 'jayson/promise/index.js' +import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' +import { Alchemy, Network, TransactionResponse } from 'alchemy-sdk' +import { Trie } from '@ethereumjs/trie' +import { fromHexString, toHexString } from '@chainsafe/ssz' +import { + getStateNetworkContentKey, + getStateNetworkContentId, + StateNetworkContentType, + AccountTrieProofType, + ContractStorageTrieProofType, + ContractStorageTrieKeyType, + ContractByteCodeType, + ContractByteCodeKeyType, +} from 'portalnetwork' +import { Address } from '@ethereumjs/util' +import { AccessList } from '@ethereumjs/tx' + +const config = { + apiKey: workerData.KEY, + network: Network.ETH_MAINNET, + url: `https://eth-mainnet.alchemyapi.io/v2/${workerData.KEY}`, +} +const alchemy = new Alchemy({ + ...config, +}) + +const db = new Map() + +const remember = async (contentKey: Uint8Array, content: Uint8Array) => { + db.set(toHexString(contentKey), content) +} + +const store = async (contentKey: Uint8Array, content: Uint8Array) => { + const client = jayson.Client.http({ + host: workerData.host, + port: workerData.port, + }) + const stored = await client.request('portal_stateStore', [ + toHexString(contentKey), + toHexString(content), + ]) + parentPort?.postMessage(`stored: ${stored.result}`) +} + +const gossip = async (contentKey: Uint8Array, content: Uint8Array) => { + const client = jayson.Client.http({ + host: workerData.host ?? 'localhost', + port: workerData.port ?? 8545, + }) + const stored = await client.request('portal_stateGossip', [ + toHexString(contentKey), + toHexString(content), + ]) + parentPort?.postMessage(`gossiped to: ${stored.result} nodes`) +} + +const to_storage = { + store, + gossip, + remember, +} + +const toStorage = async (contentKey: Uint8Array, content: Uint8Array) => { + const memory: 'store' | 'gossip' | 'remember' = workerData.memory ?? 'remember' + const memoryFn = to_storage[memory] + await memoryFn(contentKey, content) +} + +const generateStateNetworkContent = async () => { + const latest = workerData.latest + const number = latest.result.number + const stateroot = latest.result.stateRoot + const receipts = await alchemy.core.getTransactionReceipts({ blockNumber: number }) + const block = await alchemy.core.getBlockWithTransactions(number) + let totalCSP = 0 + let totalBytes_storage = 0 + const accessLists: AccessList[] = block.transactions + .filter((x) => x.accessList && x.accessList.length > 0) + .map((t) => t.accessList) as AccessList[] + + for (const accessList of accessLists) { + for (const contract of accessList) { + const { storageProof } = await alchemy.core.send('eth_getProof', [ + contract.address, + contract.storageKeys, + number, + ]) + for (const p of storageProof) { + const contentkey = ContractStorageTrieKeyType.serialize({ + address: fromHexString( + contract.address.length % 2 === 0 + ? contract.address + : '0x0' + contract.address.slice(2), + ), + slot: BigInt(p.key), + stateRoot: fromHexString(stateroot), + }) + const data = { + data: + p.value.length % 2 === 0 + ? fromHexString(p.value) + : fromHexString('0x0' + p.value.slice(2)), + witnesses: p.proof.map((x: string) => { + return x.length % 2 === 0 ? fromHexString(x) : fromHexString('0x0' + x.slice(2)) + }), + } + const csp = ContractStorageTrieProofType.serialize(data) + totalBytes_storage += csp.length + totalCSP++ + toStorage(contentkey, csp) + } + } + } + + const tos: any = [] + const froms = receipts.receipts!.map((x) => x.from) + const total = [...new Set([...tos, ...froms])] + const contracts = receipts.receipts!.filter((x) => x.contractAddress) + let totalBytecode = 0 + let totalBytes_code = 0 + if (contracts.length > 0) { + for (const c of contracts) { + const accountProof = await alchemy.core.send('eth_getProof', [c.contractAddress, [], number]) + const accountProofContent = AccountTrieProofType.serialize({ + witnesses: accountProof.accountProof.map(fromHexString), + nonce: BigInt(accountProof.nonce), + balance: BigInt(accountProof.balance), + storageRoot: fromHexString(accountProof.storageHash), + codeHash: fromHexString(accountProof.codeHash), + }) + const accountProofContentKey = getStateNetworkContentKey({ + contentType: StateNetworkContentType.AccountTrieProof, + address: Address.fromString(c.contractAddress), + stateRoot: fromHexString(stateroot), + }) + toStorage(accountProofContentKey, accountProofContent) + const codeHash = accountProof.codeHash + const bytecode = await alchemy.core.getCode(c.contractAddress, number) + const bytecodeContentkey = ContractByteCodeKeyType.serialize({ + address: fromHexString(c.contractAddress), + codeHash: fromHexString(codeHash), + }) + const contractBytecode = ContractByteCodeType.serialize(fromHexString(bytecode)) + totalBytes_code += contractBytecode.length + totalBytecode++ + toStorage(bytecodeContentkey, contractBytecode) + } + } + + const proofs: any[] = [] + + for (const [idx, add] of total.entries()) { + if (add === null) { + continue + } + parentPort?.postMessage(['getProof', idx + 1, total.length].join('/') + '\r') + const proof = await alchemy.core.send('eth_getProof', [add, [], number]) + proofs.push(proof) + } + + const accountsData: any = Object.fromEntries( + proofs.map((x) => { + return [ + x.address, + { + witnesses: x.accountProof.map(fromHexString), + nonce: BigInt(x.nonce), + balance: BigInt(x.balance), + storageRoot: fromHexString(x.storageHash), + codeHash: fromHexString(x.codeHash), + }, + ] + }), + ) + let totalBytes_account = 0 + let totalATP = 0 + + for (const add of Object.keys(accountsData)) { + const content = AccountTrieProofType.serialize(accountsData[add]) + totalBytes_account += content.length + totalATP++ + const contentKey = getStateNetworkContentKey({ + address: Address.fromString(add), + stateRoot: fromHexString(stateroot), + contentType: StateNetworkContentType.AccountTrieProof, + }) + const contentId = getStateNetworkContentId({ + address: Address.fromString(add), + contentType: StateNetworkContentType.AccountTrieProof, + }) + return [add, { contentKey, contentId, content }] + } + + const resultMsg2 = [ + 'results', + ...Object.entries({ + hash: latest.result.hash, + stateroot, + accountTrieProofs: totalATP, + accountTrieProofs_bytes: `total: ${totalBytes_account} -- avg: ${ + totalBytes_account / totalATP + }`, + contractStorageProofs: totalCSP, + contractStorageProofs_bytes: `total: ${totalBytes_storage} -- avg: ${ + totalBytes_storage / totalCSP + }`, + bytecode: totalBytes_code, + bytecode_bytes: `total: ${totalBytes_code}, avg: ${totalBytes_code / totalBytecode}`, + total_contents: totalATP + totalCSP + totalBytecode, + total_bytes: totalBytes_account + totalBytes_storage + totalBytes_code, + }), + ].join('/') + + parentPort?.postMessage(resultMsg2 + '\r') + + return number +} + +const blockNum = await generateStateNetworkContent() +parentPort?.postMessage(`Block ${blockNum} processed.`) +process.exit(0) From 6f5986257ef2599d1e812e931281183a47dc5bbd Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:06:05 -0400 Subject: [PATCH 11/14] Remove dup stateBridge --- packages/cli/scripts/stateBridge.ts | 222 ---------------------------- 1 file changed, 222 deletions(-) delete mode 100644 packages/cli/scripts/stateBridge.ts diff --git a/packages/cli/scripts/stateBridge.ts b/packages/cli/scripts/stateBridge.ts deleted file mode 100644 index 4199843f9..000000000 --- a/packages/cli/scripts/stateBridge.ts +++ /dev/null @@ -1,222 +0,0 @@ -import jayson from 'jayson/promise/index.js' -import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' -import { Alchemy, Network, TransactionResponse } from 'alchemy-sdk' -import { Trie } from '@ethereumjs/trie' -import { fromHexString, toHexString } from '@chainsafe/ssz' -import { - getStateNetworkContentKey, - getStateNetworkContentId, - StateNetworkContentType, - AccountTrieProofType, - ContractStorageTrieProofType, - ContractStorageTrieKeyType, - ContractByteCodeType, - ContractByteCodeKeyType, -} from 'portalnetwork' -import { Address } from '@ethereumjs/util' -import { AccessList } from '@ethereumjs/tx' - -const config = { - apiKey: workerData.KEY, - network: Network.ETH_MAINNET, - url: `https://eth-mainnet.alchemyapi.io/v2/${workerData.KEY}`, -} -const alchemy = new Alchemy({ - ...config, -}) - -const db = new Map() - -const remember = async (contentKey: Uint8Array, content: Uint8Array) => { - db.set(toHexString(contentKey), content) -} - -const store = async (contentKey: Uint8Array, content: Uint8Array) => { - const client = jayson.Client.http({ - host: workerData.host, - port: workerData.port, - }) - const stored = await client.request('portal_stateStore', [ - toHexString(contentKey), - toHexString(content), - ]) - parentPort?.postMessage(`stored: ${stored.result}`) -} - -const gossip = async (contentKey: Uint8Array, content: Uint8Array) => { - const client = jayson.Client.http({ - host: workerData.host ?? 'localhost', - port: workerData.port ?? 8545, - }) - const stored = await client.request('portal_stateGossip', [ - toHexString(contentKey), - toHexString(content), - ]) - parentPort?.postMessage(`gossiped to: ${stored.result} nodes`) -} - -const to_storage = { - store, - gossip, - remember, -} - -const toStorage = async (contentKey: Uint8Array, content: Uint8Array) => { - const memory: 'store' | 'gossip' | 'remember' = workerData.memory ?? 'remember' - const memoryFn = to_storage[memory] - await memoryFn(contentKey, content) -} - -const generateStateNetworkContent = async () => { - const latest = workerData.latest - const number = latest.result.number - const stateroot = latest.result.stateRoot - const receipts = await alchemy.core.getTransactionReceipts({ blockNumber: number }) - const block = await alchemy.core.getBlockWithTransactions(number) - let totalCSP = 0 - let totalBytes_storage = 0 - const accessLists: AccessList[] = block.transactions - .filter((x) => x.accessList && x.accessList.length > 0) - .map((t) => t.accessList) as AccessList[] - - for (const accessList of accessLists) { - for (const contract of accessList) { - const { storageProof } = await alchemy.core.send('eth_getProof', [ - contract.address, - contract.storageKeys, - number, - ]) - for (const p of storageProof) { - const contentkey = ContractStorageTrieKeyType.serialize({ - address: fromHexString( - contract.address.length % 2 === 0 - ? contract.address - : '0x0' + contract.address.slice(2), - ), - slot: BigInt(p.key), - stateRoot: fromHexString(stateroot), - }) - const data = { - data: - p.value.length % 2 === 0 - ? fromHexString(p.value) - : fromHexString('0x0' + p.value.slice(2)), - witnesses: p.proof.map((x: string) => { - return x.length % 2 === 0 ? fromHexString(x) : fromHexString('0x0' + x.slice(2)) - }), - } - const csp = ContractStorageTrieProofType.serialize(data) - totalBytes_storage += csp.length - totalCSP++ - toStorage(contentkey, csp) - } - } - } - - const tos: any = [] - const froms = receipts.receipts!.map((x) => x.from) - const total = [...new Set([...tos, ...froms])] - const contracts = receipts.receipts!.filter((x) => x.contractAddress) - let totalBytecode = 0 - let totalBytes_code = 0 - if (contracts.length > 0) { - for (const c of contracts) { - const accountProof = await alchemy.core.send('eth_getProof', [c.contractAddress, [], number]) - const accountProofContent = AccountTrieProofType.serialize({ - witnesses: accountProof.accountProof.map(fromHexString), - nonce: BigInt(accountProof.nonce), - balance: BigInt(accountProof.balance), - storageRoot: fromHexString(accountProof.storageHash), - codeHash: fromHexString(accountProof.codeHash), - }) - const accountProofContentKey = getStateNetworkContentKey({ - contentType: StateNetworkContentType.AccountTrieProof, - address: Address.fromString(c.contractAddress), - stateRoot: fromHexString(stateroot), - }) - toStorage(accountProofContentKey, accountProofContent) - const codeHash = accountProof.codeHash - const bytecode = await alchemy.core.getCode(c.contractAddress, number) - const bytecodeContentkey = ContractByteCodeKeyType.serialize({ - address: fromHexString(c.contractAddress), - codeHash: fromHexString(codeHash), - }) - const contractBytecode = ContractByteCodeType.serialize(fromHexString(bytecode)) - totalBytes_code += contractBytecode.length - totalBytecode++ - toStorage(bytecodeContentkey, contractBytecode) - } - } - - const proofs: any[] = [] - - for (const [idx, add] of total.entries()) { - if (add === null) { - continue - } - parentPort?.postMessage(['getProof', idx + 1, total.length].join('/') + '\r') - const proof = await alchemy.core.send('eth_getProof', [add, [], number]) - proofs.push(proof) - } - - const accountsData: any = Object.fromEntries( - proofs.map((x) => { - return [ - x.address, - { - witnesses: x.accountProof.map(fromHexString), - nonce: BigInt(x.nonce), - balance: BigInt(x.balance), - storageRoot: fromHexString(x.storageHash), - codeHash: fromHexString(x.codeHash), - }, - ] - }), - ) - let totalBytes_account = 0 - let totalATP = 0 - - for (const add of Object.keys(accountsData)) { - const content = AccountTrieProofType.serialize(accountsData[add]) - totalBytes_account += content.length - totalATP++ - const contentKey = getStateNetworkContentKey({ - address: Address.fromString(add), - stateRoot: fromHexString(stateroot), - contentType: StateNetworkContentType.AccountTrieProof, - }) - const contentId = getStateNetworkContentId({ - address: Address.fromString(add), - contentType: StateNetworkContentType.AccountTrieProof, - }) - return [add, { contentKey, contentId, content }] - } - - const resultMsg2 = [ - 'results', - ...Object.entries({ - hash: latest.result.hash, - stateroot, - accountTrieProofs: totalATP, - accountTrieProofs_bytes: `total: ${totalBytes_account} -- avg: ${ - totalBytes_account / totalATP - }`, - contractStorageProofs: totalCSP, - contractStorageProofs_bytes: `total: ${totalBytes_storage} -- avg: ${ - totalBytes_storage / totalCSP - }`, - bytecode: totalBytes_code, - bytecode_bytes: `total: ${totalBytes_code}, avg: ${totalBytes_code / totalBytecode}`, - total_contents: totalATP + totalCSP + totalBytecode, - total_bytes: totalBytes_account + totalBytes_storage + totalBytes_code, - }), - ].join('/') - - parentPort?.postMessage(resultMsg2 + '\r') - - return number -} - -const blockNum = await generateStateNetworkContent() -parentPort?.postMessage(`Block ${blockNum} processed.`) -process.exit(0) From 6f506db0cbf1c5d51a9481870cbc41676a6644c5 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:15:05 -0400 Subject: [PATCH 12/14] Move bridge script back to scripts --- packages/cli/scripts/bridgeThread.ts | 5 ++++- packages/cli/{src => scripts}/stateBridge.ts | 0 2 files changed, 4 insertions(+), 1 deletion(-) rename packages/cli/{src => scripts}/stateBridge.ts (100%) diff --git a/packages/cli/scripts/bridgeThread.ts b/packages/cli/scripts/bridgeThread.ts index c84657c92..be593b7e5 100644 --- a/packages/cli/scripts/bridgeThread.ts +++ b/packages/cli/scripts/bridgeThread.ts @@ -5,6 +5,7 @@ import EventEmitter from 'events' import jayson from 'jayson/promise/index.js' import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' import { execSync } from 'child_process' +import path from 'path' const bridgeThread = async () => { const args = await yargs(hideBin(process.argv)) @@ -110,7 +111,9 @@ const bridgeThread = async () => { } } processing.add(latest.result.number) - const worker = new Worker('./dist/stateBridge.js', { + const worker = new Worker('./scripts/stateBridge.ts', { + execArgv: ["--loader", "ts-node/esm"], + workerData: { latest, KEY: args.KEY, host: args.host, port: currentPort(), memory }, }) worker.on('message', async (msg) => { diff --git a/packages/cli/src/stateBridge.ts b/packages/cli/scripts/stateBridge.ts similarity index 100% rename from packages/cli/src/stateBridge.ts rename to packages/cli/scripts/stateBridge.ts From b668de372b2b600cf63e33b4abf4d21e2f4fec90 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:37:38 -0400 Subject: [PATCH 13/14] Clean up imports --- packages/cli/scripts/bridgeThread.ts | 1 - packages/cli/scripts/stateBridge.ts | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/cli/scripts/bridgeThread.ts b/packages/cli/scripts/bridgeThread.ts index be593b7e5..d646ce092 100644 --- a/packages/cli/scripts/bridgeThread.ts +++ b/packages/cli/scripts/bridgeThread.ts @@ -5,7 +5,6 @@ import EventEmitter from 'events' import jayson from 'jayson/promise/index.js' import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' import { execSync } from 'child_process' -import path from 'path' const bridgeThread = async () => { const args = await yargs(hideBin(process.argv)) diff --git a/packages/cli/scripts/stateBridge.ts b/packages/cli/scripts/stateBridge.ts index 4199843f9..8140893c5 100644 --- a/packages/cli/scripts/stateBridge.ts +++ b/packages/cli/scripts/stateBridge.ts @@ -1,7 +1,6 @@ import jayson from 'jayson/promise/index.js' -import { Worker, isMainThread, parentPort, workerData } from 'worker_threads' -import { Alchemy, Network, TransactionResponse } from 'alchemy-sdk' -import { Trie } from '@ethereumjs/trie' +import { parentPort, workerData } from 'worker_threads' +import { Alchemy, Network } from 'alchemy-sdk' import { fromHexString, toHexString } from '@chainsafe/ssz' import { getStateNetworkContentKey, From b39db822acecfa93df8c309b85db3078be7cc236 Mon Sep 17 00:00:00 2001 From: acolytec3 <17355484+acolytec3@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:18:33 -0400 Subject: [PATCH 14/14] Switch alchemy APi key to environmental variable --- packages/cli/scripts/bridgeThread.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/packages/cli/scripts/bridgeThread.ts b/packages/cli/scripts/bridgeThread.ts index d646ce092..a58151b51 100644 --- a/packages/cli/scripts/bridgeThread.ts +++ b/packages/cli/scripts/bridgeThread.ts @@ -8,12 +8,6 @@ import { execSync } from 'child_process' const bridgeThread = async () => { const args = await yargs(hideBin(process.argv)) - .option('KEY', { - describe: 'alchemy api key', - string: true, - default: 'JY46MOVpzcwZYEln86fa44MHIks4OoSl', - optional: true, - }) .option('devnet', { describe: 'running portal state network devnet', boolean: true, @@ -39,24 +33,16 @@ const bridgeThread = async () => { }) .strict().argv + const alchemyAPIKey = process.env.ALCHEMY_API_KEY const alchemyHTTP = jayson.Client.https({ host: 'eth-mainnet.g.alchemy.com', - path: '/v2/JY46MOVpzcwZYEln86fa44MHIks4OoSl', + path: `/v2/${alchemyAPIKey}`, }) const cmd = 'hostname -I' const pubIp = execSync(cmd).toString().split(' ') args.host = args.host ?? pubIp[0] - const config = { - apiKey: 'JY46MOVpzcwZYEln86fa44MHIks4OoSl', - network: Network.ETH_MAINNET, - url: 'https://eth-mainnet.alchemyapi.io/v2/JY46MOVpzcwZYEln86fa44MHIks4OoSl', - } - const alchemy = new Alchemy({ - ...config, - }) - const processing: Set = new Set() const processed: Set = new Set() const started: Map = new Map()