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

Feat/bump wasm 0.52.0 #702

Merged
merged 7 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ FROM golang:1.21-alpine3.18 AS go-builder
WORKDIR /src

# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a

# hadolint ignore=DL4006
RUN set -eux \
&& apk add --no-cache ca-certificates=20240226-r0 build-base=0.5-r3 git=2.40.1-r0 linux-headers=6.3-r0 \
&& sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 3b478b3e51d31e53ce9324a8895d2cd7278af5179b9a02ea55d8627958e42afa \
&& sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ca08bb7b73b49b483611d9755bb8455620bb8c0faf3014400908ed49bf3b19a5
&& sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 06945cae8fced839a2be0980887a1c5d04d15fd29837ac644a648d555c49ab4d \
&& sha256sum /lib/libwasmvm_muslc.x86_64.a | grep df4bd912c35be48781a40edea88fd5f409c643fb27e0dc043184ef51dc50a1cc

COPY . /src/

Expand Down
75 changes: 42 additions & 33 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"os"
"path/filepath"
"slices"
"sort"

"github.com/CosmWasm/wasmd/x/wasm"
Expand All @@ -20,8 +19,6 @@ import (
"github.com/ignite/cli/ignite/pkg/openapiconsole"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/types/descriptorpb"

abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
Expand Down Expand Up @@ -111,6 +108,7 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

ibccallbacks "github.com/cosmos/ibc-go/modules/apps/callbacks"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
Expand Down Expand Up @@ -493,6 +491,7 @@ func New(
// register the governance hooks
),
)

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
Expand All @@ -504,6 +503,16 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
Expand All @@ -518,16 +527,6 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
Expand All @@ -540,6 +539,8 @@ func New(
app.MsgServiceRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
// set grpc router for ica host
app.ICAHostKeeper.WithQueryRouter(app.GRPCQueryRouter())

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -606,36 +607,53 @@ func New(
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
axonewasm.AllCapabilities(),
wasmkeeper.BuiltInCapabilities(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
wasmOpts...,
)

// Create Transfer Stack
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
// Create fee enabled wasm ibc Stack
var wasmStack ibcporttypes.IBCModule
wasmStackIBCHandler := wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
wasmStack = ibcfee.NewIBCMiddleware(wasmStackIBCHandler, app.IBCFeeKeeper)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
// icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket
var icaControllerStack ibcporttypes.IBCModule

// integration point for custom authentication modules
//nolint:lll
// see https://medium.com/the-interchain-foundation/ibc-go-v6-changes-to-interchain-accounts-and-how-it-impacts-your-chain-806c185300d7
var noAuthzModule ibcporttypes.IBCModule
icaControllerStack = icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper)
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)
icaControllerStack = ibccallbacks.NewIBCMiddleware(
icaControllerStack,
app.IBCFeeKeeper,
wasmStackIBCHandler,
wasm.DefaultMaxIBCCallbackGas,
)
icaICS4Wrapper := icaControllerStack.(ibcporttypes.ICS4Wrapper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)

// Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the ica controller keeper
app.ICAControllerKeeper.WithICS4Wrapper(icaICS4Wrapper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
var icaHostStack ibcporttypes.IBCModule
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack ibcporttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper)
// Create Transfer Stack
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibccallbacks.NewIBCMiddleware(transferStack, app.IBCFeeKeeper, wasmStackIBCHandler, wasm.DefaultMaxIBCCallbackGas)
transferICS4Wrapper := transferStack.(ibcporttypes.ICS4Wrapper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
// Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the ica controller keeper
app.TransferKeeper.WithICS4Wrapper(transferICS4Wrapper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down Expand Up @@ -860,17 +878,8 @@ func New(
app.setPostHandler()

// At startup, after all modules have been registered, check that all proto
// annotations are correct, ignoring `google.crypto.tink`.
fds, err := proto.MergedGlobalFileDescriptors()
if err != nil {
panic(err)
}
fds = &descriptorpb.FileDescriptorSet{
File: slices.DeleteFunc(fds.File, func(e *descriptorpb.FileDescriptorProto) bool {
return e.GetPackage() == "google.crypto.tink"
}),
}
protoFiles, err := protodesc.NewFiles(fds)
// annotations are correct.
protoFiles, err := proto.MergedRegistry()
if err != nil {
panic(err)
}
Expand Down
17 changes: 0 additions & 17 deletions app/wasm/capabilities.go

This file was deleted.

20 changes: 20 additions & 0 deletions cmd/axoned/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"

cmtcfg "github.com/cometbft/cometbft/config"

Expand Down Expand Up @@ -50,6 +52,8 @@ import (
//
//nolint:funlen
func NewRootCmd() *cobra.Command {
sanitizeProtoRegistry()

// Set config
initSDKConfig()

Expand Down Expand Up @@ -408,3 +412,19 @@ var tempDir = func() string {

return dir
}

// sanitizeProtoRegistry removes all the unused proto definitions from the global registry to avoid surprises as the
// cosmos sdk rely on it.
func sanitizeProtoRegistry() {
safeRegistry := new(protoregistry.Files)
protoregistry.GlobalFiles.RangeFiles(func(d protoreflect.FileDescriptor) bool {
if d.FullName() != "google.crypto.tink" {
if err := safeRegistry.RegisterFile(d); err != nil {
panic(err)
}
}
return true
})

protoregistry.GlobalFiles = safeRegistry
}
amimart marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ axoned tx interchain-accounts controller register [connection-id] [flags]
--node string <host>:<port> to CometBFT rpc interface for this chain (default "tcp://localhost:26657")
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
--ordering string Channel ordering, can be one of: ORDER_ORDERED, ORDER_UNORDERED (default "ORDER_ORDERED")
--ordering string Channel ordering, can be one of: ORDER_ORDERED, ORDER_UNORDERED (default "ORDER_UNORDERED")
-o, --output string Output format (text|json) (default "json")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature
Expand Down
Loading
Loading