From ab1267844659ebda53e6567a62bc60b85f0695f0 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 20 Jan 2022 21:05:27 +0100 Subject: [PATCH 1/3] Failing test showing it was not currently pinned --- x/wasm/keeper/proposal_integration_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 1839f00d44..d912224808 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -52,6 +52,7 @@ func TestStoreCodeProposal(t *testing.T) { cInfo := wasmKeeper.GetCodeInfo(ctx, 1) require.NotNil(t, cInfo) assert.Equal(t, myActorAddress, cInfo.Creator) + assert.True(t, wasmKeeper.IsPinnedCode(ctx, 1)) storedCode, err := wasmKeeper.GetByteCode(ctx, 1) require.NoError(t, err) From d60dbd56e00fa79d89057b79b973a7d02472a8a3 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 20 Jan 2022 21:07:08 +0100 Subject: [PATCH 2/3] And properly pin it on governance vote --- x/wasm/keeper/proposal_handler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index 816036cb91..4076540fa1 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -58,8 +58,11 @@ func handleStoreCodeProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types if err != nil { return sdkerrors.Wrap(err, "run as address") } - _, err = k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission) - return err + codeID, err := k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission) + if err != nil { + return err + } + return k.PinCode(ctx, codeID) } func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.InstantiateContractProposal) error { From e9d96cf4dd80ea318b929e4503482acbac982a57 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 21 Jan 2022 10:40:39 +0100 Subject: [PATCH 3/3] Add CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b390e9505..4f7d740b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - Use replace statements to enforce consistent versioning. [\#692](https://github.com/CosmWasm/wasmd/pull/692) ([faddat](https://github.com/faddat)) - Fixed circleci by removing the golang executor from a docker build - Go 1.17 provides a much clearer go.mod file [\#679](https://github.com/CosmWasm/wasmd/pull/679) ([faddat](https://github.com/faddat)) - +- Autopin wasm code uploaded by gov proposal [\#726](https://github.com/CosmWasm/wasmd/pull/726) ([ethanfrey](https://github.com/ethanfrey)) [Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.22.0...v0.21.0)