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

Axelar Relayer 1st version #5

Merged
merged 44 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
419767c
Remove unneeded nestjs template code, add apps for mvx event processo…
raress96 Dec 5, 2023
802418d
Process gateway call contract event and save data into database.
raress96 Dec 6, 2023
32d41c9
Generate interfaces from grpc proto file and add grpc service.
raress96 Dec 7, 2023
9613ddf
Add processing of gas service events and saving to database.
raress96 Dec 7, 2023
40d7192
Improvement for gas service event handling and tests for various serv…
raress96 Dec 8, 2023
db4e26c
Finish tests for gas service contract.
raress96 Dec 8, 2023
018d5d1
Remove order from event processor.
raress96 Dec 11, 2023
8f85884
Process contract call approved event.
raress96 Dec 11, 2023
c98880e
Start processing and sending of call contract approved transactions.
raress96 Dec 11, 2023
6ef49f1
Working cronjobs for processing and sending contract call transactions.
raress96 Dec 12, 2023
5e89dea
Process contract call executed event.
raress96 Dec 12, 2023
b538965
Add e2e test for call contract approved processor.
raress96 Dec 12, 2023
63a986d
Create cron that subscribes to axelar events and sends transactions.
raress96 Dec 13, 2023
981e13c
Add test for approvals processor.
raress96 Dec 13, 2023
066322e
Add chain id as env var for simplicity.
raress96 Dec 13, 2023
3a6b65a
Merge branch 'process_multiversx_contract_calls' into process_axelar_…
raress96 Dec 13, 2023
c49f718
Merge pull request #1 from buidly/process_mvx_gateway_events
raress96 Dec 14, 2023
62d3ef9
Add chain id as env var for simplicity.
raress96 Dec 13, 2023
8482f62
Merge branch 'process_multiversx_contract_calls' into process_axelar_…
raress96 Dec 14, 2023
a279f14
Fix pipeline.
raress96 Dec 14, 2023
d46447d
Merge branch 'process_multiversx_contract_calls' into process_axelar_…
raress96 Dec 14, 2023
d395f35
Merge branch 'process_multiversx_contract_calls' into gas_checker
raress96 Dec 14, 2023
ac39ba3
Create basic cron for collecting gas service fees.
raress96 Dec 14, 2023
53e5e89
Merge branch 'process_axelar_chain_events' into gas_checker
raress96 Dec 14, 2023
80a049f
Working gas checker cron and refactoring.
raress96 Dec 14, 2023
b625875
Add gas checker test.
raress96 Dec 15, 2023
d0ce237
Merge pull request #4 from buidly/gas_checker
raress96 Jan 8, 2024
037fd42
Merge pull request #3 from buidly/process_axelar_chain_events
raress96 Jan 8, 2024
ccc16fb
Merge pull request #2 from buidly/process_multiversx_contract_calls
raress96 Jan 8, 2024
80046b3
Change unsupported log index value to 0.
raress96 Jan 22, 2024
072f460
Start working on special handling for its transactions.
raress96 Jan 22, 2024
36eede3
Handle special its transactions that need to send egld.
raress96 Jan 23, 2024
0ab7b29
Bug fixes and new proto file.
raress96 Jan 29, 2024
17afec9
Basic support for processing operatorship transferred event and impro…
raress96 Jan 30, 2024
cfb3e6c
Properly implement operatorship transferred event handling and grpc r…
raress96 Feb 2, 2024
a3782f2
Add test for call contract approved processor.
raress96 Feb 2, 2024
d576d60
Merge branch 'relayer_update' into develop
raress96 Feb 16, 2024
a09ed64
Add prisma deploy script.
raress96 Feb 16, 2024
104f7f7
Updates for new amplifier api grpc definition.
raress96 Mar 26, 2024
c4fd97b
Merge pull request #8 from multiversx/update_amplifier_api
dragos-rebegea Apr 3, 2024
c0be0bf
Update amplifier proto definition with proper package.
raress96 Apr 5, 2024
50bf850
Update for correct proto file from amplifier examples repo.
raress96 Apr 8, 2024
4bb7d56
Update message id for amplifier.
raress96 Apr 9, 2024
5e4911b
Small improvements for approvals processor and fix for send transacti…
raress96 Apr 10, 2024
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
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
DATABASE_URL=postgresql://root:password@localhost:5432/relayer

