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

ci: Create wasm e2e test #1107

Merged
merged 94 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
3bf96a5
update changelog
jgimeno Nov 23, 2022
c3927ff
update changelog
jgimeno Nov 23, 2022
c32e279
build flag for linux
jgimeno Nov 27, 2022
9a135d2
build flag for linux
jgimeno Nov 27, 2022
1feb7a2
Merge branch 'master' into releases/v0.16.x
NibiruHeisenberg Nov 28, 2022
4179c9e
temp commit
jgimeno Nov 28, 2022
396b7a6
update main
jgimeno Nov 28, 2022
0899b80
add dist
jgimeno Nov 28, 2022
75d8a6f
add cgo enabled
jgimeno Nov 28, 2022
a9da6a3
Update go release.
jgimeno Nov 28, 2022
8c3ac57
add flags
jgimeno Nov 28, 2022
8f8e7c6
other test
jgimeno Nov 28, 2022
436bc36
add rm dist flag
jgimeno Nov 28, 2022
a2b72b4
add flag amd64
jgimeno Nov 28, 2022
451994c
add go releaser action
jgimeno Nov 28, 2022
6715dd1
add flags
jgimeno Nov 28, 2022
e9f3638
remove ledger flag
jgimeno Nov 28, 2022
e164a80
add tm flag
jgimeno Nov 28, 2022
53e5dbc
add lib
jgimeno Nov 29, 2022
4502f0e
try sudo
jgimeno Nov 29, 2022
c45e081
add link statically
jgimeno Nov 29, 2022
d7529b6
change back ldflags
jgimeno Nov 29, 2022
cc0d0f0
add muslc as build tag
jgimeno Nov 29, 2022
0c265c4
some test
jgimeno Nov 29, 2022
4ca7084
remove file
jgimeno Nov 29, 2022
0ab267a
last try build flags
jgimeno Nov 29, 2022
b81071a
add ldflag linkmode
jgimeno Nov 29, 2022
f99c94c
add another ldflags
jgimeno Nov 29, 2022
282bb59
add colon
jgimeno Nov 29, 2022
4cde32f
Comment all related to muslc
jgimeno Nov 29, 2022
e761dca
add external ld flags
jgimeno Nov 29, 2022
09d6963
add netgo
jgimeno Nov 29, 2022
0ea379c
add install musl dev
jgimeno Nov 29, 2022
783a066
add lm linker flag
jgimeno Nov 29, 2022
70166e4
add math lib
jgimeno Nov 29, 2022
fe231ef
Merge branch 'releases/v0.16.x' into fix/build-cross-binaries
jgimeno Nov 30, 2022
2b9a3d1
update changelog
jgimeno Nov 30, 2022
bd70dec
Merge pull request #1088 from NibiruChain/fix/build-cross-binaries
jgimeno Nov 30, 2022
8cdf0af
add lost wasm line
jgimeno Nov 30, 2022
3a991ca
move entry to breaking changes
jgimeno Nov 30, 2022
dbbc202
Merge branch 'master' into releases/v0.16.x
NibiruHeisenberg Dec 1, 2022
bc40fee
fix: localnet script
NibiruHeisenberg Dec 1, 2022
8fd17a2
create e2e wasm
jgimeno Dec 2, 2022
0cc79cf
add tag for version
jgimeno Dec 2, 2022
963266d
use self repository
jgimeno Dec 2, 2022
5f65f02
Merge branch 'master' into ci/e2e-wasm-test
jgimeno Dec 2, 2022
b0e3742
ls release folder
jgimeno Dec 2, 2022
fbed48e
Merge branch 'ci/e2e-wasm-test' of github.com:NibiruChain/nibiru into…
jgimeno Dec 2, 2022
96b588f
echo release folder
jgimeno Dec 2, 2022
cfa2677
echo outputs
jgimeno Dec 2, 2022
dbe022b
echo outputs
jgimeno Dec 2, 2022
7cc01a9
download release
jgimeno Dec 2, 2022
d0bc4f8
try release
jgimeno Dec 2, 2022
188a408
try release output
jgimeno Dec 2, 2022
34aced9
try var
jgimeno Dec 2, 2022
3930654
use wget
jgimeno Dec 2, 2022
bc35c4c
use another action
jgimeno Dec 2, 2022
67e407a
fix action
jgimeno Dec 2, 2022
b9af5b7
use filter
jgimeno Dec 2, 2022
9a1e8a1
unpack release
jgimeno Dec 2, 2022
d64931f
change name
jgimeno Dec 2, 2022
aa474b9
show release
jgimeno Dec 2, 2022
33682a5
add nibid version
jgimeno Dec 2, 2022
bc570a9
execute nibid
jgimeno Dec 2, 2022
422f24a
add nibid
jgimeno Dec 2, 2022
6aafecd
run network
jgimeno Dec 2, 2022
a15cbfd
run network
jgimeno Dec 2, 2022
7569471
add runs on
jgimeno Dec 2, 2022
4145fbe
insert code
jgimeno Dec 2, 2022
ac10fcc
ls test
jgimeno Dec 2, 2022
4bc26be
launch localnet
jgimeno Dec 2, 2022
8ec9081
remove build localnet
jgimeno Dec 2, 2022
27dfc87
refactor binary
jgimeno Dec 2, 2022
c81351f
Merge branch 'master' into ci/e2e-wasm-test
jgimeno Dec 6, 2022
ca5a62e
try query
jgimeno Dec 6, 2022
9e24a65
Merge branch 'ci/e2e-wasm-test' of github.com:NibiruChain/nibiru into…
jgimeno Dec 6, 2022
5a40c97
add deploy wasm test
jgimeno Dec 6, 2022
707f479
add validator address
jgimeno Dec 7, 2022
9e60317
temp commit
jgimeno Dec 7, 2022
e9fa360
Merge branch 'master' into ci/e2e-wasm-test
NibiruHeisenberg Dec 7, 2022
f064222
deploy wasm
jgimeno Dec 7, 2022
bcaab22
Merge branch 'ci/e2e-wasm-test' of github.com:NibiruChain/nibiru into…
jgimeno Dec 7, 2022
142d075
add folder
jgimeno Dec 7, 2022
e86d7c1
add chain id
jgimeno Dec 7, 2022
e741dd1
add node
jgimeno Dec 7, 2022
80ae22e
add nameservice code
jgimeno Dec 7, 2022
9799f21
add register service
jgimeno Dec 7, 2022
0ecce3d
remove nibid
jgimeno Dec 7, 2022
fde918c
add end to end teset
jgimeno Dec 7, 2022
4ad44a5
add changelog
jgimeno Dec 7, 2022
67e59e9
add header
jgimeno Dec 7, 2022
fdb0436
Update .github/workflows/e2e-wasm.yml
jgimeno Dec 12, 2022
348072c
Merge remote-tracking branch 'origin/master' into ci/e2e-wasm-test
jgimeno Jan 13, 2023
06471d2
remove address
jgimeno Jan 13, 2023
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
43 changes: 43 additions & 0 deletions .github/workflows/e2e-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: CosmWasm e2e contract tests

