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: localosmosis to work for testing cosmwasm contracts #1640

Merged
merged 5 commits into from
Jun 1, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@ $RECYCLE.BIN/
/scripts/local/
/x/incentives/keeper/osmosis_testing/
tools-stamp
/tests/localosmosis/.osmosisd/*
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Upgrade from wasmd v0.23.x to [v0.27.0](https://github.com/CosmWasm/wasmd/releas
The TokenFactory module is added to the chain, making it possible for users and contracts to make new native tokens.
Cosmwasm bindings have been added, to make swapping and creating these new tokens easier within the contract ecosystem.

* [#1640](https://github.com/osmosis-labs/osmosis/pull/1640) fix: localosmosis to work for testing cosmwasm contracts

### Other Features

* [#1629](https://github.com/osmosis-labs/osmosis/pull/1629) Fix bug in the airdrop claim script
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,13 @@ localnet-build:
localnet-start:
@docker-compose -f tests/localosmosis/docker-compose.yml up

localnet-remove:
localnet-stop:
@docker-compose -f tests/localosmosis/docker-compose.yml down

localnet-remove: localnet-stop
PWD=$(shell pwd)
@docker run --user root -v ${PWD}/tests/localosmosis/.osmosisd:/root/osmosis ubuntu /bin/sh -c "rm -rf /root/osmosis/*"

.PHONY: all build-linux install format lint \
go-mod-cache draw-deps clean build build-contract-tests-hooks \
test test-all test-build test-cover test-unit test-race benchmark
30 changes: 10 additions & 20 deletions tests/localosmosis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# syntax=docker/dockerfile:1

# --------------------------------------------------------
# Build
# --------------------------------------------------------

# Build stage
FROM golang:1.18.2-alpine3.15 as build

RUN set -eux; apk add --no-cache ca-certificates build-base;
Expand All @@ -14,7 +11,6 @@ RUN apk add linux-headers
WORKDIR /osmosis
COPY . /osmosis


# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
Expand All @@ -26,26 +22,20 @@ RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a

RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build

# --------------------------------------------------------
# Runner
# --------------------------------------------------------

# Run stage
FROM ubuntu

COPY --from=build /osmosis/build/osmosisd /bin/osmosisd
COPY /tests/localosmosis/setup.sh /setup.sh

ENV HOME /osmosis
WORKDIR $HOME
RUN apk update
RUN apk add jq
RUN apk add moreutils
RUN rm -rf /var/cache/apk/*
RUN chmod +x /setup.sh
RUN /setup.sh

COPY --from=build ${HOME}/build/osmosisd /bin/osmosisd
COPY tests/localosmosis/setup.sh ${HOME}/setup.sh

RUN apt-get update -y && apt-get install -y jq moreutils
RUN chmod +x ${HOME}/setup.sh

EXPOSE 26656
EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["osmosisd"]
CMD ["start"]
ENTRYPOINT ${HOME}/setup.sh
5 changes: 5 additions & 0 deletions tests/localosmosis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ You can now quickly test your changes to Osmosis with just a few commands:

3. Once complete, run `make localnet-start`
- You will now be running a local network with your changes!
- The files in `tests/e2e/localosmosis/.osmosisd` that are produced
by this command can only be removed by running `make localnet-remove`
- That will reset the chain to genesis

4. To add your validator wallet and 9 other preloaded wallets automatically, run `make localnet-keys`
- These keys are added to your --keyring-backend test
Expand All @@ -18,6 +21,8 @@ You can now quickly test your changes to Osmosis with just a few commands:

5. To remove all block history and start from scratch, run `make localnet-remove`

6. To stop the chain but keep the state, run `make localnet-stop`

## Accounts

LocalOsmosis is pre-configured with one validator and 9 accounts with ION and OSMO balances.
Expand Down
7 changes: 4 additions & 3 deletions tests/localosmosis/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ services:
osmosisd:
image: local:osmosis
user: "root:root"
command:
- start
- --rpc.laddr=tcp://0.0.0.0:26657
volumes:
- ./.osmosisd/config:/osmosis/.osmosisd/config
- ./.osmosisd/data:/osmosis/.osmosisd/data
- ./.osmosisd/wasm:/osmosis/.osmosisd/wasm
ports:
- "26657:26657"
- "1317:1317"
Expand Down
7 changes: 6 additions & 1 deletion tests/localosmosis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["mint"]["params"]["mint
cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["mint"]["params"]["epoch_identifier"]="day"' | sponge $HOME/.osmosisd/config/genesis.json
# update gamm genesis
cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gamm"]["params"]["pool_creation_fee"][0]["denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json
# remove seeds
# update txfee basedenom
cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["txfees"]["basedenom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json
remove seeds

sed -i.bak -E 's#^(seeds[[:space:]]+=[[:space:]]+).*$#\1""#' ~/.osmosisd/config/config.toml

osmosisd start --rpc.laddr=tcp://0.0.0.0:26657