diff --git a/ops_boba/monitor/exec/run-monitor.js b/ops_boba/monitor/exec/run-monitor.js index 34fa2ca5c4..8eaddd016a 100644 --- a/ops_boba/monitor/exec/run-monitor.js +++ b/ops_boba/monitor/exec/run-monitor.js @@ -3,6 +3,7 @@ const configs = require('../services/utilities/configs') const { sleep } = require('@eth-optimism/core-utils') const { logger } = require('../services/utilities/logger') +require('dotenv').config() const loop = async (func) => { while (true) { @@ -80,26 +81,40 @@ const main = async () => { loop(() => blockService.startTransactionMonitor()).catch() loop(() => blockService.startCrossDomainMessageMonitor()).catch() - if (configs.enableTxResponseTime) { - loop(() => loopLogTx()).catch() - } + // enable the periodic transaction and check on Mainnet + if (process.env.STAGE === 'mainnet') { + if (configs.enableTxResponseTime) { + loop(() => loopLogTx()).catch() + } - const { - setupProvider, - validateMonitoring, - } = require('../services/monitoring') - - if (validateMonitoring()) { - logger.info('Start addresses monitoring service!') - setupProvider(configs.OMGXNetwork.L1, configs.l1Url, 5).catch() - setupProvider(configs.OMGXNetwork.L2, configs.l2Url, 15).catch() - } else { - logger.error( - 'Addresses Monitoring: Env variables for monitoring is missing!' - ) - } + const L1_MONITOR_INTERVAL = process.env.L1_MONITOR_INTERVAL || 5 * 60 + const L2_MONITOR_INTERVAL = process.env.L2_MONITOR_INTERVAL || 5 * 60 + + const { + setupProvider, + validateMonitoring, + } = require('../services/monitoring') + + if (validateMonitoring()) { + logger.info('Start addresses monitoring service!') + setupProvider( + configs.OMGXNetwork.L1, + configs.l1Url, + L1_MONITOR_INTERVAL + ).catch() + setupProvider( + configs.OMGXNetwork.L2, + configs.l2Url, + L2_MONITOR_INTERVAL + ).catch() + } else { + logger.error( + 'Addresses Monitoring: Env variables for monitoring is missing!' + ) + } - loop(() => loopTransferTx()).catch() + loop(() => loopTransferTx()).catch() + } } ;(async () => { diff --git a/ops_boba/monitor/package.json b/ops_boba/monitor/package.json index cef421bb3d..10ac55e31f 100644 --- a/ops_boba/monitor/package.json +++ b/ops_boba/monitor/package.json @@ -15,6 +15,7 @@ "@eth-optimism/core-utils": "0.8.1", "@eth-optimism/common-ts": "0.2.2", "@ethersproject/providers": "5.4.5", + "axios": "0.26.0", "async-mutex": "^0.3.1", "dotenv": "^9.0.0", "ethers": "^5.1.4", diff --git a/ops_boba/monitor/services/blockMonitor.js b/ops_boba/monitor/services/blockMonitor.js index 86196a92c7..0e102c6a5b 100644 --- a/ops_boba/monitor/services/blockMonitor.js +++ b/ops_boba/monitor/services/blockMonitor.js @@ -79,7 +79,7 @@ class BlockMonitorService extends OptimismEnv { const latestSQLBlock = latestSQLBlockQuery[0]['MAX(blockNumber)'] // get the blocks, transactions and receipts - this.logger.info('Fetching the block data...') + // this.logger.info('Fetching the block data...') const [blocksData, receiptsData] = await this.getChainData( latestSQLBlock, Math.min(this.latestBlock, latestSQLBlock + 1000) @@ -91,7 +91,7 @@ class BlockMonitorService extends OptimismEnv { } // write the block data into MySQL - this.logger.info('Writing the block data...') + // this.logger.info('Writing the block data...') for (const blockData of blocksData) { await this.databaseService.insertBlockData(blockData) // write the transaction data into MySQL @@ -105,7 +105,7 @@ class BlockMonitorService extends OptimismEnv { } // write the receipt data into MySQL - this.logger.info('Writing the receipt data...') + // this.logger.info('Writing the receipt data...') for (let receiptData of receiptsData) { const correspondingBlock = blocksData.filter( (i) => i && i.hash === receiptData.blockHash @@ -136,11 +136,11 @@ class BlockMonitorService extends OptimismEnv { const latestBlock = await this.L2Provider.getBlockNumber() if (latestBlock > this.latestBlock) { - this.logger.info('Finding new blocks...') + // this.logger.info('Finding new blocks...') this.latestBlock = latestBlock // get the blocks, transactions and receipts - this.logger.info('Fetching the block data...') + // this.logger.info('Fetching the block data...') const [blocksData, receiptsData] = await this.getChainData( this.scannedLastBlock, Math.min(latestBlock, this.latestBlock + 1000) @@ -154,7 +154,7 @@ class BlockMonitorService extends OptimismEnv { } // write the block data into MySQL - this.logger.info('Writing the block data...') + // this.logger.info('Writing the block data...') for (const blockData of blocksData) { if (!blockData) { continue @@ -171,7 +171,7 @@ class BlockMonitorService extends OptimismEnv { } // write the receipt data into MySQL - this.logger.info('Writing the receipt data...') + // this.logger.info('Writing the receipt data...') for (let receiptData of receiptsData) { const correspondingBlock = blocksData.filter( (i) => i && i.hash === receiptData.blockHash @@ -264,7 +264,7 @@ class BlockMonitorService extends OptimismEnv { const promisesReceipt = [] for (let i = startingBlock; i <= endingBlock; i++) { promisesBlock.push(this.L2Provider.getBlockWithTransactions(i)) - this.logger.info(`Pushing block`) + // this.logger.info(`Pushing block`) } const blocksData = await Promise.all(promisesBlock) for (const blockData of blocksData) { diff --git a/yarn.lock b/yarn.lock index 63b6868139..da17701330 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5948,6 +5948,13 @@ axe-core@^4.3.5: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413" integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw== +axios@0.26.0: + version "0.26.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.0.tgz#9a318f1c69ec108f8cd5f3c3d390366635e13928" + integrity sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og== + dependencies: + follow-redirects "^1.14.8" + axios@^0.21.1, axios@^0.21.4: version "0.21.4" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" @@ -11616,6 +11623,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.12.1, follow-redirects@^1.14.0: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685" integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ== +follow-redirects@^1.14.8: + version "1.14.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" + integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + for-each@^0.3.3, for-each@~0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"