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 34 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
39 changes: 39 additions & 0 deletions packages/reporter/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PRIVATE_KEY=

REPORTERS_ENABLED2=AMBReporterController,TelepathyReporterController,SygmaReporterController
REPORTERS_ENABLED=AMBReporterController,SygmaReporterController,TelepathyReporterController

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

AMB_REPORTER_HEADERS_GAS=300000
SYGMA_REPORT_HEADERS_TO_DOMAIN_MSG_VALUE=0.0001

TELEPATHY_PROOF_API_URL=
TELEPATHY_BLOCK_BUFFER=10
TELEPATHY_INTERVAL_FETCH_HEAD_UPDATES=30000

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
POLYGON_AXELAR_ADAPTER=0x4694E10017Ed7E0E87bfE386e5f051a7C64286A2
BSC_TELEPATHY_ADAPTER=0x2E5685F20f42cC3b01e4A9ADE49F6848E242f022
BSC_AXELAR_ADAPTER=0x856dcc80f75a9737D9D498266E1Af013668316Fb
OPTIMISM_TELEPATHY_ADAPTER=0x856dcc80f75a9737D9D498266E1Af013668316Fb
OPTIMISM_AXELAR_ADAPTER=0x6E9ce437c46e7fA4F0888c21AAC0d9099Ad133ea
ARBITRUM_TELEPATHY_ADAPTER=0x2E5685F20f42cC3b01e4A9ADE49F6848E242f022
ARBITRUM_AXELAR_ADAPTER=0x6E9ce437c46e7fA4F0888c21AAC0d9099Ad133ea
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 ./src/index.ts"
}
34 changes: 34 additions & 0 deletions packages/reporter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "reporter",
"author": {
"name": "gnosis",
"url": "https://github.com/gnosis"
},
"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": {
"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