diff --git a/.gitignore b/.gitignore index e579de7..4a7d834 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ artifacts coverage.txt profile.out sim_log_file - +mytestnet # IDE .vscode -.idea \ No newline at end of file +.idea diff --git a/Dockerfile b/Dockerfile index 5208cb5..7d75dc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,15 @@ FROM golang:1.20.5-alpine AS build-env # Set up dependencies ENV PACKAGES bash curl make git libc-dev gcc linux-headers eudev-dev python3 + # ADD . /code WORKDIR /code COPY . . -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a +RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.x86_64.a \ + -O /lib/libwasmvm_muslc.a RUN apk add --no-cache $PACKAGES && \ BUILD_TAGS=muslc LINK_STATICALLY=true make install && \ diff --git a/Makefile b/Makefile index f85f84b..bf9b20c 100644 --- a/Makefile +++ b/Makefile @@ -494,11 +494,17 @@ proto-update-deps: ### Localnet ### ############################################################################### -# Run a 4-node testnet locally +# Run a 4-node testnet locally after generating a statically built binary + +static-build: + $(DOCKER) build . -t passage-image + $(DOCKER) create --name passage-container passage-image + @mkdir -p $(BUILDDIR) + $(DOCKER) cp passage-container:/usr/local/bin/passage $(BUILDDIR)/passage && $(DOCKER) rm passage-container + localnet-start: localnet-stop $(TESTNETDIR) - docker-compose up -$(TESTNETDIR): build-linux +$(TESTNETDIR): static-build $(BUILDDIR)/passage testnet \ --chain-id $(TESTNETCHAINID) \ --keyring-backend test \ @@ -506,10 +512,12 @@ $(TESTNETDIR): build-linux --node-daemon-home passage \ --starting-ip-address 192.168.0.2 + $(DOCKER) compose up -d + localnet-stop: - docker-compose down + $(DOCKER) compose down localnet-clean: sudo rm -rf $(TESTNETDIR) -.PHONY: localnet-start localnet-stop localnet-clean \ No newline at end of file +.PHONY: localnet-start localnet-stop localnet-clean static-build diff --git a/tests/localpassage/README.md b/tests/localpassage/README.md index 8802c3a..e34da77 100644 --- a/tests/localpassage/README.md +++ b/tests/localpassage/README.md @@ -6,25 +6,35 @@ LocalPassage comes with no initial state. In the future, we would like to be abl ## Prerequisites -Ensure you have docker docker-compose, and golang installed: +Ensure you have docker and docker-compose installed: ```sh # Docker -sudo apt-get remove docker docker-engine docker.io +for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done +# Add Docker's official GPG key: sudo apt-get update -sudo apt install docker.io -y +sudo apt-get install ca-certificates curl +sudo install -m 0755 -d /etc/apt/keyrings +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc + +# Add the repository to Apt sources: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +``` -# Docker compose -sudo apt install docker-compose -y +If you're running docker as a non-root user you need to add your USER to the `docker` group to avoid appending every `docker` ccommand with `sudo`. Add `USER` to the `docker` group: -# Golang -curl -OL https://golang.org/dl/go1.19.1.linux-amd64.tar.gz -sudo tar -C /usr/local -xvf go1.19.1.linux-amd64.tar.gz -export PATH=$PATH:/usr/local/go/bin +```bash +sudo groupadd docker +sudo usermod -aG docker $USER +newgrp docker ``` -Alternatively, internal teams can use the AWS Launch Template `passage-localnet-devbox-template` to provision an instance with these dependencies already installed. - ## LocalPassage - No Initial State The following commands must be executed from the root folder of the Passage repository. @@ -42,12 +52,19 @@ The following commands must be executed from the root folder of the Passage repo - Runs `passage testnet` to initialize the configuration files of the network. These will be stored under `./mytestnet`. - Runs the `docker-compose.yml` file to spin up the networked nodes in separate containers. -3. You can stop the chain using Ctrl + C. +3. It runs the containers in deatched mode. To check the logs of the container nodes + + ```bash + docker container logs + ``` + + Where `container-name` can be `passagenode0`, `passagenode1`, `passagenode2` or `passagenode3` 4. When you are done you can clean up the environment with: ```bash + make localnet-stop make localnet-clean ``` - Which will remove the configuration files found under `./mytestnet`. + Which will stop and remove the configuration files found under `./mytestnet`.