-
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.
fix: l2-bridge-base moved 🚨🚨🚨 Base bridge balance mismatch 🚨🚨🚨from l2…
…-bridge-balance
- Loading branch information
1 parent
999a602
commit 37a7e4a
Showing
27 changed files
with
674 additions
and
410 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Tests @ l2-bridge-base | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "l2-bridge-base/**" | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/_tests.yml | ||
with: | ||
path: ./l2-bridge-base | ||
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "lido-l2-bridge-base-bot", | ||
"name": "lido-l2-bridge-base", | ||
"version": "0.0.1", | ||
"description": "Lido Detection Bot for base part of L2 bridge", | ||
"license": "MIT", | ||
|
@@ -12,6 +12,9 @@ | |
"target": 5 | ||
} | ||
}, | ||
"engines": { | ||
"node": ">=20.0" | ||
}, | ||
"scripts": { | ||
"update-version": "node ../utils/write-version.js", | ||
"build": "tsc && yarn run copy-version", | ||
|
@@ -35,10 +38,10 @@ | |
"stake": "forta-agent stake", | ||
"test": "jest", | ||
"generate-types": "typechain --target=ethers-v5 --out-dir=./src/generated ./src/abi/*", | ||
"eslint:lint": "eslint ./src ./tests", | ||
"eslint:format": "eslint ./src ./tests --fix", | ||
"prettier:check": "prettier --check ./src ./tests", | ||
"prettier:format": "prettier --write ./src ./tests README.md", | ||
"eslint:lint": "eslint ./src ", | ||
"eslint:format": "eslint ./src --fix", | ||
"prettier:check": "prettier --check ./src", | ||
"prettier:format": "prettier --write ./src README.md", | ||
"lint": "yarn run prettier:check && yarn run eslint:lint", | ||
"format": "yarn run eslint:format && yarn run prettier:format", | ||
"postinstall": "yarn generate-types" | ||
|
@@ -76,7 +79,7 @@ | |
"ts-generator": "^0.1.1", | ||
"ts-jest": "^29.1.1", | ||
"typechain": "^8.3.2", | ||
"typescript": "^5.3.2" | ||
"typescript": "^5.3.3" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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,64 @@ | ||
import { App } from './app' | ||
import * as E from 'fp-ts/Either' | ||
import { Finding } from 'forta-agent' | ||
import BigNumber from 'bignumber.js' | ||
|
||
describe('agent-base functional test', () => { | ||
test('should process app on 13_022_644 and 13_022_744 (100 l2 blocks)', async () => { | ||
const app = await App.getInstance() | ||
|
||
const l1Block = 19_632_237 | ||
const l2StartBlock = 13_022_644 | ||
const l2EndBlock = 13_022_744 | ||
const l2BlocksDto = await app.baseClient.fetchL2Blocks(l2StartBlock, l2EndBlock) | ||
|
||
for (const proxyWatcher of app.proxyWatchers) { | ||
const err = await proxyWatcher.initialize(l2StartBlock) | ||
if (err !== null) { | ||
throw null | ||
} | ||
} | ||
|
||
const monitorWithdrawalsInitResp = await app.monitorWithdrawals.initialize(l2StartBlock) | ||
if (E.isLeft(monitorWithdrawalsInitResp)) { | ||
throw monitorWithdrawalsInitResp.left | ||
} | ||
|
||
const l2logs = await app.blockSrv.getL2Logs(l2BlocksDto) | ||
if (E.isLeft(l2logs)) { | ||
throw l2logs.left | ||
} | ||
|
||
const l2BlockNumberSet: Set<number> = new Set<number>() | ||
for (const l2log of l2logs.right) { | ||
l2BlockNumberSet.add(new BigNumber(l2log.blockNumber, 10).toNumber()) | ||
} | ||
|
||
const bridgeEventFindings = app.bridgeWatcher.handleL2Logs(l2logs.right) | ||
const govEventFindings = app.govWatcher.handleL2Logs(l2logs.right) | ||
const proxyAdminEventFindings = app.proxyEventWatcher.handleL2Logs(l2logs.right) | ||
const monitorWithdrawalsFindings = app.monitorWithdrawals.handleL2Blocks(l2logs.right, l2BlocksDto) | ||
const proxyWatcherFindings: Finding[] = [] | ||
|
||
const l2BlockNumbers = Array.from(l2BlockNumberSet).toSorted((a, b) => a - b) | ||
|
||
for (const proxyWatcher of app.proxyWatchers) { | ||
const fnds = await proxyWatcher.handleL2Blocks(l2BlockNumbers) | ||
proxyWatcherFindings.push(...fnds) | ||
} | ||
|
||
const bridgeBalanceFindings = await app.bridgeBalanceSrc.handleBlock(l1Block, l2BlockNumbers) | ||
|
||
const findings: Finding[] = [] | ||
findings.push( | ||
...bridgeEventFindings, | ||
...govEventFindings, | ||
...proxyAdminEventFindings, | ||
...monitorWithdrawalsFindings, | ||
...proxyWatcherFindings, | ||
...bridgeBalanceFindings, | ||
) | ||
|
||
expect(findings.length).toEqual(0) | ||
}, 360_000) | ||
}) |
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
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 @@ | ||
import { App } from '../app' | ||
import * as E from 'fp-ts/Either' | ||
import { ETH_DECIMALS } from '../utils/constants' | ||
import BigNumber from 'bignumber.js' | ||
|
||
describe('base provider tests', () => { | ||
test('should fetch block logs', async () => { | ||
const app = await App.getInstance() | ||
|
||
const latestBlock = await app.baseClient.getLatestL2Block() | ||
if (E.isLeft(latestBlock)) { | ||
throw latestBlock | ||
} | ||
|
||
const blocksDto = await app.baseClient.getL2Logs(latestBlock.right.number, latestBlock.right.number) | ||
if (E.isLeft(blocksDto)) { | ||
throw blocksDto | ||
} | ||
|
||
expect(blocksDto.right.length).toBeGreaterThan(1) | ||
}, 120_000) | ||
|
||
test('getWstEthTotalSupply is 1696.070092078019991932 wsETH', async () => { | ||
const app = await App.getInstance() | ||
|
||
const baseBlockNumber = 13_022_744 | ||
const balance = await app.baseClient.getWstEthTotalSupply(baseBlockNumber) | ||
if (E.isLeft(balance)) { | ||
throw balance.left | ||
} | ||
|
||
expect(balance.right.dividedBy(ETH_DECIMALS)).toEqual(new BigNumber('11430.956916416032084584')) | ||
}, 120_000) | ||
}) |
Oops, something went wrong.