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) 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 { 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)