Skip to content

Commit

Permalink
Dockernet Linux Support (#327)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Co-authored-by: nghuyenthevinh2000 <nghuyenthevinh@gmail.com>
  • Loading branch information
3 people authored Nov 17, 2022
1 parent 3ec6b8e commit fb03e0d
Show file tree
Hide file tree
Showing 28 changed files with 194 additions and 165 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [master, main]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[submodule "deps/hermes"]
# Commit: fd92eb6d17342bc83003f2067d6a9cd8261f2884
path = deps/hermes
url = git@github.com:informalsystems/ibc-rs.git
url = https://github.com/informalsystems/ibc-rs.git
[submodule "deps/relayer"]
# Commit: da271a9846619bebe4d8723a13c33f613da7562d
# Commit: d1dd961969867414c499e89091137710a582cb03
# Branch: andrew/client_icq
path = deps/relayer
url = git@github.com:cosmos/relayer.git
url = https://github.com/cosmos/relayer.git
[submodule "deps/gaia"]
# Commit: 5b47714dd5607993a1a91f2b06a6d92cbb504721
path = deps/gaia
url = git@github.com:Stride-Labs/gaia.git
url = https://github.com/Stride-Labs/gaia.git
[submodule "deps/juno"]
# Commit: 955892041359443fbb5addd34c0ab8b66bd8d75c
path = deps/juno
Expand All @@ -22,4 +22,4 @@
[submodule "deps/stargaze"]
# Commit: b0bea28fc695a2a5c567e56a37b289a5b75830cc
path = deps/stargaze
url = git@github.com:public-awesome/stargaze.git
url = https://github.com/public-awesome/stargaze.git
6 changes: 4 additions & 2 deletions Dockerfile.gaia
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ RUN git clone https://github.com/Stride-Labs/gaia gaia-install \

FROM alpine:3.15
COPY --from=builder /go/bin/gaiad /usr/local/bin/
RUN adduser -S -h /home/gaia -D gaia -u 1000
RUN apk add bash vim \
&& addgroup -g 1000 gaia \
&& adduser -S -h /home/gaia -D gaia -u 1000 -G gaia

USER gaia
USER 1000
WORKDIR /home/gaia

EXPOSE 26657 26656 1317 9090
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.hermes
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY --from=builder /opt/ibc-rs/target/release/hermes /usr/local/bin/hermes
RUN apt-get update \
&& adduser --system --home /home/hermes --disabled-password --disabled-login hermes -u 1000

USER hermes
USER 1000
WORKDIR /home/hermes

CMD ["hermes", "start"]
6 changes: 4 additions & 2 deletions Dockerfile.juno
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build

FROM alpine:3.15
COPY --from=builder /opt/juno/bin/junod /usr/local/bin/
RUN adduser -S -h /home/juno -D juno -u 1000
RUN apk add bash vim \
&& addgroup -g 1000 juno \
&& adduser -S -h /home/juno -D juno -u 1000 -G juno

USER juno
USER 1000
WORKDIR /home/juno

EXPOSE 26657 26656 1317 9090
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.osmo
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build

FROM alpine:3.15
COPY --from=builder /opt/osmosis/build/osmosisd /usr/local/bin/
RUN adduser -S -h /home/osmosis -D osmosis -u 1000
RUN apk add bash vim \
&& addgroup -g 1000 osmosis \
&& adduser -S -h /home/osmosis -D osmosis -u 1000 -G osmosis

USER osmosis
USER 1000
WORKDIR /home/osmosis

EXPOSE 26657 26656 1317 9090
Expand Down
21 changes: 5 additions & 16 deletions Dockerfile.relayer
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM golang:1.18-alpine3.15 AS builder

WORKDIR /src/

ENV COMMIT_HASH=da271a9846619bebe4d8723a13c33f613da7562d
ENV COMMIT_HASH=d1dd961969867414c499e89091137710a582cb03

RUN apk add --update git make gcc linux-headers libc-dev eudev-dev
RUN git clone https://github.com/cosmos/relayer.git \
Expand All @@ -14,23 +14,12 @@ RUN git clone https://github.com/cosmos/relayer.git \
FROM alpine:3.15
COPY --from=builder /go/bin/rly /usr/local/bin/
RUN apk add bash vim \
&& adduser -S -h /home/relayer -D relayer -u 1000
&& addgroup -g 1000 relayer \
&& adduser -S -h /home/relayer -D relayer -u 1000 -G relayer

USER relayer
USER 1000
WORKDIR /home/relayer

# Create startup script that takes a path as a parameter
RUN echo 'nohup rly start $1 -p events' > start.sh
RUN echo 'rly start $1 -p events' > start.sh

# Create a script to updates the light clients so they don't expire
# Wont be necessary once https://github.com/cosmos/relayer/pull/861 is merged
RUN <<EOF cat > refresh-clients.sh
RELAY_PATHS="\$@"
while true; do
for path in \${RELAY_PATHS[@]}; do
echo "Updating \$path"
rly transact update-clients \$path
done
sleep 30
done
EOF
5 changes: 3 additions & 2 deletions Dockerfile.stars
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build
FROM alpine:3.15
COPY --from=builder /opt/stargaze/bin/starsd /usr/local/bin/
RUN apk add --update bash vim ca-certificates \
&& adduser -S -h /home/stars -D stars -u 1000
&& addgroup -g 1000 stars \
&& adduser -S -h /home/stars -D stars -u 1000 -G stars

USER stars
USER 1000
WORKDIR /home/stars

EXPOSE 26657 26656 1317 9090
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.stride
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ RUN --mount=type=cache,target=/root/.cache/go-build make build
# Add to a distroless container
FROM alpine:3.15
COPY --from=builder /src/build/strided /usr/local/bin/strided
RUN addgroup -g 1000 stride \
RUN apk add bash vim \
&& addgroup -g 1000 stride \
&& adduser -S -h /home/stride -D stride -u 1000 -G stride

USER stride
USER 1000
WORKDIR /home/stride

EXPOSE 26657 26656 1317 9090
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ test-cover:
@go test -mod=readonly -race -coverprofile=coverage.out -covermode=atomic ./x/$(module)/...

test-integration-local:
sh scripts-local/tests/run_all_tests.sh
bash scripts-local/tests/run_all_tests.sh

test-integration-docker:
sh scripts/tests/run_all_tests.sh
bash scripts/tests/run_all_tests.sh

###############################################################################
### DockerNet ###
###############################################################################

build-docker:
@sh scripts/build.sh -${build} ${BUILDDIR}
@bash scripts/build.sh -${build} ${BUILDDIR}

start-docker: build-docker
@sh scripts/start_network.sh
@bash scripts/start_network.sh

clean-docker:
@docker-compose stop
Expand All @@ -127,8 +127,8 @@ clean-docker:
docker image prune -a

stop-docker:
@pkill -f "docker-compose logs" || true
@pkill -f "/bin/bash.*create_logs.sh" || true
@-pkill -f "docker-compose logs"
@-pkill -f "/bin/bash.*create_logs.sh"
docker-compose down

###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ git submodule update --init

Build executables, initialize state, and start the network with
```
make start-docker build=sgjotrhi
make start-docker build=sgjotr
```
You can optionally pass build arguments to specify which binary to rebuild
1. `s` This will re-build the Stride binary (default)
Expand All @@ -67,7 +67,6 @@ You can optionally pass build arguments to specify which binary to rebuild
4. `o` This will re-build the Osmo binary
5. `t` This will re-build the Stargaze binary
6. `r` This will re-build the Go Relayer binary
7. `h` This will re-build the Hermes binary

Example: `make start-docker build=sg`, this will:
- Rebuild the Stride and Gaia binarys
Expand Down
2 changes: 1 addition & 1 deletion deps/relayer
Submodule relayer updated 65 files
+0 −35 .github/workflows/akash-tests.yml
+2 −0 .github/workflows/docker-publish.yaml
+0 −35 .github/workflows/gaia-tests.yml
+47 −2 .github/workflows/ibctest.yml
+5 −8 Dockerfile
+12 −12 Makefile
+3 −2 README.md
+0 −8 _test/README.md
+0 −734 _test/relayer_chain_test.go
+0 −30 _test/relayer_compat_test.go
+0 −42 _test/setup/akash-setup.sh
+0 −42 _test/setup/gaia-setup.sh
+0 −42 _test/setup/osmosis-setup.sh
+0 −0 _test/setup/valkeys/.gitkeep
+0 −156 _test/test_chains.go
+0 −125 _test/test_queries.go
+0 −286 _test/test_setup.go
+69 −82 cmd/chains.go
+10 −6 cmd/config.go
+16 −2 cmd/flags.go
+48 −0 cmd/paths.go
+49 −3 cmd/query.go
+56 −15 cmd/start.go
+56 −0 docs/advanced_usage.md
+1 −1 docs/create-path-across-chain.md
+2 −2 docs/features.md
+0 −26 docs/monitoring.md
+10 −14 docs/troubleshooting.md
+6 −42 go.mod
+12 −360 go.sum
+8 −1 ibctest/README.md
+260 −0 ibctest/client_threshold_test.go
+23 −20 ibctest/go.mod
+42 −39 ibctest/go.sum
+33 −8 ibctest/ibc_test.go
+188 −0 ibctest/multi_channel_test.go
+306 −0 ibctest/path_filter_test.go
+56 −0 ibctest/poll_test.go
+196 −0 ibctest/relay_many_test.go
+61 −13 ibctest/relayer.go
+21 −18 ibctest/relayer_factory.go
+183 −0 ibctest/relayer_override_test.go
+6 −2 internal/relaydebug/debugserver.go
+23 −13 relayer/chains/cosmos/cosmos_chain_processor.go
+6 −33 relayer/chains/cosmos/event_parser.go
+17 −3 relayer/chains/cosmos/event_parser_test.go
+6 −9 relayer/chains/cosmos/message_handlers.go
+5 −3 relayer/chains/cosmos/provider.go
+8 −2 relayer/chains/cosmos/query.go
+2 −0 relayer/chains/cosmos/tx.go
+3 −1 relayer/chains/mock/mock_chain_processor_test.go
+10 −26 relayer/channel.go
+3 −5 relayer/client.go
+5 −13 relayer/connection.go
+12 −10 relayer/naive-strategy.go
+11 −6 relayer/path.go
+9 −5 relayer/processor/metrics.go
+13 −2 relayer/processor/path_end_runtime.go
+12 −8 relayer/processor/path_processor.go
+95 −35 relayer/processor/path_processor_internal.go
+34 −20 relayer/processor/types.go
+2 −0 relayer/provider/provider.go
+34 −0 relayer/query.go
+87 −0 relayer/query_test.go
+54 −46 relayer/strategies.go
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.8"
version: "3"
services:
stride1:
image: stridezone:stride
Expand Down Expand Up @@ -152,27 +152,27 @@ services:
relayer-gaia:
image: stridezone:relayer
volumes:
- ./scripts/state/relayer:/home/relayer/.relayer
- ./scripts/state/relayer-gaia:/home/relayer/.relayer
restart: always
command: [ "bash", "start.sh", "stride-gaia" ]

relayer-juno:
image: stridezone:relayer
volumes:
- ./scripts/state/relayer:/home/relayer/.relayer
- ./scripts/state/relayer-juno:/home/relayer/.relayer
restart: always
command: [ "bash", "start.sh", "stride-juno" ]

relayer-osmo:
image: stridezone:relayer
volumes:
- ./scripts/state/relayer:/home/relayer/.relayer
- ./scripts/state/relayer-osmo:/home/relayer/.relayer
restart: always
command: [ "bash", "start.sh", "stride-osmo" ]

relayer-stars:
image: stridezone:relayer
volumes:
- ./scripts/state/relayer:/home/relayer/.relayer
- ./scripts/state/relayer-stars:/home/relayer/.relayer
restart: always
command: [ "bash", "start.sh", "stride-stars" ]
3 changes: 3 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ HERMES_${CHAIN_ID}_MNEMONIC=""
RELAYER_{CHAIN_ID}_EXEC="docker-compose run --rm relayer-{new-host-zone}"
RELAYER_{CHAIN_ID}_ACCT=rly{add one since the account from the last host zone}
HOST_RELAYER_ACCTS=(... $RELAYER_{CHAIN_ID}_ACCT)
RELAYER_{CHAIN_ID}_MNEMONIC=""
RELAYER_MNEMONICS=(...,"$RELAYER_{CHAIN_ID}_MNEMONIC")
```
* Add the IBC denom's for the host zone across each channel. You can use the following code block (just temporarily throw it in any of the test files and run it)
Expand Down
24 changes: 18 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/vars.sh

BUILDDIR="$2"
mkdir -p $BUILDDIR

build_local_and_docker() {
module="$1"
Expand All @@ -14,16 +15,27 @@ build_local_and_docker() {
printf '%s' "Building $title Locally... "
cwd=$PWD
cd $folder
go build -mod=readonly -trimpath -o $BUILDDIR ./... 2>&1 | grep -v -E "deprecated|keychain";
local_build_succeeded=$?
GOBIN=$BUILDDIR go install -mod=readonly -trimpath ./... 2>&1 | grep -v -E "deprecated|keychain" | true
local_build_succeeded=${PIPESTATUS[0]}
cd $cwd
echo "Done"

if [[ "$local_build_succeeded" == "0" ]]; then
echo "Done"
else
echo "Failed"
return $local_build_succeeded
fi

echo "Building $title Docker... "
docker build --tag stridezone:$module -f Dockerfile.$module .
docker_build_succeeded=$?
DOCKER_BUILDKIT=1 docker build --tag stridezone:$module -f Dockerfile.$module . | true
docker_build_succeeded=${PIPESTATUS[0]}

return $docker_build_succeeded && $local_build_succeeded
if [[ "$docker_build_succeeded" == "0" ]]; then
echo "Done"
else
echo "Failed"
fi
return $docker_build_succeeded
}

ADMINS_FILE=${SCRIPT_DIR}/../utils/admins.go
Expand Down
18 changes: 0 additions & 18 deletions scripts/create_channels.sh

This file was deleted.

Loading

0 comments on commit fb03e0d

Please sign in to comment.