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

feat: reporter scripts #26

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
169d011
feat(reporter): <- adds skeleton for this
allemanfredi Oct 13, 2023
e7b600a
create ABI and AMBHeaderReporterCall script
zengzengzenghuy Oct 15, 2023
aa96a8b
WIP: first draft of reporter scripts
zengzengzenghuy Oct 18, 2023
c310d20
WIP: controller with batching blocks functionality
zengzengzenghuy Oct 20, 2023
55d965e
WIP: add Multiclient class
zengzengzenghuy Oct 21, 2023
8e3656e
feat: controller logic
zengzengzenghuy Oct 22, 2023
6f2f1e8
doc: update README.md
zengzengzenghuy Oct 22, 2023
f802b1c
fix: first review
zengzengzenghuy Oct 23, 2023
bf7dd35
fix: second review
zengzengzenghuy Oct 24, 2023
79883e0
remove unused code
zengzengzenghuy Oct 24, 2023
a7fe83e
remove process.env in class and add data field as constructor parameter
zengzengzenghuy Oct 24, 2023
afb0e58
fix: naming of variables
zengzengzenghuy Oct 24, 2023
1fb6f56
fix: change BlockListener constructur to config
zengzengzenghuy Oct 24, 2023
4422cda
refactor: putting all configurable variables under settings/index.ts
zengzengzenghuy Oct 25, 2023
91981fe
fix: remove lastProcessedBlock and move queryBlockLength logic to ind…
zengzengzenghuy Oct 25, 2023
c902049
fix: remove unused code
zengzengzenghuy Oct 25, 2023
32dffd9
chore(evm): adds gitignore
allemanfredi Oct 25, 2023
96a5ff4
feat: allow each controllers to set interval individually
zengzengzenghuy Oct 26, 2023
5cb88f7
Merge branch 'feat/reporter' of https://github.com/gnosis/hashi into …
zengzengzenghuy Oct 26, 2023
466ef45
feat: added isLightClient check and separate intervals for LC based r…
zengzengzenghuy Oct 26, 2023
fc6c679
feat(reporter): improves classes design, rm not used code and improve…
allemanfredi Oct 26, 2023
5d1cac5
refactor(reporter): rn some vars
allemanfredi Oct 26, 2023
c2e7dff
chore(reporter): fixes compile erros
allemanfredi Oct 27, 2023
40dca77
chore(reporter): rm package-lock.json
allemanfredi Oct 27, 2023
bc7b6f6
feat(reporter): <- dockerizes it
allemanfredi Oct 27, 2023
06b07b1
fix: update .env.example
zengzengzenghuy Oct 27, 2023
719ad57
Merge branch 'feat/reporter' of https://github.com/gnosis/hashi into …
zengzengzenghuy Oct 27, 2023
d0a0972
feat(reporter): handles concurrency for sending a transaction and rn …
allemanfredi Oct 27, 2023
89f4815
Merge branch 'feat/reporter' of https://github.com/gnosis/hashi into …
allemanfredi Oct 27, 2023
baecfdc
fix: update .env.example
zengzengzenghuy Oct 30, 2023
2ba2c56
fix: TelepathyReporterCntroller logic
zengzengzenghuy Oct 30, 2023
b19e6de
Merge branch 'main' into feat/reporter
zengzengzenghuy Nov 3, 2023
742c4c8
feat(reporter): adds more settings and limit AMBReporterController to…
allemanfredi Nov 10, 2023
86d0ac9
fix: wrong transaction nonce error for Telepathy
zengzengzenghuy Nov 14, 2023
12ef0c1
Merge branch 'main' into feat/reporter
allemanfredi Nov 23, 2023
acfb232
feat(reporter): adds WormholeReporterController
allemanfredi Nov 24, 2023
d08d9c1
feat(reporter): adds OptimismReporterController
allemanfredi Nov 24, 2023
ae7a3f6
feat(reporter): adds AxelarReporterController
allemanfredi Nov 24, 2023
3e27cfd
refactor(reporter): adds reporterAddresses within BaseController
allemanfredi Nov 27, 2023
e4a95a3
feat(reporter): adds ConnextReporterController
allemanfredi Nov 27, 2023
94cd1c4
feat(reporter): adds StandardReporterController and adds support to c…
allemanfredi Nov 27, 2023
ec2db70
fix(reporter): fixes wrong param
allemanfredi Nov 27, 2023
7fc61c0
feat(reporter): adds support for ccip, hyperlane and l0
allemanfredi Nov 28, 2023
25f3abf
fix(reporter): fixes lastProcessedBlock within TelepathyReporterContr…
allemanfredi Nov 29, 2023
c2812c7
feat(reporter): adds new l0 and ccip adapters and adds support for ze…
allemanfredi Nov 29, 2023
578ac99
Merge branch 'main' into feat/reporter
allemanfredi Nov 29, 2023
6eb8586
feat(reporter): enabled SygmaReporterController
allemanfredi Dec 1, 2023
e49c49f
feat(reporter): adds ElectronReporterController and changes tsconfig.…
allemanfredi Dec 7, 2023
11e7a86
refactor(reporter): rm fs
allemanfredi Dec 7, 2023
5993963
refactor(reporter): refactors getHeader
allemanfredi Dec 7, 2023
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: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
**/.coverage_contracts
**/dist
**/node_modules
**/types
**/.yarn

