Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix localnet deployment #186

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ artifacts
coverage.txt
profile.out
sim_log_file

mytestnet
# IDE
.vscode
.idea
.idea
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -494,22 +494,30 @@ 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 \
--node-dir-prefix passagenode \
--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
.PHONY: localnet-start localnet-stop localnet-clean static-build
43 changes: 30 additions & 13 deletions tests/localpassage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <container-name>
```

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`.
Loading