Skip to content

Commit

Permalink
Align bootstrapping docs and CLI commands with the latest updates. (#145
Browse files Browse the repository at this point in the history
)

* Init bridgeClient in the beginning of the CLI to set the cosmos SDK config
* Add two keys for the bridge CLI bootstrapping
* Improve evidence logging
* Use coreum KR for the tickets recovery
* Write debug log when handle expected signature errors.
  • Loading branch information
dzmitryhil committed Feb 9, 2024
1 parent 7b08c60 commit e6b8036
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 349 deletions.
177 changes: 73 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,68 @@ make build-relayer-docker
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}
```

#### Init the config
### 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:/root/.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
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 (for each relayer)
### Init relayer

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

#### Generate the relayer keys

Generate new keys:

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

./coreumbridge-xrpl-relayer keys add xrpl-relayer
coreumbridge-xrpl-relayer keys-xrpl 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.

#### Extract data for the contract deployment
Or import the existing mnemonics:
```bash
coreumbridge-xrpl-relayer keys-coreum add coreum-relayer --recover

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

#### Extract keys info for the contract deployment

```bash
./coreumbridge-xrpl-relayer relayer-keys-info
coreumbridge-xrpl-relayer relayer-keys-info
```

Output example:

```bash
2023-12-10T18:04:55.235+0300 info cli/cli.go:205 Keys info {"coreumAddress": "core1dukhz42p4qxkrtxg8ap7nj6wn3f2lqjqwf8gny", "xrplAddress": "r3YU6MLbmnxnLwCrRQYBAbaXmBR1RgK5mu", "xrplPubKey": "02ED720F8BF89D333CF7C4EAC763DA6EB7051895924DEB33AD34E87A624FE6B8F0"}
Keys info
coreumAddress: "testcore1lwzy78a7ulernmvdgvjyagaslsmp7x7g496jj4"
xrplAddress: "r41Cc8WLZMeUvZfvB4Fc4hRjpHya4T4Nqq"
xrplPubKey: "022ED182ACEBFE4C55CE0A0EA561468C31336F9B4E71FB487FC84D94A2826F1C10"
```

The output contains the `coreumAddress`, `xrplAddress` and `xrplPubKey` used for the contract deployment.
Expand All @@ -74,30 +101,42 @@ deployer.

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

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

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

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

```bash
./coreumbridge-xrpl-relayer keys show -a bridge-account
coreumbridge-xrpl-relayer keys-coreum add contract-deployer
```

Get the Coreum address from the output and fund it on the Coreum side.
The balance should cover the token issuance fee and fee for the deployment transaction.
Send some core tokens to the generated address, to have enough for the contract deployment.

#### Generate config template

```bash
export RELAYERS_COUNT={Relayes count to be used}
./coreumbridge-xrpl-relayer bootstrap-bridge bootstrapping.yaml --key-name bridge-account --init-only --relayers-count $RELAYERS_COUNT
coreumbridge-xrpl-relayer bootstrap-bridge /root/.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: "/root/.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.
Expand All @@ -111,18 +150,20 @@ relayers:
- coreum_address: ""
xrpl_address: ""
xrpl_pub_key: ""
evidence_threshold: 0
evidence_threshold: 2
used_ticket_sequence_threshold: 150
trust_set_limit_amount: "100000000000000000000000000000000000"
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 bootstrapping.yaml --key-name bridge-account
coreumbridge-xrpl-relayer bootstrap-bridge /root/.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
Expand All @@ -131,7 +172,7 @@ the relayers config.
#### Remove the bridge-account key

```bash
./coreumbridge-xrpl-relayer keys delete bridge-account
./coreumbridge-xrpl-relayer xrpl-keys delete bridge-account
```

#### Run all relayers
Expand All @@ -144,25 +185,25 @@ Use [Recover tickets](#recover-tickets) instruction and recover tickets.

### Run relayer

#### Run relayer using binary
#### Run relayer with docker

```bash
./coreumbridge-xrpl-relayer start --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```
If relayer docker image is not built, build it.

#### Run relayer in docker
##### Set up release version

If relayer docker image is not built, build it.
```bash
export RELEASE_VERSION={Relayer release version}
```

##### Run relayer
##### Run

```bash
docker run -dit --name coreumbridge-xrpl-relayer \
-v $HOME/.coreumbridge-xrpl-relayer:/.coreumbridge-xrpl-relayer \
coreumbridge-xrpl-relayer:local start \
--home /.coreumbridge-xrpl-relayer
-v $HOME/.coreumbridge-xrpl-relayer:/root/.coreumbridge-xrpl-relayer \
coreumfoundation/coreumbridge-xrpl-relayer:$RELEASE_VERSION \
start

