diff --git a/CHANGELOG.md b/CHANGELOG.md index b815fadd4c0..651c47d29cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +* [#1554](https://github.com/osmosis-labs/osmosis/pull/1554) local dev environment * [#1535](https://github.com/osmosis-labs/osmosis/pull/1535) upgrade wasmd to v0.27.0.rc3-osmo and ibc-go to v3 * [#1435] `x/tokenfactory` create denom fee for spam resistance * [#1429] solver for multi-asset CFMM diff --git a/Dockerfile b/Dockerfile index 8171358b5ac..b1d1331a642 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ COPY --from=build /osmosis/build/osmosisd /bin/osmosisd ENV HOME /osmosis WORKDIR $HOME -EXPOSE 26656 +EXPOSE 26656 EXPOSE 26657 EXPOSE 1317 diff --git a/Makefile b/Makefile index f5723691837..edbd3cc43c5 100644 --- a/Makefile +++ b/Makefile @@ -267,6 +267,17 @@ format: ### Localnet ### ############################################################################### +localnet-keys: + . tests/localosmosis/keys.sh + +localnet-build: + @docker build -t local:osmosis -f tests/localosmosis/Dockerfile . + +localnet-start: + @docker-compose -f tests/localosmosis/docker-compose.yml up + +localnet-remove: + @docker-compose -f tests/localosmosis/docker-compose.yml down .PHONY: all build-linux install format lint \ go-mod-cache draw-deps clean build build-contract-tests-hooks \ diff --git a/tests/localosmosis/Dockerfile b/tests/localosmosis/Dockerfile new file mode 100644 index 00000000000..85f681e5889 --- /dev/null +++ b/tests/localosmosis/Dockerfile @@ -0,0 +1,51 @@ +# syntax=docker/dockerfile:1 + +# -------------------------------------------------------- +# Build +# -------------------------------------------------------- + +FROM golang:1.18.2-alpine3.15 as build + +RUN set -eux; apk add --no-cache ca-certificates build-base; +RUN apk add git +# Needed by github.com/zondax/hid +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 +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc +RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 + +# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a + +RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build + +# -------------------------------------------------------- +# Runner +# -------------------------------------------------------- + +FROM alpine + +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 +EXPOSE 26656 +EXPOSE 26657 +EXPOSE 1317 + +ENTRYPOINT ["osmosisd"] +CMD ["start"] diff --git a/tests/localosmosis/README.md b/tests/localosmosis/README.md new file mode 100644 index 00000000000..4c99ab03184 --- /dev/null +++ b/tests/localosmosis/README.md @@ -0,0 +1,38 @@ +# LocalOsmosis + +You can now quickly test your changes to Osmosis with just a few commands: + +1. Make any change to the osmosis code that you want to test + +2. From the Osmosis home folder, run `make localnet-build` + - This compiles all your changes to docker image called local:osmosis (~60 seconds) + +3. Once complete, run `make localnet-start` + - You will now be running a local network with your changes! + +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 + - If the keys are already on your keyring, you will get an "Error: aborted" + - Ensure you use the name of the account as listed in the table below, as well as ensure you append the `--keyring-backend test` to your txs + - Example: `osmosisd tx bank send lo-test2 osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks --keyring-backend test --chain-id localosmosis` + +5. To remove all block history and start from scratch, run `make localnet-remove` + +## Accounts + +LocalOsmosis is pre-configured with one validator and 9 accounts with ION and OSMO balances. + + +| Account | Address | Mnemonic | +| --------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| lo-val | `osmo1phaxpevm5wecex2jyaqty2a4v02qj7qmlmzk5a`
`osmovaloper1phaxpevm5wecex2jyaqty2a4v02qj7qm9v24r6` | `satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn` | +| lo-test1 | `osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks` | `notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius` | +| lo-test2 | `osmo18s5lynnmx37hq4wlrw9gdn68sg2uxp5rgk26vv` | `quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty` | +| lo-test3 | `osmo1qwexv7c6sm95lwhzn9027vyu2ccneaqad4w8ka` | `symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb` | +| lo-test4 | `osmo14hcxlnwlqtq75ttaxf674vk6mafspg8xwgnn53` | `bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty` | +| lo-test5 | `osmo12rr534cer5c0vj53eq4y32lcwguyy7nndt0u2t` | `second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal` | +| lo-test6 | `osmo1nt33cjd5auzh36syym6azgc8tve0jlvklnq7jq` | `spatial forest elevator battle also spoon fun skirt flight initial nasty transfer glory palm drama gossip remove fan joke shove label dune debate quick` | +| lo-test7 | `osmo10qfrpash5g2vk3hppvu45x0g860czur8ff5yx0` | `noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate` | +| lo-test8 | `osmo1f4tvsdukfwh6s9swrc24gkuz23tp8pd3e9r5fa` | `cream sport mango believe inhale text fish rely elegant below earth april wall rug ritual blossom cherry detail length blind digital proof identify ride` | +| lo-test9 | `osmo1myv43sqgnj5sm4zl98ftl45af9cfzk7nhjxjqh` | `index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred` | +| lo-test10 | `osmo14gs9zqh8m49yy9kscjqu9h72exyf295afg6kgk` | `prefer forget visit mistake mixture feel eyebrow autumn shop pair address airport diesel street pass vague innocent poem method awful require hurry unhappy shoulder` | diff --git a/tests/localosmosis/docker-compose.yml b/tests/localosmosis/docker-compose.yml new file mode 100644 index 00000000000..a52d6c5a56b --- /dev/null +++ b/tests/localosmosis/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" + +services: + osmosisd: + image: local:osmosis + user: "root:root" + command: + - start + - --rpc.laddr=tcp://0.0.0.0:26657 + ports: + - "26657:26657" + - "1317:1317" + - "9090:9090" + - "9091:9091" diff --git a/tests/localosmosis/keys.sh b/tests/localosmosis/keys.sh new file mode 100755 index 00000000000..084337ee464 --- /dev/null +++ b/tests/localosmosis/keys.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn" | osmosisd keys add lo-val --recover --keyring-backend test +echo "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius" | osmosisd keys add lo-test1 --recover --keyring-backend test +echo "quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty" | osmosisd keys add lo-test2 --recover --keyring-backend test +echo "symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb" | osmosisd keys add lo-test3 --recover --keyring-backend test +echo "bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty" | osmosisd keys add lo-test4 --recover --keyring-backend test +echo "second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal" | osmosisd keys add lo-test5 --recover --keyring-backend test +echo "spatial forest elevator battle also spoon fun skirt flight initial nasty transfer glory palm drama gossip remove fan joke shove label dune debate quick" | osmosisd keys add lo-test6 --recover --keyring-backend test +echo "noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate" | osmosisd keys add lo-test7 --recover --keyring-backend test +echo "cream sport mango believe inhale text fish rely elegant below earth april wall rug ritual blossom cherry detail length blind digital proof identify ride" | osmosisd keys add lo-test8 --recover --keyring-backend test +echo "index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred" | osmosisd keys add lo-test9 --recover --keyring-backend test +echo "prefer forget visit mistake mixture feel eyebrow autumn shop pair address airport diesel street pass vague innocent poem method awful require hurry unhappy shoulder" | osmosisd keys add lo-test10 --recover --keyring-backend test diff --git a/tests/localosmosis/setup.sh b/tests/localosmosis/setup.sh new file mode 100755 index 00000000000..cc2cf878026 --- /dev/null +++ b/tests/localosmosis/setup.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# change staking denom to uosmo +osmosisd init --chain-id=localosmosis val +echo "satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn" | osmosisd keys add val --recover --keyring-backend=test +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json +osmosisd add-genesis-account osmo1phaxpevm5wecex2jyaqty2a4v02qj7qmlmzk5a 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo18s5lynnmx37hq4wlrw9gdn68sg2uxp5rgk26vv 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo1qwexv7c6sm95lwhzn9027vyu2ccneaqad4w8ka 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo14hcxlnwlqtq75ttaxf674vk6mafspg8xwgnn53 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo12rr534cer5c0vj53eq4y32lcwguyy7nndt0u2t 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo1nt33cjd5auzh36syym6azgc8tve0jlvklnq7jq 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo10qfrpash5g2vk3hppvu45x0g860czur8ff5yx0 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo1f4tvsdukfwh6s9swrc24gkuz23tp8pd3e9r5fa 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo1myv43sqgnj5sm4zl98ftl45af9cfzk7nhjxjqh 100000000000uosmo,100000000000uion +osmosisd add-genesis-account osmo14gs9zqh8m49yy9kscjqu9h72exyf295afg6kgk 100000000000uosmo,100000000000uion +osmosisd gentx val 500000000uosmo --keyring-backend=test --chain-id=localosmosis +osmosisd collect-gentxs +# update staking genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["staking"]["params"]["unbonding_time"]="240s"' | sponge $HOME/.osmosisd/config/genesis.json +# update crisis variable to uosmo +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json +# udpate gov genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="60s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json +# update epochs genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["epochs"]["epochs"][1]["duration"]="60s"' | sponge $HOME/.osmosisd/config/genesis.json +# update poolincentives genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][0]="120s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][1]="180s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["lockable_durations"][2]="240s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["poolincentives"]["params"]["minted_denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json +# update incentives genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][0]="1s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][1]="120s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][2]="180s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["lockable_durations"][3]="240s"' | sponge $HOME/.osmosisd/config/genesis.json +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["incentives"]["params"]["distr_epoch_identifier"]="day"' | sponge $HOME/.osmosisd/config/genesis.json +# update mint genesis +cat $HOME/.osmosisd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uosmo"' | sponge $HOME/.osmosisd/config/genesis.json +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 +sed -i.bak -E 's#^(seeds[[:space:]]+=[[:space:]]+).*$#\1""#' ~/.osmosisd/config/config.toml