feat: add 08-wasm module

Signed-off-by: aeryz <abdullaheryz@protonmail.com>
This commit is contained in:
aeryz 2024-07-17 12:47:09 +03:00 committed by 0g-wh
parent 07cf4ad258
commit d31a599c60
5 changed files with 52 additions and 0 deletions

View File

@ -19,6 +19,15 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/pkg/mod \
go version && go mod download go version && go mod download
# Cosmwasm - Download correct libwasmvm version
RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \
-O /lib/libwasmvm.$ARCH.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1)
# Add source files # Add source files
COPY . . COPY . .
@ -27,6 +36,7 @@ COPY . .
# Mount go build and mod caches as container caches, persisted between builder invocations # Mount go build and mod caches as container caches, persisted between builder invocations
RUN --mount=type=cache,target=/root/.cache/go-build \ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/go/pkg/mod \
LINK_STATICALLY=true \
make install make install
FROM alpine:3.15 FROM alpine:3.15

View File

@ -176,6 +176,9 @@ endif
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS))) ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ldflags += -w -s ldflags += -w -s
endif endif
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS) ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags)) ldflags := $(strip $(ldflags))

View File

@ -80,6 +80,9 @@ import (
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward" "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper" packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types" packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
@ -90,6 +93,7 @@ import (
ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
@ -183,6 +187,7 @@ var (
council.AppModuleBasic{}, council.AppModuleBasic{},
dasigners.AppModuleBasic{}, dasigners.AppModuleBasic{},
consensus.AppModuleBasic{}, consensus.AppModuleBasic{},
ibcwasm.AppModuleBasic{},
) )
// module account permissions // module account permissions
@ -252,6 +257,7 @@ type App struct {
authzKeeper authzkeeper.Keeper authzKeeper authzkeeper.Keeper
crisisKeeper crisiskeeper.Keeper crisisKeeper crisiskeeper.Keeper
slashingKeeper slashingkeeper.Keeper slashingKeeper slashingkeeper.Keeper
ibcWasmClientKeeper ibcwasmkeeper.Keeper
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
packetForwardKeeper *packetforwardkeeper.Keeper packetForwardKeeper *packetforwardkeeper.Keeper
evmKeeper *evmkeeper.Keeper evmKeeper *evmkeeper.Keeper
@ -321,6 +327,7 @@ func NewApp(
dasignerstypes.StoreKey, dasignerstypes.StoreKey,
vestingtypes.StoreKey, vestingtypes.StoreKey,
consensusparamtypes.StoreKey, crisistypes.StoreKey, precisebanktypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, precisebanktypes.StoreKey,
ibcwasmtypes.StoreKey,
) )
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
@ -453,6 +460,19 @@ func NewApp(
scopedIBCKeeper, scopedIBCKeeper,
) )
app.ibcWasmClientKeeper = ibcwasmkeeper.NewKeeperWithConfig(
appCodec,
keys[ibcwasmtypes.StoreKey],
app.ibcKeeper.ClientKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
ibcwasmtypes.WasmConfig{
DataDir: "ibc_08-wasm",
SupportedCapabilities: "iterator,stargate",
ContractDebugMode: false,
},
app.GRPCQueryRouter(),
)
// Create Ethermint keepers // Create Ethermint keepers
app.feeMarketKeeper = feemarketkeeper.NewKeeper( app.feeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec, appCodec,
@ -667,6 +687,7 @@ func NewApp(
// nil InflationCalculationFn, use SDK's default inflation function // nil InflationCalculationFn, use SDK's default inflation function
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace), mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil, mintSubspace),
precisebank.NewAppModule(app.precisebankKeeper, app.bankKeeper, app.accountKeeper), precisebank.NewAppModule(app.precisebankKeeper, app.bankKeeper, app.accountKeeper),
ibcwasm.NewAppModule(app.ibcWasmClientKeeper),
) )
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list. // Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
@ -711,6 +732,7 @@ func NewApp(
consensusparamtypes.ModuleName, consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
precisebanktypes.ModuleName, precisebanktypes.ModuleName,
ibcwasmtypes.ModuleName,
) )
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list. // Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
@ -745,6 +767,7 @@ func NewApp(
consensusparamtypes.ModuleName, consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
precisebanktypes.ModuleName, precisebanktypes.ModuleName,
ibcwasmtypes.ModuleName,
) )
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list // Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
@ -778,6 +801,7 @@ func NewApp(
packetforwardtypes.ModuleName, packetforwardtypes.ModuleName,
precisebanktypes.ModuleName, // Must be run after x/bank to verify reserve balance precisebanktypes.ModuleName, // Must be run after x/bank to verify reserve balance
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
ibcwasmtypes.ModuleName,
) )
app.mm.RegisterInvariants(&app.crisisKeeper) app.mm.RegisterInvariants(&app.crisisKeeper)
@ -852,6 +876,15 @@ func NewApp(
} }
} }
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.ibcWasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}
app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedTransferKeeper = scopedTransferKeeper

2
go.mod
View File

@ -18,6 +18,7 @@ require (
github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/iavl v1.2.0 github.com/cosmos/iavl v1.2.0
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5
github.com/cosmos/ibc-go/v7 v7.4.0 github.com/cosmos/ibc-go/v7 v7.4.0
github.com/ethereum/go-ethereum v1.10.26 github.com/ethereum/go-ethereum v1.10.26
github.com/evmos/ethermint v0.21.0 github.com/evmos/ethermint v0.21.0
@ -59,6 +60,7 @@ require (
github.com/99designs/keyring v1.2.1 // indirect github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/DataDog/zstd v1.5.5 // indirect github.com/DataDog/zstd v1.5.5 // indirect
github.com/CosmWasm/wasmvm v1.5.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect

4
go.sum
View File

@ -224,6 +224,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag=
github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
@ -442,6 +444,8 @@ github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM=
github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 h1:MZGDMETv72suFpTAD6VPGqSIm1FJcChtk2HmVh9D+Bo= github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 h1:MZGDMETv72suFpTAD6VPGqSIm1FJcChtk2HmVh9D+Bo=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3/go.mod h1:UvDmcGIWJPIytq+Q78/ff5NTOsuX/7IrNgEugTW5i0s= github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3/go.mod h1:UvDmcGIWJPIytq+Q78/ff5NTOsuX/7IrNgEugTW5i0s=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5 h1:sMoHjep+KInjMrppNCEutMVm1p8nI9WhKCuMQ+EcUHw=
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5/go.mod h1:VR2Hg2i/X1bafbmmNsV2Khwsg0PzNeuWoVKmSN5dAwo=
github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M= github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M=
github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo= github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=