-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: init * chore: refactor setup * chore: update docker stuff * chore: fix docker commands * chore: refactor docker * chore: add more expect in stop testcase * chore: export mnemonic * chore: improve gitignore * chore: return mnemonic to response * chore: add more checks in test * chore: init cosmos client * chore: replace simd with cosmd * chore: fix wasm startup script * chore: update healtchecking url * chore: setup tests and fix wrong mnemonic exposed * chore: fix hardcoded denom * chore: refactor CosmosClient * chore: add response check * chore: add wasm contract * chore: reorder import * chore: allow denom to be specified * chore: update chain_name to chain_id * chore: remove moniker in config * chore: fix moniker * chore: add denom to default config * chore: refactor test * chore: fix tests * chore: update default denom * chore: remove unnecessary confie files * feat: add axelar container * chore: fix denom issue * chore: refactor docker for axelar and wasm * chore: fix start script * chore: fix start script to start all chains * chore: stardardized logs * chore: fix port issues * chore: fix return rpcUrl and lcdIrl * chore: fix tests * chore: remove lcdPort and rpcPort in config * chore: fix gas issue * chore: added IBCRelayerClient * chore: add axelar setup commands * chore: updates tests * chore: refactor scripts * chore: add ws stop * chore: update command * chore: integrate axelar script with start command * chore: remove conflict * chore: remove empty function * chore: add doc to RelayerAccountManager * chore: fix docker path * chore: add retry function and fix path * chore: fix axelar setup bug * chore: start implemented relayer * feat: add AxelarRelayerService * chore: add start script * chore: add example contracts * feat: complete evm -> cosmos * chore: add wasm to evm test * chore: update * chore: fix relayer test * chore: remove unnecessary tests * chore: add tests for validating axelar chain states * chore: add Path to provide consistent path values * chore: remove unused functions * chore: refactor CosmosClient * chore: cleanup * chore: replace readFileSync * chore: refactor paths * chore: refactor docker * chore: fix channels bug * chore: cleanup * chore: bump version to 2.2.0-alpha.1 * chore: add build and test command * chore: fix build error * v2.2.0-alpha.2 * chore: fix dependencies * v2.2.0-alpha.3 * chore: bump to alpha.3 * v2.2.0-alpha.4 * chore: remove jest from build * v2.2.0-alpha.5 * chore: add check if docker command is installed * chore: remove logs * chore: add build:cosmos command * v2.2.0-alpha.6 * chore: add docker to published files * v2.2.0-alpha.7 * chore: clean up * chore: handle existing ibc connection doesn't work * v2.2.0-alpha.8 * chore: allow to pass mnemonic to create function * v2.2.0-alpha.9 * chore: move create and import account to CosmosClient * chore: catch error in relay function * v2.2.0-alpha.10 * chore: start traefik first * chore: bump version * chore: update port to avoid conflict * chore: bump version * v2.2.0 * chore: update package.json * feat: add waitTimeout * chore: bump to alpha 13 * chore: add rpc wait timeout * chore: bump version to 14 * chore: update docker base image * chore: add makefile for managing docker images * chore: update to alpha 16 * chore: fix bug cannot setup axelar chain * chore: bump to alpha 17 * chore: add way to stop ws connection * chore: bump to 18 * chore: add back close event listener * v2.2.0-alpha.19 * chore: refactor AxelarListener * v2.2.0-alpha.20 * chore: fix cannot remove close event on ws listener * chore: bump to version 21 * chore: bump to 22 * add maxRetries * chore: add start:cosmos script * chore: fix build script * chore: fix cosmos build error * chore: update package.lock chore: update package-lock chore: fix fsevents chore: fix interchain-token-service version * chore: increase sleep duration chore: start containers during jest setup * chore: fix fetch is not defined * chore: fix test chore: test e2e chore: fix typo * feat: updated its once more (#102) * updated its once more * update version * fix sui * chore: run all tests chore: update package-lock.json chore: don't install optional dep chore: update omit command chore: update package-lock.json chore: update package-lock chore: uncomment sui-test-validator chore: update README.md chore: update root README.md chore: fix cache key * v2.2.0-beta.1 * chore: allow configure gas price * chore: add function doc for `CosmosClient` * chore: update setup docs * chore: fix gas price bug * v2.2.0 * chore: fix need to call relay twice * chore: refactor AxelarRelayerService to make it easier to use * chore: remove testMnemonic * chore: rename function and revert package-lock.json * chore: update startAll to startChains * chore: add README.md * chore: fix test * v2.2.0-alpha.26 * v2.2.0-alpha.27 * chore: add bech32 * chore: update v28 * chore: update package.json * chore: update package-lock.json * chore: fix package-lock.json * chore: bump version to 2.3.0 * chore: bump axelar-local-dev version for cosmos * chore: fix deps install --------- Co-authored-by: Foivos <[email protected]>
- Loading branch information
Showing
80 changed files
with
5,145 additions
and
1,490 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
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 |
---|---|---|
|
@@ -137,4 +137,4 @@ target/ | |
**/*.rs.bk | ||
|
||
# Near wasm contract | ||
*.wasm | ||
packages/axelar-local-dev-near/**/*.wasm |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,8 @@ | ||
.env | ||
|
||
# Docker | ||
docker/**/.* | ||
config.json | ||
channel.json | ||
connection.json | ||
info/* |
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,84 @@ | ||
# Axelar Local Dev Cosmos | ||
|
||
Axelar Local Dev Cosmos offers a comprehensive suite of tools for local development involving Cosmos chains. With this package, developers can easily deploy WebAssembly (Wasm) contracts on a Wasm chain and seamlessly send cross-chain messages to the Ethereum Virtual Machine (EVM) chain. | ||
|
||
> **Note:** This package is currently under development. Some functionalities might be unstable. | ||
## Prerequisite | ||
|
||
- Docker installed and running on your local machine. | ||
|
||
## Quick Start | ||
|
||
### Start Wasm and Axelar Chain | ||
|
||
Run the following command to pull the Docker image, set up the chains, and establish IBC connections: | ||
|
||
```bash | ||
npm run start | ||
``` | ||
|
||
Alternatively, you can start the chains programmatically: | ||
|
||
```ts | ||
import { startChains } from "@axelar-network/axelar-local-dev-cosmos"; | ||
|
||
startChains(); | ||
``` | ||
|
||
## Running IBC Relayer and Axelar Event Listener | ||
|
||
After setting up the chains, follow these steps to run the IBC Relayer and Axelar Event Listener: | ||
|
||
**Create Axelar Relayer Service** for initailizing the IBC channels and keep listening to incoming events: | ||
|
||
```ts | ||
import { | ||
defaultAxelarChainInfo, | ||
AxelarRelayerService, | ||
} from "@axelar-network/axelar-local-dev-cosmos"; | ||
|
||
const axelarRelayerService = await AxelarRelayerService.create( | ||
defaultAxelarChainInfo | ||
); | ||
``` | ||
|
||
## Relaying Messages | ||
|
||
To relay messages after they have been submitted on the Ethereum or Wasm chains, use the following method: | ||
|
||
```ts | ||
import { | ||
evmRelayer, | ||
createNetwork, | ||
relay, | ||
RelayerType, | ||
} from "@axelar-network/axelar-local-dev"; | ||
import { | ||
defaultAxelarChainInfo, | ||
AxelarRelayerService, | ||
} from "@axelar-network/axelar-local-dev-cosmos"; | ||
|
||
// Setup for Ethereum Network and Wasm chain relayer | ||
const evmNetwork = await createNetwork({ name: "Ethereum" }); | ||
const wasmRelayer = await AxelarRelayerService.create(defaultAxelarChainInfo); | ||
|
||
// Deploy contracts, send messages, and call the relay function | ||
// ... | ||
|
||
evmRelayer.setRelayer(RelayerType.Wasm, wasmRelayer); | ||
await relay({ | ||
wasm: wasmRelayer, | ||
evm: evmRelayer, | ||
}); | ||
|
||
// Verify results on the destination chain | ||
// ... | ||
``` | ||
|
||
### Examples | ||
|
||
- We currently support `Ethereum` as the destination chain for messages originating from the Wasm chain. | ||
- For implementation details, see our [Local Example](docs/example.md) and [Axelar Example](https://github.com/axelarnetwork/axelar-examples/tree/feat/add-cosmos-examples/examples/cosmos/call-contract). | ||
|
||
> The Local Example utilizes the same contracts as in the Axelar Examples. |
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,14 @@ | ||
# Download axelar binary for alpine image | ||
FROM ubuntu:22.04 | ||
|
||
# Define a build argument for architecture | ||
ARG ARCH=amd64 | ||
|
||
RUN apt update && apt install -y wget | ||
|
||
# Download axelar binary for alpine image | ||
RUN wget https://github.com/axelarnetwork/axelar-core/releases/download/v0.34.1/axelard-linux-${ARCH}-v0.34.1 -O axelard \ | ||
&& chmod +x axelard \ | ||
&& mv axelard /usr/local/bin/ | ||
|
||
ENTRYPOINT ["/bin/sh"] |
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,24 @@ | ||
.PHONY: build-arm64 build-amd64 push-arm64 push-amd64 push manifest | ||
|
||
IMAGE_NAME=nptytn/local-axelard | ||
|
||
# Check if VERSION is set | ||
ifndef VERSION | ||
$(error VERSION is not set) | ||
endif | ||
|
||
push-arm64: | ||
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(IMAGE_NAME):$(VERSION)-arm64 . --push | ||
|
||
push-amd64: | ||
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(IMAGE_NAME):$(VERSION)-amd64 . --push | ||
|
||
push: | ||
make push-arm64 | ||
make push-amd64 | ||
|
||
manifest: | ||
docker manifest create $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(VERSION)-arm64 $(IMAGE_NAME):$(VERSION)-amd64 | ||
docker manifest annotate $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(VERSION)-arm64 --os linux --arch arm64 | ||
docker manifest annotate $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(VERSION)-amd64 --os linux --arch amd64 | ||
docker manifest push $(IMAGE_NAME):$(VERSION) |
92 changes: 92 additions & 0 deletions
92
packages/axelar-local-dev-cosmos/docker/axelar/bin/init_axelar.sh
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,92 @@ | ||
#!/bin/sh | ||
|
||
DENOM=uaxl | ||
CHAIN_ID=axelar | ||
MONIKER=axelar | ||
HOME=/root/private/.axelar | ||
|
||
# Removing the existing directory to start with a clean slate | ||
rm -rf ${HOME}/* | ||
|
||
DEFAULT_KEYS_FLAGS="--keyring-backend test --home ${HOME}" | ||
ASSETS="100000000000000000000${DENOM}" | ||
|
||
# Initializing a new blockchain with identifier ${CHAIN_ID} in the specified home directory | ||
axelard init "$MONIKER" --chain-id ${CHAIN_ID} --home ${HOME} > /dev/null 2>&1 && echo "Initialized new blockchain with chain ID ${CHAIN_ID}" | ||
|
||
# edit the app.toml file to enable the API and swagger | ||
sed -i '/\[api\]/,/\[/ s/enable = false/enable = true/' "$HOME"/config/app.toml | ||
sed -i '/\[api\]/,/\[/ s/swagger = false/swagger = true/' "$HOME"/config/app.toml | ||
|
||
# staking/governance token is hardcoded in config, change this | ||
sed -i "s/\"stake\"/\"$DENOM\"/" "$HOME"/config/genesis.json && echo "Updated staking token to $DENOM" | ||
|
||
|
||
# Adding a new key named 'owner' with a test keyring-backend in the specified home directory | ||
# and storing the mnemonic in the mnemonic.txt file | ||
mnemonic=$(axelard keys add owner ${DEFAULT_KEYS_FLAGS} 2>&1 | tail -n 1) | ||
echo ${mnemonic} | tr -d "\n" > ${HOME}/mnemonic.txt | ||
echo "Added new key 'owner'" | ||
|
||
gov1_mnemonic=$(axelard keys add gov1 ${DEFAULT_KEYS_FLAGS} 2>&1 | tail -n 1) | ||
echo ${gov1_mnemonic} | tr -d "\n" > ${HOME}/mnemonic-gov1.txt | ||
echo "Added new key 'gov1'" | ||
|
||
gov2_mnemonic=$(axelard keys add gov2 ${DEFAULT_KEYS_FLAGS} 2>&1 | tail -n 1) | ||
echo ${gov2_mnemonic} | tr -d "\n" > ${HOME}/mnemonic-gov2.txt | ||
echo "Added new key 'gov2'" | ||
|
||
$(axelard keys add governance --multisig "gov1,gov2" --multisig-threshold 1 --nosort ${DEFAULT_KEYS_FLAGS} 2>&1 | tail -n 1) | ||
echo "Added new key 'governance'" | ||
|
||
# Adding a new genesis account named 'owner' with an initial balance of 100000000000000000000 in the blockchain | ||
axelard add-genesis-account owner ${ASSETS} \ | ||
--home ${HOME} \ | ||
--keyring-backend test > /dev/null 2>&1 && echo "Added 'owner' to genesis account" | ||
|
||
axelard add-genesis-account gov1 ${ASSETS} \ | ||
--home ${HOME} \ | ||
--keyring-backend test > /dev/null 2>&1 && echo "Added 'gov1' to genesis account" | ||
|
||
axelard add-genesis-account gov2 ${ASSETS} \ | ||
--home ${HOME} \ | ||
--keyring-backend test > /dev/null 2>&1 && echo "Added 'gov2' to genesis account" | ||
|
||
axelard add-genesis-account governance ${ASSETS} \ | ||
--home ${HOME} \ | ||
--keyring-backend test > /dev/null 2>&1 && echo "Added 'governance' to genesis account" | ||
|
||
axelard set-genesis-mint --inflation-min 0 --inflation-max 0 --inflation-max-rate-change 0 --home ${HOME} | ||
axelard set-genesis-gov --minimum-deposit "100000000${DENOM}" --max-deposit-period 90s --voting-period 90s --home ${HOME} | ||
axelard set-genesis-reward --external-chain-voting-inflation-rate 0 --home ${HOME} | ||
axelard set-genesis-slashing --signed-blocks-window 35000 --min-signed-per-window 0.50 --home ${HOME} \ | ||
--downtime-jail-duration 600s --slash-fraction-double-sign 0.02 --slash-fraction-downtime 0.0001 --home ${HOME} | ||
axelard set-genesis-snapshot --min-proxy-balance 5000000 --home ${HOME} | ||
axelard set-genesis-staking --unbonding-period 168h --max-validators 50 --bond-denom "$DENOM" --home ${HOME} | ||
axelard set-genesis-chain-params evm Ethereum --evm-network-name ethereum --evm-chain-id 5 --network ethereum --confirmation-height 1 --revote-locking-period 5 --home ${HOME} | ||
|
||
GOV_1_KEY="$(axelard keys show gov1 ${DEFAULT_KEYS_FLAGS} -p)" | ||
GOV_2_KEY="$(axelard keys show gov2 ${DEFAULT_KEYS_FLAGS} -p)" | ||
axelard set-governance-key 1 "$GOV_1_KEY" "$GOV_2_KEY" --home ${HOME} | ||
axelard validate-genesis --home ${HOME} | ||
|
||
# Generating a new genesis transaction for 'owner' delegating 70000000${DENOM} in the blockchain with the specified chain-id | ||
axelard gentx owner 70000000${DENOM} \ | ||
--home ${HOME} \ | ||
--keyring-backend test \ | ||
--moniker ${MONIKER} \ | ||
--chain-id ${CHAIN_ID} > /dev/null 2>&1 && echo "Generated genesis transaction for 'owner'" | ||
|
||
# Collecting all genesis transactions to form the genesis block | ||
axelard collect-gentxs \ | ||
--home ${HOME} > /dev/null 2>&1 && echo "Collected genesis transactions" | ||
|
||
# Read the content of the local file and append it to the file inside the Docker container | ||
cat /root/private/bin/libs/evm-rpc.toml >> "$HOME"/config/config.toml | ||
|
||
# Starting the blockchain node with the specified home directory | ||
axelard start --home ${HOME} \ | ||
--minimum-gas-prices 0${DENOM} \ | ||
--moniker ${MONIKER} \ | ||
--rpc.laddr "tcp://0.0.0.0:26657" | ||
|
20 changes: 20 additions & 0 deletions
20
packages/axelar-local-dev-cosmos/docker/axelar/bin/libs/activate-chain.sh
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,20 @@ | ||
#!/bin/bash | ||
|
||
CHAIN_ID=axelar | ||
HOME=/root/private/.axelar | ||
DEFAULT_KEYS_FLAGS="--keyring-backend test --home ${HOME}" | ||
CHAIN=$1 | ||
DIR="$(dirname "$0")" | ||
|
||
if [ -z "$CHAIN" ] | ||
then | ||
echo "Chain name is required" | ||
exit 1 | ||
fi | ||
|
||
docker exec axelar /bin/bash -c "axelard tx nexus activate-chain ${CHAIN} --generate-only \ | ||
--chain-id ${CHAIN_ID} --from \$(axelard keys show governance -a ${DEFAULT_KEYS_FLAGS}) --home ${HOME} \ | ||
--output json --gas 500000 &> ${HOME}/unsigned_msg.json" | ||
docker exec axelar /bin/bash -c "cat ${HOME}/unsigned_msg.json" | ||
|
||
sh "$DIR/broadcast-unsigned-multi-tx.sh" |
19 changes: 19 additions & 0 deletions
19
packages/axelar-local-dev-cosmos/docker/axelar/bin/libs/broadcast-unsigned-multi-tx.sh
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,19 @@ | ||
#!/bin/bash | ||
|
||
CHAIN_ID=axelar | ||
HOME=/root/private/.axelar | ||
DEFAULT_KEYS_FLAGS="--keyring-backend test --home ${HOME}" | ||
|
||
## Sign unsigned transaction. | ||
docker exec axelar /bin/bash -c "axelard tx sign ${HOME}/unsigned_msg.json --from gov1 \ | ||
--multisig \$(axelard keys show governance -a ${DEFAULT_KEYS_FLAGS}) \ | ||
--chain-id $CHAIN_ID ${DEFAULT_KEYS_FLAGS} &> ${HOME}/signed_tx.json" | ||
docker exec axelar /bin/bash -c "cat ${HOME}/signed_tx.json" | ||
|
||
## Multisign signed transaction. | ||
docker exec axelar /bin/bash -c "axelard tx multisign ${HOME}/unsigned_msg.json governance ${HOME}/signed_tx.json \ | ||
--from owner --chain-id $CHAIN_ID ${DEFAULT_KEYS_FLAGS} &> ${HOME}/tx-ms.json" | ||
docker exec axelar /bin/bash -c "cat ${HOME}/tx-ms.json" | ||
|
||
## Broadcast multisigned transaction. | ||
docker exec axelar /bin/bash -c "axelard tx broadcast ${HOME}/tx-ms.json ${DEFAULT_KEYS_FLAGS}" |
Oops, something went wrong.