From 557464934aab59da979b0a629289c1f9ba3ee825 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 10:26:32 -0600 Subject: [PATCH 1/7] remove double `InitializePinnedCodes` since wasmkeeper already does it --- app/app.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 58b34cb40..ca613299b 100644 --- a/app/app.go +++ b/app/app.go @@ -449,10 +449,12 @@ func New( tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } + // This fails when upgrading a upgrade + // `failed initialize pinned codes Error calling the VM: Cache error: Error opening Wasm file for reading: pinning contract failed` // https://github.com/cosmos/ibc-go/pull/5439 - if err := wasmlckeeper.InitializePinnedCodes(ctx, appCodec); err != nil { - tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) - } + // if err := wasmlckeeper.InitializePinnedCodes(ctx, appCodec); err != nil { + // tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) + // } // Initialize and seal the capability keeper so all persistent capabilities // are loaded in-memory and prevent any further modules from creating scoped From 9464defb2e286fe94386e03311baa414c69745ca Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 10:29:01 -0600 Subject: [PATCH 2/7] attmpt 2 --- app/app.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index ca613299b..50b74ca3e 100644 --- a/app/app.go +++ b/app/app.go @@ -24,7 +24,6 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - wasmlckeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -405,9 +404,9 @@ func New( if manager := app.SnapshotManager(); manager != nil { err = manager.RegisterExtensions( - // https://github.com/cosmos/ibc-go/pull/5439 wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmKeeper), - wasmlckeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmClientKeeper), + // https://github.com/cosmos/ibc-go/pull/5439 + // wasmlckeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmClientKeeper), ) if err != nil { panic("failed to register snapshot extension: " + err.Error()) From 0e1c1ab367d5c921b3eedcaca2199292057ae23c Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 11:13:27 -0600 Subject: [PATCH 3/7] re-add NewWasmSnapshotter and InitializePinnedCodes --- app/app.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 50b74ca3e..2a4ba3aa7 100644 --- a/app/app.go +++ b/app/app.go @@ -24,6 +24,7 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + wasmlckeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -406,7 +407,7 @@ func New( err = manager.RegisterExtensions( wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmKeeper), // https://github.com/cosmos/ibc-go/pull/5439 - // wasmlckeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmClientKeeper), + wasmlckeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.AppKeepers.WasmClientKeeper), ) if err != nil { panic("failed to register snapshot extension: " + err.Error()) @@ -448,12 +449,10 @@ func New( tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) } - // This fails when upgrading a upgrade - // `failed initialize pinned codes Error calling the VM: Cache error: Error opening Wasm file for reading: pinning contract failed` // https://github.com/cosmos/ibc-go/pull/5439 - // if err := wasmlckeeper.InitializePinnedCodes(ctx, appCodec); err != nil { - // tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) - // } + if err := wasmlckeeper.InitializePinnedCodes(ctx, appCodec); err != nil { + tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) + } // Initialize and seal the capability keeper so all persistent capabilities // are loaded in-memory and prevent any further modules from creating scoped From 4887f320b83b32a369b28e147c682d6e5cb38cac Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 11:13:46 -0600 Subject: [PATCH 4/7] new `lcWasmer` --- app/keepers/keepers.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a7d1ad720..3204afee2 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -486,6 +486,7 @@ func NewAppKeepers( ) wasmDir := filepath.Join(homePath, "data") + lcWasmDir := filepath.Join(homePath, "data", "light-client-wasm") wasmConfig, err := wasm.ReadWasmConfig(appOpts) if err != nil { @@ -542,12 +543,17 @@ func NewAppKeepers( wasmOpts = append(wasmOpts, burnMessageHandler) // create a shared VM instance (x/wasm <-> wasm light client) - wasmer, err := wasmvm.NewVM(wasmDir, wasmCapabilities, 32, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) + mainWasmer, err := wasmvm.NewVM(wasmDir, wasmCapabilities, 32, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) if err != nil { panic(fmt.Sprintf("failed to create juno wasm vm: %s", err)) } - wasmOpts = append(wasmOpts, wasmkeeper.WithWasmEngine(wasmer)) + lcWasmer, err := wasmvm.NewVM(lcWasmDir, wasmCapabilities, 32, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) + if err != nil { + panic(fmt.Sprintf("failed to create juno wasm vm for 08-wasm: %s", err)) + } + + wasmOpts = append(wasmOpts, wasmkeeper.WithWasmEngine(mainWasmer)) appKeepers.WasmKeeper = wasmkeeper.NewKeeper( appCodec, @@ -592,7 +598,7 @@ func NewAppKeepers( appKeepers.keys[wasmlctypes.StoreKey], appKeepers.IBCKeeper.ClientKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - wasmer, + lcWasmer, bApp.GRPCQueryRouter(), wasmQuerierOption, ) From 8416725c289c0ade57ed6528a8a9816d91286786 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 12:41:49 -0600 Subject: [PATCH 5/7] wasmvm v1.5.2 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e3b19a420..47c888cc8 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( cosmossdk.io/math v1.2.0 cosmossdk.io/tools/rosetta v0.2.1 github.com/CosmWasm/wasmd v0.45.0 - github.com/CosmWasm/wasmvm v1.5.2-rc.0 + github.com/CosmWasm/wasmvm v1.5.2 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.8.0 github.com/cosmos/cosmos-sdk v0.47.6 diff --git a/go.sum b/go.sum index 42171ec21..5270fe279 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI= github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944= -github.com/CosmWasm/wasmvm v1.5.2-rc.0 h1:pbW8vBlz7Qb+Ghjd5ia4uqaXKeBu3YumZ/2DKVKv4e4= -github.com/CosmWasm/wasmvm v1.5.2-rc.0/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= +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/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= From 2c8b1c71f3aac7cf2f82f4663c8e496b7d782e7b Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 12:42:27 -0600 Subject: [PATCH 6/7] fix upgrade --- app/app.go | 14 ++++++-------- app/keepers/keepers.go | 9 ++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index 2a4ba3aa7..6f617663b 100644 --- a/app/app.go +++ b/app/app.go @@ -442,18 +442,16 @@ func New( } ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) - // Initialize pinned codes in wasmvm as they are not persisted there. - // We do not use the wasm light client's impl since we do not want ALL to be pinned. - // The WasmKeeper will handle is as expected. - if err := app.AppKeepers.WasmKeeper.InitializePinnedCodes(ctx); err != nil { - tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) - } - // https://github.com/cosmos/ibc-go/pull/5439 if err := wasmlckeeper.InitializePinnedCodes(ctx, appCodec); err != nil { - tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err)) + tmos.Exit(fmt.Sprintf("wasmlckeeper failed initialize pinned codes %s", err)) } + // we already load in with the wasmlc (all) + // if err := app.AppKeepers.WasmKeeper.InitializePinnedCodes(ctx); err != nil { + // tmos.Exit(fmt.Sprintf("app.AppKeepers.WasmKeeper failed initialize pinned codes %s", err)) + // } + // Initialize and seal the capability keeper so all persistent capabilities // are loaded in-memory and prevent any further modules from creating scoped // sub-keepers. diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 3204afee2..4d9359a4d 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -542,7 +542,6 @@ func NewAppKeepers( wasmOpts = append(wasmOpts, burnMessageHandler) - // create a shared VM instance (x/wasm <-> wasm light client) mainWasmer, err := wasmvm.NewVM(wasmDir, wasmCapabilities, 32, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) if err != nil { panic(fmt.Sprintf("failed to create juno wasm vm: %s", err)) @@ -553,8 +552,6 @@ func NewAppKeepers( panic(fmt.Sprintf("failed to create juno wasm vm for 08-wasm: %s", err)) } - wasmOpts = append(wasmOpts, wasmkeeper.WithWasmEngine(mainWasmer)) - appKeepers.WasmKeeper = wasmkeeper.NewKeeper( appCodec, appKeepers.keys[wasmtypes.StoreKey], @@ -573,7 +570,7 @@ func NewAppKeepers( wasmConfig, wasmCapabilities, govModAddress, - wasmOpts..., + append(wasmOpts, wasmkeeper.WithWasmEngine(mainWasmer))..., ) // 08-wasm light client @@ -591,8 +588,6 @@ func NewAppKeepers( Stargate: wasmlctypes.AcceptListStargateQuerier(accepted), } - wasmQuerierOption := wasmlckeeper.WithQueryPlugins(&wasmLightClientQuerier) - appKeepers.WasmClientKeeper = wasmlckeeper.NewKeeperWithVM( appCodec, appKeepers.keys[wasmlctypes.StoreKey], @@ -600,7 +595,7 @@ func NewAppKeepers( authtypes.NewModuleAddress(govtypes.ModuleName).String(), lcWasmer, bApp.GRPCQueryRouter(), - wasmQuerierOption, + wasmlckeeper.WithQueryPlugins(&wasmLightClientQuerier), ) appKeepers.FeePayKeeper = feepaykeeper.NewKeeper( From aadd28ce8a5176240c1085a94fa7c9575c13ee59 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 19 Jan 2024 12:50:33 -0600 Subject: [PATCH 7/7] ictest mod tidy --- interchaintest/go.mod | 2 +- interchaintest/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interchaintest/go.mod b/interchaintest/go.mod index 4e8af99dd..818b5db04 100644 --- a/interchaintest/go.mod +++ b/interchaintest/go.mod @@ -52,7 +52,7 @@ require ( github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/ChainSafe/go-schnorrkel/1 v0.0.0-00010101000000-000000000000 // indirect github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 // indirect - github.com/CosmWasm/wasmvm v1.5.2-rc.0 // indirect + github.com/CosmWasm/wasmvm v1.5.2 // indirect github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect github.com/Microsoft/go-winio v0.6.0 // indirect diff --git a/interchaintest/go.sum b/interchaintest/go.sum index 4e2e1e6a2..ff0169ab9 100644 --- a/interchaintest/go.sum +++ b/interchaintest/go.sum @@ -222,8 +222,8 @@ github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 h1:oknQF/iIhf5lVjbwjsVDzDByu github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420/go.mod h1:KYkiMX5AbOlXXYfxkrYPrRPV6EbVUALTQh5ptUOJzu8= github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI= github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944= -github.com/CosmWasm/wasmvm v1.5.2-rc.0 h1:pbW8vBlz7Qb+Ghjd5ia4uqaXKeBu3YumZ/2DKVKv4e4= -github.com/CosmWasm/wasmvm v1.5.2-rc.0/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= +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/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=