# files
Expand Down
1 change: 1 addition & 0 deletions packages/evm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
types/
7 changes: 7 additions & 0 deletions packages/reporter/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
npm - debug.log
Dockerfile
.git
.gitignore
.yarn
logs
75 changes: 75 additions & 0 deletions packages/reporter/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
PRIVATE_KEY=

REPORTERS_ENABLED=AMBReporterController,SygmaReporterController,TelepathyReporterController,WormholeReporterController,OptimismReporterController,AxelarReporterController,ConnextReporterController,CelerReporterController,LayerZeroReporterController,CCIPReporterController,ZetaReporterController

GNOSIS_RPC_URL=https://rpc.ankr.com/gnosis
MAINNET_RPC_URL=
GOERLI_RPC_URL=
POLYGON_RPC_URL=
OPTIMISM_RPC_URL=https://optimism.llamarpc.com
ARBITRUM_RPC_URL=https://arbitrum.llamarpc.com
SEPOLIA_RPC_URL=
GOERLI_BEACON_API_URL=

AMB_REPORTER_HEADERS_GAS=300000
AXELAR_REPORT_HEADERS_VALUE=0.0001
CELER_REPORT_HEADERS_VALUE=0.0001
LAYER_ZERO_REPORT_HEADERS_VALUE=0.0007
CCIP_REPORT_HEADERS_VALUE=0.0002
CONNEXT_REPORT_HEADERS_VALUE=0.00003
ZETA_CHAIN_REPORT_HEADERS_VALUE=0.001

TELEPATHY_PROOF_API_URL=
TELEPATHY_BLOCK_BUFFER=10
TELEPATHY_INTERVAL_UPDATE=30000
ELECTRON_INTERVAL_UPDATE=30000

WORMHOLE_SCAN_BASE_URL=https://api.wormholescan.io

TIME_FETCH_BLOCKS_MS=3600000
BLOCK_BUFFER=10
QUERY_BLOCK_LENGTH=200

SOURCE_CHAIN_ID=5
DESTINATION_CHAIN_IDS=100

