Skip to content

Commit

Permalink
Merge PR cosmos#266: create Dockerfile for relayer
Browse files Browse the repository at this point in the history
* add docker file with config exposed

* fix comment

Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
  • Loading branch information
tac0turtle and jackzampolin authored Oct 28, 2020
1 parent ffc10f4 commit b8ec147
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:alpine as BUILD

WORKDIR /relayer

# Copy the files from host
COPY . .

# Update and install needed deps prioir to installing the binary.
RUN apk update && \
apk --no-cache add make=4.2.1-r2 git=2.24.3-r0 && \
make install

FROM alpine:edge

ENV RELAYER /relayer

RUN addgroup rlyuser && \
adduser -S -G rlyuser rlyuser -h "$RELAYER"

USER rlyuser

# Define working directory
WORKDIR $RELAYER

# Copy binary from BUILD
COPY --from=BUILD /go/bin/rly /usr/bin/rly

ENTRYPOINT ["/usr/bin/rly"]

# Make config available ofr mutaitons
VOLUME [ $RELAYER ]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The Cosmos IBC `relayer` package contains a basic relayer implementation that is
meant for users wishing to relay packets/data between sets of IBC enabled chains.
In additon, it is well documented and intended as an example where anyone who is
In addition, it is well documented and intended as an example where anyone who is
interested in building their own relayer can come for complete, working, examples.

### Security Notice
Expand All @@ -15,13 +15,13 @@ If you would like to report a security critical bug related to the relayer repo,

## Code of Conduct

The iqlusion team is dedicated to providing an inclusive and harrassment free experience for contributors. Please visit [Code of Conduct](CODE_OF_CONDUCT.md) for more information.
The iqlusion team is dedicated to providing an inclusive and harassment free experience for contributors. Please visit [Code of Conduct](CODE_OF_CONDUCT.md) for more information.

## Testnet

If you would like to join a relayer testnet, please [check out the instructions](./testnets/README.md).

### Compatability Table:
### Compatibility Table:

> NOTE:
Expand Down Expand Up @@ -105,7 +105,7 @@ $ rly q bal ibc-1 | jq

## Setting up Developer Environment

Working with the relayer can frequently involve working with local developement branches of `gaia`, `cosmos-sdk` and the `relayer`. To setup your environment to point at the local versions of the code and reduce the amount of time in your read-eval-print loops try the following:
Working with the relayer can frequently involve working with local development branches of `gaia`, `cosmos-sdk` and the `relayer`. To setup your environment to point at the local versions of the code and reduce the amount of time in your read-eval-print loops try the following:

1. Set `replace github.com/cosmos/cosmos-sdk => /path/to/local/github.com/comsos/cosmos-sdk` at the end of the `go.mod` files for the `relayer` and `gaia`. This will force building from the local version of the `cosmos-sdk` when running the `./dev-env` script.
2. After `./dev-env` has run, you can use `go run main.go` for any relayer commands you are working on. This allows you make changes and immediately test them as long as there are no server side changes.
Expand Down
28 changes: 12 additions & 16 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,9 @@ rly chains address [chain-id]

## rly chains delete

Deletes the chain cofiguration data (does not clear light client or close and channels)

### Synopsis

Deletes the chain cofiguration data (does not clear light client or close and channels)
Deletes the chain configuration data (does not clear lite client or close and channels)

```
rly chains delete [chain-id] [flags]
Expand All @@ -199,7 +197,7 @@ Edits chain configuration data

### Synopsis

Set chain confuguration key's value
Set chain configuration key's value

```
rly chains edit [chain-id] [key] [value] [flags]
Expand Down Expand Up @@ -496,18 +494,16 @@ manage light clients held by the relayer for each chain

### Subcommands