on:
# On normal PRs or when workflow goreleaser finishes, as it gets the last release tag.
pull_request:
paths: ["**.go", "**.proto", "go.mod", "go.sum"]
workflow_run:
workflows: ["goreleaser"]
types:
- completed

jgimeno marked this conversation as resolved.
Show resolved Hide resolved

jobs:
get-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download release
id: latest_release
uses: pozetroninc/[email protected]
with:
repository: ${{ github.repository }}

- name: download release
uses: robinraju/[email protected]
with:
tag: ${{ steps.latest_release.outputs.release }}
fileName: "*linux_amd64.tar.gz"

- name: unpack release
run: |
tar -xzf *linux_amd64.tar.gz

- name: launch localnet
run: |
sh ./scripts/e2e/localnet.sh

- name: run e2e tests
run: |
sh ./scripts/e2e/deploy-wasm.sh
35 changes: 35 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.3'
cache: true
- name: Set Env
run: echo "TM_VERSION=$(go list -m github.com/tendermint/tendermint | sed 's:.* ::')" >> $GITHUB_ENV
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TM_VERSION: ${{ env.TM_VERSION }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build
*_old
mockdata/
docs
dist
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
before:
hooks:
- sudo wget https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a -O /lib/libwasmvm_muslc.a
- sudo apt install musl-dev
builds:
- id: linux-amd64
main: ./cmd/nibid
binary: nibid
goos:
- linux
goarch:
- amd64
env:
- CGO_ENABLED=1
- CC=x86_64-linux-gnu-gcc
flags:
- -mod=readonly
ldflags:
- -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X github.com/cosmos/cosmos-sdk/version.Name=nibiru -X github.com/cosmos/cosmos-sdk/version.AppName=nibid -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} -X github.com/tendermint/tendermint/version.TMCoreSemVer={{ .Env.TM_VERSION }}
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
tags:
- netgo
- muslc

