The purpose of this relayer is to facilitate execution to external chain on Carbon-Axelar bridge. e.g. withdrawals, or any external executions
- Watch
Switcheo.carbon.bridge.NewPendingActionEvent
from Carbon - Check if fees are profitable for relay (See below)
- If profitable, save
Switcheo.carbon.bridge.NewPendingActionEvent
record in DB with its nonce - Call StartRelay on Carbon
- Watch for
BridgeRevertedEvent
(delete action and stop processing) - Watch and save
Switcheo.carbon.bridge.AxelarCallContractEvent
from Carbon where event.nonce matches nonce in DB - Watch and save
ContractCallApproved
event from external chain's Axelar Gateway if thepayload_hash
matches theAxelarCallContractEvent
record in the DB - poll any new event saved,
- check
is_contract_call_approved
to see if it's already executed - execute to the external blockchain to process the withdrawal or GMP
- check
Note: relayer needs to be whitelisted on carbon
# install libssl-dev pkg-config
sudo apt install libssl-dev pkg-config
# install buf
# Substitute BIN for your bin directory.
# Substitute VERSION for the current released version.
BIN="/usr/local/bin" && \
VERSION="1.34.0" && \
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
follow installation:
then use
rustup install 1.85.1
rustup default 1.85.1
# pre: only if on linux
sudo apt update
sudo apt install build-essential pkg-config libssl-dev -y
- mac:
brew install postgresql@15
- ubuntu: https://www.postgresql.org/download/linux/ubuntu/
# install sqlx
cargo install sqlx-cli --no-default-features --features native-tls,postgres
# env variable for local development with sqlx (to enable migration etc.)
DATABASE_URL=postgresql://localhost:5432/carbon_axelar_execute_relayer
sqlx database setup
cp config.sample.toml config.toml
# download and setup
VERSION=v0.1.1
wget https://github.com/Switcheo/carbon_axelar_execute_relayer/releases/download/$VERSION/carbon_axelar_execute_relayer-x86_64-unknown-linux-gnu.tar.gz
tar -xvzf carbon_axelar_execute_relayer-x86_64-unknown-linux-gnu.tar.gz
chmod +x carbon_axelar_execute_relayer
# run
./carbon_axelar_execute_relayer -vv run
# run
cargo run -- -vv run
# run with more logs, number of v's:
# 0 => Level::ERROR,
# 1 => Level::WARN,
# 2 => Level::INFO,
# 3 => Level::DEBUG,
# >3 => Level::TRACE,
cargo run -- -vvvv run
# run with a different config file
cargo run -- --config your_config.toml -vv run
# prepares sqlx for compiling
cargo sqlx prepare -- --bin carbon_axelar_execute_relayer
# compiles to ./target/debug/carbon_axelar_execute_relayer
cargo build
# compiles to ./target/release/carbon_axelar_execute_relayer
cargo build --release
release
# optionally, add release tag to trigger compilation on github
git tag v1.0.0
git push origin v1.0.0
# INFO: Deleting a tag to re-release
git tag -d v1.0.0
git push origin :refs/tags/v1.0.0
git tag v1.0.0
git push origin v1.0.0
# reset database
sqlx database reset
# migrate
sqlx migrate run
# rollback
sqlx migrate revert
# others, use help for more info
sqlx --help
sqlx database --help
sqlx <command> --help
Sometimes transactions get stuck at various points either when a relayer is down or an RPC or WS endpoint is down.
The way to resolve this is to manually call the cli to save the tx since it is missed
# using hex payload
cargo run -- -vv execute-contract-call-approved mantle-testnet 0xcdebbc1eb3895b9d709c0e4f098b8be3ea600fa3c894b0a8c693e012ee501720 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006000000000000000000000000040eeba3ba9b2afef980079a841cd4693e3c835c0000000000000000000000000ad90498006ecb49a3bfa145aa99cb08573f924530000000000000000000000000000000000000000000000056bc75e2d63100000
# using base64 payload, with config file config.develop.toml
cargo run -- --config config.develop.toml -vv execute-contract-call-approved mantle-testnet 0xcdebbc1eb3895b9d709c0e4f098b8be3ea600fa3c894b0a8c693e012ee501720 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAOc69adqgRoWpA/5PqFt/qEMSToOAAAAAAAAAAAAAAAAp2UQC2kn1Lb2oszyaBeY1T4f0QEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ==
# resync from carbon's start block height to end block height to populate missed events so that they can be relayed
cargo run -- -vv sync-from 788086 788099
# resync from carbon's start block height to end block height to populate missed events so that they can be relayed
# specify which block to search for evm events
cargo run -- -vv sync-from 788086 788099
# start a relay on a nonce
cargo run -- -vv start-relay 1
# expires pending actions by their nonces
cargo run -- -vv expire-pending-actions 1,2,3
Pre-requisite: install buf
cli on your computer https://buf.build/docs/cli/installation/
# Note: `cd` into `proto` folder first before running buf
cd proto
# update the proto dependencies in buf.yaml
buf dep update
# generate
buf generate