Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove Moonbeam and Moonriver support from multisig-watcher #632

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions multisig-watcher/src/agent-arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 1 addition & 8 deletions multisig-watcher/src/agent-ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
ethers,
BlockEvent,
TransactionEvent,
Finding,
FindingType,
FindingSeverity,
} from "forta-agent";
import { TransactionEvent, Finding, FindingType } from "forta-agent";

import {
Blockchain,
Expand Down
38 changes: 0 additions & 38 deletions multisig-watcher/src/agent-moonbeam.ts

This file was deleted.

38 changes: 0 additions & 38 deletions multisig-watcher/src/agent-moonriver.ts

This file was deleted.

1 change: 1 addition & 0 deletions multisig-watcher/src/agent-optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions multisig-watcher/src/agent-polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 8 additions & 12 deletions multisig-watcher/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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.
Expand Down Expand Up @@ -90,7 +86,7 @@ const initialize = async () => {
process.exit(1);
}
}
}),
})
);

metadata.agents = "[" + subAgents.map((a) => `"${a.name}"`).join(", ") + "]";
Expand All @@ -103,7 +99,7 @@ const initialize = async () => {
severity: FindingSeverity.Info,
type: FindingType.Info,
metadata,
}),
})
);
console.log("Bot initialization is done!");
};
Expand All @@ -117,7 +113,7 @@ const timeout = async (agent: SubAgent) =>
});

const handleBlock: HandleBlock = async (
blockEvent: BlockEvent,
blockEvent: BlockEvent
): Promise<Finding[]> => {
let blockFindings: Finding[] = [];
// report findings from init. Will be done only for the first block report.
Expand Down Expand Up @@ -154,13 +150,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<any>, index: number) => {
if (r.status == "rejected") {
blockFindings.push(
errorToFinding(r.reason, subAgents[index], "handleBlock"),
errorToFinding(r.reason, subAgents[index], "handleBlock")
);
}
});
Expand All @@ -169,7 +165,7 @@ const handleBlock: HandleBlock = async (
};

const handleTransaction: HandleTransaction = async (
txEvent: TransactionEvent,
txEvent: TransactionEvent
) => {
let txFindings: Finding[] = [];
const run = async (agent: SubAgent, txEvent: TransactionEvent) => {
Expand Down Expand Up @@ -199,13 +195,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<any>, index: number) => {
if (r.status == "rejected") {
txFindings.push(
errorToFinding(r.reason, subAgents[index], "handleBlock"),
errorToFinding(r.reason, subAgents[index], "handleBlock")
);
}
});
Expand Down
26 changes: 10 additions & 16 deletions multisig-watcher/src/config/bot-config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"Arbitrum": {
"RpcUrlBase64": "aHR0cHM6Ly9hcmItbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x"
},
"Optimism": {
"RpcUrlBase64": "aHR0cHM6Ly9vcHQtbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x"
},
"Polygon": {
"RpcUrlBase64": "aHR0cHM6Ly9wb2x5Z29uLW1haW5uZXQuZy5hbGNoZW15LmNvbS92Mi9OM0dzNlZ0UFNoVGZhRzlFdlI4TFNoNEVFR2FnTHVucQ"
},
"Moonriver": {
"RpcUrlBase64": "aHR0cHM6Ly9tb29ucml2ZXItcnBjLmR3ZWxsaXIuY29t"
},
"Moonbeam": {
"RpcUrlBase64": "aHR0cHM6Ly8xcnBjLmlvL2dsbXI="
}
}
"Arbitrum": {
"RpcUrlBase64": "aHR0cHM6Ly9hcmItbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x"
},
"Optimism": {
"RpcUrlBase64": "aHR0cHM6Ly9vcHQtbWFpbm5ldC5nLmFsY2hlbXkuY29tL3YyL04zR3M2VnRQU2hUZmFHOUV2UjhMU2g0RUVHYWdMdW5x"
},
"Polygon": {
"RpcUrlBase64": "aHR0cHM6Ly9wb2x5Z29uLW1haW5uZXQuZy5hbGNoZW15LmNvbS92Mi9OM0dzNlZ0UFNoVGZhRzlFdlI4TFNoNEVFR2FnTHVucQ"
}
}
58 changes: 0 additions & 58 deletions multisig-watcher/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export enum Blockchain {
POLYGON = "Polygon",
ARBITRUM = "Arbitrum",
OPTIMISM = "Optimism",
MOONBEAM = "Moonbeam",
MOONRIVER = "Moonriver",
}

export interface SafeTX {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down
14 changes: 3 additions & 11 deletions multisig-watcher/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
Loading