* [rly light delete](#rly-light-delete) - wipe the light client database, forcing re-initialzation on the next run
* [rly light header](#rly-light-header) - Get header from the database. 0 returns last trusted header and all others return the header at that height if stored
* [rly light init](#rly-light-init) - Initiate the light client
* [rly light update](#rly-light-update) - Update the light client by providing a new root of trust
* [rly lite delete](#rly-lite-delete) - wipe the lite client database, forcing re-initialization on the next run
* [rly lite header](#rly-lite-header) - Get header from the database. 0 returns last trusted header and all others return the header at that height if stored
* [rly lite init](#rly-lite-init) - Initiate the light client
* [rly lite update](#rly-lite-update) - Update the light client by providing a new root of trust

## rly light delete

wipe the light client database, forcing re-initialzation on the next run

### Synopsis

wipe the light client database, forcing re-initialzation on the next run
wipe the lite client database, forcing re-initialization on the next run

```
rly light delete [chain-id] [flags]
Expand Down Expand Up @@ -705,7 +701,7 @@ IBC Query Commands

### Synopsis

Commands to query IBC primatives, and other useful data on configured chains.
Commands to query IBC primitives, and other useful data on configured chains.

### Subcommands

Expand All @@ -722,7 +718,7 @@ Commands to query IBC primatives, and other useful data on configured chains.
* [rly query full-path](#rly-query-full-path) - Query for the status of clients, connections, channels and packets on a path
* [rly query header](#rly-query-header) - Query the header of a chain at a given height
* [rly query node-state](#rly-query-node-state) - Query the consensus state of a client at a given height
* [rly query packet-ack](#rly-query-packet-ack) - Query for the packet acknoledgement given it's sequence and channel ids
* [rly query packet-ack](#rly-query-packet-ack) - Query for the packet acknowledgement given it's sequence and channel ids
* [rly query packet-commit](#rly-query-packet-commit) - Query for the packet commitment given it's sequence and channel ids
* [rly query seq-send](#rly-query-seq-send) - Query the next sequence send for a given channel
* [rly query tx](#rly-query-tx) - Query transaction by transaction hash
Expand Down Expand Up @@ -954,11 +950,11 @@ rly query node-state [chain-id] [height] [flags]

## rly query packet-ack

Query for the packet acknoledgement given it's sequence and channel ids
Query for the packet acknowledgement given it's sequence and channel ids

### Synopsis

Query for the packet acknoledgement given it's sequence and channel ids
Query for the packet acknowledgement given it's sequence and channel ids

```
rly query packet-ack [chain-id] [channel-id] [port-id] [seq] [flags]
Expand Down Expand Up @@ -1438,7 +1434,7 @@ create a connection between chains, passing in identifiers

### Synopsis

This command creates the next handshake message given a specifc set of identifiers. If the command fails, you can safely run it again to repair an unfinished connection
This command creates the next handshake message given a specific set of identifiers. If the command fails, you can safely run it again to repair an unfinished connection

```
rly transact raw connection-step [src-chain-id] [dst-chain-id] [src-client-id] [dst-client-id] [src-connection-id] [dst-connection-id] [flags]
Expand Down
14 changes: 7 additions & 7 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Testing

The relayer contains a testing framework designed to be used to test compatability between different cosmos-sdk based chains for IBC relaying. This will be especially useful during the period where IBC is under active development as it will provide a central integration test to ensure that the many different implemenations all work together. It will also be required if you are looking to participate with a custom zone in Game of Zones.
The relayer contains a testing framework designed to be used to test compatibility between different cosmos-sdk based chains for IBC relaying. This will be especially useful during the period where IBC is under active development as it will provide a central integration test to ensure that the many different implementations all work together. It will also be required if you are looking to participate with a custom zone in Game of Zones.

## Using the test framework

Because of the nature of the relayer (i.e. it is meant to run against different chains), mocking out the interfaces for unit tests would be prohibitively expensive from a resources point of view. Because of this, I've decided to go with a full integration testing framework that tests the user-critical paths of the relayer code for each chain to ensure compatability between the chains and a functional Game of Zones. To add your chain to the framework, follow the guide below:
Because of the nature of the relayer (i.e. it is meant to run against different chains), mocking out the interfaces for unit tests would be prohibitively expensive from a resources point of view. Because of this, I've decided to go with a full integration testing framework that tests the user-critical paths of the relayer code for each chain to ensure compatibility between the chains and a functional Game of Zones. To add your chain to the framework, follow the guide below:

### Overview

The test framework is built using `go test` and `docker`. What is happening for each test is that a number of independent chains of a specified type are spun up and the relayer runs a series of transactions and tests for the expected results. We are using the [`ory/dockertest`](https://github.com/ory/dockertest) to provide a nice interface for using docker programatically w/in the tests.
The test framework is built using `go test` and `docker`. What is happening for each test is that a number of independent chains of a specified type are spun up and the relayer runs a series of transactions and tests for the expected results. We are using the [`ory/dockertest`](https://github.com/ory/dockertest) to provide a nice interface for using docker programmatically w/in the tests.

### Step 1: Write a Dockerfile and publish an image for your chain

The testing framework expects your chain to have a `Dockerfile` with an `ENTRYPOINT` script that accepts two arguements: `chain-id`, which should be unique to the individual test, and `relayer-address`, an address to include in the genesis file so that the testing relayer has access to funds. This is normally best acomplished with an `./entrypoint.sh` script that performs the necessary chain bootstrapping. The `cosmos/gaia` repositories provide an example of both:
The testing framework expects your chain to have a `Dockerfile` with an `ENTRYPOINT` script that accepts two arguments: `chain-id`, which should be unique to the individual test, and `relayer-address`, an address to include in the genesis file so that the testing relayer has access to funds. This is normally best accomplished with an `./entrypoint.sh` script that performs the necessary chain bootstrapping. The `cosmos/gaia` repositories provide an example of both:

- [`./entrypoint.sh`](https://github.com/cosmos/gaia/tree/master/contrib/single-node.sh)
- [`Dockerfile.test`](https://github.com/cosmos/gaia/tree/master/contrib/Dockerfile.test)

Then you need to build and push your image to a public image repository. Having it tagged with the git sha and branch is best practice. See the build proceedure for the gaia image:
Then you need to build and push your image to a public image repository. Having it tagged with the git sha and branch is best practice. See the build procedure for the gaia image:

- [`Makefile`](https://github.com/cosmos/gaia/blob/master/Makefile#L164)

Expand Down Expand Up @@ -63,7 +63,7 @@ myChainTestConfig = testChainConfig {
}
```

> NOTE: If you do any custom encoding/decoding in your chain, you may want to import your codec and attach it here. To do this, `go get` the package your codec is in, include it in the `test/test_chains.go` `import` section and instantiate your codec. You may run into build errors due to incompatable tendermint or sdk versions. Please bring your chain up the relayer version to continue with a custom codec.
> NOTE: If you do any custom encoding/decoding in your chain, you may want to import your codec and attach it here. To do this, `go get` the package your codec is in, include it in the `test/test_chains.go` `import` section and instantiate your codec. You may run into build errors due to incompatible Tendermint or SDK versions. Please bring your chain up the relayer version to continue with a custom codec.
### Step 3: Write your tests!

Expand Down Expand Up @@ -166,4 +166,4 @@ jobs:
run: make test-mychain
```
3. Get the
3. Get the

0 comments on commit b8ec147

Please sign in to comment.