Skip to content

Commit

Permalink
fix: wasm docker file + wasm simapp gas limit (#7830)
Browse files Browse the repository at this point in the history
* fix: dockerfile layer name

* update wasm simapp image with higher max gas

* lint

* updated max gas to same as cosmos hub
  • Loading branch information
gjermundgaraba authored Jan 10, 2025
1 parent 6c5e5bf commit 7f0cf54
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
8 changes: 4 additions & 4 deletions modules/light-clients/08-wasm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.4-alpine as builder
FROM golang:1.23.4-alpine as builder-base

Check warning on line 1 in modules/light-clients/08-wasm/Dockerfile

View workflow job for this annotation

GitHub Actions / build-image-at-tag

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

ARG LIBWASM_VERSION
ARG TARGETARCH
Expand All @@ -23,12 +23,12 @@ RUN go mod download

# Since it is not easy to fully cache a RUN script download of libwasmvm, we use two different stages
# and copy the correct file in the final stage. The multistage setup also helps speed up the build process
FROM alpine:3.18 AS amd64-stage
FROM alpine:3.21 AS amd64-stage
ARG LIBWASM_VERSION
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a


FROM alpine:3.18 AS arm64-stage
FROM alpine:3.21 AS arm64-stage
ARG LIBWASM_VERSION
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a

Expand All @@ -44,6 +44,6 @@ COPY --from=libwasm-stage /lib/libwasmvm_muslc.* /lib/
RUN go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./...


FROM alpine:3.18
FROM alpine:3.21
COPY --from=builder /go/build/simd /bin/simd
ENTRYPOINT ["simd"]
12 changes: 12 additions & 0 deletions modules/light-clients/08-wasm/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmtcrypto "github.com/cometbft/cometbft/crypto"
cmted25519 "github.com/cometbft/cometbft/crypto/ed25519"
cmttypes "github.com/cometbft/cometbft/types"

wasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
wasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
Expand Down Expand Up @@ -977,6 +978,17 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.InitChainRequest) (*ab
if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {
panic(err)
}

paramsProto, err := app.ConsensusParamsKeeper.ParamsStore.Get(ctx)
if err != nil {
return nil, err
}
consensusParams := cmttypes.ConsensusParamsFromProto(paramsProto)
consensusParams.Block.MaxGas = 75_000_000 // The same as Cosmos Hub at the moment
if err := app.ConsensusParamsKeeper.ParamsStore.Set(ctx, consensusParams.ToProto()); err != nil {
return nil, err
}

return app.ModuleManager.InitGenesis(ctx, genesisState)
}

Expand Down
14 changes: 13 additions & 1 deletion modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"
txsigning "cosmossdk.io/x/tx/signing"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand All @@ -27,6 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/snapshot"
"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -64,11 +66,17 @@ func NewRootCmd() *cobra.Command {
initClientCtx := client.Context{}.
WithCodec(encodingConfig.Codec).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}).
WithAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())).
WithValidatorAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix())).
WithConsensusAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix())).
WithHomeDir(simapp.DefaultNodeHome).
WithViper("") // In simapp, we don't use any prefix for env variables.
WithViper(""). // uses by default the binary name as prefix
WithAddressPrefix(sdk.GetConfig().GetBech32AccountAddrPrefix()).
WithValidatorPrefix(sdk.GetConfig().GetBech32ValidatorAddrPrefix())

rootCmd := &cobra.Command{
Use: "simd",
Expand Down Expand Up @@ -96,6 +104,10 @@ func NewRootCmd() *cobra.Command {
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
SigningOptions: &txsigning.Options{
AddressCodec: initClientCtx.InterfaceRegistry.SigningContext().AddressCodec(),
ValidatorAddressCodec: initClientCtx.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
},
}
txConfigWithTextual, err := tx.NewTxConfigWithOptions(
codec.NewProtoCodec(encodingConfig.InterfaceRegistry),
Expand Down

0 comments on commit 7f0cf54

Please sign in to comment.