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

Development into main #1020

Merged
merged 11 commits into from
Nov 25, 2024
178 changes: 178 additions & 0 deletions docs/bridge/axelar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Axelar Amplifier setup for MultiversX

## Prerequisites

- have an [Axelar Validator](https://docs.axelar.dev/validator/setup/overview/) running (node, tofnd & vald)

## Become an Amplifier Verifier

For more detailed information check out the [Become a Verifier](https://docs.axelar.dev/validator/amplifier/verifier-onboarding/) Axelar docs.

You can skip this if already having an Amplifier Verifier up and running.

### Set up `tofnd`

If running on the same machine as the Axelar Validator, the existing `tofnd` can be used.

If you want to setup on a new machine, then you can setup `tofnd` using Docker:

```
docker pull axelarnet/tofnd:v1.0.1
docker run -p 50051:50051 --env MNEMONIC_CMD=auto --env NOPASSWORD=true --env ADDRESS=0.0.0.0 -v tofnd:/.tofnd axelarnet/tofnd:v1.0.1
```

### Set up `ampd`

Setup the `ampd` process using Docker:

```
docker pull axelarnet/axelar-ampd:v1.3.1
```

Make sure that the `ampd` process can communicate with `tofnd`.

To view your Verifier address you can run: `docker run axelarnet/axelar-ampd:v1.3.1 verifier-address`

### Configure the verifier

You need to create a configuration file at `~/.ampd/config.toml` and add the required configuration depending on your environment.

For complete configuration files for different environments, check out the [Configure the verifier](https://docs.axelar.dev/validator/amplifier/verifier-onboarding/#configure-the-verifier) section in the Axelar Amplifier docs.

Example basic `config.toml` for mainnet:

```
# replace with your Axelar mainnet node
tm_jsonrpc="http://127.0.0.1:26657"
tm_grpc="tcp://127.0.0.1:9090"
event_buffer_cap=100000

[service_registry]
cosmwasm_contract="axelar1rpj2jjrv3vpugx9ake9kgk3s2kgwt0y60wtkmcgfml5m3et0mrls6nct9m"

[broadcast]
batch_gas_limit="20000000"
broadcast_interval="1s"
chain_id="axelar-dojo-1"
gas_adjustment="2"
gas_price="0.007uaxl"
queue_cap="1000"
tx_fetch_interval="1000ms"
tx_fetch_max_retries="15"

[tofnd_config]
batch_gas_limit="10000000"
key_uid="axelar"
party_uid="ampd"
url="http://127.0.0.1:50051"

[[handlers]]
cosmwasm_contract="axelar14a4ar5jh7ue4wg28jwsspf23r8k68j7g5d6d3fsttrhp42ajn4xq6zayy5"
type="MultisigSigner"
```

You need to configure additional `handlers` for each chain you want to support. Check out the [ampd README file](https://github.com/axelarnetwork/axelar-amplifier/blob/main/ampd/README.md) for more information.
Find below an example for configuring handlers for **MultiversX**.

### Activate and run the verifier

For more information check out the [Axelar docs](https://docs.axelar.dev/validator/amplifier/verifier-onboarding/#activate-and-run-the-verifier).

Find below basic instructions for mainnet:

1. Bond your verifier: `ampd bond-verifier amplifier 50000000000 uaxl`

2. Register public key:

`ampd register-public-key ecdsa`

`ampd register-public-key ed25519`

3. Register support for chains for which you have configured handlers: `ampd register-chain-support amplifier flow ethereum multiversx [MORE_CHAINS]`

Run the `ampd` process with `docker run axelarnet/axelar-ampd:v1.3.1`

## Add support for MultiversX to Verifier

### Running a MultiversX Observing Squad

For security reasons, you will need to run your own MultiversX Observing Squad, which is a collection of nodes, one node for each MultiversX shard + the Proxy API service. This API will be used by the Verifier to get transactions from the MultiversX network in order to be able to verify them.

You can find detailed steps in the [MultiversX Observing Squad docs](https://docs.multiversx.com/integrators/observing-squad). There exist installation scripts that making setting up an Observing Squad easy.

Below you can find basic information on how to setup a squad for mainnet:

1. Clone the `mx-chain-scripts` repo: `git clone https://github.com/multiversx/mx-chain-scripts`

2. Edit the `config/variables.cfg` according, for example:

```
ENVIRONMENT="mainnet"
...
CUSTOM_HOME="/home/ubuntu"
CUSTOM_USER="ubuntu"
```

3. Setup the Observing Squad: `./script.sh observing_squad`

4. Start the nodes & the Proxy: `./script.sh start`

### Updating Verifier `config.toml` file

In order to support MultiversX, first you need to add the two required handlers at the end of your `~/.ampd/config.toml` file:

#### Devnet

```
[[handlers]]
type = 'MvxMsgVerifier'
cosmwasm_contract = 'axelar1sejw0v7gmw3fv56wqr2gy00v3t23l0hwa4p084ft66e8leap9cqq9qlw4t'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'

[[handlers]]
type = 'MvxVerifierSetVerifier'
cosmwasm_contract = 'axelar1sejw0v7gmw3fv56wqr2gy00v3t23l0hwa4p084ft66e8leap9cqq9qlw4t'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'
```

#### Testnet

```
[[handlers]]
type = 'MvxMsgVerifier'
cosmwasm_contract = 'TBD'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'

[[handlers]]
type = 'MvxVerifierSetVerifier'
cosmwasm_contract = 'TBD'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'
```

#### Mainnet

```
[[handlers]]
type = 'MvxMsgVerifier'
cosmwasm_contract = 'TBD'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'

[[handlers]]
type = 'MvxVerifierSetVerifier'
cosmwasm_contract = 'TBD'
# replace with your MultiversX Proxy URL
proxy_url = 'http://127.0.0.1:8079'
```

### Register MultiversX chain

1. (optional) If you have not done so already, first register the `ed25519` public key: `ampd register-public-key ed25519`

2. Then register support for the `multiversx` chain: `ampd register-chain-support amplifier multiversx`

At this point you can restart the `ampd` process and you should be able to validate MultiversX messages.
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ Make sure you migrate to the managed types **incrementally** and **thoroughly te
:::

:::tip
You can use the `mxpy contract report` command to verify whether your contract still requires dynamic allocation or not.
You can use the `sc-meta report` command to verify whether your contract still requires dynamic allocation or not.
:::
16 changes: 5 additions & 11 deletions docs/developers/meta/sc-build-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ title: Build Reference

## How to: Basic build

To build a contract, it is enough to navigate in your contract crate and run
To build a contract, navigate to the contract folder and run the following command:

```sh
sc-meta all build
```

:::info Note
The traditional way to trigger a build in console is to call `mxpy contract build --path <project>`, which works as well. However, mxpy currently just forwards commands to the [MultiversX Metaprogramming standalone tool](/developers/meta/sc-meta#introduction), so you might as well call it directly.
:::

---

[comment]: # (mx-exclude-context)

## Configuring the build
Expand Down Expand Up @@ -155,11 +149,11 @@ After building the contracts, there are three more operations left to perform, b

### g. Cleaning a project

Calling `cargo run clean` in the meta crate will run `cargo clean` in all wasm crates and delete the `output` folder.
In order to clean a project and remove all build artifacts, run the following command:

`mxpy contract clean` also just forwards to this.

Note that even the clean operation relies on the ABI, in order to reach all the wasm crates.
```sh
sc-meta all clean
```

[comment]: # (mx-context-auto)

Expand Down
10 changes: 9 additions & 1 deletion docs/developers/meta/sc-meta-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ This command is similar to `build-dbg`, in that it provides a shorthand for buil

### Calling `clean`

Calling `mxpy contract clean <project>` or `cargo run clean` in the meta crate will delete the `output` folder and clean outputs of the Rust crates.
Calling `sc-meta all clean` in the contract folder will remove all build artifacts, including the `output` folder.

[comment]: # (mx-context-auto)

Expand All @@ -412,3 +412,11 @@ Parameters:
- `--target-dir-meta` For the meta crates, allows specifying the target directory where the Rust compiler will build the intermediary files. Sharing the same target directory can speed up building multiple contract crates at once.
- `--target-dir-all` Overrides both the --target-dir-meta and the --target-dir-wasm args.

### Calling `cs`

Calling `cargo run cs` in the meta crate or `sc-meta cs` in the root crate will start the interaction with the chain simulator. In order to start an action, one must choose between the following subcommands.

Subcommands:
- `install` Pulls the latest chain simulator docker image available. This command needs Docker to be installed and running on the current machine.
- `start` Starts the chain simulator in verbose mode at `localhost:8085`.
- `stop` Stops the chain simulator.
1 change: 0 additions & 1 deletion docs/developers/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Below is a list of tutorials for building on MultiversX:
| [Build a microservice for your dApp](/developers/tutorials/your-first-microservice) | Video + written tutorial on how to create your microservice. |
| [Crowdfunding Smart Contract](/developers/tutorials/crowdfunding-p1) | Crowdfunding tutorial (Part 1). |
| [Crowdfunding Smart Contract](/developers/tutorials/crowdfunding-p2) | Crowdfunding tutorial (Part 2). |
| [The Counter Smart Contract](/developers/tutorials/counter) | The Counter SC tutorial. |
| [Staking contract Tutorial](/developers/tutorials/staking-contract) | Step by step tutorial on how to create a Staking Smart Contract. |
| [Energy DAO Tutorial](/developers/tutorials/energy-dao) | In depth analysis of the Energy DAO SC template. |
| [DEX Walkthrough](/developers/tutorials/dex-walkthrough) | In depth walkthrough of all the main DEX contracts. |
Expand Down
134 changes: 0 additions & 134 deletions docs/developers/tutorials/counter.md

This file was deleted.

Loading
Loading