Skip to content

Commit

Permalink
Merge branch 'master' into dzmitryhil/remove-unused-dockerfile-part
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryhil authored Mar 7, 2024
2 parents 08080c4 + 7d054d3 commit 6f89659
Showing 1 changed file with 19 additions and 183 deletions.
202 changes: 19 additions & 183 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,218 +1,54 @@
# Coreumbridge XRPL

Two-way Coreum XRPL bridge.
Two-way Coreum <-> XRPL bridge.

## Specification

The specification is described [here](spec/spec.md).

## Build relayer
## Relayer

### Relayer binary
### Build relayer binary

```bash
make build-relayer
```

### Relayer docker
### Build relayer docker

```bash
make build-relayer-docker
```

## Init relayer
## Contract

### Set env variables
### Build dev contract (fast build)

```bash
export COREUM_CHAIN_ID={Coreum chain id}
export COREUM_GRPC_URL={Coreum GRPC URL}
export XRPL_RPC_URL={XRPL RPC URL}
export RELEASE_VERSION={Relayer release version}
```

### Install relayer (with docker)

For the document simplicity we use the alias for the command which will be executed in docker.
Pay attention that all files outputs are related to docker container.

```bash
alias coreumbridge-xrpl-relayer="docker run --user $(id -u):$(id -g) -it --rm -v $HOME/.coreumbridge-xrpl-relayer:/.coreumbridge-xrpl-relayer coreumfoundation/coreumbridge-xrpl-relayer:$RELEASE_VERSION"
```

### Init relayer config

```bash
coreumbridge-xrpl-relayer init \
--coreum-chain-id $COREUM_CHAIN_ID \
--coreum-grpc-url $COREUM_GRPC_URL \
--xrpl-rpc-url $XRPL_RPC_URL
```

## Bootstrap the bridge

### Init relayer

#### Pass the [Init relayer](#init-relayer ) section.

#### Generate the relayer keys

Generate new keys:

```bash
coreumbridge-xrpl-relayer coreum keys add coreum-relayer

coreumbridge-xrpl-relayer xrpl keys add xrpl-relayer
```

!!! Save output mnemonics to a safe place to be able to recover the relayer later. !!!

The `coreum-relayer` and `xrpl-relayer` are key names set by default in the `relayer.yaml`. If for some reason you want
to update them, then updated them in the `relayer.yaml` as well.

Or import the existing mnemonics:
```bash
coreumbridge-xrpl-relayer coreum keys add coreum-relayer --recover

coreumbridge-xrpl-relayer xrpl keys add xrpl-relayer --recover
```

#### Extract keys info for the contract deployment

```bash
coreumbridge-xrpl-relayer relayer-keys
```

Output example:

```bash
Keys info
coreumAddress: "testcore1lwzy78a7ulernmvdgvjyagaslsmp7x7g496jj4"
xrplAddress: "r41Cc8WLZMeUvZfvB4Fc4hRjpHya4T4Nqq"
xrplPubKey: "022ED182ACEBFE4C55CE0A0EA561468C31336F9B4E71FB487FC84D94A2826F1C10"
```

The output contains the `coreumAddress`, `xrplAddress` and `xrplPubKey` used for the contract deployment.
Create the account with the `coreumAddress` by sending some tokens to in on the Coreum chain and XRPL account with the
`xrplAddress` by sending 10XRP tokens and to it. Once the accounts are created share the keys info with contract
deployer.

### Run bootstrapping

#### Pass the [Init relayer](#init-relayer) section.

#### Generate new key which will be used for the XRPL bridge account creation

```bash
coreumbridge-xrpl-relayer xrpl keys add bridge-account
```

#### Generate new key which will be used for the contract deployment

```bash
coreumbridge-xrpl-relayer coreum keys add contract-deployer
```

Send some core tokens to the generated address, to have enough for the contract deployment.

#### Generate config template

```bash
coreumbridge-xrpl-relayer bootstrap-bridge /.coreumbridge-xrpl-relayer/bootstrapping.yaml \
--xrpl-key-name bridge-account --coreum-key-name contract-deployer --init-only --relayers-count 32
```

The output will print the XRPL bridge address and min XRPL bridge account balance. Fund it and proceed to the nex step.

Output example:

```bash
XRPL bridge address
address: "rDtBdHaGpZpgQ4vEZv3nKujhudd5kUHVQ"
Coreum deployer address
address: "testcore1qfhm09t9wyf5ttuj9e52v90h7rhrk72zwjxv5l"
Initializing default bootstrapping config
path: "/.coreumbridge-xrpl-relayer/bootstrapping.yaml"
Computed minimum XRPL bridge balance
balance: 594
```

#### Modify the `bootstrapping.yaml` config

Collect the config from the relayer and modify the bootstrapping config.

Config example:

```yaml
owner: ""
admin: ""
relayers:
- coreum_address: ""
xrpl_address: ""
xrpl_pub_key: ""
evidence_threshold: 2
used_ticket_sequence_threshold: 150
trust_set_limit_amount: "340000000000000000000000000000000000000"
contract_bytecode_path: ""
xrpl_base_fee: 10
```
If you don't have the contract bytecode download it.
#### Run the bootstrapping
```bash
coreumbridge-xrpl-relayer bootstrap-bridge /.coreumbridge-xrpl-relayer/bootstrapping.yaml \
--xrpl-key-name bridge-account --coreum-key-name contract-deployer
```

Once the command is executed get the bridge contract address from the output and share among the relayers to update in
the relayers config.

#### Remove the bridge-account key

```bash
coreumbridge-xrpl-relayer xrpl keys delete bridge-account
```bash
make build-dev-contract
```

#### Run all relayers
### Build contract in docker

Run all relayers see [Run relayer](#run-relayer) section.

#### Recover tickets (initial tickets set)

```bash
coreumbridge-xrpl-relayer coreum tx recover-tickets --tickets-to-allocate 250 --key-name owner
```bash
make build-contract
```

### Run relayer

#### Run relayer with docker
## Dev environment

If relayer docker image is not built, build it.
* Set-up [crust](https://github.com/CoreumFoundation/crust) and [coreum](https://github.com/CoreumFoundation/coreum)

##### Set up release version
As a reference on how to set it up and run for development you can use
the [relayer-ci.yml](.github/workflows/relayer-ci.yml)

```bash
export RELEASE_VERSION={Relayer release version}
```

##### Run
## Build dev environment

```bash
docker run -it --detach-keys="ctrl-c" --name coreumbridge-xrpl-relayer \
-v $HOME/.coreumbridge-xrpl-relayer:/root/.coreumbridge-xrpl-relayer \
coreumfoundation/coreumbridge-xrpl-relayer:$RELEASE_VERSION \
start
make build-dev-env
```

Once you are attached, press any key and enter passwords for two keyrings after this preses CTRL-c to detach from the container.
It is expected that at that time the relayer is initialized and its keys are generated and accounts are funded.

##### Restart running instance
## Run dev environment

```bash
docker stop coreumbridge-xrpl-relayer && docker rm coreumbridge-xrpl-relayer
make run-dev-env
```

Once the container is stopped and removed, proceed with the instructions in [run section](#run)

0 comments on commit 6f89659

Please sign in to comment.