Skip to content

Commit

Permalink
Merge branch 'fix/most-bots-small-fixes' of work:lidofinance/alerting…
Browse files Browse the repository at this point in the history
…-forta into fix/most-bots-small-fixes
  • Loading branch information
sergeyWh1te committed May 29, 2024
2 parents 7f47ee7 + a7c6b82 commit a3378fe
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 38 deletions.
22 changes: 13 additions & 9 deletions l2-bridge-ethereum/src/agent-proxy-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { formatAddress } from "forta-agent/dist/cli/utils";
import {
ARBITRUM_GATEWAY_SET_EVENT,
ARBITRUM_L1_GATEWAY_ROUTER,
LIDO_PROXY_CONTRACTS,
LidoProxy,
L1_BRIDGES,
BridgeProxyInfo,
LINEA_CUSTOM_CONTRACT_SET_EVENT,
LINEA_L1_CROSS_DOMAIN_MESSENGER,
PROXY_ADMIN_EVENTS,
L1_BRIDGES_PROXY_EVENTS,
STETH_ADDRESS,
THIRD_PARTY_PROXY_EVENTS,
WSTETH_ADDRESS,
Expand All @@ -31,7 +31,7 @@ export async function initialize(
): Promise<{ [key: string]: string }> {
console.log(`[${name}]`);
await Promise.all(
LIDO_PROXY_CONTRACTS.map(async (proxyInfo: LidoProxy) => {
L1_BRIDGES.map(async (proxyInfo: BridgeProxyInfo) => {
const lastImpl = await getProxyImpl(proxyInfo, currentBlock);
lastImpls.set(proxyInfo.address, lastImpl);
const lastAdmin = await getProxyAdmin(proxyInfo, currentBlock);
Expand All @@ -57,7 +57,7 @@ function handleProxyAdminEvents(
txEvent: TransactionEvent,
findings: Finding[],
) {
PROXY_ADMIN_EVENTS.forEach((eventInfo) => {
L1_BRIDGES_PROXY_EVENTS.forEach((eventInfo) => {
if (formatAddress(eventInfo.address) in txEvent.addresses) {
const events = txEvent.filterLog(eventInfo.event, eventInfo.address);
events.forEach((event) => {
Expand All @@ -84,6 +84,10 @@ function handleThirdPartyProxyAdminEvents(
if (formatAddress(eventInfo.address) in txEvent.addresses) {
const events = txEvent.filterLog(eventInfo.event, eventInfo.address);
events.forEach((event) => {
if (eventInfo.condition && !eventInfo.condition(event.args)) {
return;
}

findings.push(
Finding.fromObject({
name: eventInfo.name,
Expand Down Expand Up @@ -164,7 +168,7 @@ export async function handleBlock(blockEvent: BlockEvent) {
return findings;
}

async function getProxyImpl(proxyInfo: LidoProxy, blockNumber: number) {
async function getProxyImpl(proxyInfo: BridgeProxyInfo, blockNumber: number) {
const implFunc = proxyInfo.functions.get("implementation");
if (!implFunc) {
return undefined;
Expand Down Expand Up @@ -198,7 +202,7 @@ async function handleProxyImplementationChanges(
findings: Finding[],
) {
await Promise.all(
LIDO_PROXY_CONTRACTS.map(async (proxyInfo: LidoProxy) => {
L1_BRIDGES.map(async (proxyInfo: BridgeProxyInfo) => {
const newImpl = await getProxyImpl(proxyInfo, blockEvent.blockNumber);
const lastImpl = lastImpls.get(proxyInfo.address) || "";
if (newImpl != lastImpl) {
Expand All @@ -221,7 +225,7 @@ async function handleProxyImplementationChanges(
);
}

async function getProxyAdmin(proxyInfo: LidoProxy, blockNumber: number) {
async function getProxyAdmin(proxyInfo: BridgeProxyInfo, blockNumber: number) {
const adminFunc = proxyInfo.functions.get("admin");
if (!adminFunc) {
return undefined;
Expand Down Expand Up @@ -254,7 +258,7 @@ async function handleProxyAdminChanges(
findings: Finding[],
) {
await Promise.all(
LIDO_PROXY_CONTRACTS.map(async (proxyInfo: LidoProxy) => {
L1_BRIDGES.map(async (proxyInfo: BridgeProxyInfo) => {
const newAdmin = await getProxyAdmin(proxyInfo, blockEvent.blockNumber);
const lastAdmin = lastAdmins.get(proxyInfo.address) || "";
if (newAdmin != lastAdmin) {
Expand Down
Loading

0 comments on commit a3378fe

Please sign in to comment.