Skip to content

Commit eb07386

Browse files
committed
Merge branch 'main' into feat/cosmos-50
2 parents 1d584d4 + 4f64dd3 commit eb07386

File tree

9 files changed

+124
-46
lines changed

9 files changed

+124
-46
lines changed

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM golang:1.21-alpine AS go-builder
2+
#ARG arch=x86_64
3+
4+
# See https://github.com/CosmWasm/wasmvm/releases
5+
ENV LIBWASMVM_VERSION=v1.5.0
6+
7+
# this comes from standard alpine nightly file
8+
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
9+
# with some changes to support our toolchain, etc
10+
RUN set -eux; apk add --no-cache ca-certificates build-base;
11+
12+
RUN apk add git cmake
13+
# NOTE: add these to run with LEDGER_ENABLED=true
14+
# RUN apk add libusb-dev linux-headers
15+
16+
WORKDIR /code
17+
COPY . /code/
18+
19+
# Install mimalloc
20+
RUN git clone --depth 1 https://github.com/microsoft/mimalloc; cd mimalloc; mkdir build; cd build; cmake ..; make -j$(nproc); make install
21+
ENV MIMALLOC_RESERVE_HUGE_OS_PAGES=4
22+
23+
# See https://github.com/\!cosm\!wasm/wasmvm/releases
24+
ADD https://github.com/\!cosm\!wasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
25+
ADD https://github.com/\!cosm\!wasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
26+
27+
# Highly recommend to verify the version hash
28+
# RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep a5e63292ec67f5bdefab51b42c3fbc3fa307c6aefeb6b409d971f1df909c3927
29+
# RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 762307147bf8f550bd5324b7f7c4f17ee20805ff93dc06cc073ffbd909438320
30+
# Copy the library you want to the final location that will be found by the linker flag `-linitia_muslc`
31+
32+
RUN cp /lib/libwasmvm_muslc.`uname -m`.a /lib/libwasmvm_muslc.a
33+
34+
# force it to use static lib (from above) not standard libwasmvm.so file
35+
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS="-linkmode=external -extldflags \"-L/code/mimalloc/build -lmimalloc -Wl,-z,muldefs -static\"" make build
36+
37+
FROM alpine:3.15.4
38+
39+
RUN addgroup minitia \
40+
&& adduser -G minitia -D -h /minitia minitia
41+
42+
WORKDIR /minitia
43+
44+
COPY --from=go-builder /code/build/minitiad /usr/local/bin/minitiad
45+
46+
USER minitia
47+
48+
# rest server
49+
EXPOSE 1317
50+
# grpc
51+
EXPOSE 9090
52+
# tendermint p2p
53+
EXPOSE 26656
54+
# tendermint rpc
55+
EXPOSE 26657
56+
57+
CMD ["/usr/local/bin/minitiad", "version"]

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ endif
120120

121121
build-linux:
122122
mkdir -p $(BUILDDIR)
123-
docker build --no-cache --tag initia/minitiad ./
124-
docker create --name temp initia/minitiad:latest
123+
docker build --no-cache --tag initia/minimwasm ./
124+
docker create --name temp initia/minimwasm:latest
125125
docker cp temp:/usr/local/bin/minitiad $(BUILDDIR)/
126126
docker rm temp
127127

128128
build-linux-with-shared-library:
129129
mkdir -p $(BUILDDIR)
130-
docker build --tag initia/minitiad-shared ./ -f ./shared.Dockerfile
131-
docker create --name temp initia/minitiad-shared:latest
130+
docker build --tag initia/miniwasm-shared ./ -f ./shared.Dockerfile
131+
docker create --name temp initia/miniwasm-shared:latest
132132
docker cp temp:/usr/local/bin/minitiad $(BUILDDIR)/
133-
docker cp temp:/lib/libinitia.so $(BUILDDIR)/
133+
docker cp temp:/lib/libwasmvm.so $(BUILDDIR)/
134134
docker rm temp
135135