API_URL=https://devnet-api.multiversx.com
GATEWAY_URL=https://devnet-gateway.multiversx.com
REDIS_URL=127.0.0.1

EVENTS_NOTIFIER_URL=amqp://user:password@rabbitmq:5672
EVENTS_NOTIFIER_QUEUE=queue

CONTRACT_GATEWAY=erd1qqqqqqqqqqqqqpgqhxy6dv9k5p3u4d6rawnwjyp0j3sunu9dkklspga3t9
CONTRACT_GAS_SERVICE=erd1qqqqqqqqqqqqqpgqsrhknrwuvy606ar5l2kuaz4glgyyye9vkkls5ng86g
CONTRACT_ITS=erd1qqqqqqqqqqqqqpgqw08zahneragk9rnaujwe8qcyu84ehw2lkklsvca0jx

CONTRACT_WEGLD_SWAP=erd1qqqqqqqqqqqqqpgqpv09kfzry5y4sj05udcngesat07umyj70n4sa2c0rp

AXELAR_CONTRACT_VOTING_VERIFIER=axelar1gajw625kz8el4ayk8fwpy7r6ew0m7zrg9jdd6grg85fle39shuxqwuaz2k

AXELAR_API_URL=devnet-amplifier-api.axelar.dev:11235

CHAIN_ID=D

WALLET_MNEMONIC=
23 changes: 23 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
DATABASE_URL=postgresql://root:password@localhost:5432/relayer_test

API_URL=http://api.local
GATEWAY_URL=http://gateway.local
REDIS_URL=localhost

EVENTS_NOTIFIER_URL=amqp://user:[email protected]:5672
EVENTS_NOTIFIER_QUEUE=events-2cf3b817

CONTRACT_GATEWAY=erd1qqqqqqqqqqqqqpgqvc7gdl0p4s97guh498wgz75k8sav6sjfjlwqh679jy
CONTRACT_GAS_SERVICE=erd1qqqqqqqqqqqqqpgqhe8t5jewej70zupmh44jurgn29psua5l2jps3ntjj3
CONTRACT_ITS=erd1qqqqqqqqqqqqqpgq97wezxw6l7lgg7k9rxvycrz66vn92ksh2tssxwf7ep

CONTRACT_WEGLD_SWAP=erd1qqqqqqqqqqqqqpgqhe8t5jewej70zupmh44jurgn29psua5l2jps3ntjj3

AXELAR_CONTRACT_VOTING_VERIFIER=axelar1jjtc5zemkt9tn6nfvk78xl6f8svrrsvyqcdcca

AXELAR_API_URL=localhost:5000

CHAIN_ID=test

# erd1fsk0cnaag2m78gunfddsvg0y042rf0maxxgz6kvm32kxcl25m0yq8s38vt
WALLET_MNEMONIC="fitness horror fluid six mutual ahead upon zone install stadium shuffle arrive caution flat slam machine wasp steel stand frog exist drink market absent"
29 changes: 0 additions & 29 deletions .github/workflows/lint.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: ESLint & Tests

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: 'redis:alpine'
ports:
- 6379:6379
postgres:
image: postgres:latest
ports:
- 5432:5432
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: relayer_test

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint

- run: npm run test

- run: npm install -g dotenv-cli
- run: npm run test:migrate
- run: npm run test:e2e
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ lerna-debug.log*

