From 4910c463407c85ae6164d1816e3c138149f56986 Mon Sep 17 00:00:00 2001 From: Alexander Belokon Date: Wed, 29 Jan 2025 11:38:07 +0100 Subject: [PATCH 1/2] fix: temporarily disable moonbeam watcher --- multisig-watcher/src/agent.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/multisig-watcher/src/agent.ts b/multisig-watcher/src/agent.ts index b14eaeba..b10aad5b 100644 --- a/multisig-watcher/src/agent.ts +++ b/multisig-watcher/src/agent.ts @@ -35,7 +35,7 @@ const subAgents: SubAgent[] = [ agentPolygon, agentArbitrum, agentOptimism, - agentMoonbeam, + // agentMoonbeam, agentMoonriver, ]; @@ -90,7 +90,7 @@ const initialize = async () => { process.exit(1); } } - }), + }) ); metadata.agents = "[" + subAgents.map((a) => `"${a.name}"`).join(", ") + "]"; @@ -103,7 +103,7 @@ const initialize = async () => { severity: FindingSeverity.Info, type: FindingType.Info, metadata, - }), + }) ); console.log("Bot initialization is done!"); }; @@ -117,7 +117,7 @@ const timeout = async (agent: SubAgent) => }); const handleBlock: HandleBlock = async ( - blockEvent: BlockEvent, + blockEvent: BlockEvent ): Promise => { let blockFindings: Finding[] = []; // report findings from init. Will be done only for the first block report. @@ -154,13 +154,13 @@ const handleBlock: HandleBlock = async ( const runs = await Promise.allSettled( subAgents.map(async (agent) => { return await Promise.race([run(agent, blockEvent), timeout(agent)]); - }), + }) ); runs.forEach((r: PromiseSettledResult, index: number) => { if (r.status == "rejected") { blockFindings.push( - errorToFinding(r.reason, subAgents[index], "handleBlock"), + errorToFinding(r.reason, subAgents[index], "handleBlock") ); } }); @@ -169,7 +169,7 @@ const handleBlock: HandleBlock = async ( }; const handleTransaction: HandleTransaction = async ( - txEvent: TransactionEvent, + txEvent: TransactionEvent ) => { let txFindings: Finding[] = []; const run = async (agent: SubAgent, txEvent: TransactionEvent) => { @@ -199,13 +199,13 @@ const handleTransaction: HandleTransaction = async ( const runs = await Promise.allSettled( subAgents.map(async (agent) => { return await Promise.race([run(agent, txEvent), timeout(agent)]); - }), + }) ); runs.forEach((r: PromiseSettledResult, index: number) => { if (r.status == "rejected") { txFindings.push( - errorToFinding(r.reason, subAgents[index], "handleBlock"), + errorToFinding(r.reason, subAgents[index], "handleBlock") ); } }); From a96c957a68ebc5d03f3f36c4b881f96f72667516 Mon Sep 17 00:00:00 2001 From: Alexander Belokon Date: Wed, 29 Jan 2025 12:03:45 +0100 Subject: [PATCH 2/2] refactor: remove moonbeam and moonriver watchers, add sidechain block logging --- multisig-watcher/src/agent-arbitrum.ts | 1 + multisig-watcher/src/agent-ethereum.ts | 9 +--- multisig-watcher/src/agent-moonbeam.ts | 38 -------------- multisig-watcher/src/agent-moonriver.ts | 38 -------------- multisig-watcher/src/agent-optimism.ts | 1 + multisig-watcher/src/agent-polygon.ts | 1 + multisig-watcher/src/agent.ts | 4 -- multisig-watcher/src/config/bot-config.json | 26 ++++----- multisig-watcher/src/constants.ts | 58 --------------------- multisig-watcher/src/providers.ts | 14 ++--- 10 files changed, 17 insertions(+), 173 deletions(-) delete mode 100644 multisig-watcher/src/agent-moonbeam.ts delete mode 100644 multisig-watcher/src/agent-moonriver.ts diff --git a/multisig-watcher/src/agent-arbitrum.ts b/multisig-watcher/src/agent-arbitrum.ts index e7dccd66..050ed31e 100644 --- a/multisig-watcher/src/agent-arbitrum.ts +++ b/multisig-watcher/src/agent-arbitrum.ts @@ -22,6 +22,7 @@ export async function handleBlock(blockEvent: BlockEvent) { if (blockEvent.blockNumber % NON_ETH_FETCH_INTERVAL == 0) { const currentBlock = await provider.getBlockNumber(); + console.log(`ARBITRUM block: ${currentBlock}`); const prevProcessedBlock = lastProcessedBlock; lastProcessedBlock = currentBlock; await handleSafeEvents( diff --git a/multisig-watcher/src/agent-ethereum.ts b/multisig-watcher/src/agent-ethereum.ts index 17727670..acf81018 100644 --- a/multisig-watcher/src/agent-ethereum.ts +++ b/multisig-watcher/src/agent-ethereum.ts @@ -1,11 +1,4 @@ -import { - ethers, - BlockEvent, - TransactionEvent, - Finding, - FindingType, - FindingSeverity, -} from "forta-agent"; +import { TransactionEvent, Finding, FindingType } from "forta-agent"; import { Blockchain, diff --git a/multisig-watcher/src/agent-moonbeam.ts b/multisig-watcher/src/agent-moonbeam.ts deleted file mode 100644 index 432c8f7c..00000000 --- a/multisig-watcher/src/agent-moonbeam.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { BlockEvent, Finding } from "forta-agent"; -import { Blockchain, NON_ETH_FETCH_INTERVAL, SAFES } from "./constants"; -import { moonbeamProvider as provider } from "./providers"; -import { handleSafeEvents } from "./handlers"; - -export const name = "Moonbeam-multisig-watcher"; - -const blockchain = Blockchain.MOONBEAM; -const safes = SAFES[blockchain]; -let lastProcessedBlock = 0; - -export async function initialize( - currentBlock: number -): Promise<{ [key: string]: string }> { - console.log(`[${name}] initialized on block ${currentBlock}`); - lastProcessedBlock = await provider.getBlockNumber(); - return { lastProcessedBlock: lastProcessedBlock.toString() }; -} - -export async function handleBlock(blockEvent: BlockEvent) { - const findings: Finding[] = []; - - if (blockEvent.blockNumber % NON_ETH_FETCH_INTERVAL == 0) { - const currentBlock = await provider.getBlockNumber(); - const prevProcessedBlock = lastProcessedBlock; - lastProcessedBlock = currentBlock; - await handleSafeEvents( - findings, - provider, - blockchain, - safes, - prevProcessedBlock, - currentBlock - ); - } - - return findings; -} diff --git a/multisig-watcher/src/agent-moonriver.ts b/multisig-watcher/src/agent-moonriver.ts deleted file mode 100644 index de68f97d..00000000 --- a/multisig-watcher/src/agent-moonriver.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { BlockEvent, Finding } from "forta-agent"; -import { Blockchain, NON_ETH_FETCH_INTERVAL, SAFES } from "./constants"; -import { moonriverProvider as provider } from "./providers"; -import { handleSafeEvents } from "./handlers"; - -export const name = "Moonriver-multisig-watcher"; - -const blockchain = Blockchain.MOONRIVER; -const safes = SAFES[blockchain]; -let lastProcessedBlock = 0; - -export async function initialize( - currentBlock: number -): Promise<{ [key: string]: string }> { - console.log(`[${name}] initialized on block ${currentBlock}`); - lastProcessedBlock = await provider.getBlockNumber(); - return { lastProcessedBlock: lastProcessedBlock.toString() }; -} - -export async function handleBlock(blockEvent: BlockEvent) { - const findings: Finding[] = []; - - if (blockEvent.blockNumber % NON_ETH_FETCH_INTERVAL == 0) { - const currentBlock = await provider.getBlockNumber(); - const prevProcessedBlock = lastProcessedBlock; - lastProcessedBlock = currentBlock; - await handleSafeEvents( - findings, - provider, - blockchain, - safes, - prevProcessedBlock, - currentBlock - ); - } - - return findings; -} diff --git a/multisig-watcher/src/agent-optimism.ts b/multisig-watcher/src/agent-optimism.ts index 2f9399c6..17618f0c 100644 --- a/multisig-watcher/src/agent-optimism.ts +++ b/multisig-watcher/src/agent-optimism.ts @@ -22,6 +22,7 @@ export async function handleBlock(blockEvent: BlockEvent) { if (blockEvent.blockNumber % NON_ETH_FETCH_INTERVAL == 0) { const currentBlock = await provider.getBlockNumber(); + console.log(`OPTIMISM block: ${currentBlock}`); const prevProcessedBlock = lastProcessedBlock; lastProcessedBlock = currentBlock; await handleSafeEvents( diff --git a/multisig-watcher/src/agent-polygon.ts b/multisig-watcher/src/agent-polygon.ts index be66fd99..63542aa9 100644 --- a/multisig-watcher/src/agent-polygon.ts +++ b/multisig-watcher/src/agent-polygon.ts @@ -22,6 +22,7 @@ export async function handleBlock(blockEvent: BlockEvent) { if (blockEvent.blockNumber % NON_ETH_FETCH_INTERVAL == 0) { const currentBlock = await provider.getBlockNumber(); + console.log(`POLYGON block: ${currentBlock}`); const prevProcessedBlock = lastProcessedBlock; lastProcessedBlock = currentBlock; await handleSafeEvents( diff --git a/multisig-watcher/src/agent.ts b/multisig-watcher/src/agent.ts index b10aad5b..71450127 100644 --- a/multisig-watcher/src/agent.ts +++ b/multisig-watcher/src/agent.ts @@ -16,8 +16,6 @@ import * as agentEthereum from "./agent-ethereum"; import * as agentPolygon from "./agent-polygon"; import * as agentArbitrum from "./agent-arbitrum"; import * as agentOptimism from "./agent-optimism"; -import * as agentMoonbeam from "./agent-moonbeam"; -import * as agentMoonriver from "./agent-moonriver"; import VERSION from "./version"; @@ -35,8 +33,6 @@ const subAgents: SubAgent[] = [ agentPolygon, agentArbitrum, agentOptimism, - // agentMoonbeam, - agentMoonriver, ]; // block or tx handling should take no more than 240 sec. Increased due to free RPC usage. diff --git a/multisig-watcher/src/config/bot-config.json b/multisig-watcher/src/config/bot-config.json index 976b3aad..989d3216 100644 --- a/multisig-watcher/src/config/bot-config.json +++ b/multisig-watcher/src/config/bot-config.json @@ -1,17 +1,11 @@ { - "Arbitrum": { - "RpcUrlBase64": "aHR0cHM6Ly9hcmItbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x" - }, - "Optimism": { - "RpcUrlBase64": "aHR0cHM6Ly9vcHQtbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x" - }, - "Polygon": { - "RpcUrlBase64": "aHR0cHM6Ly9wb2x5Z29uLW1haW5uZXQuZy5hbGNoZW15LmNvbS92Mi9OM0dzNlZ0UFNoVGZhRzlFdlI4TFNoNEVFR2FnTHVucQ" - }, - "Moonriver": { - "RpcUrlBase64": "aHR0cHM6Ly9tb29ucml2ZXItcnBjLmR3ZWxsaXIuY29t" - }, - "Moonbeam": { - "RpcUrlBase64": "aHR0cHM6Ly8xcnBjLmlvL2dsbXI=" - } -} \ No newline at end of file + "Arbitrum": { + "RpcUrlBase64": "aHR0cHM6Ly9hcmItbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x" + }, + "Optimism": { + "RpcUrlBase64": "aHR0cHM6Ly9vcHQtbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x" + }, + "Polygon": { + "RpcUrlBase64": "aHR0cHM6Ly9wb2x5Z29uLW1haW5uZXQuZy5hbGNoZW15LmNvbS92Mi9OM0dzNlZ0UFNoVGZhRzlFdlI4TFNoNEVFR2FnTHVucQ" + } +} diff --git a/multisig-watcher/src/constants.ts b/multisig-watcher/src/constants.ts index 2212384e..f0e4fe56 100644 --- a/multisig-watcher/src/constants.ts +++ b/multisig-watcher/src/constants.ts @@ -9,8 +9,6 @@ export enum Blockchain { POLYGON = "Polygon", ARBITRUM = "Arbitrum", OPTIMISM = "Optimism", - MOONBEAM = "Moonbeam", - MOONRIVER = "Moonriver", } export interface SafeTX { @@ -62,18 +60,6 @@ export const BLOCKCHAIN_INFO: { [key in Blockchain]: BlockchainInfo } = { safeTxUrlPrefix: "https://app.safe.global/transactions/tx?safe=oeth:", safeUrlPrefix: "https://app.safe.global/home?safe=oeth:", }, - [Blockchain.MOONBEAM]: { - addressUrlPrefix: "https://moonbeam.moonscan.io/address/", - txUrlPrefix: "https://moonbeam.moonscan.io/tx/", - safeTxUrlPrefix: "https://app.safe.global/transactions/tx?safe=mbeam:", - safeUrlPrefix: "https://app.safe.global/home?safe=mbeam:", - }, - [Blockchain.MOONRIVER]: { - addressUrlPrefix: "https://moonriver.moonscan.io/address/", - txUrlPrefix: "https://moonriver.moonscan.io/tx/", - safeTxUrlPrefix: "https://app.safe.global/transactions/tx?safe=mriver:", - safeUrlPrefix: "https://app.safe.global/home?safe=mriver:", - }, }; // ADDRESSES AND EVENTS @@ -167,50 +153,6 @@ export const SAFES = { "Liquidity Observation Lab AAVE rewards (Optimism)", ], ], - [Blockchain.MOONBEAM]: [ - [ - "0x007132343ca619c5449297507b26c3f85e80d1b1", - "Liquidity Observation Lab (Moonbeam)", - ], - [ - "0x34fc04fa7e8e142001aaeed25da8cf7dd887a5f3", - "Contracts updater (Moonbeam)", - ], - [ - "0xd00e0d8e42b8222745f4e921c6fa7ff620fa8e96", - "Parameters manager (Moonbeam)", - ], - [ - "0xab4046bdf1a58c628d925602b05fb1696b74ac2c", - "Parameters setter (Moonbeam)", - ], - [ - "0x3ef396fa1a363025b3cedc07d828fa512ccc7156", - "Renomination manager (Moonbeam)", - ], - ], - [Blockchain.MOONRIVER]: [ - [ - "0xdafc1dcb93da415604ac6187638f88a8ff8d77a4", - "Liquidity Observation Lab (Moonriver)", - ], - [ - "0xdafc1dcb93da415604ac6187638f88a8ff8d77a4", - "Contracts updater (Moonriver)", - ], - [ - "0xf3b2c83400d60ee91f716eaa4e9ef59c49f2d1ae", - "Parameters manager (Moonriver)", - ], - [ - "0xb4d206664c53986b66eba65203c7f2d2924ab351", - "Parameters setter (Moonriver)", - ], - [ - "0xc4520846052adc9d92ad161a5bde907869cd0da4", - "Renomination manager (Moonriver)", - ], - ], }; export const GNOSIS_SAFE_EVENTS_OF_NOTICE = [ diff --git a/multisig-watcher/src/providers.ts b/multisig-watcher/src/providers.ts index 6d3611aa..8ecf340d 100644 --- a/multisig-watcher/src/providers.ts +++ b/multisig-watcher/src/providers.ts @@ -2,21 +2,13 @@ import config from "./config/bot-config.json"; import { ethers } from "forta-agent"; export const polygonProvider = new ethers.providers.JsonRpcProvider( - Buffer.from(config.Polygon.RpcUrlBase64, "base64").toString("utf-8"), + Buffer.from(config.Polygon.RpcUrlBase64, "base64").toString("utf-8") ); export const arbitrumProvider = new ethers.providers.JsonRpcProvider( - Buffer.from(config.Arbitrum.RpcUrlBase64, "base64").toString("utf-8"), + Buffer.from(config.Arbitrum.RpcUrlBase64, "base64").toString("utf-8") ); export const optimismProvider = new ethers.providers.JsonRpcProvider( - Buffer.from(config.Optimism.RpcUrlBase64, "base64").toString("utf-8"), -); - -export const moonbeamProvider = new ethers.providers.JsonRpcProvider( - Buffer.from(config.Moonbeam.RpcUrlBase64, "base64").toString("utf-8"), -); - -export const moonriverProvider = new ethers.providers.JsonRpcProvider( - Buffer.from(config.Moonriver.RpcUrlBase64, "base64").toString("utf-8"), + Buffer.from(config.Optimism.RpcUrlBase64, "base64").toString("utf-8") );