136136
install: go.sum

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import (
9595
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
9696

9797
// initia imports
98+
initialanes "github.com/initia-labs/initia/app/lanes"
9899
"github.com/initia-labs/initia/app/params"
99100
ibctestingtypes "github.com/initia-labs/initia/x/ibc/testing/types"
100101
icaauth "github.com/initia-labs/initia/x/intertx"
@@ -105,7 +106,6 @@ import (
105106
opchild "github.com/initia-labs/OPinit/x/opchild"
106107
opchildkeeper "github.com/initia-labs/OPinit/x/opchild/keeper"
107108
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
108-
initialanes "github.com/initia-labs/initia/app/lanes"
109109

110110
// skip imports
111111
mevabci "github.com/skip-mev/block-sdk/abci"

app/ibc-middleware/util.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,10 @@ func jsonStringHasKey(memo, key string) (found bool, jsonObject map[string]inter
8787

8888
// newEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the
8989
// details of the error.
90-
func newEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement {
91-
attributes := make([]sdk.Attribute, len(errorContexts)+1)
92-
attributes[0] = sdk.NewAttribute("error", err.Error())
93-
for i, s := range errorContexts {
94-
attributes[i+1] = sdk.NewAttribute("error-context", s)
90+
func newEmitErrorAcknowledgement(ctx sdk.Context, err error) channeltypes.Acknowledgement {
91+
return channeltypes.Acknowledgement{
92+
Response: &channeltypes.Acknowledgement_Error{
93+
Error: fmt.Sprintf("ibc wasm hook error: %s", err.Error()),
94+
},
9595
}
96-
97-
ctx.EventManager().EmitEvents(sdk.Events{
98-
sdk.NewEvent(
99-
"ibc-acknowledgement-error",
100-
attributes...,
101-
),
102-
})
103-
104-
return channeltypes.NewErrorAcknowledgement(err)
10596
}

app/lanes/free.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ package lanes
33
import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55

6+
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
67
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
78

89
"github.com/skip-mev/block-sdk/block/base"
910
)
1011

1112
// FreeLaneMatchHandler returns the default match handler for the free lane. The
1213
// default implementation matches transactions that are ibc related. In particular,
13-
// any transaction that is a MsgTimeout, MsgAcknowledgement.
14+
// any transaction that is a MsgUpdateClient, MsgTimeout, MsgAcknowledgement.
1415
func FreeLaneMatchHandler() base.MatchHandler {
1516
return func(ctx sdk.Context, tx sdk.Tx) bool {
1617
for _, msg := range tx.GetMsgs() {
1718
switch msg.(type) {
19+
case *clienttypes.MsgUpdateClient:
1820
case *channeltypes.MsgTimeout:
19-
return true
2021
case *channeltypes.MsgAcknowledgement:
21-
return true
22+
default:
23+
return false
2224
}
2325
}
2426

25-
return false
27+
return true
2628
}
2729
}

app/test_helpers.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ func SetupWithGenesisAccounts(
7979
) *MinitiaApp {
8080
app, genesisState := setup(nil, true)
8181

82+
if len(genAccs) == 0 {
83+
privAcc := secp256k1.GenPrivKey()
84+
genAccs = []authtypes.GenesisAccount{
85+
authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0),
86+
}
87+
}
88+
8289
// set genesis accounts
8390
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
8491
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)
@@ -95,15 +102,7 @@ func SetupWithGenesisAccounts(
95102
valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
96103
}
97104

98-
if len(genAccs) == 0 {
99-
privAcc := secp256k1.GenPrivKey()
100-
genAccs = []authtypes.GenesisAccount{
101-
authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0),
102-
}
103-
}
104-
105105
validators := make([]opchildtypes.Validator, 0, len(valSet.Validators))
106-
107106
for _, val := range valSet.Validators {
108107
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey)
109108
if err != nil {

cmd/minitiad/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ func initTendermintConfig() *tmcfg.Config {
5959
cfg.Consensus.CreateEmptyBlocks = false
6060
cfg.Consensus.CreateEmptyBlocksInterval = time.Minute
6161

62-
// block time from 5s to 0.5s
63-
cfg.Consensus.TimeoutPropose = cfg.Consensus.TimeoutPropose / 10
64-
cfg.Consensus.TimeoutProposeDelta = cfg.Consensus.TimeoutProposeDelta / 10
65-
cfg.Consensus.TimeoutPrevote = cfg.Consensus.TimeoutPrevote / 10
66-
cfg.Consensus.TimeoutPrevoteDelta = cfg.Consensus.TimeoutPrevoteDelta / 10
67-
cfg.Consensus.TimeoutPrecommit = cfg.Consensus.TimeoutPrecommit / 10
68-
cfg.Consensus.TimeoutPrecommitDelta = cfg.Consensus.TimeoutPrecommitDelta / 10
69-
cfg.Consensus.TimeoutCommit = cfg.Consensus.TimeoutCommit / 10
62+
// block time to 0.5s
63+
cfg.Consensus.TimeoutPropose = 300 * time.Millisecond
64+
cfg.Consensus.TimeoutProposeDelta = 500 * time.Millisecond
65+
cfg.Consensus.TimeoutPrevote = 1000 * time.Millisecond
66+
cfg.Consensus.TimeoutPrevoteDelta = 500 * time.Millisecond
67+
cfg.Consensus.TimeoutPrecommit = 1000 * time.Millisecond
68+
cfg.Consensus.TimeoutPrecommitDelta = 500 * time.Millisecond
69+
cfg.Consensus.TimeoutCommit = 500 * time.Millisecond
7070

7171
return cfg
7272
}

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ go 1.21.5
44

55
require (
66
cosmossdk.io/api v0.7.2
7+
cosmossdk.io/client/v2 v2.0.0-beta.1
78
cosmossdk.io/core v0.11.0
89
cosmossdk.io/errors v1.0.0
910
cosmossdk.io/log v1.2.1
1011
cosmossdk.io/math v1.2.0
1112
cosmossdk.io/store v1.0.1
13+
cosmossdk.io/tools/confix v0.1.1
1214
cosmossdk.io/x/feegrant v0.1.0
1315
cosmossdk.io/x/upgrade v0.1.1
1416
// we also need to update `LIBWASMVM_VERSION` of images/private/Dockerfile#5
@@ -25,6 +27,7 @@ require (
2527
github.com/initia-labs/OPinit v0.2.0-beta.0
2628
github.com/initia-labs/initia v0.2.0-beta.0
2729
github.com/pkg/errors v0.9.1
30+
github.com/prometheus/client_golang v1.17.0
2831
github.com/rakyll/statik v0.1.7
2932
github.com/skip-mev/block-sdk v0.0.0-20231213233341-deceeb0e993b
3033
github.com/spf13/cast v1.5.1
@@ -33,12 +36,6 @@ require (
3336
github.com/stretchr/testify v1.8.4
3437
)
3538

36-
require (
37-
cosmossdk.io/client/v2 v2.0.0-beta.1
38-
cosmossdk.io/tools/confix v0.1.1
39-
github.com/prometheus/client_golang v1.17.0
40-
)
41-
4239
require (
4340
cloud.google.com/go v0.110.9 // indirect
4441
cloud.google.com/go/compute v1.23.2 // indirect

shared.Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM golang:1.21-bullseye AS go-builder
2+
3+
# Install minimum necessary dependencies, build Cosmos SDK, remove packages
4+
RUN apt update
5+
RUN apt install -y curl git build-essential
6+
# debug: for live editting in the image
7+
RUN apt install -y vim
8+
9+
WORKDIR /code
10+
COPY . /code/
11+
12+
RUN LEDGER_ENABLED=false make build
13+
14+
RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm@v*/internal/api/libwasmvm.`uname -m`.so /lib/libwasmvm.so
15+
16+
FROM ubuntu:20.04
17+
18+
WORKDIR /root
19+
20+
COPY --from=go-builder /code/build/minitiad /usr/local/bin/minitiad
21+
COPY --from=go-builder /lib/libwasmvm.so /lib/libwasmvm.so
22+
23+
# rest server
24+
EXPOSE 1317
25+
# grpc
26+
EXPOSE 9090
27+
# tendermint p2p
28+
EXPOSE 26656
29+
# tendermint rpc
30+
EXPOSE 26657
31+
32+
CMD ["/usr/local/bin/minitiad", "version"]

0 commit comments

Comments
 (0)