diff --git a/Dockerfile b/Dockerfile index c2d006efc..cb35bb960 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,10 @@ 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 && \ + apk --no-cache add make git && \ make install -FROM alpine:edge +FROM alpine:latest ENV RELAYER /relayer @@ -26,6 +26,3 @@ WORKDIR $RELAYER COPY --from=BUILD /go/bin/rly /usr/bin/rly ENTRYPOINT ["/usr/bin/rly"] - -# Make config available ofr mutaitons -VOLUME [ $RELAYER ] diff --git a/Makefile b/Makefile index f1acf9bac..985a86fe6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') COMMIT := $(shell git log -1 --format='%H') SDKCOMMIT := $(shell go list -m -u -f '{{.Version}}' github.com/cosmos/cosmos-sdk) GAIA_VERSION := v4.1.0 -AKASH_VERSION := jack/update-sdk +AKASH_VERSION := v0.10.2 WASMD_VERSION := v0.14.1 GOPATH := $(shell go env GOPATH) @@ -104,4 +104,3 @@ check-swagger: update-swagger-docs: check-swagger swagger generate spec -o ./docs/swagger-ui/swagger.yaml - diff --git a/test/setup/Dockerfile.akashtest b/test/setup/Dockerfile.akashtest new file mode 100644 index 000000000..9ee7666fd --- /dev/null +++ b/test/setup/Dockerfile.akashtest @@ -0,0 +1,14 @@ +# https://hub.docker.com/r/ovrclk/akash/tags?page=1&ordering=last_updated +FROM ovrclk/akash:0.10.0 + +# Set up dependencies +ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 + +USER root + +COPY ./akash-setup.sh . + +EXPOSE 26657 + +ENTRYPOINT [ "./akash-setup.sh" ] +# NOTE: to run this image, docker run -d -p 26657:26657 ./single-node.sh {{chain_id}} {{genesis_account}} diff --git a/test/setup/Dockerfile.gaiatest b/test/setup/Dockerfile.gaiatest new file mode 100644 index 000000000..34bef1cb1 --- /dev/null +++ b/test/setup/Dockerfile.gaiatest @@ -0,0 +1,20 @@ +FROM tendermint/gaia:v4.1.0 + +# Set up dependencies +ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 + +USER root + +# Install minimum necessary dependencies, build Cosmos SDK, remove packages +RUN apk add --no-cache $PACKAGES + +USER gaia + +WORKDIR /gaia + +COPY ./gaia-setup.sh . + +EXPOSE 26657 + +ENTRYPOINT [ "./gaia-setup.sh" ] +# NOTE: to run this image, docker run -d -p 26657:26657 ./single-node.sh {{chain_id}} {{genesis_account}} diff --git a/test/setup/akash-setup.sh b/test/setup/akash-setup.sh new file mode 100755 index 000000000..741575922 --- /dev/null +++ b/test/setup/akash-setup.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -o errexit -o nounset + +CHAINID=$1 +GENACCT=$2 + +if [ -z "$1" ]; then + echo "Need to input chain id..." + exit 1 +fi + +if [ -z "$2" ]; then + echo "Need to input genesis account address..." + exit 1 +fi + +# Build genesis file incl account for passed address +coins="10000000000stake,100000000000samoleans" +akash init --chain-id $CHAINID $CHAINID +akash keys add validator --keyring-backend="test" +akash add-genesis-account $(akash keys show validator -a --keyring-backend="test") $coins +akash add-genesis-account $GENACCT $coins +akash gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID +akash collect-gentxs + +# Set proper defaults and change ports +sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.akash/config/config.toml +sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.akash/config/config.toml +sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.akash/config/config.toml +sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.akash/config/config.toml + +# Start the akash +akash start --pruning=nothing + diff --git a/test/setup/gaia-setup.sh b/test/setup/gaia-setup.sh new file mode 100755 index 000000000..ea9e4c689 --- /dev/null +++ b/test/setup/gaia-setup.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -o errexit -o nounset + +CHAINID=$1 +GENACCT=$2 + +if [ -z "$1" ]; then + echo "Need to input chain id..." + exit 1 +fi + +if [ -z "$2" ]; then + echo "Need to input genesis account address..." + exit 1 +fi + +# Build genesis file incl account for passed address +coins="10000000000stake,100000000000samoleans" +gaiad init --chain-id $CHAINID $CHAINID +gaiad keys add validator --keyring-backend="test" +gaiad add-genesis-account $(gaiad keys show validator -a --keyring-backend="test") $coins +gaiad add-genesis-account $GENACCT $coins +gaiad gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID +gaiad collect-gentxs + +# Set proper defaults and change ports +sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml +sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml +sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml +sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml + +# Start the gaia +gaiad start --pruning=nothing + diff --git a/test/test_chains.go b/test/test_chains.go index 0f996a4d1..ec12d2609 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -12,17 +12,13 @@ import ( ) var ( - // Chains built using SDK v0.41.0 - - // GAIA BLOCK TIMEOUTS are located in the single node setup script on gaia - // https://github.com/cosmos/gaia/blob/main/contrib/single-node.sh + // GAIA BLOCK TIMEOUTS are located in the gaia setup script in the + // setup directory. // timeout_commit = "1000ms" // timeout_propose = "1000ms" // 3 second relayer timeout works well with these block times gaiaTestConfig = testChainConfig{ - // This is built from contrib/Dockerfile.test from the gaia repository: - dockerImage: "colinaxner/gaiatest", - dockerTag: "v4.0.0", + dockerfile: "./setup/Dockerfile.gaiatest", timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "cosmos", @@ -35,8 +31,7 @@ var ( // 3 second relayer timeout works well with these block times // This is built from contrib/Dockerfile.test from the akash repository: akashTestConfig = testChainConfig{ - dockerImage: "colinaxner/akashtest", - dockerTag: "latest", + dockerfile: "./setup/Dockerfile.akashtest", timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "akash", @@ -55,8 +50,7 @@ type ( // testChainConfig represents the chain specific docker and codec configurations // required. testChainConfig struct { - dockerImage string - dockerTag string + dockerfile string rpcPort string timeout time.Duration accountPrefix string diff --git a/test/test_setup.go b/test/test_setup.go index ed4565b4b..2ad86f60f 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -78,8 +78,7 @@ func removeTestContainer(pool *dockertest.Pool, containerName string) error { containers, err := pool.Client.ListContainers(dc.ListContainersOptions{ All: true, Filters: map[string][]string{ - "name": {containerName}, - "label": {"io.iqlusion.relayer.test=true"}, + "name": {containerName}, }, }) if err != nil { @@ -103,6 +102,8 @@ func removeTestContainer(pool *dockertest.Pool, containerName string) error { } // spinUpTestContainer spins up a test container with the given configuration +// A docker image is built for each chain using its provided configuration. +// This image is then ran using the options set below. func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, pool *dockertest.Pool, c *ry.Chain, dir string, wg *sync.WaitGroup, tc testChain) { defer wg.Done() @@ -126,16 +127,15 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, // create the test key require.NoError(t, c.CreateTestKey()) - containerName := fmt.Sprintf("%s-%s", c.ChainID, t.Name()) + containerName := c.ChainID // setup docker options dockerOpts := &dockertest.RunOptions{ Name: containerName, - Repository: tc.t.dockerImage, - Tag: tc.t.dockerTag, + Repository: containerName, // Name must match Repository + Tag: "latest", // Must match docker default build tag ExposedPorts: []string{tc.t.rpcPort, c.GetRPCPort()}, Cmd: []string{c.ChainID, c.MustGetAddress().String()}, - Labels: map[string]string{"io.iqlusion.relayer.test": "true"}, PortBindings: map[dc.Port][]dc.PortBinding{ dc.Port(tc.t.rpcPort): {{HostPort: c.GetRPCPort()}}, }, @@ -145,7 +145,7 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, require.NoError(t, removeTestContainer(pool, containerName)) // create the proper docker image with port forwarding setup - resource, err = pool.RunWithOptions(dockerOpts) + resource, err = pool.BuildAndRunWithOptions(tc.t.dockerfile, dockerOpts) require.NoError(t, err) c.Log(fmt.Sprintf("- [%s] SPUN UP IN CONTAINER %s from %s", c.ChainID,