AMB_ADAPTER=0x4efB95c26bB2ebD3281749A5eAA388bc302b4445
SYMGA_ADAPTER=0x9AD7a6f4FDA8247cC0bF5932B68c5b619937dB15
GNOSIS_TELEPATHY_ADAPTER=0xDeF29f44f8315d0079A25EF03cfB0b0D8CdA3cF8
MAINNET_AMB_REPORTER=0x6be796cb66CdB3566b8AbebA2C516CbDF93fE831
MAINNET_HEADER_REPORTER=0x11378C54aA4e2Daf4603f9be86ae0Cb70786682a
POLYGON_TELEPATHY_ADAPTER=0x04413A4795dD1f5347eAD1CD7C76Bd9E5e48b461
BSC_TELEPATHY_ADAPTER=0x2E5685F20f42cC3b01e4A9ADE49F6848E242f022
OPTIMISM_TELEPATHY_ADAPTER=0x856dcc80f75a9737D9D498266E1Af013668316Fb
ARBITRUM_TELEPATHY_ADAPTER=0x2E5685F20f42cC3b01e4A9ADE49F6848E242f022
GNOSIS_WORMHOLE_ADAPTER=0x8EA3F385be8FCB98eB4dBfad2D00846860Bf648D
POLYGON_WORMHOLE_ADAPTER=0xb7806ea66c1bb9FfeB41Dc303601a469ddf3b9C2
BSC_WORMHOLE_ADAPTER=0x11378C54aA4e2Daf4603f9be86ae0Cb70786682a
OPTIMISM_WORMHOLE_ADAPTER=0x1fF52708D610b1D17F0830f036e992677CDc508A
AVALANCHE_WORMHOLE_ADAPTER=0x6E9ce437c46e7fA4F0888c21AAC0d9099Ad133ea
MAINNET_WORMHOLE_HEADER_REPORTER=0xDeF29f44f8315d0079A25EF03cfB0b0D8CdA3cF8
MAINNET_WORMHOLE_ADDRESS=0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B
MAINNET_L1_CROSS_DOMAIN_MESSENGER_HEADER_REPORTER_ADDRESS=0xbA5B3f0643582E75AF252e7631dE62c046970167
OPTIMISM_L2_CROSS_DOMAIN_MESSENGER_ADAPTER_ADDRESS=0xe58E7bF7aCD1396D8F9eAF44DB3D4Fd055DCDb51
MAINNET_AXELAR_REPORTER_BSC=0xBfd877753F8B4f4117a08aD54DcBE69cF3165d81
BSC_AXELAR_ADAPTER_MAINNET=0xb7806ea66c1bb9FfeB41Dc303601a469ddf3b9C2
POLYGON_CELER_ADAPTER_MAINNET=0x1fF52708D610b1D17F0830f036e992677CDc508A
MAINNET_CELER_REPORTER_POLYGON=0x52258b83051B7031483740aC9EcAa07926392ea0
AVALANCHE_LAYER_ZERO_ADAPTER_MAINNET=0x11378C54aA4e2Daf4603f9be86ae0Cb70786682a
MAINNET_LAYER_ZERO_REPORTER_AVALANCHE=0x16B43E348e0A19E9196ae79D172aDC52B3Aa3E20
OPTIMISM_GOERLI_CCIP_ADAPTER_SEPOLIA=0x520185210Aa645220a49afD9C33d28b73494e14d
SEPOLIA_CCIP_REPORTER_OPTIMISM_GOERLI=0xF3D2877866cd8E6771843b96B66aFcE425B2353C
BSC_TESTNET_CCIP_ADAPTER_SEPOLIA=0xB6133Ab655B990E80Af3E948852C8ec2a46651A5
SEPOLIA_CCIP_REPORTER_BSC_TESTNET=0x855A2814E0DFf8327f1a52aCC9537772B829e226
MAINNET_LAYER_ZERO_REPORTER_BSC=0x6E8793E22480e9Bfd6031E2230e68e1822193717
BSC_LAYER_ZERO_ADAPTER_MAINNET=0xaC3c8D19A64B98d62ED16FFf8a4229E8ED36A469
GOERLI_ZETA_REPORTER_BSC_TESTNET=0x9a9fc484D3F83B489bc58c2A3EeeA8331F21796B
BSC_TESTNET_ZETA_ADAPTER_GOERLI=0x2829D554678a767c5B091D28A0A294dB7643ec05
MAINNET_CCIP_REPORTER_AVALANCHE=0xeEFD0D67E4eF9330870961C38a3e25ECE369B141
AVALANCHE_CCIP_ADAPTER_MAINNET=0x04413A4795dD1f5347eAD1CD7C76Bd9E5e48b461
GNOSIS_SYGMA_ADAPTER=0x483285D0e24401D0C5DB6cF1FAC4f79f412079C0
MAINNET_SYGMA_REPORTER_GNOSIS=0x973bB99db211755b80c9087fe436fBb81A45AD5E
MAINNET_HEADER_STORAGE=0x22F1fc71A505c0b2bf4D5075801cc5E0ec84B09e
GOERLI_HEADER_STORAGE=0x4cD014AC64AAa899b46BF3a477B68bb67e33eDC4
CHIADO_ELECTRON_ADAPTER_GOERLI=0x66fBC348aef3797fb885f8073173E5064bf7ABBb
CHIADO_ELECTRON_LIGHT_CLIENT_GOERLI=0xc01707bD835f6108785DF081C943C7C108FC3D89
2 changes: 2 additions & 0 deletions packages/reporter/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/dist
**/node_modules
21 changes: 21 additions & 0 deletions packages/reporter/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/eslint-recommended"
- "plugin:@typescript-eslint/recommended"
- "prettier"
parser: "@typescript-eslint/parser"
parserOptions:
project: "tsconfig.json"
plugins:
- "@typescript-eslint"
root: true
rules:
"@typescript-eslint/no-floating-promises":
- error
- ignoreIIFE: true
ignoreVoid: true
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-unused-vars":
- error
- argsIgnorePattern: "_"
varsIgnorePattern: "_"
1 change: 1 addition & 0 deletions packages/reporter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logs/
1 change: 1 addition & 0 deletions packages/reporter/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
2 changes: 2 additions & 0 deletions packages/reporter/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/dist
**/node_modules
7 changes: 7 additions & 0 deletions packages/reporter/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"
semi: false
13 changes: 13 additions & 0 deletions packages/reporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:alpine

