diff --git a/.env-sample b/.env-sample index 8d1824c2..233224a4 100644 --- a/.env-sample +++ b/.env-sample @@ -3,6 +3,12 @@ CONFIG_NETWORK_NAME="custom" DEPLOYED_CONTRACTS_DIR="./scripts/files/" DISABLE_VERIFICATION=true +# yarn script:bold-populate-lookup looks for the latest confirmed node's creation event +# these 2 parameters configure log lookup behavior. the script searches backwards in batches +# if the script throws "Could not find latest confirmed node", consider tweaking these values +NODECREATED_LOG_LOOKUP_BATCH_SIZE=10000 +NODECREATED_LOG_LOOKUP_BATCH_COUNT=100 + # to use the 'custom' hardhat network, set the following variables CUSTOM_RPC_URL="http://127.0.0.1:8545" CUSTOM_ETHERSCAN_API_KEY= diff --git a/scripts/boldUpgradeFunctions.ts b/scripts/boldUpgradeFunctions.ts index 5334c40e..765dd06a 100644 --- a/scripts/boldUpgradeFunctions.ts +++ b/scripts/boldUpgradeFunctions.ts @@ -86,10 +86,14 @@ export const populateLookup = async ( const latestConfirmed = await oldRollup.latestConfirmed() let latestConfirmedLog let toBlock = await wallet.provider!.getBlockNumber() - for (let i = 0; i < 100; i++) { + const numBatches = parseInt(process.env.NODECREATED_LOG_LOOKUP_BATCH_COUNT || '100') + const batchSize = parseInt( + process.env.NODECREATED_LOG_LOOKUP_BATCH_SIZE || '10000' + ) + for (let i = 0; i < numBatches; i++) { latestConfirmedLog = await wallet.provider!.getLogs({ address: rollupAddr, - fromBlock: toBlock >= 1000 ? toBlock - 1000 : 0, + fromBlock: toBlock >= batchSize ? toBlock - batchSize : 0, toBlock: toBlock, topics: [ oldRollup.interface.getEventTopic('NodeCreated'), @@ -100,7 +104,7 @@ export const populateLookup = async ( if (toBlock == 0) { throw new Error('Could not find latest confirmed node') } - toBlock -= 1000 + toBlock -= batchSize if (toBlock < 0) { toBlock = 0 }