15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

* ...
### CI

* [#1032](https://github.com/NibiruChain/nibiru/pull/1107) - ci: Create e2e wasm contract test

## [v0.16.0](https://github.com/NibiruChain/nibiru/releases/tag/v0.16.0) - Unreleased

Expand All @@ -51,12 +53,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1038](https://github.com/NibiruChain/nibiru/pull/1038) - feat(dex): add single asset join
* [#1050](https://github.com/NibiruChain/nibiru/pull/1050) - feat(dex): add stableswap pools
* [#1058](https://github.com/NibiruChain/nibiru/pull/1058) - feature: use collections external lib
* [#1074](https://github.com/NibiruChain/nibiru/pull/1074) - feat(vpool): Add gov proposal for editing the vpool config without changing the reserves.
* [#1082](https://github.com/NibiruChain/nibiru/pull/1082) - feat(vpool): Add gov proposal for editing the sswap invariant of a vpool..
* [#1092](https://github.com/NibiruChain/nibiru/pull/1092) - refactor(dex)!: revive dex module using intermediate test app
* [#1097](https://github.com/NibiruChain/nibiru/pull/1097) - feat(perp): Track and expose the net size of a pair with a query
* [#1105](https://github.com/NibiruChain/nibiru/pull/1105) - feat(perp): Add (notional) volume to metrics state

### API Breaking
* [#1074](https://github.com/NibiruChain/nibiru/pull/1074) - feat(vpool): Add gov proposal for editing the vpool config without changing the reserves.

### State Machine Breaking

* [#1102](https://github.com/NibiruChain/nibiru/pull/1102) - refactor(perp)!: replace CumulativePremiumFractions array with single value
Expand All @@ -77,7 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1055](https://github.com/NibiruChain/nibiru/pull/1055) - chore(deps): Bump github.com/spf13/viper from 1.13.0 to 1.14.0
* [#1061](https://github.com/NibiruChain/nibiru/pull/1061) - feat(cmd): hard-code block time parameters in the Tendermint config
* [#1068](https://github.com/NibiruChain/nibiru/pull/1068) - refactor(vpool)!: Remove ReserveSnapshot from the vpool genesis state since reserves are taken automatically on vpool initialization.
* [#1064](https://github.com/NibiruChain/nibiru/pull/1064) - test(wasm): add test for cosmwasm
* [#1064](https://github.com/NibiruChain/nibiru/pull/1064) - test(wasm): add test for Cosmwasm
* [#1075](https://github.com/NibiruChain/nibiru/pull/1075) - feat(dex): remove possibility to create multiple pools with the same assets
* [#1080](https://github.com/NibiruChain/nibiru/pull/1080) - feat(perp): Add exchanged notional to the position changed event #1080
* [#1082](https://github.com/NibiruChain/nibiru/pull/1082) - feat(localnet.sh): Set genesis prices based on real BTC and ETH prices
Expand All @@ -91,6 +95,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1100](https://github.com/NibiruChain/nibiru/pull/1100) - fix(oracle): fix flaky oracle test
* [#1110](https://github.com/NibiruChain/nibiru/pull/1110) - fix(dex): fix dex issue on unsorted join pool

### CI

* [#1088](https://github.com/NibiruChain/nibiru/pull/1088) - ci: build cross binaries

## v0.15.0

### CI
Expand Down Expand Up @@ -131,6 +139,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

* [#1044](https://github.com/NibiruChain/nibiru/pull/1044) - feat(wasm): cosmwasm module integration
* [#858](https://github.com/NibiruChain/nibiru/pull/858) - fix trading limit ratio check; checks in both directions on both quote and base assets
* [#865](https://github.com/NibiruChain/nibiru/pull/865) - refactor(vpool): clean up interface for CmdGetBaseAssetPrice to use add and remove as directions
* [#868](https://github.com/NibiruChain/nibiru/pull/868) - refactor dex integration tests to be independent between them
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.19-alpine

WORKDIR /build

ARG ARCH=x86_64

RUN set -eux; apk add --no-cache ca-certificates build-base;
RUN apk add git


ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 9ecb037336bd56076573dc18c26631a9d2099a7f2b40dc04b6cae31ffb4c8f9a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 6e4de7ba9bad4ae9679c7f9ecf7e283dd0160e71567c6a7be6ae47c81ebe7f32

RUN cp /lib/libwasmvm_muslc.${ARCH}.a /lib/libwasmvm_muslc.a
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ $(BUILDDIR)/:

# build for linux architecture
build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
CGO_ENABLED=1 LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
Expand Down Expand Up @@ -166,6 +166,21 @@ test-sim-benchmark-invariants:
test-create-test-cases:
@python scripts/testing/stableswap_model.py

###############################################################################
### Lint ###
###############################################################################
release:
docker run --rm -v "$(CURDIR)":/code -w /code goreleaser/goreleaser-cross --skip-publish --rm-dist

build-docker: go.sum $(BUILDDIR)/
go build -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/nibid/main.go
tar -czvf build/$(TARNAME).tar.gz build/nibid
rm build/nibid

build-linux-docker:
BUILD_TAGS=muslc LINK_STATICALLY=true TARNAME="nibiru_linux_amd64" CC=aarch64-linux-gnu-gcc BUILD_ARGS="-o $(BUILDDIR)/nibid -tags=muslc" CGO_ENABLED=1 LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build-docker
# TARNAME="nibiru_linux_arm64" BUILD_ARGS="-o $(BUILDDIR)/nibid -tags=muslc" CGO_ENABLED=1 LEDGER_ENABLED=false GOOS=linux GOARCH=arm64 $(MAKE) build-docker
jgimeno marked this conversation as resolved.
Show resolved Hide resolved

###############################################################################
### Lint ###
###############################################################################
Expand Down
Binary file added scripts/e2e/contracts/cw_nameservice.wasm
Binary file not shown.
47 changes: 47 additions & 0 deletions scripts/e2e/deploy-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
BINARY="./nibid"
DENOM="unibi"
CHAIN_ID="nibiru-localnet-0"
TXFLAG="--gas-prices 0.1$DENOM --gas auto --gas-adjustment 1.3 -y -b block --chain-id $CHAIN_ID"
DEFAULT_DEV_ADDRESS="juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y"
jgimeno marked this conversation as resolved.
Show resolved Hide resolved

# validator addr
VALIDATOR_ADDR=$($BINARY keys show validator --address)
echo "Validator address:"
echo "$VALIDATOR_ADDR"

BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR)
echo "Pre-store balance:"
echo "$BALANCE_1"

# you ideally want to run locally, get a user and then
# pass that addr in here
echo "Address to deploy contracts: $DEFAULT_DEV_ADDRESS"
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
echo "TX Flags: $TXFLAG"

CONTRACT_CODE=$($BINARY tx wasm store "./scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
echo "Stored: $CONTRACT_CODE"

BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR)
echo "Post-store balance:"
echo "$BALANCE_2"

INIT='{"purchase_price":{"amount":"100","denom":"unibi"},"transfer_price":{"amount":"999","denom":"unibi"}}'
$BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin

CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CONTRACT_CODE --output json | jq -r '.contracts[-1]')
echo "Contract Address: $CONTRACT_ADDRESS"

$BINARY query wasm contract $CONTRACT_ADDRESS

# purchase a domain name
$BINARY tx wasm execute $CONTRACT_ADDRESS '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator $TXFLAG -y

# query registered name
NAME_QUERY='{"resolve_record": {"name": "uniques-domain"}}'
DOMAIN_OWNER=$($BINARY query wasm contract-state smart $CONTRACT_ADDRESS "$NAME_QUERY" --output json | jq -r '.data.address')
echo "Owner: $DOMAIN_OWNER"

if [ $DOMAIN_OWNER != $VALIDATOR_ADDR ]; then
echo "Domain owner is not the validator address"
exit 1
fi
Loading