WORKDIR /usr/src/app

COPY package.json yarn.lock .env ./

RUN yarn install

ADD . /usr/src/app

RUN yarn compile

CMD ["node", "dist/index.js"]
65 changes: 65 additions & 0 deletions packages/reporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# reporter

Script to call Header Reporter contracts of different oracle from source chain to destination chain.

&nbsp;

---

&nbsp;

## Getting Started

These instructions will cover the usage information and how to run the code using Docker.

### Create the .env file

Configure the mode you want to run by editing the variable in `.env` by checking `.env.example`

### Building the Docker Image

To build the Docker image, run the following command from the root of the project:

```sh
docker build -t reporter .
```

### Running the reporter

After building the image, you can run it using the following command:

```sh
docker run -d -p reporter
```

### Viewing Logs

To view the logs from the running container, use:

```sh
docker logs -f [CONTAINER_ID or CONTAINER_NAME]
```

You can find the `CONTAINER_ID` or `CONTAINER_NAME` using `docker ps`.

### Stopping the reporter

To stop the running container:

```sh
docker stop [CONTAINER_ID or CONTAINER_NAME]
```

&nbsp;

---

&nbsp;

## How to add a new controller

1. Add a new file under `/controllers`, create the constructor and `onBlocks` function to call block header reporter
contract periodically.
2. Configure the settings under `settings/index.ts`.
3. Add the new controller instant in `index.ts`.
4. Add the env variable in `.env.example`.
6 changes: 6 additions & 0 deletions packages/reporter/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts,json",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node --esm ./src/index.ts"
}
42 changes: 42 additions & 0 deletions packages/reporter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "reporter",
"author": {
"name": "gnosis",
"url": "https://github.com/gnosis"
},
"type": "module",
"scripts": {
"compile": "tsc",
"lint": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
"prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yml}\"",
"prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yml}\"",
"start:dev": "nodemon"
},
"packageManager": "[email protected]",
"dependencies": {
"@chainsafe/persistent-merkle-tree": "^0.6.1",
"@chainsafe/ssz": "^0.14.0",
"@ethereumjs/rlp": "^5.0.1",
"@ethereumjs/trie": "^6.0.1",
"@ethereumjs/util": "^9.0.1",
"@ethereumjs/vm": "^7.1.0",
"@lodestar/types": "^1.12.0",
"async-mutex": "^0.4.0",
"axios": "^1.5.1",
"dotenv": "^16.3.1",
"viem": "^1.16.5",
"winston": "^3.11.0"
},
"devDependencies": {
"@types/node": "^20.8.9",
"@types/node-cron": "^3.0.9",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
98 changes: 98 additions & 0 deletions packages/reporter/src/ABIs/AMBReporterContractABI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[
{
"inputs": [
{
"internalType": "contract IAMB",
"name": "_amb",
"type": "address"
},
{
"internalType": "contract HeaderStorage",
"name": "_headerStorage",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "emitter",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "blockHeader",
"type": "bytes32"
}
],
"name": "HeaderReported",
"type": "event"
},
{
"inputs": [],
"name": "amb",
"outputs": [
{
"internalType": "contract IAMB",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "headerStorage",
"outputs": [
{
"internalType": "contract HeaderStorage",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256[]",
"name": "blockNumbers",
"type": "uint256[]"
},
{
"internalType": "address",
"name": "ambAdapter",
"type": "address"
},
{
"internalType": "uint256",
"name": "gas",
"type": "uint256"
}
],
"name": "reportHeaders",
"outputs": [
{
"internalType": "bytes32",
"name": "receipt",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading
Loading