docker attach coreumbridge-xrpl-relayer
docker attach coreumbridge-xrpl-relayer
```

Once you are attached, press any key and enter the keyring password.
Expand All @@ -175,75 +216,3 @@ docker restart coreumbridge-xrpl-relayer && docker attach coreumbridge-xrpl-rela
```

Once you are attached, press any key and enter the keyring password.

## Public CLI

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

Additionally, set the bridge contract address in the `relayer.yaml`

### Send from coreum to XRPL

```bash
./coreumbridge-xrpl-relayer send-from-coreum-to-xrpl 1000000ucore rrrrrrrrrrrrrrrrrrrrrhoLvTp --key-name sender --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```

### Send from XRPL to coreum

```bash
./coreumbridge-xrpl-relayer send-from-xrpl-to-coreum 1000000 rrrrrrrrrrrrrrrrrrrrrhoLvTp XRP testcore1adst6w4e79tddzhcgaru2l2gms8jjep6a4caa7 --key-name sender --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```

### Get contact config

```bash
./coreumbridge-xrpl-relayer contract-config
```

### Get all registered tokens

```bash
./coreumbridge-xrpl-relayer registered-tokens
```

### Get Coreum balances

```bash
./coreumbridge-xrpl-relayer coreum-balances testcore1adst6w4e79tddzhcgaru2l2gms8jjep6a4caa7
```

### Get XRPL balances

```bash
./coreumbridge-xrpl-relayer xrpl-balances rrrrrrrrrrrrrrrrrrrrrhoLvTp
```

### Set XRPL TrustSet

```bash
./coreumbridge-xrpl-relayer set-xrpl-trust-set 1e80 rrrrrrrrrrrrrrrrrrrrrhoLvTp XRP --key-name sender --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```

## Owner CLI

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

Additionally, set the bridge contract address in the `relayer.yaml`

### Recover tickets to allow XRPL to coreum operations

```bash
./coreumbridge-xrpl-relayer recovery-tickets --key-name owner --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```

### Register Coreum token

```bash
./coreumbridge-xrpl-relayer register-coreum-token ucore 6 2 500000000000000 --key-name owner --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```

### Register XRPL token

```bash
./coreumbridge-xrpl-relayer register-xrpl-token rcoreNywaoz2ZCQ8Lg2EbSLnGuRBmun6D 434F524500000000000000000000000000000000 2 500000000000000 --key-name owner --keyring-dir $HOME/.coreumbridge-xrpl-relayer/keys
```
2 changes: 1 addition & 1 deletion integration-tests/processes/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func createDevRunner(
// exit on errors
relayerRunnerCfg.Processes.ExitOnError = true

components, err := runner.NewComponents(relayerRunnerCfg, xrplKeyring, coreumKeyring, chains.Log, false)
components, err := runner.NewComponents(relayerRunnerCfg, xrplKeyring, coreumKeyring, chains.Log, false, false)
require.NoError(t, err)

relayerRunner, err := runner.NewRunner(ctx, components, relayerRunnerCfg)
Expand Down
10 changes: 2 additions & 8 deletions relayer/client/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ func (b *BridgeClient) Bootstrap(
}
b.log.Info(ctx, "Deploying contract", zap.Any("settings", instantiationCfg))
contractAddress, err := b.contractClient.DeployAndInstantiate(ctx, senderAddress, contactByteCode, instantiationCfg)
b.log.Info(ctx, "Contract is deployed successfully", zap.String("address", contractAddress.String()))
if err != nil {
return nil, errors.Wrap(err, "failed to deploy contract")
}
b.log.Info(ctx, "Contract is deployed successfully", zap.String("address", contractAddress.String()))

if err := b.setUpXRPLBridgeAccount(ctx, bridgeAccountKeyName, cfg, xrplSignerEntries); err != nil {
return nil, err
Expand Down Expand Up @@ -359,7 +359,6 @@ func (b *BridgeClient) RecoverTickets(
b.log.Info(
ctx,
"Successfully submitted recovery tickets transaction",
zap.Uint32("numberOfTickets", xrpl.MaxTicketsToAllocate),
zap.String("txHash", txRes.TxHash),
)

Expand Down Expand Up @@ -1178,12 +1177,7 @@ func (b *BridgeClient) autoFillSignSubmitAndAwaitXRPLTx(
return err
}

b.log.Info(
ctx,
"Submitting XRPL transaction",
zap.String("txHash", tx.GetHash().String()),
zap.Any("tx", tx),
)
b.log.Info(ctx, "Submitting XRPL transaction", zap.String("txHash", tx.GetHash().String()))
if err = b.xrplRPCClient.SubmitAndAwaitSuccess(ctx, tx); err != nil {
return err
}
Expand Down
Loading

0 comments on commit e6b8036

Please sign in to comment.