diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index fa47709174..5f4c0e67dd 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -23,6 +23,7 @@ Write the changes made after branching from cosmos-sdk v0.42.1. * (global) [\#97](https://github.com/line/lbm-sdk/pull/97) Add codespace to query error * (config) [\#114](https://github.com/line/lbm-sdk/pull/114) Add idle-timeout to rest server and rpc server config * (x/wasm) [\#127](https://github.com/line/lbm-sdk/pull/127) Add wasm with Staragate migration completed. +* (x/wasm) [\#151](https://github.com/line/lbm-sdk/pull/151) Add contract access control. ### IMPROVEMENTS diff --git a/x/wasm/client/cli/new_tx.go b/x/wasm/client/cli/new_tx.go index cabfc4d904..9af82d24ee 100644 --- a/x/wasm/client/cli/new_tx.go +++ b/x/wasm/client/cli/new_tx.go @@ -113,3 +113,35 @@ func ClearContractAdminCmd() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } + +// UpdateContractStatusCmd clears an admin for a contract +func UpdateContractStatusCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-contract-status [contract_addr_bech32] [status(Active|Inactive)]", + Short: "Clears admin for a contract to prevent further migrations", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + status := types.ContractStatusUnspecified + if err := (&status).UnmarshalText([]byte(args[1])); err != nil { + return err + } + + msg := types.MsgUpdateContractStatus{ + Sender: clientCtx.GetFromAddress().String(), + Contract: args[0], + Status: status, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/wasm/client/cli/tx.go b/x/wasm/client/cli/tx.go index 0419a7d457..fe4d69b7b3 100644 --- a/x/wasm/client/cli/tx.go +++ b/x/wasm/client/cli/tx.go @@ -46,6 +46,7 @@ func GetTxCmd() *cobra.Command { MigrateContractCmd(), UpdateContractAdminCmd(), ClearContractAdminCmd(), + UpdateContractStatusCmd(), ) return txCmd } diff --git a/x/wasm/handler.go b/x/wasm/handler.go index d081150909..ff95a6060f 100644 --- a/x/wasm/handler.go +++ b/x/wasm/handler.go @@ -38,6 +38,8 @@ func NewHandler(k *Keeper) sdk.Handler { res, err = msgServer.UpdateAdmin(sdk.WrapSDKContext(ctx), msg) case *MsgClearAdmin: res, err = msgServer.ClearAdmin(sdk.WrapSDKContext(ctx), msg) + case *types.MsgUpdateContractStatus: + res, err = msgServer.UpdateContractStatus(sdk.WrapSDKContext(ctx), msg) default: errMsg := fmt.Sprintf("unrecognized wasm message type: %T", msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/wasm/internal/keeper/authz_policy.go b/x/wasm/internal/keeper/authz_policy.go index 30dd0ec36b..66b2517cfb 100644 --- a/x/wasm/internal/keeper/authz_policy.go +++ b/x/wasm/internal/keeper/authz_policy.go @@ -9,6 +9,7 @@ type AuthorizationPolicy interface { CanCreateCode(c types.AccessConfig, creator sdk.AccAddress) bool CanInstantiateContract(c types.AccessConfig, actor sdk.AccAddress) bool CanModifyContract(admin, actor sdk.AccAddress) bool + CanUpdateContractStatus(c types.AccessConfig, actor sdk.AccAddress) bool } type DefaultAuthorizationPolicy struct { @@ -26,17 +27,30 @@ func (p DefaultAuthorizationPolicy) CanModifyContract(admin, actor sdk.AccAddres return admin != nil && admin.Equals(actor) } +func (p DefaultAuthorizationPolicy) CanUpdateContractStatus(config types.AccessConfig, actor sdk.AccAddress) bool { + return config.Allowed(actor) +} + +// GovAuthorizationPolicy is for the gov handler(proposal_handler.go) authorities type GovAuthorizationPolicy struct { } func (p GovAuthorizationPolicy) CanCreateCode(types.AccessConfig, sdk.AccAddress) bool { + // The gov handler can create code regardless of the current access config return true } func (p GovAuthorizationPolicy) CanInstantiateContract(types.AccessConfig, sdk.AccAddress) bool { + // The gov handler can instantiate contract regardless of the code access config return true } func (p GovAuthorizationPolicy) CanModifyContract(sdk.AccAddress, sdk.AccAddress) bool { + // The gov handler can migrate contract regardless of the contract admin + return true +} + +func (p GovAuthorizationPolicy) CanUpdateContractStatus(types.AccessConfig, sdk.AccAddress) bool { + // The gov handler can update contract status regardless of the current access config return true } diff --git a/x/wasm/internal/keeper/genesis_test.go b/x/wasm/internal/keeper/genesis_test.go index ec4553ab32..74022254bd 100644 --- a/x/wasm/internal/keeper/genesis_test.go +++ b/x/wasm/internal/keeper/genesis_test.go @@ -444,6 +444,9 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { "permission": "Everybody" }, "instantiate_default_permission": "Everybody", + "contract_status_access": { + "permission": "Nobody" + }, "max_wasm_code_size": 500000, "gas_multiplier": 100, "instance_cost": 40000, @@ -472,7 +475,8 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { "code_id": "1", "creator": "link1p0yx9c9q4xsnedlcn24gqfry5dcu6e9xkhv9aj", "admin": "link1qyqszqgpqyqszqgpqyqszqgpqyqszqgp8apuk5", - "label": "ȀĴnZV芢毤" + "label": "ȀĴnZV芢毤", + "status": "Active" } } ], @@ -537,6 +541,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { Admin: adminAddr, Label: "ȀĴnZV芢毤", Created: &types.AbsoluteTxPosition{BlockHeight: 0, TxIndex: 0}, + Status: wasmTypes.ContractStatusActive, } assert.Equal(t, expContractInfo, *gotContractInfo) diff --git a/x/wasm/internal/keeper/keeper.go b/x/wasm/internal/keeper/keeper.go index 442ef4e050..9aa9876316 100644 --- a/x/wasm/internal/keeper/keeper.go +++ b/x/wasm/internal/keeper/keeper.go @@ -127,6 +127,12 @@ func (k Keeper) getInstantiateAccessConfig(ctx sdk.Context) types.AccessType { return a } +func (k Keeper) getContractStatusAccessConfig(ctx sdk.Context) types.AccessConfig { + var a types.AccessConfig + k.paramSpace.Get(ctx, types.ParamStoreKeyContractStatusAccess, &a) + return a +} + func (k Keeper) getMaxWasmCodeSize(ctx sdk.Context) uint64 { var a uint64 k.paramSpace.Get(ctx, types.ParamStoreKeyMaxWasmCodeSize, &a) @@ -289,7 +295,7 @@ func (k Keeper) instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.A // persist instance first createdAt := types.NewAbsoluteTxPosition(ctx) - contractInfo := types.NewContractInfo(codeID, creator, admin, label, createdAt) + contractInfo := types.NewContractInfo(codeID, creator, admin, label, createdAt, types.ContractStatusActive) // check for IBC flag report, err := k.wasmer.AnalyzeCode(codeInfo.CodeHash) @@ -324,6 +330,9 @@ func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller if err != nil { return nil, err } + if contractInfo.Status != types.ContractStatusActive { + return nil, sdkerrors.Wrap(types.ErrInvalid, "inactive contract") + } if !k.IsPinnedCode(ctx, contractInfo.CodeID) { ctx.GasMeter().ConsumeGas(k.getInstanceCost(ctx), "Loading CosmWasm module: execute") @@ -377,6 +386,9 @@ func (k Keeper) migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller if contractInfo == nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unknown contract") } + if contractInfo.Status != types.ContractStatusActive { + return nil, sdkerrors.Wrap(types.ErrInvalid, "inactive contract") + } if !authZ.CanModifyContract(contractInfo.AdminAddr(), caller) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not migrate") } @@ -534,11 +546,35 @@ func (k Keeper) ClearContractAdmin(ctx sdk.Context, contractAddress sdk.AccAddre return k.setContractAdmin(ctx, contractAddress, caller, nil, k.authZPolicy) } +// UpdateContractStatus sets a new status of the contract on the ContractInfo. +func (k Keeper) UpdateContractStatus(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, status types.ContractStatus) error { + return k.updateContractStatus(ctx, contractAddress, caller, status, k.authZPolicy) +} + +func (k Keeper) updateContractStatus(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, status types.ContractStatus, authZ AuthorizationPolicy) error { + if !authZ.CanUpdateContractStatus(k.getContractStatusAccessConfig(ctx), caller) { + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not update contract status") + } + + contractInfo := k.GetContractInfo(ctx, contractAddress) + if contractInfo == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unknown contract") + } + if contractInfo.Status != status { + contractInfo.Status = status + k.storeContractInfo(ctx, contractAddress, contractInfo) + } + return nil +} + func (k Keeper) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ AuthorizationPolicy) error { contractInfo := k.GetContractInfo(ctx, contractAddress) if contractInfo == nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unknown contract") } + if contractInfo.Status != types.ContractStatusActive { + return sdkerrors.Wrap(types.ErrInvalid, "inactive contract") + } if !authZ.CanModifyContract(contractInfo.AdminAddr(), caller) { return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not modify contract") } diff --git a/x/wasm/internal/keeper/keeper_test.go b/x/wasm/internal/keeper/keeper_test.go index 65e8307cb4..681cf22355 100644 --- a/x/wasm/internal/keeper/keeper_test.go +++ b/x/wasm/internal/keeper/keeper_test.go @@ -10,13 +10,12 @@ import ( wasmvm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - banktypes "github.com/line/lbm-sdk/v2/x/bank/types" - "github.com/line/lbm-sdk/v2/x/wasm/internal/keeper/wasmtesting" - stypes "github.com/line/lbm-sdk/v2/store/types" sdk "github.com/line/lbm-sdk/v2/types" sdkerrors "github.com/line/lbm-sdk/v2/types/errors" authtypes "github.com/line/lbm-sdk/v2/x/auth/types" + banktypes "github.com/line/lbm-sdk/v2/x/bank/types" + "github.com/line/lbm-sdk/v2/x/wasm/internal/keeper/wasmtesting" "github.com/line/lbm-sdk/v2/x/wasm/internal/types" tmproto "github.com/line/ostracon/proto/ostracon/types" "github.com/stretchr/testify/assert" @@ -85,6 +84,7 @@ func TestCreateStoresInstantiatePermission(t *testing.T) { keeper.setParams(ctx, types.Params{ CodeUploadAccess: types.AllowEverybody, InstantiateDefaultPermission: spec.srcPermission, + ContractStatusAccess: types.DefaultContractStatusAccess, MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, GasMultiplier: types.DefaultGasMultiplier, InstanceCost: types.DefaultInstanceCost, @@ -287,7 +287,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x13324), gasAfter-gasBefore) + require.Equal(t, uint64(0x13360), gasAfter-gasBefore) } // ensure it is stored properly @@ -296,6 +296,7 @@ func TestInstantiate(t *testing.T) { assert.Equal(t, creator.String(), info.Creator) assert.Equal(t, codeID, info.CodeID) assert.Equal(t, "demo contract 1", info.Label) + assert.Equal(t, types.ContractStatusActive, info.Status) exp := []types.ContractCodeHistoryEntry{{ Operation: types.ContractCodeHistoryOperationTypeInit, @@ -520,7 +521,7 @@ func TestExecute(t *testing.T) { // make sure gas is properly deducted from ctx gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1405a), gasAfter-gasBefore) + require.Equal(t, uint64(0x14060), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) @@ -765,6 +766,43 @@ func TestExecuteWithStorageLoop(t *testing.T) { require.True(t, false, "We must panic before this line") } +func TestExecuteInactiveContract(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + + wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + contractID, err := keeper.Create(ctx, creator, wasmCode, "", "", nil) + require.NoError(t, err) + + _, _, bob := keyPubAddr() + initMsg := HackatomExampleInitMsg{ + Verifier: fred, + Beneficiary: bob, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + addr, _, err := keeper.Instantiate(ctx, contractID, creator, nil, initMsgBz, "demo contract 3", deposit) + require.NoError(t, err) + require.Equal(t, "link18vd8fpwxzck93qlwghaj6arh4p7c5n89fvcmzu", addr.String()) + + // execute inactive contract + params := keeper.GetParams(ctx) + params.ContractStatusAccess = types.AccessTypeOnlyAddress.With(creator) + keeper.setParams(ctx, params) + err = keeper.UpdateContractStatus(ctx, addr, creator, types.ContractStatusInactive) + require.NoError(t, err) + _, err = keeper.Execute(ctx, addr, fred, []byte(`{"release":{}}`), topUp) + require.True(t, types.ErrInvalid.Is(err), "expected %v but got %+v", types.ErrInvalid, err) +} + func TestMigrate(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper @@ -1050,6 +1088,41 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { assert.Equal(t, deposit, balance) } +func TestMigrateInactiveContract(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + + originalCodeID := StoreHackatomExampleContract(t, ctx, keepers).CodeID + newCodeID := StoreHackatomExampleContract(t, ctx, keepers).CodeID + require.NotEqual(t, originalCodeID, newCodeID) + + anyAddr := RandomAccountAddress(t) + newVerifierAddr := RandomAccountAddress(t) + initMsgBz := HackatomExampleInitMsg{ + Verifier: fred, + Beneficiary: anyAddr, + }.GetBytes(t) + migMsg := struct { + Verifier sdk.AccAddress `json:"verifier"` + }{Verifier: newVerifierAddr} + migMsgBz, err := json.Marshal(migMsg) + + contractAddr, _, err := keeper.Instantiate(ctx, originalCodeID, creator, creator, initMsgBz, "demo contract", nil) + + params := keeper.GetParams(ctx) + params.ContractStatusAccess = types.AccessTypeOnlyAddress.With(creator) + keeper.setParams(ctx, params) + err = keeper.UpdateContractStatus(ctx, contractAddr, creator, types.ContractStatusInactive) + require.NoError(t, err) + _, err = keeper.Migrate(ctx, contractAddr, creator, newCodeID, migMsgBz) + require.True(t, types.ErrInvalid.Is(err), "expected %v but got %+v", types.ErrInvalid, err) +} + type sudoMsg struct { // This is a tongue-in-check demo command. This is not the intended purpose of Sudo. // Here we show that some priviledged Go module can make a call that should never be exposed @@ -1217,6 +1290,42 @@ func TestUpdateContractAdmin(t *testing.T) { } } +func TestUpdateContractAdminInactiveContract(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + + wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + originalContractID, err := keeper.Create(ctx, creator, wasmCode, "", "", nil) + require.NoError(t, err) + + _, _, anyAddr := keyPubAddr() + initMsg := HackatomExampleInitMsg{ + Verifier: fred, + Beneficiary: anyAddr, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + addr, _, err := keeper.Instantiate(ctx, originalContractID, creator, fred, initMsgBz, "demo contract", nil) + require.NoError(t, err) + + params := keeper.GetParams(ctx) + params.ContractStatusAccess = types.AccessTypeOnlyAddress.With(creator) + keeper.setParams(ctx, params) + err = keeper.UpdateContractStatus(ctx, addr, creator, types.ContractStatusInactive) + require.NoError(t, err) + + err = keeper.UpdateContractAdmin(ctx, addr, fred, anyAddr) + require.True(t, types.ErrInvalid.Is(err), "expected %v but got %+v", types.ErrInvalid, err) +} + func TestClearContractAdmin(t *testing.T) { ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper @@ -1282,3 +1391,145 @@ func TestClearContractAdmin(t *testing.T) { }) } } + +func TestClearContractAdminInactiveContract(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + + wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + originalContractID, err := keeper.Create(ctx, creator, wasmCode, "", "", nil) + require.NoError(t, err) + + _, _, anyAddr := keyPubAddr() + initMsg := HackatomExampleInitMsg{ + Verifier: fred, + Beneficiary: anyAddr, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + addr, _, err := keeper.Instantiate(ctx, originalContractID, creator, fred, initMsgBz, "demo contract", nil) + require.NoError(t, err) + + params := keeper.GetParams(ctx) + params.ContractStatusAccess = types.AccessTypeOnlyAddress.With(creator) + keeper.setParams(ctx, params) + err = keeper.UpdateContractStatus(ctx, addr, creator, types.ContractStatusInactive) + require.NoError(t, err) + + err = keeper.ClearContractAdmin(ctx, addr, fred) + require.True(t, types.ErrInvalid.Is(err), "expected %v but got %+v", types.ErrInvalid, err) +} + +func TestUpdateContractStatus(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures, nil, nil) + accKeeper, keeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, deposit.Add(deposit...)) + fred := createFakeFundedAccount(t, ctx, accKeeper, bankKeeper, topUp) + + wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + originalContractID, err := keeper.Create(ctx, creator, wasmCode, "", "", nil) + require.NoError(t, err) + + _, _, anyAddr := keyPubAddr() + initMsg := HackatomExampleInitMsg{ + Verifier: fred, + Beneficiary: anyAddr, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + type spec struct { + instAdmin sdk.AccAddress + newStatus types.ContractStatus + overrideContractAddr sdk.AccAddress + caller sdk.AccAddress + expErr *sdkerrors.Error + } + + // Default Nobody can update the status + s := spec{ + instAdmin: fred, + newStatus: types.ContractStatusInactive, + caller: fred, + expErr: sdkerrors.ErrUnauthorized, + } + runUpdateStatusSpec(t, "ContractStatusAccess nobody", keeper, ctx, originalContractID, creator, s, initMsgBz) + + // Everybody can update the status + params := keeper.GetParams(ctx) + params.ContractStatusAccess = types.AllowEverybody + keeper.setParams(ctx, params) + specs := map[string]spec{ + "admin can update the status": { + instAdmin: fred, + newStatus: types.ContractStatusInactive, + caller: fred, + }, + "any can update the status": { + instAdmin: fred, + newStatus: types.ContractStatusInactive, + caller: anyAddr, + }, + } + for msg, spec := range specs { + runUpdateStatusSpec(t, msg, keeper, ctx, originalContractID, creator, spec, initMsgBz) + } + + // Only authorized account can update the status + params = keeper.GetParams(ctx) + params.ContractStatusAccess = types.AccessTypeOnlyAddress.With(fred) + keeper.setParams(ctx, params) + specs = map[string]spec{ + "authorized account update the status": { + instAdmin: fred, + newStatus: types.ContractStatusInactive, + caller: fred, + }, + "any cannot update the status": { + instAdmin: fred, + newStatus: types.ContractStatusInactive, + caller: anyAddr, + expErr: sdkerrors.ErrUnauthorized, + }, + } + for msg, spec := range specs { + runUpdateStatusSpec(t, msg, keeper, ctx, originalContractID, creator, spec, initMsgBz) + } +} + +func runUpdateStatusSpec(t *testing.T, msg string, keeper *Keeper, ctx sdk.Context, originalContractID uint64, creator sdk.AccAddress, spec struct { + instAdmin sdk.AccAddress + newStatus types.ContractStatus + overrideContractAddr sdk.AccAddress + caller sdk.AccAddress + expErr *sdkerrors.Error +}, initMsgBz []byte) { + + t.Run(msg, func(t *testing.T) { + addr, _, err := keeper.Instantiate(ctx, originalContractID, creator, spec.instAdmin, initMsgBz, "demo contract", nil) + require.NoError(t, err) + if spec.overrideContractAddr != nil { + addr = spec.overrideContractAddr + } + err = keeper.UpdateContractStatus(ctx, addr, spec.caller, types.ContractStatusInactive) + require.True(t, spec.expErr.Is(err), "expected %v but got %+v", spec.expErr, err) + if spec.expErr != nil { + return + } + cInfo := keeper.GetContractInfo(ctx, addr) + assert.Equal(t, spec.newStatus, cInfo.Status) + }) +} diff --git a/x/wasm/internal/keeper/msg_server.go b/x/wasm/internal/keeper/msg_server.go index f21355660b..be6fc4d8aa 100644 --- a/x/wasm/internal/keeper/msg_server.go +++ b/x/wasm/internal/keeper/msg_server.go @@ -230,3 +230,37 @@ func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) ( return &types.MsgClearAdminResponse{}, nil } + +// UpdateContractStatus handles MsgUpdateContractStatus +// CONTRACT: msg.validateBasic() must be called before calling this +func (m msgServer) UpdateContractStatus(goCtx context.Context, msg *types.MsgUpdateContractStatus) (*types.MsgUpdateContractStatusResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + return nil, sdkerrors.Wrap(err, "contract") + } + + if err = m.keeper.UpdateContractStatus(ctx, contractAddr, senderAddr, msg.Status); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + ), + sdk.NewEvent( + types.EventTypeUpdateContractStatus, + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + sdk.NewAttribute(types.AttributeKeyContractStatus, msg.Status.String()), + ), + }) + + return &types.MsgUpdateContractStatusResponse{}, nil +} diff --git a/x/wasm/internal/keeper/proposal_handler.go b/x/wasm/internal/keeper/proposal_handler.go index 862b37c78b..f6dbd5a7a8 100644 --- a/x/wasm/internal/keeper/proposal_handler.go +++ b/x/wasm/internal/keeper/proposal_handler.go @@ -19,6 +19,7 @@ type governing interface { setContractAdmin(ctx sdk.Context, contractAddress, caller, newAdmin sdk.AccAddress, authZ AuthorizationPolicy) error PinCode(ctx sdk.Context, codeID uint64) error UnpinCode(ctx sdk.Context, codeID uint64) error + updateContractStatus(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, status types.ContractStatus, authZ AuthorizationPolicy) error } // NewWasmProposalHandler creates a new governance Handler for wasm proposals @@ -49,6 +50,8 @@ func NewWasmProposalHandler(k governing, enabledProposalTypes []types.ProposalTy return handlePinCodesProposal(ctx, k, *c) case *types.UnpinCodesProposal: return handleUnpinCodesProposal(ctx, k, *c) + case *types.UpdateContractStatusProposal: + return handleUpdateContractStatusProposal(ctx, k, *c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized wasm proposal content type: %T", c) } @@ -233,3 +236,24 @@ func handleUnpinCodesProposal(ctx sdk.Context, k governing, p types.UnpinCodesPr return nil } + +func handleUpdateContractStatusProposal(ctx sdk.Context, k governing, p types.UpdateContractStatusProposal) error { + if err := p.ValidateBasic(); err != nil { + return err + } + contractAddr, err := sdk.AccAddressFromBech32(p.Contract) + if err != nil { + return sdkerrors.Wrap(err, "contract") + } + + if err = k.updateContractStatus(ctx, contractAddr, nil, p.Status, GovAuthorizationPolicy{}); err != nil { + return err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeUpdateContractStatus, + sdk.NewAttribute(types.AttributeKeyContract, p.Contract), + sdk.NewAttribute(types.AttributeKeyContractStatus, p.Status.String()), + )) + return nil +} diff --git a/x/wasm/internal/keeper/proposal_integration_test.go b/x/wasm/internal/keeper/proposal_integration_test.go index 867d4c362a..9ff2e72ee8 100644 --- a/x/wasm/internal/keeper/proposal_integration_test.go +++ b/x/wasm/internal/keeper/proposal_integration_test.go @@ -9,11 +9,10 @@ import ( "testing" wasmvm "github.com/CosmWasm/wasmvm" - "github.com/line/lbm-sdk/v2/x/wasm/internal/keeper/wasmtesting" - sdk "github.com/line/lbm-sdk/v2/types" govtypes "github.com/line/lbm-sdk/v2/x/gov/types" "github.com/line/lbm-sdk/v2/x/params/types/proposal" + "github.com/line/lbm-sdk/v2/x/wasm/internal/keeper/wasmtesting" "github.com/line/lbm-sdk/v2/x/wasm/internal/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,6 +24,7 @@ func TestStoreCodeProposal(t *testing.T) { wasmKeeper.setParams(ctx, types.Params{ CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, + ContractStatusAccess: types.DefaultContractStatusAccess, MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, GasMultiplier: types.DefaultGasMultiplier, InstanceCost: types.DefaultInstanceCost, @@ -69,6 +69,7 @@ func TestInstantiateProposal(t *testing.T) { wasmKeeper.setParams(ctx, types.Params{ CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, + ContractStatusAccess: types.DefaultContractStatusAccess, MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, GasMultiplier: types.DefaultGasMultiplier, InstanceCost: types.DefaultInstanceCost, @@ -128,6 +129,7 @@ func TestMigrateProposal(t *testing.T) { wasmKeeper.setParams(ctx, types.Params{ CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, + ContractStatusAccess: types.DefaultContractStatusAccess, MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, GasMultiplier: types.DefaultGasMultiplier, InstanceCost: types.DefaultInstanceCost, @@ -263,6 +265,7 @@ func TestAdminProposals(t *testing.T) { wasmKeeper.setParams(ctx, types.Params{ CodeUploadAccess: types.AllowNobody, InstantiateDefaultPermission: types.AccessTypeNobody, + ContractStatusAccess: types.DefaultContractStatusAccess, MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, GasMultiplier: types.DefaultGasMultiplier, InstanceCost: types.DefaultInstanceCost, @@ -536,3 +539,69 @@ func TestUnpinCodesProposal(t *testing.T) { }) } } + +func TestUpdateContractStatusProposals(t *testing.T) { + var contractAddr = contractAddress(1, 1) + wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + specs := map[string]struct { + state types.ContractInfo + srcProposal govtypes.Content + expStatus types.ContractStatus + }{ + "update with different Status": { + state: types.ContractInfoFixture(), + srcProposal: &types.UpdateContractStatusProposal{ + Title: "Foo", + Description: "Bar", + Contract: contractAddr.String(), + Status: types.ContractStatusInactive, + }, + expStatus: types.ContractStatusInactive, + }, + "update with old Status": { + state: types.ContractInfoFixture(), + srcProposal: &types.UpdateContractStatusProposal{ + Title: "Foo", + Description: "Bar", + Contract: contractAddr.String(), + Status: types.ContractStatusActive, + }, + expStatus: types.ContractStatusActive, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, "staking", nil, nil) + govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper + wasmKeeper.setParams(ctx, types.Params{ + CodeUploadAccess: types.AllowNobody, + InstantiateDefaultPermission: types.AccessTypeNobody, + ContractStatusAccess: types.AllowNobody, + MaxWasmCodeSize: types.DefaultMaxWasmCodeSize, + GasMultiplier: types.DefaultGasMultiplier, + InstanceCost: types.DefaultInstanceCost, + CompileCost: types.DefaultCompileCost, + }) + + codeInfoFixture := types.CodeInfoFixture(types.WithSHA256CodeHash(wasmCode)) + require.NoError(t, wasmKeeper.importCode(ctx, 1, codeInfoFixture, wasmCode)) + + require.NoError(t, wasmKeeper.importContract(ctx, contractAddr, &spec.state, []types.Model{})) + // when stored + storedProposal, err := govKeeper.SubmitProposal(ctx, spec.srcProposal) + require.NoError(t, err) + + // and execute proposal + handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute()) + err = handler(ctx, storedProposal.GetContent()) + require.NoError(t, err) + + // then + cInfo := wasmKeeper.GetContractInfo(ctx, contractAddr) + require.NotNil(t, cInfo) + assert.Equal(t, spec.expStatus, cInfo.Status) + }) + } +} diff --git a/x/wasm/internal/keeper/recurse_test.go b/x/wasm/internal/keeper/recurse_test.go index f12d1e156c..82ca94692f 100644 --- a/x/wasm/internal/keeper/recurse_test.go +++ b/x/wasm/internal/keeper/recurse_test.go @@ -58,9 +58,9 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc func TestGasCostOnQuery(t *testing.T) { const ( - GasNoWork uint64 = 50_149 + GasNoWork uint64 = 50_155 // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork50 uint64 = 55_818 // this is a little shy of 50k gas - to keep an eye on the limit + GasWork50 uint64 = 55_824 // this is a little shy of 50k gas - to keep an eye on the limit GasReturnUnhashed uint64 = 287 GasReturnHashed uint64 = 262 @@ -225,7 +225,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) { const ( // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 - GasWork2k uint64 = 278_872 // = InstanceCost + x // we have 6x gas used in cpu than in the instance + GasWork2k uint64 = 278_878 // = InstanceCost + x // we have 6x gas used in cpu than in the instance // This is overhead for calling into a sub-contract GasReturnHashed uint64 = 265 ) diff --git a/x/wasm/internal/keeper/relay_test.go b/x/wasm/internal/keeper/relay_test.go index 63b4d7bb05..dd3bce2c4f 100644 --- a/x/wasm/internal/keeper/relay_test.go +++ b/x/wasm/internal/keeper/relay_test.go @@ -67,7 +67,7 @@ func TestOnOpenChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) }) } @@ -91,12 +91,12 @@ func TestOnConnectChannel(t *testing.T) { }{ "consume contract gas": { contractAddr: example.Contract, - contractGas: 10, + contractGas: 16, contractResp: &wasmvmtypes.IBCBasicResponse{}, }, "consume gas on error, ignore events + messages": { contractAddr: example.Contract, - contractGas: 20, + contractGas: 26, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}}, Attributes: []wasmvmtypes.EventAttribute{{Key: "Foo", Value: "Bar"}}, @@ -107,14 +107,14 @@ func TestOnConnectChannel(t *testing.T) { }, "dispatch contract messages on success": { contractAddr: example.Contract, - contractGas: 30, + contractGas: 36, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}, {Custom: json.RawMessage(`{"foo":"bar"}`)}}, }, }, "emit contract events on success": { contractAddr: example.Contract, - contractGas: 40, + contractGas: 46, contractResp: &wasmvmtypes.IBCBasicResponse{ Attributes: []wasmvmtypes.EventAttribute{{Key: "Foo", Value: "Bar"}}, }, @@ -122,7 +122,7 @@ func TestOnConnectChannel(t *testing.T) { }, "messenger errors returned, events stored": { contractAddr: example.Contract, - contractGas: 50, + contractGas: 56, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}, {Custom: json.RawMessage(`{"foo":"bar"}`)}}, Attributes: []wasmvmtypes.EventAttribute{{Key: "Foo", Value: "Bar"}}, @@ -174,7 +174,7 @@ func TestOnConnectChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched assert.Equal(t, spec.contractResp.Messages, *capturedMsgs) @@ -201,7 +201,7 @@ func TestOnCloseChannel(t *testing.T) { }{ "consume contract gas": { contractAddr: example.Contract, - contractGas: 10, + contractGas: 16, contractResp: &wasmvmtypes.IBCBasicResponse{}, }, "consume gas on error, ignore events + messages": { @@ -217,14 +217,14 @@ func TestOnCloseChannel(t *testing.T) { }, "dispatch contract messages on success": { contractAddr: example.Contract, - contractGas: 30, + contractGas: 36, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}, {Custom: json.RawMessage(`{"foo":"bar"}`)}}, }, }, "emit contract events on success": { contractAddr: example.Contract, - contractGas: 40, + contractGas: 46, contractResp: &wasmvmtypes.IBCBasicResponse{ Attributes: []wasmvmtypes.EventAttribute{{Key: "Foo", Value: "Bar"}}, }, @@ -283,7 +283,7 @@ func TestOnCloseChannel(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched assert.Equal(t, spec.contractResp.Messages, *capturedMsgs) @@ -408,7 +408,7 @@ func TestOnRecvPacket(t *testing.T) { require.Equal(t, spec.contractResp.Acknowledgement, gotAck) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched assert.Equal(t, spec.contractResp.Messages, *capturedMsgs) @@ -436,7 +436,7 @@ func TestOnAckPacket(t *testing.T) { }{ "consume contract gas": { contractAddr: example.Contract, - contractGas: 10, + contractGas: 16, contractResp: &wasmvmtypes.IBCBasicResponse{}, }, "consume gas on error, ignore events + messages": { @@ -452,14 +452,14 @@ func TestOnAckPacket(t *testing.T) { }, "dispatch contract messages on success": { contractAddr: example.Contract, - contractGas: 30, + contractGas: 36, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}, {Custom: json.RawMessage(`{"foo":"bar"}`)}}, }, }, "emit contract events on success": { contractAddr: example.Contract, - contractGas: 40, + contractGas: 46, contractResp: &wasmvmtypes.IBCBasicResponse{ Attributes: []wasmvmtypes.EventAttribute{{Key: "Foo", Value: "Bar"}}, }, @@ -519,7 +519,7 @@ func TestOnAckPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched assert.Equal(t, spec.contractResp.Messages, *capturedMsgs) @@ -547,7 +547,7 @@ func TestOnTimeoutPacket(t *testing.T) { }{ "consume contract gas": { contractAddr: example.Contract, - contractGas: 10, + contractGas: 22, contractResp: &wasmvmtypes.IBCBasicResponse{}, }, "consume gas on error, ignore events + messages": { @@ -563,7 +563,7 @@ func TestOnTimeoutPacket(t *testing.T) { }, "dispatch contract messages on success": { contractAddr: example.Contract, - contractGas: 30, + contractGas: 42, contractResp: &wasmvmtypes.IBCBasicResponse{ Messages: []wasmvmtypes.CosmosMsg{{Bank: &wasmvmtypes.BankMsg{}}, {Custom: json.RawMessage(`{"foo":"bar"}`)}}, }, @@ -629,7 +629,7 @@ func TestOnTimeoutPacket(t *testing.T) { } require.NoError(t, err) // verify gas consumed - const storageCosts = sdk.Gas(0x1a61) + const storageCosts = sdk.Gas(0x1a67) assert.Equal(t, spec.contractGas, ctx.GasMeter().GasConsumed()-before-storageCosts) // verify msgs dispatched assert.Equal(t, spec.contractResp.Messages, *capturedMsgs) diff --git a/x/wasm/internal/types/events.go b/x/wasm/internal/types/events.go index 2f48e5847c..b235990d9a 100644 --- a/x/wasm/internal/types/events.go +++ b/x/wasm/internal/types/events.go @@ -1,12 +1,14 @@ package types const ( - EventTypePinCode = "pin_code" - EventTypeUnpinCode = "unpin_code" + EventTypePinCode = "pin_code" + EventTypeUnpinCode = "unpin_code" + EventTypeUpdateContractStatus = "update_contract_status" ) const ( // event attributes - AttributeKeyContract = "contract_address" - AttributeKeyCodeID = "code_id" - AttributeKeyCodeIDs = "code_ids" - AttributeKeySigner = "signer" + AttributeKeyContract = "contract_address" + AttributeKeyCodeID = "code_id" + AttributeKeyCodeIDs = "code_ids" + AttributeKeySigner = "signer" + AttributeKeyContractStatus = "contract_status" ) diff --git a/x/wasm/internal/types/params.go b/x/wasm/internal/types/params.go index 52b7bf6734..9d09e3ced6 100644 --- a/x/wasm/internal/types/params.go +++ b/x/wasm/internal/types/params.go @@ -33,10 +33,12 @@ const ( var ParamStoreKeyUploadAccess = []byte("uploadAccess") var ParamStoreKeyInstantiateAccess = []byte("instantiateAccess") +var ParamStoreKeyContractStatusAccess = []byte("contractStatusAccess") var ParamStoreKeyMaxWasmCodeSize = []byte("maxWasmCodeSize") var ParamStoreKeyGasMultiplier = []byte("gasMultiplier") var ParamStoreKeyInstanceCost = []byte("instanceCost") var ParamStoreKeyCompileCost = []byte("compileCost") + var AllAccessTypes = []AccessType{ AccessTypeNobody, AccessTypeOnlyAddress, @@ -97,9 +99,10 @@ func (a AccessConfig) Equals(o AccessConfig) bool { } var ( - DefaultUploadAccess = AllowEverybody - AllowEverybody = AccessConfig{Permission: AccessTypeEverybody} - AllowNobody = AccessConfig{Permission: AccessTypeNobody} + DefaultUploadAccess = AllowEverybody + DefaultContractStatusAccess = AllowNobody + AllowEverybody = AccessConfig{Permission: AccessTypeEverybody} + AllowNobody = AccessConfig{Permission: AccessTypeNobody} ) // ParamKeyTable returns the parameter key table. @@ -113,6 +116,7 @@ func DefaultParams() Params { CodeUploadAccess: AllowEverybody, InstantiateDefaultPermission: AccessTypeEverybody, MaxWasmCodeSize: DefaultMaxWasmCodeSize, + ContractStatusAccess: DefaultContractStatusAccess, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, CompileCost: DefaultCompileCost, @@ -129,6 +133,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(ParamStoreKeyUploadAccess, &p.CodeUploadAccess, validateAccessConfig), paramtypes.NewParamSetPair(ParamStoreKeyInstantiateAccess, &p.InstantiateDefaultPermission, validateAccessType), + paramtypes.NewParamSetPair(ParamStoreKeyContractStatusAccess, &p.ContractStatusAccess, validateAccessConfig), paramtypes.NewParamSetPair(ParamStoreKeyMaxWasmCodeSize, &p.MaxWasmCodeSize, validateMaxWasmCodeSize), paramtypes.NewParamSetPair(ParamStoreKeyGasMultiplier, &p.GasMultiplier, validateGasMultiplier), paramtypes.NewParamSetPair(ParamStoreKeyInstanceCost, &p.InstanceCost, validateInstanceCost), @@ -144,6 +149,9 @@ func (p Params) ValidateBasic() error { if err := validateAccessConfig(p.CodeUploadAccess); err != nil { return errors.Wrap(err, "upload access") } + if err := validateAccessConfig(p.ContractStatusAccess); err != nil { + return errors.Wrap(err, "contract status access") + } if err := validateMaxWasmCodeSize(p.MaxWasmCodeSize); err != nil { return errors.Wrap(err, "max wasm code size") } diff --git a/x/wasm/internal/types/params_test.go b/x/wasm/internal/types/params_test.go index dbf93a44d4..812ccbbab9 100644 --- a/x/wasm/internal/types/params_test.go +++ b/x/wasm/internal/types/params_test.go @@ -28,6 +28,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AllowNobody, InstantiateDefaultPermission: AccessTypeNobody, + ContractStatusAccess: AllowNobody, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -38,6 +39,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AllowEverybody, InstantiateDefaultPermission: AccessTypeEverybody, + ContractStatusAccess: AllowEverybody, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -48,6 +50,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AccessTypeOnlyAddress.With(anyAddress), InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: AccessTypeOnlyAddress.With(anyAddress), MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -56,11 +59,12 @@ func TestValidateParams(t *testing.T) { }, "reject empty type in instantiate permission": { src: Params{ - CodeUploadAccess: AllowNobody, - MaxWasmCodeSize: DefaultMaxWasmCodeSize, - GasMultiplier: DefaultGasMultiplier, - InstanceCost: DefaultInstanceCost, - CompileCost: DefaultCompileCost, + CodeUploadAccess: AllowNobody, + ContractStatusAccess: DefaultContractStatusAccess, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, }, expErr: true, }, @@ -68,6 +72,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AllowNobody, InstantiateDefaultPermission: 1111, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -75,10 +80,11 @@ func TestValidateParams(t *testing.T) { }, expErr: true, }, - "reject invalid address in only address": { + "reject CodeUploadAccess invalid address in only address": { src: Params{ CodeUploadAccess: AccessConfig{Permission: AccessTypeOnlyAddress, Address: invalidAddress}, InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -90,6 +96,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AccessConfig{Permission: AccessTypeEverybody, Address: anyAddress.String()}, InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -101,6 +108,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AccessConfig{Permission: AccessTypeNobody, Address: anyAddress.String()}, InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -111,6 +119,7 @@ func TestValidateParams(t *testing.T) { "reject empty CodeUploadAccess": { src: Params{ InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -122,6 +131,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AccessConfig{Permission: AccessTypeUnspecified}, InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: DefaultContractStatusAccess, MaxWasmCodeSize: DefaultMaxWasmCodeSize, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, @@ -133,6 +143,7 @@ func TestValidateParams(t *testing.T) { src: Params{ CodeUploadAccess: AllowNobody, InstantiateDefaultPermission: AccessTypeNobody, + ContractStatusAccess: DefaultContractStatusAccess, GasMultiplier: DefaultGasMultiplier, InstanceCost: DefaultInstanceCost, CompileCost: DefaultCompileCost, @@ -169,6 +180,65 @@ func TestValidateParams(t *testing.T) { }, expErr: true, }, + "reject ContractStatusAccess invalid address in only address": { + src: Params{ + CodeUploadAccess: DefaultUploadAccess, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: AccessConfig{Permission: AccessTypeOnlyAddress, Address: invalidAddress}, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, + }, + expErr: true, + }, + "reject ContractStatusAccess Everybody with obsolete address": { + src: Params{ + CodeUploadAccess: DefaultUploadAccess, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: AccessConfig{Permission: AccessTypeEverybody, Address: anyAddress.String()}, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, + }, + expErr: true, + }, + "reject ContractStatusAccess Nobody with obsolete address": { + src: Params{ + CodeUploadAccess: DefaultUploadAccess, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: AccessConfig{Permission: AccessTypeNobody, Address: anyAddress.String()}, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, + }, + expErr: true, + }, + "reject empty ContractStatusAccess": { + src: Params{ + CodeUploadAccess: DefaultUploadAccess, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, + }, + expErr: true, + }, + "reject undefined permission in ContractStatusAccess": { + src: Params{ + CodeUploadAccess: DefaultUploadAccess, + InstantiateDefaultPermission: AccessTypeOnlyAddress, + ContractStatusAccess: AccessConfig{Permission: AccessTypeUnspecified}, + MaxWasmCodeSize: DefaultMaxWasmCodeSize, + GasMultiplier: DefaultGasMultiplier, + InstanceCost: DefaultInstanceCost, + CompileCost: DefaultCompileCost, + }, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -231,6 +301,7 @@ func TestParamsUnmarshalJson(t *testing.T) { "defaults": { src: `{"code_upload_access": {"permission": "Everybody"}, "instantiate_default_permission": "Everybody", + "contract_status_access": {"permission": "Nobody"}, "max_wasm_code_size": 614400, "gas_multiplier": 100, "instance_cost": 40000, diff --git a/x/wasm/internal/types/proposal.go b/x/wasm/internal/types/proposal.go index b485f3fe7f..0fbf0ca421 100644 --- a/x/wasm/internal/types/proposal.go +++ b/x/wasm/internal/types/proposal.go @@ -416,6 +416,49 @@ func (p UnpinCodesProposal) String() string { `, p.Title, p.Description, p.CodeIDs) } +// ProposalRoute returns the routing key of a parameter change proposal. +func (p UpdateContractStatusProposal) ProposalRoute() string { return RouterKey } + +// GetTitle returns the title of the proposal +func (p *UpdateContractStatusProposal) GetTitle() string { return p.Title } + +// GetDescription returns the human readable description of the proposal +func (p UpdateContractStatusProposal) GetDescription() string { return p.Description } + +// ProposalType returns the type +func (p UpdateContractStatusProposal) ProposalType() string { return string(ProposalTypeUpdateAdmin) } + +// ValidateBasic validates the proposal +func (p UpdateContractStatusProposal) ValidateBasic() error { + if err := validateProposalCommons(p.Title, p.Description); err != nil { + return err + } + if _, err := sdk.AccAddressFromBech32(p.Contract); err != nil { + return sdkerrors.Wrap(err, "contract") + } + found := false + for _, v := range AllContractStatus { + if p.Status == v { + found = true + break + } + } + if !found || p.Status == ContractStatusUnspecified { + return sdkerrors.Wrap(govtypes.ErrInvalidProposalContent, "invalid status") + } + return nil +} + +// String implements the Stringer interface. +func (p UpdateContractStatusProposal) String() string { + return fmt.Sprintf(`Update Contract Status Proposal: + Title: %s + Description: %s + Contract: %s + Status: %s +`, p.Title, p.Description, p.Contract, p.Status.String()) +} + func validateProposalCommons(title, description string) error { if strings.TrimSpace(title) != title { return sdkerrors.Wrap(govtypes.ErrInvalidProposalContent, "proposal title must not start/end with white spaces") diff --git a/x/wasm/internal/types/proposal.pb.go b/x/wasm/internal/types/proposal.pb.go index 8a2daacfea..4584fe15d2 100644 --- a/x/wasm/internal/types/proposal.pb.go +++ b/x/wasm/internal/types/proposal.pb.go @@ -347,6 +347,50 @@ func (m *UnpinCodesProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UnpinCodesProposal proto.InternalMessageInfo +// UpdateStatusProposal gov proposal content type to update the contract status. +type UpdateContractStatusProposal struct { + // Title is a short summary + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // Description is a human readable text + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // Contract is the address of the smart contract + Contract string `protobuf:"bytes,3,opt,name=contract,proto3" json:"contract,omitempty"` + // Status to be set + Status ContractStatus `protobuf:"varint,4,opt,name=status,proto3,enum=cosmwasm.wasm.v1beta1.ContractStatus" json:"status,omitempty"` +} + +func (m *UpdateContractStatusProposal) Reset() { *m = UpdateContractStatusProposal{} } +func (*UpdateContractStatusProposal) ProtoMessage() {} +func (*UpdateContractStatusProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c3ac5ce23bf32d05, []int{7} +} +func (m *UpdateContractStatusProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateContractStatusProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateContractStatusProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UpdateContractStatusProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateContractStatusProposal.Merge(m, src) +} +func (m *UpdateContractStatusProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateContractStatusProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateContractStatusProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateContractStatusProposal proto.InternalMessageInfo + func init() { proto.RegisterType((*StoreCodeProposal)(nil), "cosmwasm.wasm.v1beta1.StoreCodeProposal") proto.RegisterType((*InstantiateContractProposal)(nil), "cosmwasm.wasm.v1beta1.InstantiateContractProposal") @@ -355,58 +399,61 @@ func init() { proto.RegisterType((*ClearAdminProposal)(nil), "cosmwasm.wasm.v1beta1.ClearAdminProposal") proto.RegisterType((*PinCodesProposal)(nil), "cosmwasm.wasm.v1beta1.PinCodesProposal") proto.RegisterType((*UnpinCodesProposal)(nil), "cosmwasm.wasm.v1beta1.UnpinCodesProposal") + proto.RegisterType((*UpdateContractStatusProposal)(nil), "cosmwasm.wasm.v1beta1.UpdateContractStatusProposal") } func init() { proto.RegisterFile("proposal.proto", fileDescriptor_c3ac5ce23bf32d05) } var fileDescriptor_c3ac5ce23bf32d05 = []byte{ - // 730 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0x4d, 0x6b, 0xe3, 0x46, - 0x18, 0xc7, 0xad, 0x38, 0x7e, 0xc9, 0xd8, 0xa4, 0xae, 0xea, 0xb8, 0x22, 0x29, 0x92, 0x51, 0x20, - 0xf8, 0x52, 0xa9, 0x49, 0xa1, 0x6f, 0xd0, 0x83, 0xe5, 0x5e, 0x72, 0x30, 0x04, 0x85, 0xb4, 0x10, - 0x0a, 0x66, 0x24, 0x4d, 0x94, 0x69, 0xa5, 0x19, 0xa1, 0x19, 0xc7, 0xf5, 0xb7, 0xe8, 0x07, 0xe8, - 0x07, 0x08, 0xbd, 0x94, 0x7e, 0x8b, 0x1c, 0x73, 0xd8, 0x43, 0x4e, 0xda, 0x8d, 0x73, 0xd9, 0xb3, - 0x8f, 0x7b, 0x5a, 0x46, 0x23, 0x7b, 0x9d, 0x25, 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 0xf3, 0xcc, 0xf8, - 0x4c, 0x4e, 0x58, 0x88, 0x4c, 0xb7, 0x26, 0x0f, 0x9e, 0x99, 0xff, 0x2b, 0x40, 0x3d, 0x21, 0xc9, - 0xa7, 0x94, 0xd9, 0xf9, 0xf5, 0xea, 0x56, 0x2f, 0xdd, 0xdc, 0xea, 0xa5, 0xcb, 0x99, 0xae, 0x5c, - 0xcd, 0x74, 0xe5, 0x7a, 0xa6, 0x2b, 0x2f, 0x66, 0xba, 0xf2, 0xf7, 0x9d, 0x5e, 0xba, 0xbe, 0xd3, - 0x4b, 0x37, 0x77, 0x7a, 0xe9, 0xf4, 0x9b, 0x47, 0x5e, 0xd7, 0xbf, 0x6c, 0xf1, 0x2b, 0x69, 0x63, - 0xc2, 0x51, 0x4a, 0x60, 0x24, 0x5f, 0x5f, 0xaf, 0x9a, 0xff, 0x75, 0x7c, 0xfb, 0x3a, 0x00, 0x00, - 0xff, 0xff, 0x72, 0x5c, 0xc9, 0xf7, 0xa3, 0x06, 0x00, 0x00, + // 763 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0x9b, 0xc6, 0x49, 0x27, 0x51, 0x09, 0x26, 0x0d, 0x56, 0x77, 0x65, 0x47, 0x5e, 0xb1, + 0xca, 0x05, 0x9b, 0x06, 0x89, 0x7f, 0xd2, 0x1e, 0xe2, 0x70, 0xe9, 0x21, 0x52, 0xe5, 0x6a, 0x41, + 0x5a, 0x21, 0x45, 0x63, 0x7b, 0xd6, 0x3b, 0x60, 0xcf, 0x58, 0x9e, 0xc9, 0x86, 0x7c, 0x0b, 0x3e, + 0x00, 0x1f, 0x60, 0xc5, 0x05, 0xf1, 0x2d, 0x7a, 0xdc, 0x03, 0x87, 0x3d, 0x19, 0x9a, 0x5e, 0x38, + 0xe7, 0xc8, 0x09, 0xcd, 0x8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0x82, 0x66, 0x38, 0xc7, + 0x69, 0x8c, 0x0a, 0x53, 0x97, 0x89, 0x4d, 0x68, 0x3c, 0x03, 0x7d, 0x4c, 0x18, 0x87, 0x84, 0x63, + 0xc8, 0xd1, 0x2c, 0x47, 0x45, 0x86, 0x19, 0x13, 0x6a, 0x9b, 0x03, 0x6d, 0xd8, 0x1e, 0x3d, 0x72, + 0x6f, 0xb4, 0xd1, 0x1d, 0x47, 0x11, 0x62, 0x6c, 0x42, 0xc9, 0x73, 0x9c, 0x04, 0x47, 0x3b, 0x2d, + 0xce, 0xb6, 0x1d, 0x9c, 0x9f, 0xf7, 0xc0, 0x83, 0xd3, 0x3f, 0x33, 0x13, 0x4a, 0x78, 0x01, 0x23, + 0x7e, 0x5f, 0xa6, 0xf5, 0x40, 0x03, 0xc6, 0x19, 0x26, 0xd2, 0xab, 0x83, 0x40, 0x05, 0xc6, 0x23, + 0xd0, 0x14, 0x06, 0xce, 0x70, 0x2c, 0x3d, 0xd9, 0xf7, 0xc1, 0xaa, 0xb4, 0x75, 0xe1, 0xd6, 0xe9, + 0xe7, 0x81, 0x2e, 0x52, 0xa7, 0xb1, 0x28, 0x4d, 0x61, 0x88, 0xd2, 0xca, 0x1d, 0x15, 0x18, 0x1f, + 0x83, 0x16, 0x26, 0x98, 0xcf, 0x32, 0x96, 0x48, 0x37, 0x3a, 0xfe, 0xc3, 0xdf, 0x4b, 0xdb, 0x44, + 0x24, 0xa2, 0x31, 0x26, 0x89, 0xf7, 0x35, 0xa3, 0xc4, 0x0d, 0xe0, 0x62, 0x8a, 0x18, 0x83, 0x09, + 0x0a, 0x9a, 0x02, 0x3d, 0x65, 0x89, 0xf1, 0x15, 0x68, 0x3c, 0x9f, 0x93, 0x98, 0x99, 0xad, 0x41, + 0x7d, 0xd8, 0x1e, 0xf5, 0xdd, 0x34, 0xcc, 0x5c, 0xb1, 0x5d, 0x5b, 0xfb, 0x26, 0x14, 0x13, 0xdf, + 0xbd, 0x28, 0xed, 0xda,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 0x4d, 0x35, 0x64, 0xb6, 0x2e, 0xed, + 0xb7, 0x54, 0x87, 0x0d, 0xc8, 0x09, 0x9a, 0x6a, 0xf0, 0xcc, 0xf9, 0x49, 0x03, 0xc6, 0x53, 0x92, + 0xff, 0xdf, 0x34, 0x3f, 0x54, 0xeb, 0xb6, 0xf9, 0x61, 0x9d, 0x73, 0xc8, 0xe7, 0xec, 0x3e, 0x47, + 0x6b, 0x3c, 0x01, 0x3a, 0x93, 0x2c, 0x72, 0xbd, 0x0e, 0x47, 0xef, 0xfd, 0xcd, 0x8b, 0x7b, 0x5d, + 0x52, 0x50, 0x15, 0xf9, 0x5f, 0x5c, 0x5c, 0x5a, 0xb5, 0x37, 0x97, 0x56, 0xed, 0xd5, 0xca, 0xd2, + 0x2e, 0x56, 0x96, 0xf6, 0x7a, 0x65, 0x69, 0xbf, 0xae, 0x2c, 0xed, 0xbb, 0x2b, 0xab, 0xf6, 0xfa, + 0xca, 0xaa, 0xbd, 0xb9, 0xb2, 0x6a, 0xcf, 0x3e, 0xb8, 0xe5, 0x89, 0xf9, 0xd6, 0x13, 0x3c, 0x1e, + 0x26, 0x1c, 0x15, 0x04, 0xa6, 0xea, 0xc9, 0x09, 0x75, 0xf9, 0x77, 0xf7, 0xe1, 0x1f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xc8, 0x67, 0x26, 0x46, 0x57, 0x07, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -673,6 +720,39 @@ func (this *UnpinCodesProposal) Equal(that interface{}) bool { } return true } +func (this *UpdateContractStatusProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UpdateContractStatusProposal) + if !ok { + that2, ok := that.(UpdateContractStatusProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if this.Contract != that1.Contract { + return false + } + if this.Status != that1.Status { + return false + } + return true +} func (m *StoreCodeProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1102,6 +1182,55 @@ func (m *UnpinCodesProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *UpdateContractStatusProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UpdateContractStatusProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateContractStatusProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintProposal(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x20 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { offset -= sovProposal(v) base := offset @@ -1318,6 +1447,30 @@ func (m *UnpinCodesProposal) Size() (n int) { return n } +func (m *UpdateContractStatusProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovProposal(uint64(m.Status)) + } + return n +} + func sovProposal(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2836,6 +2989,171 @@ func (m *UnpinCodesProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpdateContractStatusProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UpdateContractStatusProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateContractStatusProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ContractStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProposal(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/internal/types/proposal.proto b/x/wasm/internal/types/proposal.proto index 4ed23ee833..33fb27d9ab 100644 --- a/x/wasm/internal/types/proposal.proto +++ b/x/wasm/internal/types/proposal.proto @@ -106,3 +106,15 @@ message UnpinCodesProposal { // CodeIDs references the WASM codes repeated uint64 code_ids = 3 [(gogoproto.customname) = "CodeIDs", (gogoproto.moretags) = "yaml:\"code_ids\""]; } + +// UpdateStatusProposal gov proposal content type to update the contract status. +message UpdateContractStatusProposal { + // Title is a short summary + string title = 1; + // Description is a human readable text + string description = 2; + // Contract is the address of the smart contract + string contract = 3; + // Status to be set + ContractStatus status = 4; +} diff --git a/x/wasm/internal/types/proposal_test.go b/x/wasm/internal/types/proposal_test.go index c24ba7f4f9..2953d3f776 100644 --- a/x/wasm/internal/types/proposal_test.go +++ b/x/wasm/internal/types/proposal_test.go @@ -430,6 +430,61 @@ func TestValidateClearAdminProposal(t *testing.T) { } } +func TestValidateUpdateContractStatusProposal(t *testing.T) { + var ( + invalidAddress = "invalid address" + ) + + specs := map[string]struct { + src *UpdateContractStatusProposal + expErr bool + }{ + "all good": { + src: UpdateContractStatusProposalFixture(), + }, + "base data missing": { + src: UpdateContractStatusProposalFixture(func(p *UpdateContractStatusProposal) { + p.Title = "" + }), + expErr: true, + }, + "contract missing": { + src: UpdateContractStatusProposalFixture(func(p *UpdateContractStatusProposal) { + p.Contract = "" + }), + expErr: true, + }, + "contract invalid": { + src: UpdateContractStatusProposalFixture(func(p *UpdateContractStatusProposal) { + p.Contract = invalidAddress + }), + expErr: true, + }, + "status missing": { + src: UpdateContractStatusProposalFixture(func(p *UpdateContractStatusProposal) { + p.Status = ContractStatusUnspecified + }), + expErr: true, + }, + "status invalid": { + src: UpdateContractStatusProposalFixture(func(p *UpdateContractStatusProposal) { + p.Status = 3 + }), + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + func TestProposalStrings(t *testing.T) { specs := map[string]struct { src govtypes.Content diff --git a/x/wasm/internal/types/test_fixtures.go b/x/wasm/internal/types/test_fixtures.go index fe9ff59ca4..a6b60af7a8 100644 --- a/x/wasm/internal/types/test_fixtures.go +++ b/x/wasm/internal/types/test_fixtures.go @@ -111,6 +111,7 @@ func ContractInfoFixture(mutators ...func(*ContractInfo)) ContractInfo { Creator: anyAddress, Label: "any", Created: &AbsoluteTxPosition{BlockHeight: 1, TxIndex: 1}, + Status: ContractStatusActive, } for _, m := range mutators { @@ -294,3 +295,18 @@ func ClearAdminProposalFixture(mutators ...func(p *ClearAdminProposal)) *ClearAd } return p } + +func UpdateContractStatusProposalFixture(mutators ...func(p *UpdateContractStatusProposal)) *UpdateContractStatusProposal { + const contractAddr = "link1hcttwju93d5m39467gjcq63p5kc4fdcn30dgd8" + + p := &UpdateContractStatusProposal{ + Title: "Foo", + Description: "Bar", + Contract: contractAddr, + Status: ContractStatusActive, + } + for _, m := range mutators { + m(p) + } + return p +} diff --git a/x/wasm/internal/types/tx.go b/x/wasm/internal/types/tx.go index fe65364aab..a4add48fd9 100644 --- a/x/wasm/internal/types/tx.go +++ b/x/wasm/internal/types/tx.go @@ -319,6 +319,46 @@ func (msg MsgClearAdmin) GetSigners() []sdk.AccAddress { } +func (msg MsgUpdateContractStatus) Route() string { + return RouterKey +} + +func (msg MsgUpdateContractStatus) Type() string { + return "update-contract-status" +} + +func (msg MsgUpdateContractStatus) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { + return sdkerrors.Wrap(err, "sender") + } + if _, err := sdk.AccAddressFromBech32(msg.Contract); err != nil { + return sdkerrors.Wrap(err, "contract") + } + found := false + for _, v := range AllContractStatus { + if msg.Status == v { + found = true + break + } + } + if !found || msg.Status == ContractStatusUnspecified { + return sdkerrors.Wrap(ErrInvalidMsg, "invalid status") + } + return nil +} + +func (msg MsgUpdateContractStatus) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgUpdateContractStatus) GetSigners() []sdk.AccAddress { + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{senderAddr} +} + func (msg MsgIBCSend) Route() string { return RouterKey } diff --git a/x/wasm/internal/types/tx.pb.go b/x/wasm/internal/types/tx.pb.go index ead6dff000..10c79aab71 100644 --- a/x/wasm/internal/types/tx.pb.go +++ b/x/wasm/internal/types/tx.pb.go @@ -636,6 +636,86 @@ func (m *MsgClearAdminResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgClearAdminResponse proto.InternalMessageInfo +// MsgUpdateContractStatus sets a new status for a smart contract +type MsgUpdateContractStatus struct { + // Sender is the that actor that signed the messages + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // Contract is the address of the smart contract + Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` + // Status to be set + Status ContractStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmwasm.wasm.v1beta1.ContractStatus" json:"status,omitempty"` +} + +func (m *MsgUpdateContractStatus) Reset() { *m = MsgUpdateContractStatus{} } +func (m *MsgUpdateContractStatus) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateContractStatus) ProtoMessage() {} +func (*MsgUpdateContractStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_0fd2153dc07d3b5c, []int{14} +} +func (m *MsgUpdateContractStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateContractStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateContractStatus.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateContractStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateContractStatus.Merge(m, src) +} +func (m *MsgUpdateContractStatus) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateContractStatus) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateContractStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateContractStatus proto.InternalMessageInfo + +// MsgUpdateContractStatusResponse returns empty data +type MsgUpdateContractStatusResponse struct { +} + +func (m *MsgUpdateContractStatusResponse) Reset() { *m = MsgUpdateContractStatusResponse{} } +func (m *MsgUpdateContractStatusResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateContractStatusResponse) ProtoMessage() {} +func (*MsgUpdateContractStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0fd2153dc07d3b5c, []int{15} +} +func (m *MsgUpdateContractStatusResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateContractStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateContractStatusResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateContractStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateContractStatusResponse.Merge(m, src) +} +func (m *MsgUpdateContractStatusResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateContractStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateContractStatusResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateContractStatusResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgStoreCode)(nil), "cosmwasm.wasm.v1beta1.MsgStoreCode") proto.RegisterType((*MsgStoreCodeResponse)(nil), "cosmwasm.wasm.v1beta1.MsgStoreCodeResponse") @@ -651,67 +731,73 @@ func init() { proto.RegisterType((*MsgUpdateAdminResponse)(nil), "cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse") proto.RegisterType((*MsgClearAdmin)(nil), "cosmwasm.wasm.v1beta1.MsgClearAdmin") proto.RegisterType((*MsgClearAdminResponse)(nil), "cosmwasm.wasm.v1beta1.MsgClearAdminResponse") + proto.RegisterType((*MsgUpdateContractStatus)(nil), "cosmwasm.wasm.v1beta1.MsgUpdateContractStatus") + proto.RegisterType((*MsgUpdateContractStatusResponse)(nil), "cosmwasm.wasm.v1beta1.MsgUpdateContractStatusResponse") } func init() { proto.RegisterFile("tx.proto", fileDescriptor_0fd2153dc07d3b5c) } var fileDescriptor_0fd2153dc07d3b5c = []byte{ - // 874 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x4d, 0x6f, 0xe3, 0x54, - 0x14, 0x8d, 0xeb, 0x36, 0x1f, 0x37, 0x61, 0x40, 0xa6, 0x2d, 0x96, 0x07, 0x25, 0x55, 0x06, 0x50, - 0xf9, 0xa8, 0x3d, 0x2d, 0x02, 0x84, 0x10, 0x8b, 0x24, 0xb0, 0xe8, 0xc2, 0x23, 0xe4, 0x11, 0x42, - 0x1a, 0x81, 0xc2, 0xb3, 0xfd, 0xc6, 0x3c, 0xb0, 0xdf, 0x8b, 0xfc, 0x5e, 0xa6, 0xad, 0x58, 0xf0, - 0x17, 0x58, 0xb2, 0x63, 0x8f, 0xe6, 0x6f, 0x20, 0x75, 0x39, 0x2b, 0xc4, 0x2a, 0x40, 0xba, 0xe5, - 0x17, 0xb0, 0x42, 0xfe, 0x88, 0xf3, 0x26, 0xc4, 0x19, 0x77, 0xd0, 0x6c, 0x66, 0x13, 0xf9, 0xda, - 0xe7, 0x9e, 0xfb, 0xee, 0xf1, 0xb9, 0xd7, 0x81, 0xa6, 0x38, 0x37, 0x27, 0x31, 0x13, 0x4c, 0xdb, - 0xf3, 0x18, 0x8f, 0xce, 0x10, 0x8f, 0xcc, 0xf4, 0xe7, 0xc1, 0xb1, 0x8b, 0x05, 0x3a, 0x36, 0x6e, - 0x86, 0x6e, 0x64, 0xb9, 0x88, 0x63, 0x2b, 0xbf, 0x63, 0x79, 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xff, 0x21, 0xb1, 0x98, 0x95, 0x8f, 0x0b, 0x00, 0x00, + // 934 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0x4d, 0x6f, 0xe3, 0x54, + 0x14, 0x8d, 0x9b, 0x36, 0x1f, 0x37, 0xa1, 0x20, 0xd3, 0x76, 0x2c, 0x0f, 0x4a, 0x8a, 0x87, 0x41, + 0xe5, 0xa3, 0xf6, 0x34, 0x88, 0x41, 0x08, 0xcd, 0x22, 0x09, 0x2c, 0xba, 0xf0, 0x08, 0xb9, 0x42, + 0x48, 0x23, 0x50, 0x78, 0xb6, 0xdf, 0x98, 0x07, 0xf6, 0x7b, 0x91, 0xdf, 0xcb, 0xb4, 0x15, 0x12, + 0xfc, 0x01, 0x16, 0x2c, 0xd9, 0xb1, 0x47, 0xf3, 0x37, 0x90, 0xba, 0x9c, 0x15, 0x62, 0x55, 0x20, + 0xdd, 0xf2, 0x0b, 0x58, 0x21, 0x7f, 0xc4, 0x71, 0x43, 0x9c, 0xba, 0x45, 0xb3, 0x61, 0x53, 0xf9, + 0x26, 0xe7, 0xde, 0x73, 0xef, 0xf1, 0x79, 0xf7, 0x35, 0xd0, 0x10, 0x27, 0xfa, 0x38, 0x64, 0x82, + 0xc9, 0xdb, 0x0e, 0xe3, 0xc1, 0x31, 0xe2, 0x81, 0x1e, 0xff, 0x79, 0x72, 0x60, 0x63, 0x81, 0x0e, + 0xd4, 0xdb, 0xbe, 0x1d, 0x18, 0x36, 0xe2, 0xd8, 0x48, 0x3f, 0x31, 0x1c, 0x46, 0x68, 0x92, 0xa3, + 0x6e, 0x79, 0xcc, 0x63, 0xf1, 0xa3, 0x11, 0x3d, 0xa5, 0x9f, 0xb6, 0xc4, 0xe9, 0x18, 0xf3, 0x24, + 0xd0, 0xfe, 0x92, 0xa0, 0x6d, 0x72, 0xef, 0x48, 0xb0, 0x10, 0x0f, 0x99, 0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f, 0xc5, 0xdd, 0x74, 0x62, 0x44, 0x44, 0x06, 0xa1, 0x02, 0x87, 0x14, 0xf9, + 0xc9, 0x5d, 0x65, 0xd7, 0xe2, 0x9f, 0x17, 0xef, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x74, + 0x70, 0x20, 0xc1, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -740,6 +826,8 @@ type MsgClient interface { UpdateAdmin(ctx context.Context, in *MsgUpdateAdmin, opts ...grpc.CallOption) (*MsgUpdateAdminResponse, error) // ClearAdmin removes any admin stored for a smart contract ClearAdmin(ctx context.Context, in *MsgClearAdmin, opts ...grpc.CallOption) (*MsgClearAdminResponse, error) + // UpdateContractStatus sets a new status for a smart contract + UpdateContractStatus(ctx context.Context, in *MsgUpdateContractStatus, opts ...grpc.CallOption) (*MsgUpdateContractStatusResponse, error) } type msgClient struct { @@ -813,6 +901,15 @@ func (c *msgClient) ClearAdmin(ctx context.Context, in *MsgClearAdmin, opts ...g return out, nil } +func (c *msgClient) UpdateContractStatus(ctx context.Context, in *MsgUpdateContractStatus, opts ...grpc.CallOption) (*MsgUpdateContractStatusResponse, error) { + out := new(MsgUpdateContractStatusResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/UpdateContractStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // StoreCode to submit Wasm code to the system @@ -829,6 +926,8 @@ type MsgServer interface { UpdateAdmin(context.Context, *MsgUpdateAdmin) (*MsgUpdateAdminResponse, error) // ClearAdmin removes any admin stored for a smart contract ClearAdmin(context.Context, *MsgClearAdmin) (*MsgClearAdminResponse, error) + // UpdateContractStatus sets a new status for a smart contract + UpdateContractStatus(context.Context, *MsgUpdateContractStatus) (*MsgUpdateContractStatusResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -856,6 +955,9 @@ func (*UnimplementedMsgServer) UpdateAdmin(ctx context.Context, req *MsgUpdateAd func (*UnimplementedMsgServer) ClearAdmin(ctx context.Context, req *MsgClearAdmin) (*MsgClearAdminResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClearAdmin not implemented") } +func (*UnimplementedMsgServer) UpdateContractStatus(ctx context.Context, req *MsgUpdateContractStatus) (*MsgUpdateContractStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateContractStatus not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -987,6 +1089,24 @@ func _Msg_ClearAdmin_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Msg_UpdateContractStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateContractStatus) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateContractStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/UpdateContractStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateContractStatus(ctx, req.(*MsgUpdateContractStatus)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmwasm.wasm.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -1019,6 +1139,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ClearAdmin", Handler: _Msg_ClearAdmin_Handler, }, + { + MethodName: "UpdateContractStatus", + Handler: _Msg_UpdateContractStatus_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "tx.proto", @@ -1656,6 +1780,71 @@ func (m *MsgClearAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateContractStatus) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateContractStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateContractStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateContractStatusResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateContractStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateContractStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1959,6 +2148,35 @@ func (m *MsgClearAdminResponse) Size() (n int) { return n } +func (m *MsgUpdateContractStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovTx(uint64(m.Status)) + } + return n +} + +func (m *MsgUpdateContractStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3959,6 +4177,189 @@ func (m *MsgClearAdminResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateContractStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateContractStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateContractStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ContractStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateContractStatusResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateContractStatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateContractStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/internal/types/tx.proto b/x/wasm/internal/types/tx.proto index 72d832b367..9179bd51ec 100644 --- a/x/wasm/internal/types/tx.proto +++ b/x/wasm/internal/types/tx.proto @@ -15,7 +15,8 @@ service Msg { // Instantiate creates a new smart contract instance for the given code id. rpc InstantiateContract(MsgInstantiateContract) returns (MsgInstantiateContractResponse); // Store Wasm code and Instantiate a new contract - rpc StoreCodeAndInstantiateContract(MsgStoreCodeAndInstantiateContract) returns (MsgStoreCodeAndInstantiateContractResponse); + rpc StoreCodeAndInstantiateContract(MsgStoreCodeAndInstantiateContract) + returns (MsgStoreCodeAndInstantiateContractResponse); // Execute submits the given message data to a smart contract rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse); // Migrate runs a code upgrade/ downgrade for a smart contract @@ -24,6 +25,8 @@ service Msg { rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse); // ClearAdmin removes any admin stored for a smart contract rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse); + // UpdateContractStatus sets a new status for a smart contract + rpc UpdateContractStatus(MsgUpdateContractStatus) returns (MsgUpdateContractStatusResponse); } // MsgStoreCode submit Wasm code to the system @@ -162,3 +165,16 @@ message MsgClearAdmin { // MsgClearAdminResponse returns empty data message MsgClearAdminResponse {} + +// MsgUpdateContractStatus sets a new status for a smart contract +message MsgUpdateContractStatus { + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + string contract = 2; + // Status to be set + ContractStatus status = 3; +} + +// MsgUpdateContractStatusResponse returns empty data +message MsgUpdateContractStatusResponse {} diff --git a/x/wasm/internal/types/tx_test.go b/x/wasm/internal/types/tx_test.go index f263c82ef3..0c54c3d5d2 100644 --- a/x/wasm/internal/types/tx_test.go +++ b/x/wasm/internal/types/tx_test.go @@ -707,3 +707,66 @@ func TestMsgMigrateContract(t *testing.T) { }) } } + +func TestMsgUpdateContractStatus(t *testing.T) { + bad, err := sdk.AccAddressFromHex("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + anotherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x2}, 20)).String() + + specs := map[string]struct { + src MsgUpdateContractStatus + expErr bool + }{ + "all good": { + src: MsgUpdateContractStatus{ + Sender: goodAddress, + Status: ContractStatusInactive, + Contract: anotherGoodAddress, + }, + }, + "status required": { + src: MsgUpdateContractStatus{ + Sender: goodAddress, + Contract: anotherGoodAddress, + }, + expErr: true, + }, + "bad sender": { + src: MsgUpdateContractStatus{ + Sender: badAddress, + Status: ContractStatusInactive, + Contract: anotherGoodAddress, + }, + expErr: true, + }, + "bad status": { + src: MsgUpdateContractStatus{ + Sender: goodAddress, + Status: 3, + Contract: anotherGoodAddress, + }, + expErr: true, + }, + "bad contract addr": { + src: MsgUpdateContractStatus{ + Sender: goodAddress, + Status: ContractStatusInactive, + Contract: badAddress, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/wasm/internal/types/types.go b/x/wasm/internal/types/types.go index 3ff34206ad..db43e6d419 100644 --- a/x/wasm/internal/types/types.go +++ b/x/wasm/internal/types/types.go @@ -1,9 +1,11 @@ package types import ( + "encoding/json" "fmt" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + "github.com/gogo/protobuf/jsonpb" sdk "github.com/line/lbm-sdk/v2/types" sdkerrors "github.com/line/lbm-sdk/v2/types/errors" ) @@ -14,6 +16,44 @@ const ( defaultContractDebugMode = false ) +var AllContractStatus = []ContractStatus{ + ContractStatusInactive, + ContractStatusActive, +} + +func (c ContractStatus) String() string { + switch c { + case ContractStatusActive: + return "Active" + case ContractStatusInactive: + return "Inactive" + } + return "Unspecified" +} + +func (c *ContractStatus) UnmarshalText(text []byte) error { + for _, v := range AllContractStatus { + if v.String() == string(text) { + *c = v + return nil + } + } + *c = ContractStatusUnspecified + return nil +} + +func (c ContractStatus) MarshalText() ([]byte, error) { + return []byte(c.String()), nil +} + +func (c *ContractStatus) MarshalJSONPB(_ *jsonpb.Marshaler) ([]byte, error) { + return json.Marshal(c) +} + +func (c *ContractStatus) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, data []byte) error { + return json.Unmarshal(data, c) +} + func (m Model) ValidateBasic() error { if len(m.Key) == 0 { return sdkerrors.Wrap(ErrEmpty, "key") @@ -54,7 +94,7 @@ func NewCodeInfo(codeHash []byte, creator sdk.AccAddress, source string, builder var AllCodeHistoryTypes = []ContractCodeHistoryOperationType{ContractCodeHistoryOperationTypeGenesis, ContractCodeHistoryOperationTypeInit, ContractCodeHistoryOperationTypeMigrate} // NewContractInfo creates a new instance of a given WASM contract info -func NewContractInfo(codeID uint64, creator, admin sdk.AccAddress, label string, createdAt *AbsoluteTxPosition) ContractInfo { +func NewContractInfo(codeID uint64, creator, admin sdk.AccAddress, label string, createdAt *AbsoluteTxPosition, status ContractStatus) ContractInfo { var adminAddr string if !admin.Empty() { adminAddr = admin.String() @@ -65,6 +105,7 @@ func NewContractInfo(codeID uint64, creator, admin sdk.AccAddress, label string, Admin: adminAddr, Label: label, Created: createdAt, + Status: status, } } func (c *ContractInfo) ValidateBasic() error { @@ -82,6 +123,16 @@ func (c *ContractInfo) ValidateBasic() error { if err := validateLabel(c.Label); err != nil { return sdkerrors.Wrap(err, "label") } + found := false + for _, v := range AllContractStatus { + if c.Status == v { + found = true + break + } + } + if !found || c.Status == ContractStatusUnspecified { + return sdkerrors.Wrap(ErrInvalidMsg, "invalid status") + } return nil } diff --git a/x/wasm/internal/types/types.pb.go b/x/wasm/internal/types/types.pb.go index dbc9dd4ef4..c90aa4630b 100644 --- a/x/wasm/internal/types/types.pb.go +++ b/x/wasm/internal/types/types.pb.go @@ -58,6 +58,34 @@ func (AccessType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_d938547f84707355, []int{0} } +// ContractStatus types +type ContractStatus int32 + +const ( + // ContractStatus unspecified + ContractStatusUnspecified ContractStatus = 0 + // ContractStatus active + ContractStatusActive ContractStatus = 1 + // ContractStatus inactive + ContractStatusInactive ContractStatus = 2 +) + +var ContractStatus_name = map[int32]string{ + 0: "CONTRACT_STATUS_UNSPECIFIED", + 1: "CONTRACT_STATUS_ACTIVE", + 2: "CONTRACT_STATUS_INACTIVE", +} + +var ContractStatus_value = map[string]int32{ + "CONTRACT_STATUS_UNSPECIFIED": 0, + "CONTRACT_STATUS_ACTIVE": 1, + "CONTRACT_STATUS_INACTIVE": 2, +} + +func (ContractStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_d938547f84707355, []int{1} +} + // ContractCodeHistoryOperationType actions that caused a code change type ContractCodeHistoryOperationType int32 @@ -91,7 +119,7 @@ func (x ContractCodeHistoryOperationType) String() string { } func (ContractCodeHistoryOperationType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{1} + return fileDescriptor_d938547f84707355, []int{2} } // AccessTypeParam @@ -175,10 +203,11 @@ var xxx_messageInfo_AccessConfig proto.InternalMessageInfo type Params struct { CodeUploadAccess AccessConfig `protobuf:"bytes,1,opt,name=code_upload_access,json=codeUploadAccess,proto3" json:"code_upload_access" yaml:"code_upload_access"` InstantiateDefaultPermission AccessType `protobuf:"varint,2,opt,name=instantiate_default_permission,json=instantiateDefaultPermission,proto3,enum=cosmwasm.wasm.v1beta1.AccessType" json:"instantiate_default_permission,omitempty" yaml:"instantiate_default_permission"` - MaxWasmCodeSize uint64 `protobuf:"varint,3,opt,name=max_wasm_code_size,json=maxWasmCodeSize,proto3" json:"max_wasm_code_size,omitempty" yaml:"max_wasm_code_size"` - GasMultiplier uint64 `protobuf:"varint,4,opt,name=gas_multiplier,json=gasMultiplier,proto3" json:"gas_multiplier,omitempty" yaml:"max_gas"` - InstanceCost uint64 `protobuf:"varint,5,opt,name=instance_cost,json=instanceCost,proto3" json:"instance_cost,omitempty" yaml:"instance_cost"` - CompileCost uint64 `protobuf:"varint,6,opt,name=compile_cost,json=compileCost,proto3" json:"compile_cost,omitempty" yaml:"compile_cost"` + ContractStatusAccess AccessConfig `protobuf:"bytes,3,opt,name=contract_status_access,json=contractStatusAccess,proto3" json:"contract_status_access" yaml:"contract_status_access"` + MaxWasmCodeSize uint64 `protobuf:"varint,4,opt,name=max_wasm_code_size,json=maxWasmCodeSize,proto3" json:"max_wasm_code_size,omitempty" yaml:"max_wasm_code_size"` + GasMultiplier uint64 `protobuf:"varint,5,opt,name=gas_multiplier,json=gasMultiplier,proto3" json:"gas_multiplier,omitempty" yaml:"max_gas"` + InstanceCost uint64 `protobuf:"varint,6,opt,name=instance_cost,json=instanceCost,proto3" json:"instance_cost,omitempty" yaml:"instance_cost"` + CompileCost uint64 `protobuf:"varint,7,opt,name=compile_cost,json=compileCost,proto3" json:"compile_cost,omitempty" yaml:"compile_cost"` } func (m *Params) Reset() { *m = Params{} } @@ -274,6 +303,8 @@ type ContractInfo struct { // This data should kept internal and not be exposed via query results. Just use for sorting Created *AbsoluteTxPosition `protobuf:"bytes,5,opt,name=created,proto3" json:"created,omitempty"` IBCPortID string `protobuf:"bytes,6,opt,name=ibc_port_id,json=ibcPortId,proto3" json:"ibc_port_id,omitempty"` + // Status is a status of a contract + Status ContractStatus `protobuf:"varint,7,opt,name=status,proto3,enum=cosmwasm.wasm.v1beta1.ContractStatus" json:"status,omitempty"` } func (m *ContractInfo) Reset() { *m = ContractInfo{} } @@ -436,6 +467,7 @@ var xxx_messageInfo_Model proto.InternalMessageInfo func init() { proto.RegisterEnum("cosmwasm.wasm.v1beta1.AccessType", AccessType_name, AccessType_value) + proto.RegisterEnum("cosmwasm.wasm.v1beta1.ContractStatus", ContractStatus_name, ContractStatus_value) proto.RegisterEnum("cosmwasm.wasm.v1beta1.ContractCodeHistoryOperationType", ContractCodeHistoryOperationType_name, ContractCodeHistoryOperationType_value) proto.RegisterType((*AccessTypeParam)(nil), "cosmwasm.wasm.v1beta1.AccessTypeParam") proto.RegisterType((*AccessConfig)(nil), "cosmwasm.wasm.v1beta1.AccessConfig") @@ -450,83 +482,92 @@ func init() { func init() { proto.RegisterFile("types.proto", fileDescriptor_d938547f84707355) } var fileDescriptor_d938547f84707355 = []byte{ - // 1213 bytes of a gzipped FileDescriptorProto + // 1349 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0xc6, 0x8e, 0x13, 0x4f, 0xdc, 0xd6, 0x9d, 0x26, 0xd4, 0x35, 0xc5, 0x76, 0xb7, 0x20, - 0xd2, 0x36, 0xb5, 0xdb, 0x20, 0x51, 0x11, 0x89, 0x83, 0xbd, 0x5e, 0x9a, 0x45, 0xc4, 0xb6, 0xc6, - 0x0e, 0x6d, 0x90, 0xd0, 0x6a, 0x76, 0x77, 0xe2, 0x0c, 0xdd, 0xdd, 0xb1, 0x76, 0xc6, 0xa9, 0xdd, - 0xbf, 0x00, 0x85, 0x0b, 0xe2, 0x84, 0x04, 0x91, 0x90, 0x40, 0xa8, 0x7f, 0x4a, 0x2f, 0x48, 0x3d, - 0x72, 0xb2, 0x20, 0xbd, 0xc0, 0xd5, 0xdc, 0x7a, 0x42, 0x3b, 0x6b, 0x63, 0xab, 0xbf, 0x62, 0x2e, - 0xd6, 0xbe, 0x99, 0xf7, 0x7d, 0x6f, 0xbe, 0x6f, 0xde, 0xf3, 0x2e, 0x58, 0x11, 0x83, 0x2e, 0xe1, - 0xa5, 0x6e, 0xc0, 0x04, 0x83, 0x6b, 0x36, 0xe3, 0xde, 0x43, 0xcc, 0xbd, 0x92, 0xfc, 0x39, 0xbc, - 0x6d, 0x11, 0x81, 0x6f, 0xe7, 0x56, 0x3b, 0xac, 0xc3, 0x64, 0x46, 0x39, 0x7c, 0x8a, 0x92, 0x55, - 0x0b, 0x9c, 0xab, 0xd8, 0x36, 0xe1, 0xbc, 0x3d, 0xe8, 0x92, 0x26, 0x0e, 0xb0, 0x07, 0x0d, 0xb0, - 0x78, 0x88, 0xdd, 0x1e, 0xc9, 0x2a, 0x45, 0x65, 0xfd, 0xec, 0xe6, 0x95, 0xd2, 0x2b, 0xf9, 0x4a, - 0x53, 0x58, 0x35, 0x33, 0x1a, 0x16, 0xd2, 0x03, 0xec, 0xb9, 0x5b, 0xaa, 0x44, 0xaa, 0x28, 0x62, - 0xd8, 0x4a, 0x7c, 0xff, 0x53, 0x41, 0x51, 0x7f, 0x54, 0x40, 0x3a, 0xca, 0xd6, 0x98, 0xbf, 0x4f, - 0x3b, 0xf0, 0x3e, 0x00, 0x5d, 0x12, 0x78, 0x94, 0x73, 0xca, 0xfc, 0xf9, 0xcb, 0xac, 0x8d, 0x86, - 0x85, 0xf3, 0x51, 0x99, 0x29, 0x5c, 0x45, 0x33, 0x5c, 0x70, 0x03, 0x2c, 0x61, 0xc7, 0x09, 0x08, - 0xe7, 0xd9, 0x85, 0xa2, 0xb2, 0x9e, 0xaa, 0xc2, 0xd1, 0xb0, 0x70, 0x36, 0xc2, 0x8c, 0x37, 0x54, - 0x34, 0x49, 0x19, 0x1f, 0xef, 0x87, 0x04, 0x48, 0x4a, 0xe5, 0x1c, 0x0a, 0x00, 0x6d, 0xe6, 0x10, - 0xb3, 0xd7, 0x75, 0x19, 0x76, 0x4c, 0x2c, 0x6b, 0xcb, 0x03, 0xae, 0x6c, 0x5e, 0x7d, 0xe3, 0x01, - 0x23, 0x65, 0xd5, 0x2b, 0x4f, 0x86, 0x85, 0xd8, 0x68, 0x58, 0xb8, 0x14, 0x95, 0x7c, 0x99, 0x4c, - 0x45, 0x99, 0x70, 0x71, 0x57, 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3e, 0x83, 0x6f, 0x83, 0x94, - 0xd4, 0x79, 0x80, 0xf9, 0x81, 0x6c, 0x8b, 0x34, 0x5a, 0x0e, 0x17, 0xb6, 0x31, 0x3f, 0x80, 0x59, - 0xb0, 0x64, 0x07, 0x04, 0x0b, 0x16, 0x44, 0xbd, 0x87, 0x26, 0x21, 0x7c, 0x0b, 0x24, 0x39, 0xeb, - 0x05, 0x76, 0xe4, 0x5f, 0x0a, 0x8d, 0xa3, 0x10, 0x61, 0xf5, 0xa8, 0xeb, 0x8c, 0x0d, 0x49, 0xa1, - 0x49, 0x08, 0xef, 0x03, 0x38, 0x7b, 0x7d, 0xb6, 0xec, 0x2e, 0xa9, 0x7d, 0xce, 0x46, 0x4c, 0x84, - 0x8d, 0x88, 0xce, 0xcf, 0x90, 0x44, 0x1b, 0xea, 0x3f, 0x0a, 0x48, 0x6b, 0xcc, 0x17, 0x01, 0xb6, - 0x85, 0xd4, 0x74, 0x15, 0x2c, 0x49, 0x4d, 0xd4, 0x91, 0x8a, 0x12, 0x55, 0x70, 0x32, 0x2c, 0x24, - 0xa5, 0xe4, 0x1a, 0x4a, 0x86, 0x5b, 0x86, 0xf3, 0x06, 0x6d, 0xab, 0x60, 0x11, 0x3b, 0x1e, 0xf5, - 0xc7, 0xd2, 0xa2, 0x20, 0x5c, 0x75, 0xb1, 0x45, 0xdc, 0xb1, 0xae, 0x28, 0x80, 0xda, 0x98, 0x85, - 0x38, 0x63, 0x29, 0xd7, 0x5e, 0x27, 0xc5, 0xe2, 0xcc, 0xed, 0x09, 0xd2, 0xee, 0x37, 0x19, 0xa7, - 0x82, 0x32, 0x1f, 0x4d, 0x90, 0xf0, 0x26, 0x58, 0xa1, 0x96, 0x6d, 0x76, 0x59, 0x20, 0xc2, 0x33, - 0x27, 0xe5, 0x98, 0x9f, 0x39, 0x19, 0x16, 0x52, 0x46, 0x55, 0x6b, 0xb2, 0x40, 0x18, 0x35, 0x94, - 0xa2, 0x96, 0x2d, 0x1f, 0x9d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0x27, 0x43, 0x9f, 0xdf, 0x3c, 0x7e, 0x98, 0xed, 0x5a, 0xe3, 0x06, 0xb7, 0x1e, 0x66, + 0xf7, 0xd7, 0xb2, 0xed, 0xac, 0x77, 0x63, 0x65, 0xa9, 0x23, 0x88, 0xeb, 0x60, 0x3b, 0x2b, 0xff, + 0x56, 0xd7, 0x22, 0xf2, 0xaf, 0xf2, 0x7b, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xac, 0x3d, 0x57, + 0xeb, 0x66, 0x0b, 0x00, 0x00, } func (this *AccessTypeParam) Equal(that interface{}) bool { @@ -605,6 +646,9 @@ func (this *Params) Equal(that interface{}) bool { if this.InstantiateDefaultPermission != that1.InstantiateDefaultPermission { return false } + if !this.ContractStatusAccess.Equal(&that1.ContractStatusAccess) { + return false + } if this.MaxWasmCodeSize != that1.MaxWasmCodeSize { return false } @@ -692,6 +736,9 @@ func (this *ContractInfo) Equal(that interface{}) bool { if this.IBCPortID != that1.IBCPortID { return false } + if this.Status != that1.Status { + return false + } return true } func (this *ContractCodeHistoryEntry) Equal(that interface{}) bool { @@ -867,23 +914,33 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.CompileCost != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.CompileCost)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.InstanceCost != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.InstanceCost)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if m.GasMultiplier != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.GasMultiplier)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.MaxWasmCodeSize != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.MaxWasmCodeSize)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } + { + size, err := m.ContractStatusAccess.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a if m.InstantiateDefaultPermission != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.InstantiateDefaultPermission)) i-- @@ -983,6 +1040,11 @@ func (m *ContractInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Status != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x38 + } if len(m.IBCPortID) > 0 { i -= len(m.IBCPortID) copy(dAtA[i:], m.IBCPortID) @@ -1203,6 +1265,8 @@ func (m *Params) Size() (n int) { if m.InstantiateDefaultPermission != 0 { n += 1 + sovTypes(uint64(m.InstantiateDefaultPermission)) } + l = m.ContractStatusAccess.Size() + n += 1 + l + sovTypes(uint64(l)) if m.MaxWasmCodeSize != 0 { n += 1 + sovTypes(uint64(m.MaxWasmCodeSize)) } @@ -1274,6 +1338,9 @@ func (m *ContractInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + if m.Status != 0 { + n += 1 + sovTypes(uint64(m.Status)) + } return n } @@ -1590,6 +1657,39 @@ func (m *Params) Unmarshal(dAtA []byte) error { } } case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractStatusAccess", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ContractStatusAccess.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxWasmCodeSize", wireType) } @@ -1608,7 +1708,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GasMultiplier", wireType) } @@ -1627,7 +1727,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field InstanceCost", wireType) } @@ -1646,7 +1746,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CompileCost", wireType) } @@ -2111,6 +2211,25 @@ func (m *ContractInfo) Unmarshal(dAtA []byte) error { } m.IBCPortID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ContractStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/x/wasm/internal/types/types.proto b/x/wasm/internal/types/types.proto index 6b4bfd7379..6751bd6c20 100644 --- a/x/wasm/internal/types/types.proto +++ b/x/wasm/internal/types/types.proto @@ -21,6 +21,19 @@ enum AccessType { ACCESS_TYPE_EVERYBODY = 3 [(gogoproto.enumvalue_customname) = "AccessTypeEverybody"]; } +// ContractStatus types +enum ContractStatus { + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.goproto_enum_stringer) = false; + + // ContractStatus unspecified + CONTRACT_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "ContractStatusUnspecified"]; + // ContractStatus active + CONTRACT_STATUS_ACTIVE = 1 [(gogoproto.enumvalue_customname) = "ContractStatusActive"]; + // ContractStatus inactive + CONTRACT_STATUS_INACTIVE = 2 [(gogoproto.enumvalue_customname) = "ContractStatusInactive"]; +} + // AccessTypeParam message AccessTypeParam { option (gogoproto.goproto_stringer) = true; @@ -39,11 +52,13 @@ message Params { option (gogoproto.goproto_stringer) = false; AccessConfig code_upload_access = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"code_upload_access\""]; - AccessType instantiate_default_permission = 2 [(gogoproto.moretags) = "yaml:\"instantiate_default_permission\""]; - uint64 max_wasm_code_size = 3 [(gogoproto.moretags) = "yaml:\"max_wasm_code_size\""]; - uint64 gas_multiplier = 4 [(gogoproto.moretags) = "yaml:\"max_gas\""]; - uint64 instance_cost = 5 [(gogoproto.moretags) = "yaml:\"instance_cost\""]; - uint64 compile_cost = 6 [(gogoproto.moretags) = "yaml:\"compile_cost\""]; + AccessType instantiate_default_permission = 2 [(gogoproto.moretags) = "yaml:\"instantiate_default_permission\""]; + AccessConfig contract_status_access = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"contract_status_access\""]; + uint64 max_wasm_code_size = 4 [(gogoproto.moretags) = "yaml:\"max_wasm_code_size\""]; + uint64 gas_multiplier = 5 [(gogoproto.moretags) = "yaml:\"max_gas\""]; + uint64 instance_cost = 6 [(gogoproto.moretags) = "yaml:\"instance_cost\""]; + uint64 compile_cost = 7 [(gogoproto.moretags) = "yaml:\"compile_cost\""]; } // CodeInfo is data for the uploaded contract WASM code @@ -76,6 +91,8 @@ message ContractInfo { // This data should kept internal and not be exposed via query results. Just use for sorting AbsoluteTxPosition created = 5; string ibc_port_id = 6 [(gogoproto.customname) = "IBCPortID"]; + // Status is a status of a contract + ContractStatus status = 7; } // ContractCodeHistoryOperationType actions that caused a code change diff --git a/x/wasm/internal/types/types_test.go b/x/wasm/internal/types/types_test.go index 53a9d2170a..86da8de7df 100644 --- a/x/wasm/internal/types/types_test.go +++ b/x/wasm/internal/types/types_test.go @@ -41,6 +41,14 @@ func TestContractInfoValidateBasic(t *testing.T) { srcMutator: func(c *ContractInfo) { c.Label = strings.Repeat("a", MaxLabelSize+1) }, expError: true, }, + "empty status": { + srcMutator: func(c *ContractInfo) { c.Status = 0 }, + expError: true, + }, + "invalid status": { + srcMutator: func(c *ContractInfo) { c.Status = 3 }, + expError: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) {