From 72710effca8e8583c9a3f96ef1e67a4174a25a21 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 1 Apr 2022 09:04:38 -0600 Subject: [PATCH 01/13] add UpdateInstantiateConfig gov proposal --- Makefile | 2 +- docs/proto/proto-docs.md | 20 ++ proto/cosmwasm/wasm/v1/proposal.proto | 16 + x/wasm/keeper/contract_keeper.go | 6 + x/wasm/keeper/keeper.go | 11 + x/wasm/keeper/proposal_handler.go | 14 + x/wasm/types/codec.go | 2 + x/wasm/types/exported_keepers.go | 3 + x/wasm/types/proposal.go | 58 ++- x/wasm/types/proposal.pb.go | 496 +++++++++++++++++++++++--- 10 files changed, 570 insertions(+), 58 deletions(-) diff --git a/Makefile b/Makefile index fa00a49f6a..fe48b7905a 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SIMAPP = ./app # for dockerized protobuf tools DOCKER := $(shell which docker) -BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0 +BUF_IMAGE=bufbuild/buf:1.0.0-rc8 DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE) HTTPS_GIT := https://github.com/CosmWasm/wasmd.git diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index d293dce932..402f028fd7 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -54,6 +54,7 @@ - [SudoContractProposal](#cosmwasm.wasm.v1.SudoContractProposal) - [UnpinCodesProposal](#cosmwasm.wasm.v1.UnpinCodesProposal) - [UpdateAdminProposal](#cosmwasm.wasm.v1.UpdateAdminProposal) + - [UpdateInstantiateConfigProposal](#cosmwasm.wasm.v1.UpdateInstantiateConfigProposal) - [cosmwasm/wasm/v1/query.proto](#cosmwasm/wasm/v1/query.proto) - [CodeInfoResponse](#cosmwasm.wasm.v1.CodeInfoResponse) @@ -814,6 +815,25 @@ UpdateAdminProposal gov proposal content type to set an admin for a contract. + + + +### UpdateInstantiateConfigProposal +UpdateInstantiateConfigProposal gov proposal content type to update +instantiate config to a set of code ids. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `title` | [string](#string) | | Title is a short summary | +| `description` | [string](#string) | | Description is a human readable text | +| `code_ids` | [uint64](#uint64) | repeated | CodeIDs references the WASM codes | +| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids | + + + + + diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index 98318128c3..8baf31c96a 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -148,3 +148,19 @@ message UnpinCodesProposal { (gogoproto.moretags) = "yaml:\"code_ids\"" ]; } + +// UpdateInstantiateConfigProposal gov proposal content type to update +// instantiate config to a set of code ids. +message UpdateInstantiateConfigProposal { + // Title is a short summary + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + // Description is a human readable text + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + // CodeIDs references the WASM codes + repeated uint64 code_ids = 3 [ + (gogoproto.customname) = "CodeIDs", + (gogoproto.moretags) = "yaml:\"code_ids\"" + ]; + // InstantiatePermission to apply to the set of code ids + AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ]; +} diff --git a/x/wasm/keeper/contract_keeper.go b/x/wasm/keeper/contract_keeper.go index ffdcc91895..9dc0a4be9d 100644 --- a/x/wasm/keeper/contract_keeper.go +++ b/x/wasm/keeper/contract_keeper.go @@ -19,6 +19,7 @@ type decoratedKeeper interface { execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) setContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error + setAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error } type PermissionedKeeper struct { @@ -78,3 +79,8 @@ func (p PermissionedKeeper) UnpinCode(ctx sdk.Context, codeID uint64) error { func (p PermissionedKeeper) SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error { return p.nested.setContractInfoExtension(ctx, contract, extra) } + +// SetAccessConfig updates the access config of a code id. +func (p PermissionedKeeper) SetAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error { + return p.nested.setAccessConfig(ctx, codeID, config) +} diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index a42d16aa2d..5dbd5483f7 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -833,6 +833,17 @@ func (k Keeper) setContractInfoExtension(ctx sdk.Context, contractAddr sdk.AccAd return nil } +// setAccessConfig updates the access config of a code id. +func (k Keeper) setAccessConfig(ctx sdk.Context, codeID uint64, config types.AccessConfig) error { + info := k.GetCodeInfo(ctx, codeID) + if info == nil { + return sdkerrors.Wrap(types.ErrNotFound, "code info") + } + info.InstantiateConfig = config + k.storeCodeInfo(ctx, codeID, *info) + return nil +} + // handleContractResponse processes the contract response data by emitting events and sending sub-/messages. func (k *Keeper) handleContractResponse( ctx sdk.Context, diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index ddc94a23bb..4e1833e115 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -47,6 +47,8 @@ func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []t return handlePinCodesProposal(ctx, k, *c) case *types.UnpinCodesProposal: return handleUnpinCodesProposal(ctx, k, *c) + case *types.UpdateInstantiateConfigProposal: + return handleUpdateInstantiateConfigProposal(ctx, k, *c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized wasm proposal content type: %T", c) } @@ -221,3 +223,15 @@ func handleUnpinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type } return nil } + +func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.UpdateInstantiateConfigProposal) error { + if err := p.ValidateBasic(); err != nil { + return err + } + for _, v := range p.CodeIDs { + if err := k.SetAccessConfig(ctx, v, p.InstantiatePermission); err != nil { + return sdkerrors.Wrapf(err, "code id: %d", v) + } + } + return nil +} diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go index 1d2114a576..e7e578b7f8 100644 --- a/x/wasm/types/codec.go +++ b/x/wasm/types/codec.go @@ -27,6 +27,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { //nolint:staticcheck cdc.RegisterConcrete(&ExecuteContractProposal{}, "wasm/ExecuteContractProposal", nil) cdc.RegisterConcrete(&UpdateAdminProposal{}, "wasm/UpdateAdminProposal", nil) cdc.RegisterConcrete(&ClearAdminProposal{}, "wasm/ClearAdminProposal", nil) + cdc.RegisterConcrete(&UpdateInstantiateConfigProposal{}, "wasm/UpdateInstantiateConfigProposal", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { @@ -52,6 +53,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &ClearAdminProposal{}, &PinCodesProposal{}, &UnpinCodesProposal{}, + &UpdateInstantiateConfigProposal{}, ) registry.RegisterInterface("ContractInfoExtension", (*ContractInfoExtension)(nil)) diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index 515b946fa8..c48a3615c5 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -53,6 +53,9 @@ type ContractOpsKeeper interface { // SetContractInfoExtension updates the extension point data that is stored with the contract info SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra ContractInfoExtension) error + + // SetAccessConfig updates the access config of a code id. + SetAccessConfig(ctx sdk.Context, codeID uint64, config AccessConfig) error } // IBCContractKeeper IBC lifecycle event handler diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 77bf7d0636..d85c7235a0 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -13,15 +13,16 @@ import ( type ProposalType string const ( - ProposalTypeStoreCode ProposalType = "StoreCode" - ProposalTypeInstantiateContract ProposalType = "InstantiateContract" - ProposalTypeMigrateContract ProposalType = "MigrateContract" - ProposalTypeSudoContract ProposalType = "SudoContract" - ProposalTypeExecuteContract ProposalType = "ExecuteContract" - ProposalTypeUpdateAdmin ProposalType = "UpdateAdmin" - ProposalTypeClearAdmin ProposalType = "ClearAdmin" - ProposalTypePinCodes ProposalType = "PinCodes" - ProposalTypeUnpinCodes ProposalType = "UnpinCodes" + ProposalTypeStoreCode ProposalType = "StoreCode" + ProposalTypeInstantiateContract ProposalType = "InstantiateContract" + ProposalTypeMigrateContract ProposalType = "MigrateContract" + ProposalTypeSudoContract ProposalType = "SudoContract" + ProposalTypeExecuteContract ProposalType = "ExecuteContract" + ProposalTypeUpdateAdmin ProposalType = "UpdateAdmin" + ProposalTypeClearAdmin ProposalType = "ClearAdmin" + ProposalTypePinCodes ProposalType = "PinCodes" + ProposalTypeUnpinCodes ProposalType = "UnpinCodes" + ProposalTypeUpdateInstantiateConfig ProposalType = "UpdateInstantiateConfig" ) // DisableAllProposals contains no wasm gov types. @@ -77,6 +78,7 @@ func init() { // register new content types with the sdk govtypes.RegisterProposalTypeCodec(&ClearAdminProposal{}, "wasm/ClearAdminProposal") govtypes.RegisterProposalTypeCodec(&PinCodesProposal{}, "wasm/PinCodesProposal") govtypes.RegisterProposalTypeCodec(&UnpinCodesProposal{}, "wasm/UnpinCodesProposal") + govtypes.RegisterProposalTypeCodec(&UpdateInstantiateConfigProposal{}, "wasm/UpdateInstantiateConfigProposal") } // ProposalRoute returns the routing key of a parameter change proposal. @@ -546,3 +548,41 @@ func validateProposalCommons(title, description string) error { } return nil } + +// ProposalRoute returns the routing key of a parameter change proposal. +func (p UpdateInstantiateConfigProposal) ProposalRoute() string { return RouterKey } + +// GetTitle returns the title of the proposal +func (p *UpdateInstantiateConfigProposal) GetTitle() string { return p.Title } + +// GetDescription returns the human readable description of the proposal +func (p UpdateInstantiateConfigProposal) GetDescription() string { return p.Description } + +// ProposalType returns the type +func (p UpdateInstantiateConfigProposal) ProposalType() string { + return string(ProposalTypeUpdateInstantiateConfig) +} + +// ValidateBasic validates the proposal +func (p UpdateInstantiateConfigProposal) ValidateBasic() error { + if err := validateProposalCommons(p.Title, p.Description); err != nil { + return err + } + if len(p.CodeIDs) == 0 { + return sdkerrors.Wrap(ErrEmpty, "code ids") + } + if err := p.InstantiatePermission.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "instantiate permission") + } + return nil +} + +// String implements the Stringer interface. +func (p UpdateInstantiateConfigProposal) String() string { + return fmt.Sprintf(`Update Instantiate Config Proposal: + Title: %s + Description: %s + Codes: %v + InstantiatePermission: %v +`, p.Title, p.Description, p.CodeIDs, p.InstantiatePermission) +} diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index 8d9c2a2402..aa3e58273c 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -438,6 +438,51 @@ func (m *UnpinCodesProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UnpinCodesProposal proto.InternalMessageInfo +// UpdateInstantiateConfigProposal gov proposal content type to update +// instantiate config to a set of code ids. +type UpdateInstantiateConfigProposal struct { + // Title is a short summary + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + // Description is a human readable text + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // CodeIDs references the WASM codes + CodeIDs []uint64 `protobuf:"varint,3,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` + // InstantiatePermission to apply to the set of code ids + InstantiatePermission AccessConfig `protobuf:"bytes,4,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission"` +} + +func (m *UpdateInstantiateConfigProposal) Reset() { *m = UpdateInstantiateConfigProposal{} } +func (*UpdateInstantiateConfigProposal) ProtoMessage() {} +func (*UpdateInstantiateConfigProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_be6422d717c730cb, []int{9} +} +func (m *UpdateInstantiateConfigProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateInstantiateConfigProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateInstantiateConfigProposal.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 *UpdateInstantiateConfigProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateInstantiateConfigProposal.Merge(m, src) +} +func (m *UpdateInstantiateConfigProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateInstantiateConfigProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateInstantiateConfigProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateInstantiateConfigProposal proto.InternalMessageInfo + func init() { proto.RegisterType((*StoreCodeProposal)(nil), "cosmwasm.wasm.v1.StoreCodeProposal") proto.RegisterType((*InstantiateContractProposal)(nil), "cosmwasm.wasm.v1.InstantiateContractProposal") @@ -448,59 +493,62 @@ func init() { proto.RegisterType((*ClearAdminProposal)(nil), "cosmwasm.wasm.v1.ClearAdminProposal") proto.RegisterType((*PinCodesProposal)(nil), "cosmwasm.wasm.v1.PinCodesProposal") proto.RegisterType((*UnpinCodesProposal)(nil), "cosmwasm.wasm.v1.UnpinCodesProposal") + proto.RegisterType((*UpdateInstantiateConfigProposal)(nil), "cosmwasm.wasm.v1.UpdateInstantiateConfigProposal") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 737 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xc1, 0x6e, 0xd3, 0x4a, - 0x14, 0x8d, 0x9b, 0xc4, 0x49, 0xa7, 0xd1, 0x7b, 0x79, 0x7e, 0x69, 0x1b, 0x0a, 0xb2, 0x23, 0x23, - 0x55, 0xde, 0x60, 0x93, 0x22, 0x21, 0x60, 0x17, 0x07, 0x16, 0xad, 0xa8, 0x54, 0xb9, 0xaa, 0x2a, - 0xb1, 0x89, 0x26, 0xf6, 0x34, 0xb5, 0x88, 0x67, 0x2c, 0xcf, 0xa4, 0x69, 0xfe, 0x02, 0x24, 0x96, - 0x7c, 0x00, 0x62, 0x83, 0xd8, 0xf3, 0x01, 0x15, 0xab, 0x2e, 0xbb, 0x32, 0x34, 0xfd, 0x83, 0x2c, - 0x91, 0x90, 0xd0, 0x78, 0x9c, 0x90, 0x16, 0xd4, 0x82, 0x68, 0x16, 0x6c, 0x9c, 0x5c, 0xdf, 0x73, - 0xe7, 0x1c, 0x1f, 0x9d, 0xab, 0x01, 0x9a, 0x4b, 0x68, 0xd0, 0x87, 0x34, 0xb0, 0x92, 0xc7, 0x41, - 0xdd, 0x0a, 0x23, 0x12, 0x12, 0x0a, 0xbb, 0x66, 0x18, 0x11, 0x46, 0x94, 0xf2, 0x18, 0x60, 0x26, - 0x8f, 0x83, 0xfa, 0x4a, 0xa5, 0x43, 0x3a, 0x24, 0x69, 0x5a, 0xfc, 0x9f, 0xc0, 0xad, 0xa8, 0x1c, - 0x47, 0xa8, 0xd5, 0x86, 0x14, 0x59, 0x07, 0xf5, 0x36, 0x62, 0xb0, 0x6e, 0xb9, 0xc4, 0xc7, 0x69, - 0xff, 0xd6, 0x0f, 0x44, 0x6c, 0x10, 0x22, 0x2a, 0xba, 0xfa, 0x57, 0x09, 0xfc, 0xb7, 0xcd, 0x48, - 0x84, 0x9a, 0xc4, 0x43, 0x5b, 0xa9, 0x02, 0xa5, 0x02, 0xf2, 0xcc, 0x67, 0x5d, 0x54, 0x95, 0x6a, - 0x92, 0x31, 0xef, 0x88, 0x42, 0xa9, 0x81, 0x05, 0x0f, 0x51, 0x37, 0xf2, 0x43, 0xe6, 0x13, 0x5c, - 0x9d, 0x4b, 0x7a, 0xd3, 0xaf, 0x94, 0x45, 0x20, 0x47, 0x3d, 0xdc, 0x82, 0xb4, 0x9a, 0x15, 0x83, - 0x51, 0x0f, 0x37, 0xa8, 0x72, 0x1f, 0xfc, 0xc3, 0xb9, 0x5b, 0xed, 0x01, 0x43, 0x2d, 0x97, 0x78, - 0xa8, 0x9a, 0xab, 0x49, 0x46, 0xc9, 0x2e, 0x0f, 0x63, 0xad, 0xb4, 0xdb, 0xd8, 0xde, 0xb4, 0x07, - 0x2c, 0x11, 0xe0, 0x94, 0x38, 0x6e, 0x5c, 0x29, 0x3b, 0x60, 0xc9, 0xc7, 0x94, 0x41, 0xcc, 0x7c, - 0xc8, 0x50, 0x2b, 0x44, 0x51, 0xe0, 0x53, 0xca, 0xb9, 0x0b, 0x35, 0xc9, 0x58, 0x58, 0x53, 0xcd, - 0x8b, 0x1e, 0x99, 0x0d, 0xd7, 0x45, 0x94, 0x36, 0x09, 0xde, 0xf3, 0x3b, 0xce, 0xe2, 0xd4, 0xf4, - 0xd6, 0x64, 0x78, 0x23, 0x57, 0xcc, 0x97, 0xe5, 0x8d, 0x5c, 0x51, 0x2e, 0x17, 0xf4, 0x8f, 0x73, - 0xe0, 0xe6, 0xfa, 0x77, 0x54, 0x93, 0x60, 0x16, 0x41, 0x97, 0xcd, 0xca, 0x89, 0x0a, 0xc8, 0x43, - 0x2f, 0xf0, 0x71, 0x62, 0xc0, 0xbc, 0x23, 0x0a, 0xe5, 0x36, 0x28, 0x70, 0x57, 0x5a, 0xbe, 0x57, - 0xcd, 0xd7, 0x24, 0x23, 0x67, 0x83, 0x61, 0xac, 0xc9, 0xdc, 0x82, 0xf5, 0xc7, 0x8e, 0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xe8, 0x8c, 0x03, 0x08, 0x00, - 0x00, + // 774 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x16, 0x25, 0x8a, 0x92, 0xd7, 0x42, 0xab, 0xb2, 0xb2, 0xad, 0xba, 0x05, 0x29, 0xb0, 0x80, + 0xc1, 0x4b, 0xc9, 0xca, 0x05, 0x8a, 0xb6, 0x37, 0x51, 0xed, 0xc1, 0x46, 0x0d, 0x18, 0x34, 0x0c, + 0x03, 0xed, 0x41, 0x58, 0x91, 0x6b, 0x9a, 0x88, 0xc8, 0x25, 0xb8, 0x2b, 0xcb, 0x7a, 0x8b, 0x04, + 0xc8, 0x2d, 0x79, 0x80, 0x20, 0x97, 0x20, 0xf7, 0x3c, 0x80, 0x91, 0x93, 0x8f, 0x3e, 0x31, 0xb1, + 0xfc, 0x06, 0x3a, 0x06, 0x08, 0x10, 0x2c, 0x97, 0x52, 0x64, 0x27, 0xfe, 0x09, 0x62, 0x1d, 0x7c, + 0xa1, 0x34, 0x3b, 0x33, 0x3b, 0xdf, 0x7e, 0xf8, 0x3e, 0xec, 0x02, 0xd5, 0xc1, 0x24, 0x18, 0x40, + 0x12, 0x98, 0xe9, 0xe7, 0xb0, 0x69, 0x46, 0x31, 0x8e, 0x30, 0x81, 0x3d, 0x23, 0x8a, 0x31, 0xc5, + 0x72, 0x75, 0x52, 0x60, 0xa4, 0x9f, 0xc3, 0xe6, 0x6a, 0xcd, 0xc3, 0x1e, 0x4e, 0x93, 0x26, 0xfb, + 0xc7, 0xeb, 0x56, 0x15, 0x56, 0x87, 0x89, 0xd9, 0x85, 0x04, 0x99, 0x87, 0xcd, 0x2e, 0xa2, 0xb0, + 0x69, 0x3a, 0xd8, 0x0f, 0xb3, 0xfc, 0x4f, 0x9f, 0x0c, 0xa2, 0xc3, 0x08, 0x11, 0x9e, 0xd5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 0x23, 0x17, + 0x52, 0xd4, 0x62, 0x0e, 0xfa, 0x6a, 0x3e, 0x9a, 0x60, 0x21, 0x44, 0x83, 0x0e, 0xf7, 0x66, 0x4a, + 0x89, 0x55, 0x1b, 0x27, 0x6a, 0x75, 0x08, 0x83, 0xde, 0x5f, 0xda, 0x34, 0xa5, 0xd9, 0xe5, 0x10, + 0x0d, 0xd2, 0x91, 0xd7, 0x71, 0xa5, 0x1d, 0x00, 0xb9, 0xdd, 0x43, 0x30, 0xbe, 0x1b, 0x70, 0xd7, + 0xc8, 0x48, 0x7b, 0x21, 0x80, 0xea, 0xb6, 0x1f, 0x32, 0xcd, 0x93, 0xe9, 0xa0, 0xb5, 0x0b, 0x83, + 0xac, 0xea, 0x38, 0x51, 0x2b, 0xfc, 0x24, 0xe9, 0xb2, 0x36, 0x19, 0xfd, 0xc7, 0x67, 0x46, 0x5b, + 0xcb, 0xe3, 0x44, 0x95, 0x79, 0xf5, 0x4c, 0x52, 0xbb, 0x08, 0xe9, 0x4f, 0x06, 0x29, 0x75, 0x1e, + 0x53, 0x50, 0x41, 0x17, 0x2d, 0x65, 0x94, 0xa8, 0x25, 0x6e, 0x3d, 0x32, 0x4e, 0xd4, 0x6f, 0xf9, + 0x0e, 0x93, 0x22, 0xcd, 0x2e, 0x71, 0x3b, 0x12, 0xed, 0xa5, 0x00, 0xe4, 0xdd, 0x30, 0xba, 0x57, + 0x98, 0x9f, 0xe4, 0x81, 0xca, 0xe5, 0x76, 0xf1, 0xae, 0xd8, 0xf7, 0xbd, 0x7b, 0x71, 0x00, 0xf9, + 0xff, 0x2b, 0x6f, 0x52, 0xf1, 0x36, 0x37, 0xa9, 0x25, 0x32, 0xa3, 0x5e, 0x71, 0x9f, 0x5a, 0xff, + 0x1e, 0x9f, 0x29, 0xb9, 0xd3, 0x33, 0x25, 0xf7, 0x6c, 0xa4, 0x08, 0xc7, 0x23, 0x45, 0x38, 0x19, + 0x29, 0xc2, 0xdb, 0x91, 0x22, 0x3c, 0x3c, 0x57, 0x72, 0x27, 0xe7, 0x4a, 0xee, 0xf4, 0x5c, 0xc9, + 0xfd, 0xb7, 0x36, 0xe3, 0xf1, 0x36, 0x26, 0xc1, 0xde, 0xe4, 0x49, 0xe2, 0x9a, 0x47, 0xfc, 0x69, + 0x92, 0xfa, 0xbc, 0x2b, 0xa5, 0x0f, 0x93, 0xdf, 0x3e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xb8, + 0x86, 0x60, 0x21, 0x09, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -835,6 +883,44 @@ func (this *UnpinCodesProposal) Equal(that interface{}) bool { } return true } +func (this *UpdateInstantiateConfigProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UpdateInstantiateConfigProposal) + if !ok { + that2, ok := that.(UpdateInstantiateConfigProposal) + 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 len(this.CodeIDs) != len(that1.CodeIDs) { + return false + } + for i := range this.CodeIDs { + if this.CodeIDs[i] != that1.CodeIDs[i] { + return false + } + } + if !this.InstantiatePermission.Equal(&that1.InstantiatePermission) { + return false + } + return true +} func (m *StoreCodeProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1366,6 +1452,71 @@ func (m *UnpinCodesProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *UpdateInstantiateConfigProposal) 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 *UpdateInstantiateConfigProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.InstantiatePermission.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.CodeIDs) > 0 { + dAtA8 := make([]byte, len(m.CodeIDs)*10) + var j7 int + for _, num := range m.CodeIDs { + for num >= 1<<7 { + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j7++ + } + dAtA8[j7] = uint8(num) + j7++ + } + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintProposal(dAtA, i, uint64(j7)) + 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 @@ -1630,6 +1781,32 @@ func (m *UnpinCodesProposal) Size() (n int) { return n } +func (m *UpdateInstantiateConfigProposal) 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)) + } + if len(m.CodeIDs) > 0 { + l = 0 + for _, e := range m.CodeIDs { + l += sovProposal(uint64(e)) + } + n += 1 + sovProposal(uint64(l)) + l + } + l = m.InstantiatePermission.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + func sovProposal(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3478,6 +3655,229 @@ func (m *UnpinCodesProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpdateInstantiateConfigProposal) 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: UpdateInstantiateConfigProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateInstantiateConfigProposal: 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 == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.CodeIDs) == 0 { + m.CodeIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field CodeIDs", wireType) + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 From e490a5ed2fd7334abf487f264de6c05074774299 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 3 May 2022 09:25:29 -0600 Subject: [PATCH 02/13] fix Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fe48b7905a..fa00a49f6a 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SIMAPP = ./app # for dockerized protobuf tools DOCKER := $(shell which docker) -BUF_IMAGE=bufbuild/buf:1.0.0-rc8 +BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0 DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE) HTTPS_GIT := https://github.com/CosmWasm/wasmd.git From cd76a61bcfd4f96304ef55dc45bb3d9ffb0a2633 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 4 May 2022 13:04:05 -0600 Subject: [PATCH 03/13] update UpdateInstantiateConfigProposal proto definition --- Makefile | 2 +- docs/proto/proto-docs.md | 21 +- proto/cosmwasm/wasm/v1/proposal.proto | 20 +- x/wasm/keeper/proposal_handler.go | 7 +- x/wasm/types/proposal.go | 23 +- x/wasm/types/proposal.pb.go | 457 +++++++++++++++++--------- 6 files changed, 346 insertions(+), 184 deletions(-) diff --git a/Makefile b/Makefile index fa00a49f6a..1b63ca4883 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,7 @@ proto-lint: @$(DOCKER_BUF) lint --error-format=json proto-check-breaking: - @$(DOCKER_BUF) breaking --against-input $(HTTPS_GIT)#branch=master + @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main .PHONY: all install install-debug \ go-mod-cache draw-deps clean build format \ diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 402f028fd7..995650af18 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -46,6 +46,7 @@ - [cosmwasm/wasm/v1/proposal.proto](#cosmwasm/wasm/v1/proposal.proto) - [ClearAdminProposal](#cosmwasm.wasm.v1.ClearAdminProposal) + - [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) - [ExecuteContractProposal](#cosmwasm.wasm.v1.ExecuteContractProposal) - [InstantiateContractProposal](#cosmwasm.wasm.v1.InstantiateContractProposal) - [MigrateContractProposal](#cosmwasm.wasm.v1.MigrateContractProposal) @@ -660,6 +661,23 @@ contract. + + +### CodeAccessConfigUpdate +CodeAccessConfigUpdate contains the code id and the access config to be +applied. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code to be updated | +| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids | + + + + + + ### ExecuteContractProposal @@ -827,8 +845,7 @@ instantiate config to a set of code ids. | ----- | ---- | ----- | ----------- | | `title` | [string](#string) | | Title is a short summary | | `description` | [string](#string) | | Description is a human readable text | -| `code_ids` | [uint64](#uint64) | repeated | CodeIDs references the WASM codes | -| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids | +| `code_updates` | [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) | repeated | CodeAccessConfigUpdate contains the list of code ids and the access config to be applied. | diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index 8baf31c96a..242c38811f 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -149,6 +149,15 @@ message UnpinCodesProposal { ]; } +// CodeAccessConfigUpdate contains the code id and the access config to be +// applied. +message CodeAccessConfigUpdate { + // CodeID is the reference to the stored WASM code to be updated + uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; + // InstantiatePermission to apply to the set of code ids + AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ]; +} + // UpdateInstantiateConfigProposal gov proposal content type to update // instantiate config to a set of code ids. message UpdateInstantiateConfigProposal { @@ -156,11 +165,8 @@ message UpdateInstantiateConfigProposal { string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; // Description is a human readable text string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; - // CodeIDs references the WASM codes - repeated uint64 code_ids = 3 [ - (gogoproto.customname) = "CodeIDs", - (gogoproto.moretags) = "yaml:\"code_ids\"" - ]; - // InstantiatePermission to apply to the set of code ids - AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ]; + // CodeAccessConfigUpdate contains the list of code ids and the access config + // to be applied. + repeated CodeAccessConfigUpdate code_updates = 3 + [ (gogoproto.nullable) = false ]; } diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index 4e1833e115..c0fef8c847 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -228,9 +228,10 @@ func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsK if err := p.ValidateBasic(); err != nil { return err } - for _, v := range p.CodeIDs { - if err := k.SetAccessConfig(ctx, v, p.InstantiatePermission); err != nil { - return sdkerrors.Wrapf(err, "code id: %d", v) + + for _, codeUpdate := range p.CodeUpdates { + if err := k.SetAccessConfig(ctx, codeUpdate.CodeID, codeUpdate.InstantiatePermission); err != nil { + return sdkerrors.Wrapf(err, "code id: %d", codeUpdate.CodeID) } } return nil diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index d85c7235a0..2e4bcc375b 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -568,11 +568,13 @@ func (p UpdateInstantiateConfigProposal) ValidateBasic() error { if err := validateProposalCommons(p.Title, p.Description); err != nil { return err } - if len(p.CodeIDs) == 0 { - return sdkerrors.Wrap(ErrEmpty, "code ids") + if len(p.CodeUpdates) == 0 { + return sdkerrors.Wrap(ErrEmpty, "code updates") } - if err := p.InstantiatePermission.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "instantiate permission") + for _, codeUpdate := range p.CodeUpdates { + if err := codeUpdate.InstantiatePermission.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "instantiate permission") + } } return nil } @@ -582,7 +584,14 @@ func (p UpdateInstantiateConfigProposal) String() string { return fmt.Sprintf(`Update Instantiate Config Proposal: Title: %s Description: %s - Codes: %v - InstantiatePermission: %v -`, p.Title, p.Description, p.CodeIDs, p.InstantiatePermission) + CodeUpdates: %v +`, p.Title, p.Description, p.CodeUpdates) +} + +// String implements the Stringer interface. +func (c CodeAccessConfigUpdate) String() string { + return fmt.Sprintf(`CodeAccessUpdate: + CodeID: %d + AccessConfig: %v +`, c.CodeID, c.InstantiatePermission) } diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index aa3e58273c..2a63aaf361 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -438,6 +438,47 @@ func (m *UnpinCodesProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UnpinCodesProposal proto.InternalMessageInfo +// CodeAccessConfigUpdate contains the code id and the access config to be +// applied. +type CodeAccessConfigUpdate struct { + // CodeID is the reference to the stored WASM code to be updated + CodeID uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // InstantiatePermission to apply to the set of code ids + InstantiatePermission AccessConfig `protobuf:"bytes,4,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission"` +} + +func (m *CodeAccessConfigUpdate) Reset() { *m = CodeAccessConfigUpdate{} } +func (*CodeAccessConfigUpdate) ProtoMessage() {} +func (*CodeAccessConfigUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_be6422d717c730cb, []int{9} +} +func (m *CodeAccessConfigUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CodeAccessConfigUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CodeAccessConfigUpdate.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 *CodeAccessConfigUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_CodeAccessConfigUpdate.Merge(m, src) +} +func (m *CodeAccessConfigUpdate) XXX_Size() int { + return m.Size() +} +func (m *CodeAccessConfigUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_CodeAccessConfigUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_CodeAccessConfigUpdate proto.InternalMessageInfo + // UpdateInstantiateConfigProposal gov proposal content type to update // instantiate config to a set of code ids. type UpdateInstantiateConfigProposal struct { @@ -445,16 +486,15 @@ type UpdateInstantiateConfigProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` // Description is a human readable text Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // CodeIDs references the WASM codes - CodeIDs []uint64 `protobuf:"varint,3,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` - // InstantiatePermission to apply to the set of code ids - InstantiatePermission AccessConfig `protobuf:"bytes,4,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission"` + // CodeAccessConfigUpdate contains the list of code ids and the access config + // to be applied. + CodeUpdates []CodeAccessConfigUpdate `protobuf:"bytes,3,rep,name=code_updates,json=codeUpdates,proto3" json:"code_updates"` } func (m *UpdateInstantiateConfigProposal) Reset() { *m = UpdateInstantiateConfigProposal{} } func (*UpdateInstantiateConfigProposal) ProtoMessage() {} func (*UpdateInstantiateConfigProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{9} + return fileDescriptor_be6422d717c730cb, []int{10} } func (m *UpdateInstantiateConfigProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,62 +533,65 @@ func init() { proto.RegisterType((*ClearAdminProposal)(nil), "cosmwasm.wasm.v1.ClearAdminProposal") proto.RegisterType((*PinCodesProposal)(nil), "cosmwasm.wasm.v1.PinCodesProposal") proto.RegisterType((*UnpinCodesProposal)(nil), "cosmwasm.wasm.v1.UnpinCodesProposal") + proto.RegisterType((*CodeAccessConfigUpdate)(nil), "cosmwasm.wasm.v1.CodeAccessConfigUpdate") proto.RegisterType((*UpdateInstantiateConfigProposal)(nil), "cosmwasm.wasm.v1.UpdateInstantiateConfigProposal") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 774 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x16, 0x25, 0x8a, 0x92, 0xd7, 0x42, 0xab, 0xb2, 0xb2, 0xad, 0xba, 0x05, 0x29, 0xb0, 0x80, - 0xc1, 0x4b, 0xc9, 0xca, 0x05, 0x8a, 0xb6, 0x37, 0x51, 0xed, 0xc1, 0x46, 0x0d, 0x18, 0x34, 0x0c,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 0x61, 0x8b, 0xc8, 0xbf, 0x83, 0x6f, 0xd8, 0xec, 0x4e, - 0x77, 0x48, 0x51, 0xc7, 0xc1, 0x2e, 0xaa, 0x8b, 0x0d, 0x41, 0xaf, 0x58, 0xd5, 0x51, 0xa2, 0x56, - 0xf6, 0x5a, 0x3b, 0x5b, 0xd6, 0x90, 0xa6, 0x00, 0xec, 0x0a, 0xab, 0x9b, 0x44, 0xf2, 0x2e, 0x58, - 0xf6, 0x43, 0x42, 0x61, 0x48, 0x7d, 0x48, 0x51, 0x27, 0x42, 0x71, 0xe0, 0x13, 0xc2, 0x66, 0x97, - 0x1a, 0x82, 0xbe, 0xb8, 0xae, 0x18, 0x97, 0x39, 0x32, 0x5a, 0x8e, 0x83, 0x08, 0x69, 0xe3, 0x70, - 0xdf, 0xf7, 0xec, 0xa5, 0x99, 0xee, 0xed, 0x69, 0xf3, 0xa6, 0x58, 0x2e, 0x56, 0xa5, 0x4d, 0xb1, - 0x2c, 0x55, 0x4b, 0xda, 0xeb, 0x3c, 0xf8, 0x71, 0xe3, 0x63, 0x55, 0x1b, 0x87, 0x34, 0x86, 0x0e, - 0x9d, 0x17, 0x13, 0x35, 0x50, 0x84, 0x6e, 0xe0, 0x87, 0x29, 0x01, 0x0b, 0x36, 0x0f, 0xe4, 0x9f, - 0x41, 0x89, 0xb1, 0xd2, 0xf1, 0xdd, 0x7a, 0xb1, 0x21, 0xe8, 0xa2, 0x05, 0x46, 0x89, 0x2a, 0x31, - 0x0a, 0x36, 0xfe, 0xb6, 0x25, 0x96, 0xda, 0x70, 0x59, 0x6b, 0x0f, 0x76, 0x51, 0xaf, 0x2e, 0xf1, - 0xd6, 0x34, 0x90, 0x75, 0x50, 0x08, 0x88, 0x97, 0xf2, 0x51, 0xb1, 0x96, 0xdf, 0x25, 0xaa, 0x6c, - 0xc3, 0xc1, 0xe4, 0x14, 0x5b, 0x88, 0x10, 0xe8, 0x21, 0x9b, 0x95, 0xc8, 0x10, 0x14, 0xf7, 0x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, 0x1f, 0x32, 0xcd, 0x93, 0xe9, 0xa0, 0xb5, 0x0b, 0x83, - 0xac, 0xea, 0x38, 0x51, 0x2b, 0xfc, 0x24, 0xe9, 0xb2, 0x36, 0x19, 0xfd, 0xc7, 0x67, 0x46, 0x5b, - 0xcb, 0xe3, 0x44, 0x95, 0x79, 0xf5, 0x4c, 0x52, 0xbb, 0x08, 0xe9, 0x4f, 0x06, 0x29, 0x75, 0x1e, - 0x53, 0x50, 0x41, 0x17, 0x2d, 0x65, 0x94, 0xa8, 0x25, 0x6e, 0x3d, 0x32, 0x4e, 0xd4, 0x6f, 0xf9, - 0x0e, 0x93, 0x22, 0xcd, 0x2e, 0x71, 0x3b, 0x12, 0xed, 0xa5, 0x00, 0xe4, 0xdd, 0x30, 0xba, 0x57, - 0x98, 0x9f, 0xe4, 0x81, 0xca, 0xe5, 0x76, 0xf1, 0xae, 0xd8, 0xf7, 0xbd, 0x7b, 0x71, 0x00, 0xf9, - 0xff, 0x2b, 0x6f, 0x52, 0xf1, 0x36, 0x37, 0xa9, 0x25, 0x32, 0xa3, 0x5e, 0x71, 0x9f, 0x5a, 0xff, - 0x1e, 0x9f, 0x29, 0xb9, 0xd3, 0x33, 0x25, 0xf7, 0x6c, 0xa4, 0x08, 0xc7, 0x23, 0x45, 0x38, 0x19, - 0x29, 0xc2, 0xdb, 0x91, 0x22, 0x3c, 0x3c, 0x57, 0x72, 0x27, 0xe7, 0x4a, 0xee, 0xf4, 0x5c, 0xc9, - 0xfd, 0xb7, 0x36, 0xe3, 0xf1, 0x36, 0x26, 0xc1, 0xde, 0xe4, 0x49, 0xe2, 0x9a, 0x47, 0xfc, 0x69, - 0x92, 0xfa, 0xbc, 0x2b, 0xa5, 0x0f, 0x93, 0xdf, 0x3e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xb8, - 0x86, 0x60, 0x21, 0x09, 0x00, 0x00, + // 813 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0xcf, 0x34, 0x8e, 0x93, 0x4e, 0x22, 0x08, 0x26, 0x9b, 0x0d, 0x05, 0xd9, 0x91, 0x91, 0x56, + 0xbe, 0x60, 0x93, 0x22, 0x21, 0xe0, 0x16, 0x07, 0x0e, 0x5d, 0x51, 0xa9, 0xb8, 0xaa, 0x56, 0x82, + 0x43, 0x34, 0xb1, 0xa7, 0x5e, 0x8b, 0xd8, 0x63, 0x79, 0x26, 0xcd, 0xe6, 0x5b, 0x80, 0xc4, 0x09, + 0xf1, 0x01, 0x10, 0x17, 0xc4, 0x9d, 0x0f, 0x50, 0x71, 0xda, 0x13, 0xda, 0x93, 0x61, 0xd3, 0x6f, + 0x90, 0x23, 0x12, 0x12, 0x9a, 0x19, 0x27, 0xa4, 0xff, 0x8b, 0x68, 0x90, 0xb8, 0x38, 0x79, 0xf3, + 0xde, 0x9b, 0xf7, 0x9b, 0x9f, 0x7e, 0x6f, 0xde, 0x40, 0xc3, 0x27, 0x34, 0x9e, 0x22, 0x1a, 0x3b, + 0xe2, 0x73, 0xd2, 0x73, 0xd2, 0x8c, 0xa4, 0x84, 0xa2, 0xb1, 0x9d, 0x66, 0x84, 0x11, 0xad, 0xb9, + 0x0c, 0xb0, 0xc5, 0xe7, 0xa4, 0xb7, 0xd3, 0x0a, 0x49, 0x48, 0x84, 0xd3, 0xe1, 0xff, 0x64, 0xdc, + 0x8e, 0xce, 0xe3, 0x08, 0x75, 0x46, 0x88, 0x62, 0xe7, 0xa4, 0x37, 0xc2, 0x0c, 0xf5, 0x1c, 0x9f, + 0x44, 0x49, 0xe1, 0x7f, 0xeb, 0x52, 0x21, 0x36, 0x4b, 0x31, 0x95, 0x5e, 0xf3, 0x4f, 0x00, 0x5f, + 0x3b, 0x64, 0x24, 0xc3, 0x03, 0x12, 0xe0, 0x83, 0x02, 0x81, 0xd6, 0x82, 0x15, 0x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x75, + 0xbe, 0x87, 0x5c, 0xa1, 0xee, 0xa7, 0xa7, 0x2f, 0xf5, 0xd2, 0x8b, 0x97, 0x7a, 0xe9, 0xfb, 0xb9, + 0x0e, 0x4e, 0xe7, 0x3a, 0x78, 0x3e, 0xd7, 0xc1, 0xef, 0x73, 0x1d, 0x7c, 0x75, 0xa6, 0x97, 0x9e, + 0x9f, 0xe9, 0xa5, 0x17, 0x67, 0x7a, 0xe9, 0xf3, 0x47, 0x6b, 0x77, 0xc7, 0x80, 0xd0, 0xf8, 0xc9, + 0xf2, 0xa9, 0x13, 0x38, 0xcf, 0xe4, 0x93, 0x47, 0xdc, 0x1f, 0x23, 0x55, 0x3c, 0x78, 0xde, 0xfb, + 0x2b, 0x00, 0x00, 0xff, 0xff, 0xad, 0x12, 0x0a, 0xc1, 0x79, 0x09, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -883,6 +926,33 @@ func (this *UnpinCodesProposal) Equal(that interface{}) bool { } return true } +func (this *CodeAccessConfigUpdate) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CodeAccessConfigUpdate) + if !ok { + that2, ok := that.(CodeAccessConfigUpdate) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.CodeID != that1.CodeID { + return false + } + if !this.InstantiatePermission.Equal(&that1.InstantiatePermission) { + return false + } + return true +} func (this *UpdateInstantiateConfigProposal) Equal(that interface{}) bool { if that == nil { return this == nil @@ -908,17 +978,14 @@ func (this *UpdateInstantiateConfigProposal) Equal(that interface{}) bool { if this.Description != that1.Description { return false } - if len(this.CodeIDs) != len(that1.CodeIDs) { + if len(this.CodeUpdates) != len(that1.CodeUpdates) { return false } - for i := range this.CodeIDs { - if this.CodeIDs[i] != that1.CodeIDs[i] { + for i := range this.CodeUpdates { + if !this.CodeUpdates[i].Equal(&that1.CodeUpdates[i]) { return false } } - if !this.InstantiatePermission.Equal(&that1.InstantiatePermission) { - return false - } return true } func (m *StoreCodeProposal) Marshal() (dAtA []byte, err error) { @@ -1452,7 +1519,7 @@ func (m *UnpinCodesProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *UpdateInstantiateConfigProposal) Marshal() (dAtA []byte, err error) { +func (m *CodeAccessConfigUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1462,12 +1529,12 @@ func (m *UpdateInstantiateConfigProposal) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UpdateInstantiateConfigProposal) MarshalTo(dAtA []byte) (int, error) { +func (m *CodeAccessConfigUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *CodeAccessConfigUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1482,23 +1549,47 @@ func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int } i-- dAtA[i] = 0x22 - if len(m.CodeIDs) > 0 { - dAtA8 := make([]byte, len(m.CodeIDs)*10) - var j7 int - for _, num := range m.CodeIDs { - for num >= 1<<7 { - dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j7++ + if m.CodeID != 0 { + i = encodeVarintProposal(dAtA, i, uint64(m.CodeID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UpdateInstantiateConfigProposal) 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 *UpdateInstantiateConfigProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeUpdates) > 0 { + for iNdEx := len(m.CodeUpdates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CodeUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) } - dAtA8[j7] = uint8(num) - j7++ + i-- + dAtA[i] = 0x1a } - i -= j7 - copy(dAtA[i:], dAtA8[:j7]) - i = encodeVarintProposal(dAtA, i, uint64(j7)) - i-- - dAtA[i] = 0x1a } if len(m.Description) > 0 { i -= len(m.Description) @@ -1781,6 +1872,20 @@ func (m *UnpinCodesProposal) Size() (n int) { return n } +func (m *CodeAccessConfigUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeID != 0 { + n += 1 + sovProposal(uint64(m.CodeID)) + } + l = m.InstantiatePermission.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + func (m *UpdateInstantiateConfigProposal) Size() (n int) { if m == nil { return 0 @@ -1795,15 +1900,12 @@ func (m *UpdateInstantiateConfigProposal) Size() (n int) { if l > 0 { n += 1 + l + sovProposal(uint64(l)) } - if len(m.CodeIDs) > 0 { - l = 0 - for _, e := range m.CodeIDs { - l += sovProposal(uint64(e)) + if len(m.CodeUpdates) > 0 { + for _, e := range m.CodeUpdates { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) } - n += 1 + sovProposal(uint64(l)) + l } - l = m.InstantiatePermission.Size() - n += 1 + l + sovProposal(uint64(l)) return n } @@ -3655,6 +3757,108 @@ func (m *UnpinCodesProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *CodeAccessConfigUpdate) 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: CodeAccessConfigUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CodeAccessConfigUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) + } + m.CodeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3749,84 +3953,8 @@ func (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error { m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CodeIDs = append(m.CodeIDs, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProposal - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.CodeIDs) == 0 { - m.CodeIDs = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CodeIDs = append(m.CodeIDs, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field CodeIDs", wireType) - } - case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CodeUpdates", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3853,7 +3981,8 @@ func (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.InstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.CodeUpdates = append(m.CodeUpdates, CodeAccessConfigUpdate{}) + if err := m.CodeUpdates[len(m.CodeUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 7c0763e57b3decbe1765b75ae8a8c740f6d24b25 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 4 May 2022 18:06:43 -0600 Subject: [PATCH 04/13] add to EnableAllProposals --- x/wasm/types/proposal.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 2e4bcc375b..4a34761cfb 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -39,6 +39,7 @@ var EnableAllProposals = []ProposalType{ ProposalTypeClearAdmin, ProposalTypePinCodes, ProposalTypeUnpinCodes, + ProposalTypeUpdateInstantiateConfig, } // ConvertToProposals maps each key to a ProposalType and returns a typed list. @@ -571,10 +572,16 @@ func (p UpdateInstantiateConfigProposal) ValidateBasic() error { if len(p.CodeUpdates) == 0 { return sdkerrors.Wrap(ErrEmpty, "code updates") } + dedup := make(map[uint64]bool) for _, codeUpdate := range p.CodeUpdates { + _, found := dedup[codeUpdate.CodeID] + if found { + return sdkerrors.Wrapf(ErrDuplicate, "duplicate code: %d", codeUpdate.CodeID) + } if err := codeUpdate.InstantiatePermission.ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "instantiate permission") } + dedup[codeUpdate.CodeID] = true } return nil } From 01157fa914625b61755aa01e97e3032911b8e82c Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 4 May 2022 18:06:54 -0600 Subject: [PATCH 05/13] add tests --- x/wasm/keeper/proposal_integration_test.go | 98 ++++++++++++++++++++++ x/wasm/keeper/test_common.go | 11 ++- 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index ea88f398d9..7829950584 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -749,3 +749,101 @@ func TestUnpinCodesProposal(t *testing.T) { }) } } + +func TestUpdateInstantiateConfigProposal(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, "staking") + govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper + + mock := wasmtesting.MockWasmer{ + CreateFn: wasmtesting.NoOpCreateFn, + AnalyzeCodeFn: wasmtesting.WithoutIBCAnalyzeFn, + } + anyAddress, err := sdk.AccAddressFromBech32("cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz") + require.NoError(t, err) + + withAddressAccessConfig := types.AccessTypeOnlyAddress.With(anyAddress) + var ( + nobody = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &types.AllowNobody) + everybody = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &types.AllowEverybody) + withAddress = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &withAddressAccessConfig) + ) + type codeUpdate struct { + codeID uint64 + AccessConfig types.AccessConfig + } + specs := map[string]struct { + codeUpdates []codeUpdate + expErr bool + }{ + "update one": { + codeUpdates: []codeUpdate{ + {codeID: nobody.CodeID, AccessConfig: types.AllowEverybody}, + }, + }, + "update multiple": { + codeUpdates: []codeUpdate{ + {codeID: everybody.CodeID, AccessConfig: types.AllowNobody}, + {codeID: nobody.CodeID, AccessConfig: withAddressAccessConfig}, + {codeID: withAddress.CodeID, AccessConfig: types.AllowEverybody}, + }, + }, + "update same code id": { + codeUpdates: []codeUpdate{ + {codeID: everybody.CodeID, AccessConfig: types.AllowNobody}, + {codeID: everybody.CodeID, AccessConfig: types.AllowEverybody}, + }, + expErr: true, + }, + "update non existing code id": { + codeUpdates: []codeUpdate{ + {codeID: 100, AccessConfig: types.AllowNobody}, + {codeID: everybody.CodeID, AccessConfig: types.AllowEverybody}, + }, + expErr: true, + }, + "update empty list": { + codeUpdates: make([]codeUpdate, 0), + expErr: true, + }, + } + parentCtx := ctx + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + + ctx, _ := parentCtx.CacheContext() + + updates := make([]types.CodeAccessConfigUpdate, 0) + for _, cu := range spec.codeUpdates { + updates = append(updates, types.CodeAccessConfigUpdate{ + CodeID: cu.codeID, + InstantiatePermission: cu.AccessConfig, + }) + } + + proposal := types.UpdateInstantiateConfigProposal{ + Title: "Foo", + Description: "Bar", + CodeUpdates: updates, + } + + // when stored + storedProposal, gotErr := govKeeper.SubmitProposal(ctx, &proposal) + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + + // and proposal execute + handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute()) + gotErr = handler(ctx, storedProposal.GetContent()) + require.NoError(t, gotErr) + + // then + for i := range spec.codeUpdates { + c := wasmKeeper.GetCodeInfo(ctx, spec.codeUpdates[i].codeID) + require.Equal(t, spec.codeUpdates[i].AccessConfig, c.InstantiateConfig) + } + }) + } +} diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index ed5bec8ebd..8235fb33ad 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -586,16 +586,25 @@ func SeedNewContractInstance(t testing.TB, ctx sdk.Context, keepers TestKeepers, // StoreRandomContract sets the mock wasmerEngine in keeper and calls store func StoreRandomContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContract { + return StoreRandomContractWithAccessConfig(t, ctx, keepers, mock, nil) +} + +func StoreRandomContractWithAccessConfig( + t testing.TB, ctx sdk.Context, + keepers TestKeepers, + mock types.WasmerEngine, + cfg *types.AccessConfig) ExampleContract { t.Helper() anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) creator, _, creatorAddr := keyPubAddr() fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) keepers.WasmKeeper.wasmVM = mock wasmCode := append(wasmIdent, rand.Bytes(10)...) //nolint:gocritic - codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) + codeID, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, cfg) require.NoError(t, err) exampleContract := ExampleContract{InitialAmount: anyAmount, Creator: creator, CreatorAddr: creatorAddr, CodeID: codeID} return exampleContract + } type HackatomExampleInstance struct { From 931bffeef9b12c4fd18915f63ab60c077f1149c9 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 5 May 2022 13:04:19 -0600 Subject: [PATCH 06/13] add to docs --- x/wasm/Governance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/x/wasm/Governance.md b/x/wasm/Governance.md index 7d7a32abee..cd7d0ae2cb 100644 --- a/x/wasm/Governance.md +++ b/x/wasm/Governance.md @@ -17,6 +17,7 @@ We have added 9 new wasm specific proposal types that cover the contract's live * `ClearAdminProposal` - clear admin for a contract to prevent further migrations * `PinCodes` - pin the given code ids in cache. This trades memory for reduced startup time and lowers gas cost * `UnpinCodes` - unpin the given code ids from the cache. This frees up memory and returns to standard speed and gas cost +* `UpdateInstantiateConfigProposal` - update instantiate permissions to a list of given code ids. For details see the proposal type [implementation](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/proposal.go) From bf9c6e2ce6b85e555e58faf08ab51b900942a9dc Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 5 May 2022 13:04:31 -0600 Subject: [PATCH 07/13] Add handlers --- x/wasm/client/cli/gov_tx.go | 108 ++++++++++++++++++++++++++++++ x/wasm/client/proposal_handler.go | 1 + x/wasm/client/rest/gov.go | 45 ++++++++++++- 3 files changed, 153 insertions(+), 1 deletion(-) diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 94150de28e..5e26317a64 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -3,10 +3,12 @@ package cli import ( "fmt" "strconv" + "strings" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/gov/client/cli" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/pkg/errors" @@ -614,3 +616,109 @@ func ProposalUnpinCodesCmd() *cobra.Command { cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") return cmd } + +func parseAccessConfig(config string) (types.AccessConfig, error) { + switch config { + case "nobody": + return types.AllowNobody, nil + case "everybody": + return types.AllowEverybody, nil + default: + address, err := sdk.AccAddressFromBech32(config) + if err != nil { + return types.AccessConfig{}, fmt.Errorf("unable to parse address %s", config) + } + return types.AccessTypeOnlyAddress.With(address), nil + } +} + +func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error) { + updates := make([]types.CodeAccessConfigUpdate, len(args)) + for i, c := range args { + // format: code_id,access_config + // access_config: nobody|everybody|address + parts := strings.Split(c, ",") + if len(parts) != 2 { + return nil, fmt.Errorf("invalid ") + } + + codeID, err := strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid code ID: %s", err) + } + + accessConfig, err := parseAccessConfig(parts[1]) + if err != nil { + return nil, err + } + updates[i] = types.CodeAccessConfigUpdate{ + CodeID: codeID, + InstantiatePermission: accessConfig, + } + } + return updates, nil +} +func ProposalUpdateInstantiateConfigCmd() *cobra.Command { + bech32Prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() + cmd := &cobra.Command{ + Use: "update-instantiate-config [code-id,permission]...", + Short: "Submit an update instantiate config proposal.", + Args: cobra.MinimumNArgs(1), + Long: strings.TrimSpace( + fmt.Sprintf(`Submit an update instantiate config proposal for multiple code ids. + +Example: +$ %s tx gov submit-proposal update-instantiate-config 1,nobody 2,everybody 3,%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm +`, version.AppName, bech32Prefix)), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) + if err != nil { + return fmt.Errorf("proposal title: %s", err) + } + proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription) + if err != nil { + return fmt.Errorf("proposal description: %s", err) + } + depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) + if err != nil { + return fmt.Errorf("deposit: %s", err) + } + deposit, err := sdk.ParseCoinsNormalized(depositArg) + if err != nil { + return err + } + updates, err := parseCodeUpdateArgs(args) + if err != nil { + return err + } + + content := types.UpdateInstantiateConfigProposal{ + Title: proposalTitle, + Description: proposalDescr, + CodeUpdates: updates, + } + msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) + if err != nil { + return err + } + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + // proposal flags + cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") + cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") + cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") + cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") + // type values must match the "ProposalHandler" "routes" in cli + cmd.Flags().String(flagProposalType, "", "Permission of proposal, types: store-code/instantiate/migrate/update-admin/clear-admin/text/parameter_change/software_upgrade") + return cmd +} diff --git a/x/wasm/client/proposal_handler.go b/x/wasm/client/proposal_handler.go index ad3363ac7a..6d4735180e 100644 --- a/x/wasm/client/proposal_handler.go +++ b/x/wasm/client/proposal_handler.go @@ -18,4 +18,5 @@ var ProposalHandlers = []govclient.ProposalHandler{ govclient.NewProposalHandler(cli.ProposalClearContractAdminCmd, rest.ClearContractAdminProposalHandler), govclient.NewProposalHandler(cli.ProposalPinCodesCmd, rest.PinCodeProposalHandler), govclient.NewProposalHandler(cli.ProposalUnpinCodesCmd, rest.UnpinCodeProposalHandler), + govclient.NewProposalHandler(cli.ProposalUpdateInstantiateConfigCmd, rest.UpdateInstantiateConfigProposalHandler), } diff --git a/x/wasm/client/rest/gov.go b/x/wasm/client/rest/gov.go index 5178b29852..ee4b5b1631 100644 --- a/x/wasm/client/rest/gov.go +++ b/x/wasm/client/rest/gov.go @@ -407,7 +407,50 @@ func (s UnpinCodeJSONReq) GetBaseReq() rest.BaseReq { func UnpinCodeProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "pin_code", + SubRoute: "unpin_code", + Handler: func(w http.ResponseWriter, r *http.Request) { + var req UnpinCodeJSONReq + if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { + return + } + toStdTxResponse(cliCtx, w, req) + }, + } +} + +type UpdateInstantiateConfigProposalJSONReq struct { + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + Proposer string `json:"proposer" yaml:"proposer"` + Deposit sdk.Coins `json:"deposit" yaml:"deposit"` + + CodeUpdates []types.CodeAccessConfigUpdate `json:"code_updates" yaml:"code_updates"` + // InstantiatePermission to apply on contract creation, optional + InstantiatePermission *types.AccessConfig `json:"instantiate_permission" yaml:"instantiate_permission"` +} + +func (s UpdateInstantiateConfigProposalJSONReq) Content() govtypes.Content { + return &types.UpdateInstantiateConfigProposal{ + Title: s.Title, + Description: s.Description, + CodeUpdates: s.CodeUpdates, + } +} +func (s UpdateInstantiateConfigProposalJSONReq) GetProposer() string { + return s.Proposer +} +func (s UpdateInstantiateConfigProposalJSONReq) GetDeposit() sdk.Coins { + return s.Deposit +} +func (s UpdateInstantiateConfigProposalJSONReq) GetBaseReq() rest.BaseReq { + return s.BaseReq +} + +func UpdateInstantiateConfigProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "update_instatiate_config", Handler: func(w http.ResponseWriter, r *http.Request) { var req UnpinCodeJSONReq if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { From 86c61efe70f1afb80aac661196d2e43c7156fd1a Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 5 May 2022 21:37:44 -0600 Subject: [PATCH 08/13] add code-info query command --- x/wasm/client/cli/query.go | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/x/wasm/client/cli/query.go b/x/wasm/client/cli/query.go index c8e1c7a2d7..9d9cbcbdac 100644 --- a/x/wasm/client/cli/query.go +++ b/x/wasm/client/cli/query.go @@ -33,6 +33,7 @@ func GetQueryCmd() *cobra.Command { GetCmdListCode(), GetCmdListContractByCode(), GetCmdQueryCode(), + GetCmdQueryCodeInfo(), GetCmdGetContractInfo(), GetCmdGetContractHistory(), GetCmdGetContractState(), @@ -181,6 +182,45 @@ func GetCmdQueryCode() *cobra.Command { return cmd } +// GetCmdQueryCodeInfo returns the code info for a given code id +func GetCmdQueryCodeInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "code-info [code_id]", + Short: "Prints out metadata of a code id", + Long: "Prints out metadata of a code id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + codeID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Code( + context.Background(), + &types.QueryCodeRequest{ + CodeId: codeID, + }, + ) + if err != nil { + return err + } + if res.CodeInfoResponse == nil { + return fmt.Errorf("contract not found") + } + + return clientCtx.PrintProto(res.CodeInfoResponse) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + // GetCmdGetContractInfo gets details about a given contract func GetCmdGetContractInfo() *cobra.Command { cmd := &cobra.Command{ From a89083261c74ca904755d25d74731edaa1ecddf2 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Thu, 5 May 2022 21:59:45 -0600 Subject: [PATCH 09/13] fix missing gov registration type --- x/wasm/types/proposal.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 4a34761cfb..a4cefc0010 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -70,6 +70,7 @@ func init() { // register new content types with the sdk govtypes.RegisterProposalType(string(ProposalTypeClearAdmin)) govtypes.RegisterProposalType(string(ProposalTypePinCodes)) govtypes.RegisterProposalType(string(ProposalTypeUnpinCodes)) + govtypes.RegisterProposalType(string(ProposalTypeUpdateInstantiateConfig)) govtypes.RegisterProposalTypeCodec(&StoreCodeProposal{}, "wasm/StoreCodeProposal") govtypes.RegisterProposalTypeCodec(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal") govtypes.RegisterProposalTypeCodec(&MigrateContractProposal{}, "wasm/MigrateContractProposal") From 30f05722f1717df22bc4244f1df4d2677ae10e13 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 6 May 2022 09:22:04 -0600 Subject: [PATCH 10/13] address code review comments --- x/wasm/client/rest/gov.go | 6 ++-- x/wasm/keeper/proposal_integration_test.go | 41 ++++++++++------------ 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/x/wasm/client/rest/gov.go b/x/wasm/client/rest/gov.go index ee4b5b1631..70685a7646 100644 --- a/x/wasm/client/rest/gov.go +++ b/x/wasm/client/rest/gov.go @@ -427,8 +427,6 @@ type UpdateInstantiateConfigProposalJSONReq struct { Deposit sdk.Coins `json:"deposit" yaml:"deposit"` CodeUpdates []types.CodeAccessConfigUpdate `json:"code_updates" yaml:"code_updates"` - // InstantiatePermission to apply on contract creation, optional - InstantiatePermission *types.AccessConfig `json:"instantiate_permission" yaml:"instantiate_permission"` } func (s UpdateInstantiateConfigProposalJSONReq) Content() govtypes.Content { @@ -450,9 +448,9 @@ func (s UpdateInstantiateConfigProposalJSONReq) GetBaseReq() rest.BaseReq { func UpdateInstantiateConfigProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "update_instatiate_config", + SubRoute: "update_instantiate_config", Handler: func(w http.ResponseWriter, r *http.Request) { - var req UnpinCodeJSONReq + var req UpdateInstantiateConfigProposalJSONReq if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { return } diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 7829950584..523c5bed9c 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -767,42 +767,39 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { everybody = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &types.AllowEverybody) withAddress = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &withAddressAccessConfig) ) - type codeUpdate struct { - codeID uint64 - AccessConfig types.AccessConfig - } + specs := map[string]struct { - codeUpdates []codeUpdate + codeUpdates []types.CodeAccessConfigUpdate expErr bool }{ "update one": { - codeUpdates: []codeUpdate{ - {codeID: nobody.CodeID, AccessConfig: types.AllowEverybody}, + codeUpdates: []types.CodeAccessConfigUpdate{ + {CodeID: nobody.CodeID, InstantiatePermission: types.AllowEverybody}, }, }, "update multiple": { - codeUpdates: []codeUpdate{ - {codeID: everybody.CodeID, AccessConfig: types.AllowNobody}, - {codeID: nobody.CodeID, AccessConfig: withAddressAccessConfig}, - {codeID: withAddress.CodeID, AccessConfig: types.AllowEverybody}, + codeUpdates: []types.CodeAccessConfigUpdate{ + {CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody}, + {CodeID: nobody.CodeID, InstantiatePermission: withAddressAccessConfig}, + {CodeID: withAddress.CodeID, InstantiatePermission: types.AllowEverybody}, }, }, "update same code id": { - codeUpdates: []codeUpdate{ - {codeID: everybody.CodeID, AccessConfig: types.AllowNobody}, - {codeID: everybody.CodeID, AccessConfig: types.AllowEverybody}, + codeUpdates: []types.CodeAccessConfigUpdate{ + {CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody}, + {CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody}, }, expErr: true, }, "update non existing code id": { - codeUpdates: []codeUpdate{ - {codeID: 100, AccessConfig: types.AllowNobody}, - {codeID: everybody.CodeID, AccessConfig: types.AllowEverybody}, + codeUpdates: []types.CodeAccessConfigUpdate{ + {CodeID: 100, InstantiatePermission: types.AllowNobody}, + {CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody}, }, expErr: true, }, "update empty list": { - codeUpdates: make([]codeUpdate, 0), + codeUpdates: make([]types.CodeAccessConfigUpdate, 0), expErr: true, }, } @@ -815,8 +812,8 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { updates := make([]types.CodeAccessConfigUpdate, 0) for _, cu := range spec.codeUpdates { updates = append(updates, types.CodeAccessConfigUpdate{ - CodeID: cu.codeID, - InstantiatePermission: cu.AccessConfig, + CodeID: cu.CodeID, + InstantiatePermission: cu.InstantiatePermission, }) } @@ -841,8 +838,8 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { // then for i := range spec.codeUpdates { - c := wasmKeeper.GetCodeInfo(ctx, spec.codeUpdates[i].codeID) - require.Equal(t, spec.codeUpdates[i].AccessConfig, c.InstantiateConfig) + c := wasmKeeper.GetCodeInfo(ctx, spec.codeUpdates[i].CodeID) + require.Equal(t, spec.codeUpdates[i].InstantiatePermission, c.InstantiateConfig) } }) } From ac6876f657cc8e40574a9c3f3e0eb8eb062e3078 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 6 May 2022 09:36:47 -0600 Subject: [PATCH 11/13] fix error message --- x/wasm/client/cli/gov_tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 5e26317a64..aede9bc81c 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -639,7 +639,7 @@ func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error) // access_config: nobody|everybody|address parts := strings.Split(c, ",") if len(parts) != 2 { - return nil, fmt.Errorf("invalid ") + return nil, fmt.Errorf("invalid format") } codeID, err := strconv.ParseUint(parts[0], 10, 64) From 3ade8159b6ffbfaead84c1bd0ea3960924b26eb2 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Mon, 9 May 2022 11:35:04 -0600 Subject: [PATCH 12/13] update proto field name --- docs/proto/proto-docs.md | 30 ++-- proto/cosmwasm/wasm/v1/proposal.proto | 10 +- x/wasm/client/cli/gov_tx.go | 14 +- x/wasm/client/rest/gov.go | 17 +- x/wasm/keeper/proposal_handler.go | 6 +- x/wasm/keeper/proposal_integration_test.go | 34 ++-- x/wasm/types/proposal.go | 12 +- x/wasm/types/proposal.pb.go | 185 +++++++++++---------- 8 files changed, 154 insertions(+), 154 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 995650af18..f6c0182b6d 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -45,8 +45,8 @@ - [MsgIBCSend](#cosmwasm.wasm.v1.MsgIBCSend) - [cosmwasm/wasm/v1/proposal.proto](#cosmwasm/wasm/v1/proposal.proto) + - [AccessConfigUpdate](#cosmwasm.wasm.v1.AccessConfigUpdate) - [ClearAdminProposal](#cosmwasm.wasm.v1.ClearAdminProposal) - - [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) - [ExecuteContractProposal](#cosmwasm.wasm.v1.ExecuteContractProposal) - [InstantiateContractProposal](#cosmwasm.wasm.v1.InstantiateContractProposal) - [MigrateContractProposal](#cosmwasm.wasm.v1.MigrateContractProposal) @@ -643,35 +643,35 @@ MsgIBCSend - + -### ClearAdminProposal -ClearAdminProposal gov proposal content type to clear the admin of a -contract. +### AccessConfigUpdate +AccessConfigUpdate contains the code id and the access config to be +applied. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | Title is a short summary | -| `description` | [string](#string) | | Description is a human readable text | -| `contract` | [string](#string) | | Contract is the address of the smart contract | +| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code to be updated | +| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids | - + -### CodeAccessConfigUpdate -CodeAccessConfigUpdate contains the code id and the access config to be -applied. +### ClearAdminProposal +ClearAdminProposal gov proposal content type to clear the admin of a +contract. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code to be updated | -| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids | +| `title` | [string](#string) | | Title is a short summary | +| `description` | [string](#string) | | Description is a human readable text | +| `contract` | [string](#string) | | Contract is the address of the smart contract | @@ -845,7 +845,7 @@ instantiate config to a set of code ids. | ----- | ---- | ----- | ----------- | | `title` | [string](#string) | | Title is a short summary | | `description` | [string](#string) | | Description is a human readable text | -| `code_updates` | [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) | repeated | CodeAccessConfigUpdate contains the list of code ids and the access config to be applied. | +| `access_config_updates` | [AccessConfigUpdate](#cosmwasm.wasm.v1.AccessConfigUpdate) | repeated | AccessConfigUpdate contains the list of code ids and the access config to be applied. | diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index 242c38811f..68eae73a12 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -149,13 +149,13 @@ message UnpinCodesProposal { ]; } -// CodeAccessConfigUpdate contains the code id and the access config to be +// AccessConfigUpdate contains the code id and the access config to be // applied. -message CodeAccessConfigUpdate { +message AccessConfigUpdate { // CodeID is the reference to the stored WASM code to be updated uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; // InstantiatePermission to apply to the set of code ids - AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ]; + AccessConfig instantiate_permission = 2 [ (gogoproto.nullable) = false ]; } // UpdateInstantiateConfigProposal gov proposal content type to update @@ -165,8 +165,8 @@ message UpdateInstantiateConfigProposal { string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; // Description is a human readable text string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; - // CodeAccessConfigUpdate contains the list of code ids and the access config + // AccessConfigUpdate contains the list of code ids and the access config // to be applied. - repeated CodeAccessConfigUpdate code_updates = 3 + repeated AccessConfigUpdate access_config_updates = 3 [ (gogoproto.nullable) = false ]; } diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index aede9bc81c..2a044c2d42 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -632,8 +632,8 @@ func parseAccessConfig(config string) (types.AccessConfig, error) { } } -func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error) { - updates := make([]types.CodeAccessConfigUpdate, len(args)) +func parseAccessConfigUpdates(args []string) ([]types.AccessConfigUpdate, error) { + updates := make([]types.AccessConfigUpdate, len(args)) for i, c := range args { // format: code_id,access_config // access_config: nobody|everybody|address @@ -651,7 +651,7 @@ func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error) if err != nil { return nil, err } - updates[i] = types.CodeAccessConfigUpdate{ + updates[i] = types.AccessConfigUpdate{ CodeID: codeID, InstantiatePermission: accessConfig, } @@ -692,15 +692,15 @@ $ %s tx gov submit-proposal update-instantiate-config 1,nobody 2,everybody 3,%s1 if err != nil { return err } - updates, err := parseCodeUpdateArgs(args) + updates, err := parseAccessConfigUpdates(args) if err != nil { return err } content := types.UpdateInstantiateConfigProposal{ - Title: proposalTitle, - Description: proposalDescr, - CodeUpdates: updates, + Title: proposalTitle, + Description: proposalDescr, + AccessConfigUpdates: updates, } msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress()) if err != nil { diff --git a/x/wasm/client/rest/gov.go b/x/wasm/client/rest/gov.go index 70685a7646..d62381039f 100644 --- a/x/wasm/client/rest/gov.go +++ b/x/wasm/client/rest/gov.go @@ -421,19 +421,18 @@ func UnpinCodeProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler type UpdateInstantiateConfigProposalJSONReq struct { BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Proposer string `json:"proposer" yaml:"proposer"` - Deposit sdk.Coins `json:"deposit" yaml:"deposit"` - - CodeUpdates []types.CodeAccessConfigUpdate `json:"code_updates" yaml:"code_updates"` + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + Proposer string `json:"proposer" yaml:"proposer"` + Deposit sdk.Coins `json:"deposit" yaml:"deposit"` + AccessConfigUpdates []types.AccessConfigUpdate `json:"access_config_updates" yaml:"access_config_updates"` } func (s UpdateInstantiateConfigProposalJSONReq) Content() govtypes.Content { return &types.UpdateInstantiateConfigProposal{ - Title: s.Title, - Description: s.Description, - CodeUpdates: s.CodeUpdates, + Title: s.Title, + Description: s.Description, + AccessConfigUpdates: s.AccessConfigUpdates, } } func (s UpdateInstantiateConfigProposalJSONReq) GetProposer() string { diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index c0fef8c847..9da330ce0f 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -229,9 +229,9 @@ func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsK return err } - for _, codeUpdate := range p.CodeUpdates { - if err := k.SetAccessConfig(ctx, codeUpdate.CodeID, codeUpdate.InstantiatePermission); err != nil { - return sdkerrors.Wrapf(err, "code id: %d", codeUpdate.CodeID) + for _, accessConfigUpdate := range p.AccessConfigUpdates { + if err := k.SetAccessConfig(ctx, accessConfigUpdate.CodeID, accessConfigUpdate.InstantiatePermission); err != nil { + return sdkerrors.Wrapf(err, "code id: %d", accessConfigUpdate.CodeID) } } return nil diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 523c5bed9c..441e75fd75 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -769,38 +769,38 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { ) specs := map[string]struct { - codeUpdates []types.CodeAccessConfigUpdate - expErr bool + accessConfigUpdates []types.AccessConfigUpdate + expErr bool }{ "update one": { - codeUpdates: []types.CodeAccessConfigUpdate{ + accessConfigUpdates: []types.AccessConfigUpdate{ {CodeID: nobody.CodeID, InstantiatePermission: types.AllowEverybody}, }, }, "update multiple": { - codeUpdates: []types.CodeAccessConfigUpdate{ + accessConfigUpdates: []types.AccessConfigUpdate{ {CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody}, {CodeID: nobody.CodeID, InstantiatePermission: withAddressAccessConfig}, {CodeID: withAddress.CodeID, InstantiatePermission: types.AllowEverybody}, }, }, "update same code id": { - codeUpdates: []types.CodeAccessConfigUpdate{ + accessConfigUpdates: []types.AccessConfigUpdate{ {CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody}, {CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody}, }, expErr: true, }, "update non existing code id": { - codeUpdates: []types.CodeAccessConfigUpdate{ + accessConfigUpdates: []types.AccessConfigUpdate{ {CodeID: 100, InstantiatePermission: types.AllowNobody}, {CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody}, }, expErr: true, }, "update empty list": { - codeUpdates: make([]types.CodeAccessConfigUpdate, 0), - expErr: true, + accessConfigUpdates: make([]types.AccessConfigUpdate, 0), + expErr: true, }, } parentCtx := ctx @@ -809,18 +809,18 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { ctx, _ := parentCtx.CacheContext() - updates := make([]types.CodeAccessConfigUpdate, 0) - for _, cu := range spec.codeUpdates { - updates = append(updates, types.CodeAccessConfigUpdate{ + updates := make([]types.AccessConfigUpdate, 0) + for _, cu := range spec.accessConfigUpdates { + updates = append(updates, types.AccessConfigUpdate{ CodeID: cu.CodeID, InstantiatePermission: cu.InstantiatePermission, }) } proposal := types.UpdateInstantiateConfigProposal{ - Title: "Foo", - Description: "Bar", - CodeUpdates: updates, + Title: "Foo", + Description: "Bar", + AccessConfigUpdates: updates, } // when stored @@ -837,9 +837,9 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { require.NoError(t, gotErr) // then - for i := range spec.codeUpdates { - c := wasmKeeper.GetCodeInfo(ctx, spec.codeUpdates[i].CodeID) - require.Equal(t, spec.codeUpdates[i].InstantiatePermission, c.InstantiateConfig) + for i := range spec.accessConfigUpdates { + c := wasmKeeper.GetCodeInfo(ctx, spec.accessConfigUpdates[i].CodeID) + require.Equal(t, spec.accessConfigUpdates[i].InstantiatePermission, c.InstantiateConfig) } }) } diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index a4cefc0010..748a03895b 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -570,11 +570,11 @@ func (p UpdateInstantiateConfigProposal) ValidateBasic() error { if err := validateProposalCommons(p.Title, p.Description); err != nil { return err } - if len(p.CodeUpdates) == 0 { + if len(p.AccessConfigUpdates) == 0 { return sdkerrors.Wrap(ErrEmpty, "code updates") } dedup := make(map[uint64]bool) - for _, codeUpdate := range p.CodeUpdates { + for _, codeUpdate := range p.AccessConfigUpdates { _, found := dedup[codeUpdate.CodeID] if found { return sdkerrors.Wrapf(ErrDuplicate, "duplicate code: %d", codeUpdate.CodeID) @@ -592,13 +592,13 @@ func (p UpdateInstantiateConfigProposal) String() string { return fmt.Sprintf(`Update Instantiate Config Proposal: Title: %s Description: %s - CodeUpdates: %v -`, p.Title, p.Description, p.CodeUpdates) + AccessConfigUpdates: %v +`, p.Title, p.Description, p.AccessConfigUpdates) } // String implements the Stringer interface. -func (c CodeAccessConfigUpdate) String() string { - return fmt.Sprintf(`CodeAccessUpdate: +func (c AccessConfigUpdate) String() string { + return fmt.Sprintf(`AccessConfigUpdate: CodeID: %d AccessConfig: %v `, c.CodeID, c.InstantiatePermission) diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index 2a63aaf361..787bed1351 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -438,26 +438,26 @@ func (m *UnpinCodesProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UnpinCodesProposal proto.InternalMessageInfo -// CodeAccessConfigUpdate contains the code id and the access config to be +// AccessConfigUpdate contains the code id and the access config to be // applied. -type CodeAccessConfigUpdate struct { +type AccessConfigUpdate struct { // CodeID is the reference to the stored WASM code to be updated CodeID uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` // InstantiatePermission to apply to the set of code ids - InstantiatePermission AccessConfig `protobuf:"bytes,4,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission"` + InstantiatePermission AccessConfig `protobuf:"bytes,2,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission"` } -func (m *CodeAccessConfigUpdate) Reset() { *m = CodeAccessConfigUpdate{} } -func (*CodeAccessConfigUpdate) ProtoMessage() {} -func (*CodeAccessConfigUpdate) Descriptor() ([]byte, []int) { +func (m *AccessConfigUpdate) Reset() { *m = AccessConfigUpdate{} } +func (*AccessConfigUpdate) ProtoMessage() {} +func (*AccessConfigUpdate) Descriptor() ([]byte, []int) { return fileDescriptor_be6422d717c730cb, []int{9} } -func (m *CodeAccessConfigUpdate) XXX_Unmarshal(b []byte) error { +func (m *AccessConfigUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *CodeAccessConfigUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AccessConfigUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_CodeAccessConfigUpdate.Marshal(b, m, deterministic) + return xxx_messageInfo_AccessConfigUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -467,17 +467,17 @@ func (m *CodeAccessConfigUpdate) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *CodeAccessConfigUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_CodeAccessConfigUpdate.Merge(m, src) +func (m *AccessConfigUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccessConfigUpdate.Merge(m, src) } -func (m *CodeAccessConfigUpdate) XXX_Size() int { +func (m *AccessConfigUpdate) XXX_Size() int { return m.Size() } -func (m *CodeAccessConfigUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_CodeAccessConfigUpdate.DiscardUnknown(m) +func (m *AccessConfigUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_AccessConfigUpdate.DiscardUnknown(m) } -var xxx_messageInfo_CodeAccessConfigUpdate proto.InternalMessageInfo +var xxx_messageInfo_AccessConfigUpdate proto.InternalMessageInfo // UpdateInstantiateConfigProposal gov proposal content type to update // instantiate config to a set of code ids. @@ -486,9 +486,9 @@ type UpdateInstantiateConfigProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` // Description is a human readable text Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // CodeAccessConfigUpdate contains the list of code ids and the access config + // AccessConfigUpdate contains the list of code ids and the access config // to be applied. - CodeUpdates []CodeAccessConfigUpdate `protobuf:"bytes,3,rep,name=code_updates,json=codeUpdates,proto3" json:"code_updates"` + AccessConfigUpdates []AccessConfigUpdate `protobuf:"bytes,3,rep,name=access_config_updates,json=accessConfigUpdates,proto3" json:"access_config_updates"` } func (m *UpdateInstantiateConfigProposal) Reset() { *m = UpdateInstantiateConfigProposal{} } @@ -533,65 +533,66 @@ func init() { proto.RegisterType((*ClearAdminProposal)(nil), "cosmwasm.wasm.v1.ClearAdminProposal") proto.RegisterType((*PinCodesProposal)(nil), "cosmwasm.wasm.v1.PinCodesProposal") proto.RegisterType((*UnpinCodesProposal)(nil), "cosmwasm.wasm.v1.UnpinCodesProposal") - proto.RegisterType((*CodeAccessConfigUpdate)(nil), "cosmwasm.wasm.v1.CodeAccessConfigUpdate") + proto.RegisterType((*AccessConfigUpdate)(nil), "cosmwasm.wasm.v1.AccessConfigUpdate") proto.RegisterType((*UpdateInstantiateConfigProposal)(nil), "cosmwasm.wasm.v1.UpdateInstantiateConfigProposal") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 813 bytes of a gzipped FileDescriptorProto + // 817 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xcf, 0x34, 0x8e, 0x93, 0x4e, 0x22, 0x08, 0x26, 0x9b, 0x0d, 0x05, 0xd9, 0x91, 0x91, 0x56, - 0xbe, 0x60, 0x93, 0x22, 0x21, 0xe0, 0x16, 0x07, 0x0e, 0x5d, 0x51, 0xa9, 0xb8, 0xaa, 0x56, 0x82, - 0x43, 0x34, 0xb1, 0xa7, 0x5e, 0x8b, 0xd8, 0x63, 0x79, 0x26, 0xcd, 0xe6, 0x5b, 0x80, 0xc4, 0x09, - 0xf1, 0x01, 0x10, 0x17, 0xc4, 0x9d, 0x0f, 0x50, 0x71, 0xda, 0x13, 0xda, 0x93, 0x61, 0xd3, 0x6f, - 0x90, 0x23, 0x12, 0x12, 0x9a, 0x19, 0x27, 0xa4, 0xff, 0x8b, 0x68, 0x90, 0xb8, 0x38, 0x79, 0xf3, - 0xde, 0x9b, 0xf7, 0x9b, 0x9f, 0x7e, 0x6f, 0xde, 0x40,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0x21, 0xe0, 0x16, 0x07, 0x0e, 0x5d, 0x51, 0xa9, 0x72, 0x55, 0xad, 0x04, + 0x12, 0xd6, 0xc4, 0x9e, 0x7a, 0x2d, 0x62, 0x8f, 0xe5, 0x99, 0x34, 0x9b, 0x6f, 0x01, 0x12, 0xe2, + 0xc4, 0x07, 0x40, 0x5c, 0x10, 0x77, 0x3e, 0x40, 0xc5, 0x69, 0x8f, 0x7b, 0x32, 0x6c, 0xf2, 0x0d, + 0x72, 0x44, 0x42, 0x42, 0x33, 0xe3, 0x84, 0x74, 0x97, 0x66, 0x17, 0xd1, 0x20, 0x71, 0x71, 0xf2, + 0xe6, 0xbd, 0x37, 0xef, 0x37, 0x3f, 0xfd, 0xde, 0xbc, 0x81, 0xba, 0x4f, 0x68, 0x3c, 0x45, 0x34, + 0xb6, 0xc5, 0xe7, 0xb2, 0x6f, 0xa7, 0x19, 0x49, 0x09, 0x45, 0x63, 0x2b, 0xcd, 0x08, 0x23, 0x6a, + 0x7b, 0x15, 0x60, 0x89, 0xcf, 0x65, 0xff, 0xb0, 0x13, 0x92, 0x90, 0x08, 0xa7, 0xcd, 0xff, 0xc9, + 0xb8, 0x43, 0x8d, 0xc7, 0x11, 0x6a, 0x8f, 0x10, 0xc5, 0xf6, 0x65, 0x7f, 0x84, 0x19, 0xea, 0xdb, + 0x3e, 0x89, 0x92, 0xc2, 0xff, 0xe6, 0x73, 0x85, 0xd8, 0x2c, 0xc5, 0x54, 0x7a, 0x8d, 0x3f, 0x00, + 0x7c, 0xed, 0x8c, 0x91, 0x0c, 0x0f, 0x49, 0x80, 0x4f, 0x0b, 0x04, 0x6a, 0x07, 0xd6, 0x58, 0xc4, + 0xc6, 0xb8, 0x0b, 0x7a, 0xc0, 0xdc, 0x73, 0xa5, 0xa1, 0xf6, 0x60, 0x33, 0xc0, 0xd4, 0xcf, 0xa2, + 0x94, 0x45, 0x24, 0xe9, 0x96, 0x85, 0x6f, 0x73, 0x49, 0xdd, 0x87, 0x4a, 0x36, 0x49, 0x3c, 0x44, + 0xbb, 0x15, 0x99, 0x98, 0x4d, 0x92, 0x01, 0x55, 0xdf, 0x87, 0xaf, 0xf0, 0xda, 0xde, 0x68, 0xc6, + 0xb0, 0xe7, 0x93, 0x00, 0x77, 0xab, 0x3d, 0x60, 0xb6, 0x9c, 0xf6, 0x3c, 0xd7, 0x5b, 0x0f, 0x06, + 0x67, 0x27, 0xce, 0x8c, 0x09, 0x00, 0x6e, 0x8b, 0xc7, 0xad, 0x2c, 0xf5, 0x1c, 0x1e, 0x44, 0x09, + 0x65, 0x28, 0x61, 0x11, 0x62, 0xd8, 0x4b, 0x71, 0x16, 0x47, 0x94, 0xf2, 0xda, 0xf5, 0x1e, 0x30, + 0x9b, 0x47, 0x9a, 0xf5, 0x2c, 0x47, 0xd6, 0xc0, 0xf7, 0x31, 0xa5, 0x43, 0x92, 0x5c, 0x44, 0xa1, + 0xbb, 0xbf, 0x91, 0x7d, 0xba, 0x4e, 0xbe, 0x5f, 0x6d, 0xd4, 0xda, 0xca, 0xfd, 0x6a, 0x43, 0x69, + 0xd7, 0x8d, 0x5f, 0xca, 0xf0, 0x8d, 0xe3, 0xbf, 0xa2, 0x86, 0x24, 0x61, 0x19, 0xf2, 0xd9, 0xae, + 0x98, 0xe8, 0xc0, 0x1a, 0x0a, 0xe2, 0x28, 0x11, 0x04, 0xec, 0xb9, 0xd2, 0x50, 0xdf, 0x82, 0x75, + 0xce, 0x8a, 0x17, 0x05, 0xdd, 0x5a, 0x0f, 0x98, 0x55, 0x07, 0xce, 0x73, 0x5d, 0xe1, 0x14, 0x1c, + 0x7f, 0xec, 0x2a, 0xdc, 0x75, 0x1c, 0xf0, 0xd4, 0x31, 0x1a, 0xe1, 0x71, 0x57, 0x91, 0xa9, 0xc2, + 0x50, 0x4d, 0x58, 0x89, 0x69, 0x28, 0xf8, 0x68, 0x39, 0x07, 0xbf, 0xe7, 0xba, 0xea, 0xa2, 0xe9, + 0xea, 0x14, 0x27, 0x98, 0x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 0xf4, 0x78, 0xa1, 0x95, 0x9e, 0x2c, 0xb4, 0xd2, 0x67, 0xf7, 0x36, 0x2e, 0x91, 0x21, + 0xa1, 0xf1, 0x83, 0xd5, 0x9b, 0x27, 0xb0, 0x1f, 0xc9, 0xb7, 0x8f, 0xb8, 0x48, 0x46, 0x8a, 0x78, + 0xf9, 0xbc, 0xf7, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x70, 0x3f, 0xe6, 0xf2, 0x82, 0x09, 0x00, + 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -926,14 +927,14 @@ func (this *UnpinCodesProposal) Equal(that interface{}) bool { } return true } -func (this *CodeAccessConfigUpdate) Equal(that interface{}) bool { +func (this *AccessConfigUpdate) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*CodeAccessConfigUpdate) + that1, ok := that.(*AccessConfigUpdate) if !ok { - that2, ok := that.(CodeAccessConfigUpdate) + that2, ok := that.(AccessConfigUpdate) if ok { that1 = &that2 } else { @@ -978,11 +979,11 @@ func (this *UpdateInstantiateConfigProposal) Equal(that interface{}) bool { if this.Description != that1.Description { return false } - if len(this.CodeUpdates) != len(that1.CodeUpdates) { + if len(this.AccessConfigUpdates) != len(that1.AccessConfigUpdates) { return false } - for i := range this.CodeUpdates { - if !this.CodeUpdates[i].Equal(&that1.CodeUpdates[i]) { + for i := range this.AccessConfigUpdates { + if !this.AccessConfigUpdates[i].Equal(&that1.AccessConfigUpdates[i]) { return false } } @@ -1519,7 +1520,7 @@ func (m *UnpinCodesProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *CodeAccessConfigUpdate) Marshal() (dAtA []byte, err error) { +func (m *AccessConfigUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1529,12 +1530,12 @@ func (m *CodeAccessConfigUpdate) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CodeAccessConfigUpdate) MarshalTo(dAtA []byte) (int, error) { +func (m *AccessConfigUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *CodeAccessConfigUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AccessConfigUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1548,7 +1549,7 @@ func (m *CodeAccessConfigUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintProposal(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 if m.CodeID != 0 { i = encodeVarintProposal(dAtA, i, uint64(m.CodeID)) i-- @@ -1577,10 +1578,10 @@ func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l - if len(m.CodeUpdates) > 0 { - for iNdEx := len(m.CodeUpdates) - 1; iNdEx >= 0; iNdEx-- { + if len(m.AccessConfigUpdates) > 0 { + for iNdEx := len(m.AccessConfigUpdates) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.CodeUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AccessConfigUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1872,7 +1873,7 @@ func (m *UnpinCodesProposal) Size() (n int) { return n } -func (m *CodeAccessConfigUpdate) Size() (n int) { +func (m *AccessConfigUpdate) Size() (n int) { if m == nil { return 0 } @@ -1900,8 +1901,8 @@ func (m *UpdateInstantiateConfigProposal) Size() (n int) { if l > 0 { n += 1 + l + sovProposal(uint64(l)) } - if len(m.CodeUpdates) > 0 { - for _, e := range m.CodeUpdates { + if len(m.AccessConfigUpdates) > 0 { + for _, e := range m.AccessConfigUpdates { l = e.Size() n += 1 + l + sovProposal(uint64(l)) } @@ -3757,7 +3758,7 @@ func (m *UnpinCodesProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *CodeAccessConfigUpdate) Unmarshal(dAtA []byte) error { +func (m *AccessConfigUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3780,10 +3781,10 @@ func (m *CodeAccessConfigUpdate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CodeAccessConfigUpdate: wiretype end group for non-group") + return fmt.Errorf("proto: AccessConfigUpdate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CodeAccessConfigUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AccessConfigUpdate: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3805,7 +3806,7 @@ func (m *CodeAccessConfigUpdate) Unmarshal(dAtA []byte) error { break } } - case 4: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) } @@ -3954,7 +3955,7 @@ func (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeUpdates", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AccessConfigUpdates", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3981,8 +3982,8 @@ func (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CodeUpdates = append(m.CodeUpdates, CodeAccessConfigUpdate{}) - if err := m.CodeUpdates[len(m.CodeUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.AccessConfigUpdates = append(m.AccessConfigUpdates, AccessConfigUpdate{}) + if err := m.AccessConfigUpdates[len(m.AccessConfigUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 22144c33b10b0080e5f9f2ac9ee751e44bec3a88 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Mon, 9 May 2022 11:37:28 -0600 Subject: [PATCH 13/13] add to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b56d67ca37..c4f5735150 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Yes - Fix SudoContractProposal and ExecuteContractProposal [\#808](https://github.com/CosmWasm/wasmd/pull/808) ([the-frey](https://github.com/the-frey)) **Implemented Enhancements** +- Add UpdateInstantiateConfig governance proposal [\#820](https://github.com/CosmWasm/wasmd/pull/796) ([jhernandezb](https://github.com/jhernandezb)) - Upgrade wasmvm to v1.0.0-rc.0 [\#844](https://github.com/CosmWasm/wasmd/pull/844) - Support state sync [\#478](https://github.com/CosmWasm/wasmd/issues/478) - Upgrade to ibc-go v3 [\#806](https://github.com/CosmWasm/wasmd/issues/806)