From 88f738daae5258833f0ae6b8b7538e9f7fecd721 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 23 Jul 2024 13:40:34 -0400 Subject: [PATCH] feat: Dockerize our wasmd single-node validator (#110) Signed-off-by: Thane Thomson --- docker/wasmd/Dockerfile | 30 ++++++++++++ docker/wasmd/Makefile | 38 +++++++++++++++ docker/wasmd/README.md | 81 +++++++++++++++++++++++++++++++ docker/wasmd/accounts/admin.txt | 11 +++++ docker/wasmd/accounts/alice.txt | 11 +++++ docker/wasmd/accounts/bob.txt | 11 +++++ docker/wasmd/accounts/charlie.txt | 11 +++++ 7 files changed, 193 insertions(+) create mode 100644 docker/wasmd/Dockerfile create mode 100644 docker/wasmd/Makefile create mode 100644 docker/wasmd/README.md create mode 100644 docker/wasmd/accounts/admin.txt create mode 100644 docker/wasmd/accounts/alice.txt create mode 100644 docker/wasmd/accounts/bob.txt create mode 100644 docker/wasmd/accounts/charlie.txt diff --git a/docker/wasmd/Dockerfile b/docker/wasmd/Dockerfile new file mode 100644 index 0000000..190c62d --- /dev/null +++ b/docker/wasmd/Dockerfile @@ -0,0 +1,30 @@ +ARG WASMD_VERSION=v0.44.0 + +FROM cosmwasm/wasmd:${WASMD_VERSION} + +# Increase the amount of ucosm given to accounts +RUN sed -i 's/1000000000/12000000000000/g' /opt/setup_wasmd.sh + +# Set up wasmd. The account numbers correspond to those in the ./accounts/ +# folder. +RUN /opt/setup_wasmd.sh \ + wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3 \ + wasm19azg82cx3qx88gar8nl08rz7x0p27amtmadfep \ + wasm1adcnk7lt6qst7p5d0g5607e28k77um7nxwxuqy \ + wasm1jn34x50hy3my0a2mxwcx8fttgfxu2n5gpvu0ty + +# Configure the validator for single-node operation within a Docker container +RUN < ./accounts/admin.txt 2>&1 + wasmd keys add alice > ./accounts/alice.txt 2>&1 + wasmd keys add bob > ./accounts/bob.txt 2>&1 + wasmd keys add charlie > ./accounts/charlie.txt 2>&1 +.PHONY: create-accounts + +delete-accounts: + wasmd keys delete -y admin + wasmd keys delete -y alice + wasmd keys delete -y bob + wasmd keys delete -y charlie +.PHONY: delete-accounts \ No newline at end of file diff --git a/docker/wasmd/README.md b/docker/wasmd/README.md new file mode 100644 index 0000000..9569e0e --- /dev/null +++ b/docker/wasmd/README.md @@ -0,0 +1,81 @@ +# Quartz app wasmd image + +This folder contains a `Dockerfile` that helps build a single-node [wasmd] +validator for use in testing your Quartz application. + +It facilitates the creation of a Docker image with 4 accounts pre-loaded, each +having a small amount of `ucosm` preloaded from genesis for experimentation. + +- `admin` +- `alice` +- `bob` +- `charlie` + +These accounts' details are stored in clear text in the [accounts](./accounts/) +folder. + +**Note: this image is _not_ intended to be used in production.** + +## Running the image + +From this directory, simply run: + +```bash +make run +``` + +This will implicitly call `make build` to build the Docker image, and then run +it, binding to the following ports on the local machine: + +- 1317 +- 9090 +- 26656 +- 26657 + +It also implicitly creates a Docker volume called `wasmd_data` such that just +the contents of the `/root` directory in the container persist across restarts. +To wipe this volume and start from scratch, simply terminate the container and +run: + +```bash +docker volume rm wasmd_data +``` + +## Building the image + +To build the image without running it, simply run: + +```bash +make +``` + +This will, by default, build a Docker image tagged `informaldev/wasmd:v0.44.0`. + +## Querying accounts in the container + +To query, for example, the `admin` account's balance, where the `admin` +account's address is `wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3`, once the +Docker container is running, in a separate terminal run: + +```bash +# The first "wasmd" indicates the name of the running Docker container, whereas +# the second "wasmd" indicates the name of the command to run inside the +# container. +docker exec -it wasmd \ + wasmd query bank balances wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3 +``` + +You should see output like: + +```bash +balances: +- amount: "12000000000000" + denom: ucosm +- amount: "12000000000000" + denom: ustake +pagination: + next_key: null + total: "0" +``` + +[wasmd]: https://github.com/CosmWasm/wasmd diff --git a/docker/wasmd/accounts/admin.txt b/docker/wasmd/accounts/admin.txt new file mode 100644 index 0000000..713faea --- /dev/null +++ b/docker/wasmd/accounts/admin.txt @@ -0,0 +1,11 @@ + +- address: wasm1mkrm9m8g0dzv5z73xg8yzlj6srqc72qru5xfv3 + name: admin + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ax3A4I9zO4eI9+3YuU4s2wAy7vQZANa7SgdCjvgkE592"}' + type: local + + +**Important** write this mnemonic phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +scrap toss pottery food asset question utility uncle napkin glare sketch poet entire column comfort traffic hurdle person annual quick party crumble slab tissue diff --git a/docker/wasmd/accounts/alice.txt b/docker/wasmd/accounts/alice.txt new file mode 100644 index 0000000..a356bb8 --- /dev/null +++ b/docker/wasmd/accounts/alice.txt @@ -0,0 +1,11 @@ + +- address: wasm19azg82cx3qx88gar8nl08rz7x0p27amtmadfep + name: alice + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AjTyNLPEA3jD6+BUogvEowwjKi9XjVlJ09RDnc4mhlcR"}' + type: local + + +**Important** write this mnemonic phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +grain shoe diamond mix chunk turn odor across reduce room smart napkin scale ghost emotion stove mistake someone account snow country rail boy rescue diff --git a/docker/wasmd/accounts/bob.txt b/docker/wasmd/accounts/bob.txt new file mode 100644 index 0000000..64a90a0 --- /dev/null +++ b/docker/wasmd/accounts/bob.txt @@ -0,0 +1,11 @@ + +- address: wasm1adcnk7lt6qst7p5d0g5607e28k77um7nxwxuqy + name: bob + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A7IHJ0ihzXP/pQqhCQxH7+qsMEvarKWaVsYqzPeblAn+"}' + type: local + + +**Important** write this mnemonic phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +inmate surface cement any mule sweet what hamster rent ridge series equip equal supply plunge mango mystery chase other economy build pool coyote enter diff --git a/docker/wasmd/accounts/charlie.txt b/docker/wasmd/accounts/charlie.txt new file mode 100644 index 0000000..c7d6b6e --- /dev/null +++ b/docker/wasmd/accounts/charlie.txt @@ -0,0 +1,11 @@ + +- address: wasm1jn34x50hy3my0a2mxwcx8fttgfxu2n5gpvu0ty + name: charlie + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A9LnFBufvSFCF+aRd3eIB9sSLcguFHOsGJZsaN9D/zx7"}' + type: local + + +**Important** write this mnemonic phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +wrestle garage wrist bread woman depart service butter sorry soup tunnel gorilla absurd mansion obtain since security hair okay sense fly keep door inject