Skip to content

Commit

Permalink
chore: add x/wasm module to simapp (#591)
Browse files Browse the repository at this point in the history
* feat: add `x/wasm` feature to `simapp`

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: apply the changes of NewSimApp.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix lint error

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: error of `TestAppStateDeterminism` unittest

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix lint error

Signed-off-by: zemyblue <zemyblue@gmail.com>

* fix: import cycle error

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update docs (include changelog)

Signed-off-by: zemyblue <zemyblue@gmail.com>
  • Loading branch information
zemyblue authored Jul 15, 2022
1 parent ddf7778 commit f46f02b
Show file tree
Hide file tree
Showing 22 changed files with 485 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (ci) [\#457](https://github.com/line/lbm-sdk/pull/457), [\#471](https://github.com/line/lbm-sdk/pull/471) add swagger check
* (ci) [\#469](https://github.com/line/lbm-sdk/pull/469) publish docker image on tag push
* (ci) [\#580](https://github.com/line/lbm-sdk/pull/580) fix the problem that the registered docker image couldn't run on M1.
* (simapp) [\#591](https://github.com/line/lbm-sdk/pull/591) chore: add x/wasm module to simapp

### Document Updates

Expand Down
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Simple usage with a mounted data directory:
# > docker build -t simapp .
# > docker build --platform="linux/amd64" -t simapp .
#
# Server:
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd init test-chain
Expand All @@ -14,23 +14,48 @@ FROM golang:alpine AS build-env

# Install minimum necessary dependencies,
ENV PACKAGES curl make git libc-dev bash gcc g++ linux-headers eudev-dev python3
RUN apk add --no-cache $PACKAGES
RUN apk add --update --no-cache $PACKAGES

# Set working directory for the build
WORKDIR /go/src/github.com/line/lbm-sdk

# prepare dbbackend before building; this can be cached
COPY ./Makefile ./
COPY ./contrib ./contrib
#RUN make dbbackend

# Install GO dependencies
COPY ./go.mod /go/src/github.com/line/lbm-sdk/go.mod
COPY ./go.sum /go/src/github.com/line/lbm-sdk/go.sum
RUN go mod download

# Build cosmwasm
ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=$CARGO_HOME/bin:$PATH

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init"
RUN chmod +x rustup-init
RUN ./rustup-init -y --no-modify-path --default-toolchain 1.57.0; rm rustup-init
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME
RUN cd $(go list -f "{{ .Dir }}" -m github.com/line/wasmvm) && \
cd ./libwasmvm && \
RUSTFLAGS='-C target-feature=-crt-static' cargo build --release --example staticlib && \
mv -f target/release/examples/libstaticlib.a /usr/lib/libwasmvm_static.a && \
rm -rf target

# Add source files
COPY . .

# install simapp, remove packages
RUN make build-linux
RUN BUILD_TAGS=static make build CGO_ENABLED=1


# Final image
FROM alpine:edge

# Install ca-certificates
RUN apk add --update ca-certificates libstdc++
# Set up OS dependencies
RUN apk add --update --no-cache ca-certificates libstdc++
WORKDIR /root

# Copy over binaries from the build-env
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/line/lbm-sdk.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
CGO_ENABLED ?= 1

export GO111MODULE = on

Expand Down Expand Up @@ -113,6 +114,9 @@ include contrib/devtools/Makefile
BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=$(CGO_ENABLED) go build -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

# todo: should be fix
build-linux:
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build

Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
encCfg.InterfaceRegistry.RegisterImplementations((*sdk.Msg)(nil),
&testdata.TestMsg{},
)
app = simapp.NewSimApp(log.NewNopLogger(), memdb.NewDB(), nil, true, map[int64]bool{}, "", 0, encCfg, simapp.EmptyAppOptions{}, routerOpt)
app = simapp.NewSimApp(log.NewNopLogger(), memdb.NewDB(), nil, true, map[int64]bool{}, "", 0, encCfg, simapp.EmptyAppOptions{}, nil, routerOpt)
genState := simapp.NewDefaultGenesisState(encCfg.Marshaler)
stateBytes, err := json.MarshalIndent(genState, "", " ")
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit f46f02b

Please sign in to comment.