-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #503 from lidofinance/feat/scroll-support
Add Scroll support (a separate bot)
- Loading branch information
Showing
42 changed files
with
8,029 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Tests @ l2-bridge-scroll | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "l2-bridge-scroll/**" | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/_tests.yml | ||
with: | ||
path: ./l2-bridge-scroll | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
forta.config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"curly": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
dist | ||
forta.config.json | ||
.yarn/* | ||
!.yarn/releases/ | ||
*.log | ||
version.json | ||
.DS_Store | ||
src/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": false, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Build stage: compile Typescript to Javascript | ||
FROM node:20.9.0-alpine3.18 AS base | ||
|
||
FROM base as builder | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN yarn install --immutable && yarn run build | ||
# Build app | ||
RUN yarn run build | ||
|
||
# Final stage: copy compiled Javascript from previous stage and install production dependencies | ||
FROM base as production | ||
LABEL "network.forta.settings.agent-logs.enable"="true" | ||
ENV NODE_ENV=production | ||
WORKDIR /app | ||
|
||
COPY package*.json yarn.lock ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/dist ./src | ||
COPY version.json ./ | ||
|
||
CMD ["yarn", "run", "start:prod"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Lido Detection Scroll Bot | ||
|
||
How does it work. | ||
|
||
The bot works on two networks: ETH mainnet and Scroll. | ||
Here's how it operates: The bot monitors new blocks on the ETH mainnet. | ||
Since Forta doesn't currently support Scroll, the bot reads blocks on the L2 network (Scroll) and stores the latest one | ||
in an in-memory cache. | ||
When the bot reads the next block on ETH, it also retrieves a segment of Scroll blocks (cachedBlock, latestBlock) from | ||
the cache. | ||
|
||
## Supported chains | ||
|
||
- Ethereum mainnet, Scroll network | ||
|
||
## Alerts | ||
|
||
1. Bridge events | ||
1. 🚨🚨🚨 Scroll bridge balance mismatch 🚨🚨🚨 | ||
2. 🚨 Scroll L2 Bridge: (re-)initialized | ||
3. 🚨 Scroll L2 Bridge: Deposits Disabled | ||
4. 🚨 Scroll: L2 gateway owner changed | ||
5. 🚨 Scroll L2 Bridge: Withdrawals Disabled | ||
6. ⚠️ Scroll L2 Bridge: Role granted | ||
7. ⚠️ Scroll L2 Bridge: Role revoked | ||
8. ℹ️ Scroll L2 Bridge: Deposits Enabled | ||
9. ℹ️ Scroll L2 Bridge: Withdrawals Enabled | ||
2. Gov Events | ||
1. 🚨 Scroll Gov Bridge: Ethereum Governance Executor Updated | ||
2. 🚨 Scroll Gov Bridge: Guardian Updated | ||
3. ⚠️ Scroll Gov Bridge: Delay Updated | ||
4. ⚠️ Scroll Gov Bridge: Grace Period Updated | ||
5. ⚠️ Scroll Gov Bridge: Min Delay Updated | ||
6. ⚠️ Scroll Gov Bridge: Max Delay Updated | ||
7. ℹ️ Scroll Gov Bridge: Action set queued | ||
8. ℹ️ Scroll Gov Bridge: Action set executed | ||
9. ℹ️ Scroll Gov Bridge: Action set canceled | ||
3. Proxy events | ||
1. 🚨 Scroll: Proxy admin changed | ||
2. 🚨 Scroll: Proxy implementation changed | ||
3. 🚨 Scroll: Proxy upgraded | ||
4. 🚨 Scroll: Proxy beacon upgraded | ||
4. Monitor Withdrawals | ||
1. ⚠️ Scroll: Huge withdrawals during the last ... | ||
|
||
## Development (Forta specific) | ||
|
||
Edit `alerting-forta/<SUBMODULE>/forta.config.json` and set `jsonRpcUrl` to your JSON-RPC provider. Install deps: | ||
|
||
``` | ||
yarn install | ||
``` | ||
|
||
Running in a live mode: | ||
|
||
``` | ||
yarn start:dev | ||
``` | ||
|
||
Testing on a specific block/range/transaction: | ||
|
||
``` | ||
yarn block 13626668 | ||
yarn range '13626667..13626668' | ||
yarn tx 0x2d2774c04e3faf9f17cd26e0978bb812081b9d0b5cc6fd8bf04cc441f92c0a8c | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import("ts-jest").JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['dist'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"name": "lido-l2-bridge-scroll-bot", | ||
"displayName": "Forta Agent Starter", | ||
"version": "0.0.1", | ||
"description": "Lido Detection Bot for Scroll part of L2 bridge", | ||
"repository": { | ||
"type": "git", | ||
"directory": "https://github.com/lidofinance/alerting-forta/tree/main/l2-bridge-scroll" | ||
}, | ||
"license": "MIT", | ||
"chainIds": [ | ||
1 | ||
], | ||
"chainSettings": { | ||
"default": { | ||
"shards": 1, | ||
"target": 5 | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn run lint" | ||
} | ||
}, | ||
"scripts": { | ||
"update-version": "node ../utils/write-version.js", | ||
"build": "tsc && yarn run copy-version", | ||
"copy-version": "cp version.json dist", | ||
"start": "yarn run update-version && yarn run start:dev", | ||
"start:dev": "nodemon --watch src --watch forta.config.json -e js,ts,json --exec \"yarn run build && yarn run copy-version && forta-agent run\"", | ||
"start:prod": "forta-agent run --prod", | ||
"tx": "yarn run build && forta-agent run --tx", | ||
"block": "yarn run build && forta-agent run --block", | ||
"range": "yarn run build && forta-agent run --range", | ||
"alert": "yarn run build && forta-agent run --alert", | ||
"sequence": "yarn run build && forta-agent run --sequence", | ||
"file": "yarn run build && forta-agent run --file", | ||
"publish": "yarn run update-version && forta-agent publish", | ||
"info": "forta-agent info", | ||
"logs": "forta-agent logs", | ||
"push": "yarn run update-version && forta-agent push", | ||
"disable": "forta-agent disable", | ||
"enable": "forta-agent enable", | ||
"keyfile": "forta-agent keyfile", | ||
"stake": "forta-agent stake", | ||
"test": "jest", | ||
"generate-types": "typechain --target=ethers-v5 --out-dir=./src/generated ./src/abi/*", | ||
"eslint:lint": "eslint ./src", | ||
"eslint:format": "eslint ./src --fix", | ||
"prettier:check": "prettier --check ./src", | ||
"prettier:format": "prettier --write ./src", | ||
"lint": "yarn run prettier:check && yarn run eslint:lint", | ||
"format": "yarn run eslint:format && yarn run prettier:format", | ||
"postinstall": "yarn generate-types" | ||
}, | ||
"dependencies": { | ||
"@types/lodash": "^4.14.202", | ||
"async-mutex": "^0.4.0", | ||
"bignumber.js": "^9.1.2", | ||
"ethers": "^5.5.1", | ||
"forta-agent": "^0.1.48", | ||
"fp-ts": "^2.16.1", | ||
"lodash": "^4.17.21", | ||
"ts-retry": "^4.2.4", | ||
"winston": "^3.11.0" | ||
}, | ||
"devDependencies": { | ||
"@ethersproject/abi": "^5.0.0", | ||
"@ethersproject/providers": "^5.0.0", | ||
"@jest/globals": "^29.7.0", | ||
"@tsconfig/node20": "^20.1.2", | ||
"@typechain/ethers-v5": "^11.1.2", | ||
"@types/jest": "^29.5.10", | ||
"@types/nodemon": "^1.19.0", | ||
"@types/ws": "^8.5.10", | ||
"@typescript-eslint/eslint-plugin": "^6.12.0", | ||
"@typescript-eslint/parser": "^6.12.0", | ||
"eslint": "^8.54.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-jest": "^27.6.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"husky": "^8.0.3", | ||
"jest": "^29.7.0", | ||
"nodemon": "^3.0.1", | ||
"postinstall": "^0.8.0", | ||
"prettier": "^3.1.0", | ||
"ts-generator": "^0.1.1", | ||
"ts-jest": "^29.1.1", | ||
"typechain": "^8.3.2", | ||
"typescript": "^5.3.2" | ||
}, | ||
"packageManager": "yarn@1.22.21" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "account", | ||
"type": "address" | ||
} | ||
], | ||
"name": "balanceOf", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "totalSupply", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
Oops, something went wrong.