# Configs
**/*/config/config.yaml
**/*/config/config.custom.yaml
**/*/config/config.custom.yaml

.db/*

.env
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"printWidth": 120
}
126 changes: 31 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,108 +1,22 @@
REST API facade template for microservices that interacts with the MultiversX blockchain.
Axelar Relayer for MultiversX blockchain.

Based on Amplifier API Docs: https://bright-ambert-2bd.notion.site/Amplifier-API-Docs-EXTERNAL-7c56c143852147cd95b1c4a949121851

## Quick start

1. Run `npm install` in the project directory
2. Optionally make edits to `config.yaml` or create `config.custom.yaml` for each microservice
2. Copy `.env.example` file to `.env` file and update the values
3. Run `docker-compose up -d`
4. Run `npm start` or `npm start:axelar-event-processor`

## Dependencies

1. Redis Server is required to be installed [docs](https://redis.io/).
2. MySQL Server is required to be installed [docs](https://dev.mysql.com/doc/refman/8.0/en/installing.html).
3. MongoDB Server is required to be installed [docs](https://docs.mongodb.com/).

You can run `docker-compose up` in a separate terminal to use a local Docker container for all these dependencies.

After running the sample, you can stop the Docker container with `docker-compose down`

## Available Features

These features can be enabled/disabled in config file

### `Public API`

Endpoints that can be used by anyone (public endpoints).

### `Private API`

Endpoints that are not exposed on the internet
For example: We do not want to expose our metrics and cache interactions to anyone (/metrics /cache)

### `Cache Warmer`

This is used to keep the application cache in sync with new updates.

### `Transaction Processor`
2. PostgreSQL is required to be installed [docs](https://www.postgresql.org/).

This is used for scanning the transactions from MultiversX Blockchain.
In this repo there is a `docker-compose.yml` file providing these services so you can run them easily using `docker-compose up -d`

### `Queue Worker`

This is used for concurrently processing heavy jobs.

## Available Scripts

This is a MultiversX project built on Nest.js framework.

### `npm run start:mainnet`

Runs the app in the production mode.
Make requests to [http://localhost:3001](http://localhost:3001).

Redis Server is required to be installed.

## Running the api

```bash
# development watch mode on devnet
$ npm run start:devnet:watch

# development debug mode on devnet
$ npm run start:devnet:debug

# development mode on devnet
$ npm run start:devnet

# production mode
$ npm run start:mainnet
```

## Running the transactions-processor

```bash
# development watch mode on devnet
$ npm run start:transactions-processor:devnet:watch

# development debug mode on devnet
$ npm run start:transactions-processor:devnet:debug

# development mode on devnet
$ npm run start:transactions-processor:devnet

# production mode
$ npm run start:transactions-processor:mainnet
```

## Running the queue-worker

```bash
# development watch mode on devnet
$ npm run start:queue-worker:devnet:watch

# development debug mode on devnet
$ npm run start:queue-worker:devnet:debug

# development mode on devnet
$ npm run start:queue-worker:devnet

# production mode
$ npm run start:queue-worker:mainnet
```

Requests can be made to http://localhost:3001 for the api. The app will reload when you'll make edits (if opened in watch mode). You will also see any lint errors in the console.​

### `npm run test`
## Tests

```bash
# unit tests
Expand All @@ -114,3 +28,25 @@ $ npm run test:e2e
# test coverage
$ npm run test:cov
```

## Regenerating gRPC Typescript interfaces from proto file

Make sure to have `protoc` installed https://grpc.io/docs/protoc-installation/.

Then you can compile the files using:
```
TS_ARGS=('lowerCaseServiceMethods=true'
'outputEncodeMethods=false'
'outputJsonMethods=false'
'outputClientImpl=false'
'snakeToCamel=true')
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto\
--ts_proto_out=./libs/common/src/grpc/entities\
--proto_path=./libs/common/src/assets\
--ts_proto_opt="$(IFS=, ; echo "${TS_ARGS[*]}")"\
./libs/common/src/assets/amplifier.proto
```

Check out these resources for more information:
- https://github.com/stephenh/ts-proto/blob/main/NESTJS.markdown
- https://blog.stackademic.com/nestjs-grpc-typescript-codegen-9a342bbd32f9
33 changes: 0 additions & 33 deletions apps/api/config/config.devnet.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions apps/api/config/config.mainnet.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions apps/api/config/config.testnet.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions apps/api/config/configuration.ts

This file was deleted.

Loading
Loading