From 431027561d213f291f9d3ff2d4026232bd032d5d Mon Sep 17 00:00:00 2001 From: kaustubhkapatral Date: Wed, 19 Jun 2024 12:19:44 +0530 Subject: [PATCH 1/4] update dockerfile to remove hardcoded wasmvm version --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 && \ From 2e941fd295c3c574ddca53d8e432900baf40fa1f Mon Sep 17 00:00:00 2001 From: kaustubhkapatral Date: Wed, 19 Jun 2024 12:33:56 +0530 Subject: [PATCH 2/4] added cmd for building statically linked binary --- Makefile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 From 48047fc3e2f24b060d6dde8fe8fcb96fccecbbbf Mon Sep 17 00:00:00 2001 From: kaustubhkapatral Date: Wed, 19 Jun 2024 12:34:34 +0530 Subject: [PATCH 3/4] updated gitignore to add testnet files --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 7e44952e0dc03dd087c80f4fddb612a7e1e5606a Mon Sep 17 00:00:00 2001 From: kaustubhkapatral Date: Wed, 19 Jun 2024 12:35:04 +0530 Subject: [PATCH 4/4] updated localnet readme --- tests/localpassage/README.md | 43 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) 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`.