From 72ec4386447fd16728a79caf9ad06966b5e6bf20 Mon Sep 17 00:00:00 2001 From: Jay Jie Date: Mon, 18 Dec 2023 18:20:38 -0800 Subject: [PATCH] feat: add ability to change max-wasm-size via gov --- proto/sedachain/wasm_storage/v1/tx.proto | 8 + .../wasm_storage/v1/wasm_storage.proto | 4 +- x/wasm-storage/keeper/keeper.go | 32 +- x/wasm-storage/keeper/msg_server.go | 12 + x/wasm-storage/keeper/msg_server_test.go | 47 ++ x/wasm-storage/types/keys.go | 6 + x/wasm-storage/types/tx.pb.go | 403 ++++++++++++++++-- 7 files changed, 465 insertions(+), 47 deletions(-) diff --git a/proto/sedachain/wasm_storage/v1/tx.proto b/proto/sedachain/wasm_storage/v1/tx.proto index d869e51d..269dcd7c 100644 --- a/proto/sedachain/wasm_storage/v1/tx.proto +++ b/proto/sedachain/wasm_storage/v1/tx.proto @@ -17,6 +17,7 @@ service Msg { rpc InstantiateAndRegisterProxyContract( MsgInstantiateAndRegisterProxyContract) returns (MsgInstantiateAndRegisterProxyContractResponse); + rpc SetMaxWasmSize(MsgSetMaxWasmSize) returns (MsgSetMaxWasmSizeResponse); } message MsgStoreDataRequestWasm { @@ -61,3 +62,10 @@ message MsgInstantiateAndRegisterProxyContractResponse { string contract_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } + +message MsgSetMaxWasmSize { + uint64 max_wasm_size = 1; +} + +// no data needs to be returned +message MsgSetMaxWasmSizeResponse {} \ No newline at end of file diff --git a/proto/sedachain/wasm_storage/v1/wasm_storage.proto b/proto/sedachain/wasm_storage/v1/wasm_storage.proto index cf0786fe..31973a37 100644 --- a/proto/sedachain/wasm_storage/v1/wasm_storage.proto +++ b/proto/sedachain/wasm_storage/v1/wasm_storage.proto @@ -28,4 +28,6 @@ enum WasmType { [ (gogoproto.enumvalue_customname) = "WasmTypeRelayer" ]; } -message Params { uint64 max_wasm_size = 1; } +message Params { + uint64 max_wasm_size = 1; +} \ No newline at end of file diff --git a/x/wasm-storage/keeper/keeper.go b/x/wasm-storage/keeper/keeper.go index 7d98f46f..5b7cfa08 100644 --- a/x/wasm-storage/keeper/keeper.go +++ b/x/wasm-storage/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "encoding/hex" + "errors" "fmt" "cosmossdk.io/log" @@ -10,7 +11,6 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sedaprotocol/seda-chain/x/wasm-storage/types" ) @@ -145,3 +145,33 @@ func (k Keeper) GetAllWasms(ctx sdk.Context) []types.Wasm { func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +// GetParams returns all the parameters for the module. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(types.KeyParams)) + + var params types.Params + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// SetParams sets the parameters in the store. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.KeyParams), bz) +} + +// SetMaxWasmSize updates the MaxWasmSize parameter. +func (k Keeper) SetMaxWasmSize(ctx sdk.Context, maxWasmSize uint64) error { + if maxWasmSize == 0 { + return errors.New("MaxWasmSize cannot be zero") + } + + params := k.GetParams(ctx) + params.MaxWasmSize = maxWasmSize + k.SetParams(ctx, params) + + return nil +} diff --git a/x/wasm-storage/keeper/msg_server.go b/x/wasm-storage/keeper/msg_server.go index 77a3d00e..aee575b4 100644 --- a/x/wasm-storage/keeper/msg_server.go +++ b/x/wasm-storage/keeper/msg_server.go @@ -173,3 +173,15 @@ func unzipWasm(wasm []byte) ([]byte, error) { } return unzipped, nil } + +// SetMaxWasmSize sets the MaxWasmSize parameter in the store. +func (k msgServer) SetMaxWasmSize(goCtx context.Context, msg *types.MsgSetMaxWasmSize) (*types.MsgSetMaxWasmSizeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := k.Keeper.SetMaxWasmSize(ctx, msg.MaxWasmSize) + if err != nil { + return nil, err + } + + return &types.MsgSetMaxWasmSizeResponse{}, nil +} diff --git a/x/wasm-storage/keeper/msg_server_test.go b/x/wasm-storage/keeper/msg_server_test.go index f5a885f5..ccb49ce9 100644 --- a/x/wasm-storage/keeper/msg_server_test.go +++ b/x/wasm-storage/keeper/msg_server_test.go @@ -265,3 +265,50 @@ func (s *KeeperTestSuite) TestMarshalJSON() { }) } } + +func (s *KeeperTestSuite) TestSetMaxWasmSize() { + cases := []struct { + name string + preRun func() + input types.MsgSetMaxWasmSize + expErr bool + expErrMsg string + }{ + { + name: "happy path", + input: types.MsgSetMaxWasmSize{ + MaxWasmSize: 1000000, // 1 MB + }, + preRun: func() {}, + expErr: false, + expErrMsg: "", + }, + { + name: "zero size", + input: types.MsgSetMaxWasmSize{ + MaxWasmSize: 0, + }, + preRun: func() {}, + expErr: true, + expErrMsg: "MaxWasmSize cannot be zero", + }, + } + + for _, tc := range cases { + s.Run(tc.name, func() { + s.SetupTest() + tc.preRun() + _, err := s.msgSrvr.SetMaxWasmSize(s.ctx, &tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Equal(tc.expErrMsg, err.Error()) + } else { + s.Require().NoError(err) + + // Check that the MaxWasmSize parameter was correctly set + params := s.wasmStorageKeeper.GetParams(s.ctx) + s.Require().Equal(tc.input.MaxWasmSize, params.MaxWasmSize) + } + }) + } +} diff --git a/x/wasm-storage/types/keys.go b/x/wasm-storage/types/keys.go index d7eded11..1ccd755d 100644 --- a/x/wasm-storage/types/keys.go +++ b/x/wasm-storage/types/keys.go @@ -15,6 +15,12 @@ const ( // RouterKey defines the module's message routing key RouterKey = ModuleName + + // KeyParams is the store key for the parameters. + KeyParams = "params" + + // KeyMaxWasmSize defines the key for the MaxWasmSize parameter + KeyMaxWasmSize = "max-wasm-size" ) var ( diff --git a/x/wasm-storage/types/tx.pb.go b/x/wasm-storage/types/tx.pb.go index 1d5bc7a8..f1a30fc7 100644 --- a/x/wasm-storage/types/tx.pb.go +++ b/x/wasm-storage/types/tx.pb.go @@ -393,6 +393,87 @@ func (m *MsgInstantiateAndRegisterProxyContractResponse) GetContractAddress() st return "" } +type MsgSetMaxWasmSize struct { + MaxWasmSize uint64 `protobuf:"varint,1,opt,name=max_wasm_size,json=maxWasmSize,proto3" json:"max_wasm_size,omitempty"` +} + +func (m *MsgSetMaxWasmSize) Reset() { *m = MsgSetMaxWasmSize{} } +func (m *MsgSetMaxWasmSize) String() string { return proto.CompactTextString(m) } +func (*MsgSetMaxWasmSize) ProtoMessage() {} +func (*MsgSetMaxWasmSize) Descriptor() ([]byte, []int) { + return fileDescriptor_10a76e8135c0d000, []int{6} +} +func (m *MsgSetMaxWasmSize) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMaxWasmSize) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMaxWasmSize.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 *MsgSetMaxWasmSize) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMaxWasmSize.Merge(m, src) +} +func (m *MsgSetMaxWasmSize) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMaxWasmSize) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMaxWasmSize.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMaxWasmSize proto.InternalMessageInfo + +func (m *MsgSetMaxWasmSize) GetMaxWasmSize() uint64 { + if m != nil { + return m.MaxWasmSize + } + return 0 +} + +// no data needs to be returned +type MsgSetMaxWasmSizeResponse struct { +} + +func (m *MsgSetMaxWasmSizeResponse) Reset() { *m = MsgSetMaxWasmSizeResponse{} } +func (m *MsgSetMaxWasmSizeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetMaxWasmSizeResponse) ProtoMessage() {} +func (*MsgSetMaxWasmSizeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_10a76e8135c0d000, []int{7} +} +func (m *MsgSetMaxWasmSizeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMaxWasmSizeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMaxWasmSizeResponse.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 *MsgSetMaxWasmSizeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMaxWasmSizeResponse.Merge(m, src) +} +func (m *MsgSetMaxWasmSizeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMaxWasmSizeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMaxWasmSizeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMaxWasmSizeResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgStoreDataRequestWasm)(nil), "sedachain.wasm_storage.v1.MsgStoreDataRequestWasm") proto.RegisterType((*MsgStoreDataRequestWasmResponse)(nil), "sedachain.wasm_storage.v1.MsgStoreDataRequestWasmResponse") @@ -400,6 +481,8 @@ func init() { proto.RegisterType((*MsgStoreOverlayWasmResponse)(nil), "sedachain.wasm_storage.v1.MsgStoreOverlayWasmResponse") proto.RegisterType((*MsgInstantiateAndRegisterProxyContract)(nil), "sedachain.wasm_storage.v1.MsgInstantiateAndRegisterProxyContract") proto.RegisterType((*MsgInstantiateAndRegisterProxyContractResponse)(nil), "sedachain.wasm_storage.v1.MsgInstantiateAndRegisterProxyContractResponse") + proto.RegisterType((*MsgSetMaxWasmSize)(nil), "sedachain.wasm_storage.v1.MsgSetMaxWasmSize") + proto.RegisterType((*MsgSetMaxWasmSizeResponse)(nil), "sedachain.wasm_storage.v1.MsgSetMaxWasmSizeResponse") } func init() { @@ -407,51 +490,54 @@ func init() { } var fileDescriptor_10a76e8135c0d000 = []byte{ - // 691 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x6b, 0x13, 0x4f, - 0x14, 0xcf, 0x7e, 0xd3, 0xa4, 0xfd, 0x4e, 0x45, 0xcb, 0x1a, 0xe8, 0x36, 0xc2, 0x26, 0xa4, 0x20, - 0x41, 0xcc, 0x6e, 0x13, 0x51, 0xb1, 0x20, 0xd2, 0xa4, 0x97, 0x1c, 0x42, 0x75, 0x2b, 0x14, 0xbc, - 0x84, 0xc9, 0xee, 0x74, 0xb2, 0x98, 0xdd, 0x89, 0xfb, 0x26, 0x6d, 0xe2, 0xd1, 0x83, 0x67, 0xff, - 0x0d, 0x05, 0x41, 0xa8, 0x7f, 0x80, 0xc7, 0x1e, 0x8b, 0x27, 0x4f, 0x55, 0xd2, 0x83, 0xff, 0x83, - 0x27, 0x99, 0x9d, 0x49, 0x48, 0xb1, 0x89, 0xa9, 0x5e, 0x3c, 0xcd, 0x9b, 0x79, 0x9f, 0xf7, 0xfb, - 0x7d, 0x76, 0x51, 0x01, 0x88, 0x87, 0xdd, 0x36, 0xf6, 0x43, 0xfb, 0x10, 0x43, 0xd0, 0x04, 0xce, - 0x22, 0x4c, 0x89, 0x7d, 0x50, 0xb6, 0x79, 0xdf, 0xea, 0x46, 0x8c, 0x33, 0x7d, 0x6d, 0x8c, 0xb1, - 0x26, 0x31, 0xd6, 0x41, 0x39, 0x6b, 0xba, 0x0c, 0x02, 0x06, 0x76, 0x0b, 0x83, 0xb0, 0x69, 0x11, - 0x8e, 0xcb, 0xb6, 0xcb, 0xfc, 0x50, 0x9a, 0x66, 0x57, 0x95, 0x3e, 0x00, 0x2a, 0x5c, 0x06, 0x40, - 0x95,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, 0xbf, 0x29, 0x6a, - 0x59, 0xca, 0x6b, 0xc5, 0x25, 0x27, 0xbd, 0xef, 0xf7, 0x1b, 0x40, 0xcf, 0x0f, 0xba, 0x87, 0xac, - 0xf9, 0x86, 0x36, 0x9e, 0x7d, 0x0d, 0xad, 0xb8, 0xea, 0xad, 0x89, 0x65, 0xef, 0x7f, 0x3b, 0xc6, - 0x6b, 0x23, 0x0b, 0xf5, 0x5c, 0xf9, 0x94, 0x44, 0xc9, 0x06, 0x50, 0xfd, 0xb5, 0x86, 0x32, 0x17, - 0xf2, 0xbe, 0x32, 0x63, 0x79, 0xa7, 0x90, 0x2f, 0xbb, 0x79, 0x79, 0x9b, 0x71, 0x55, 0x2f, 0xd1, - 0xca, 0x2f, 0xc4, 0xb4, 0xe6, 0xf0, 0x37, 0x81, 0xcf, 0xde, 0xbb, 0x1c, 0x7e, 0x1c, 0xfb, 0x48, - 0x43, 0xeb, 0xf3, 0xd0, 0x66, 0x6b, 0xb6, 0xff, 0x39, 0x5c, 0x64, 0xeb, 0x7f, 0xed, 0x62, 0x94, - 0x75, 0xf5, 0xc9, 0xf1, 0xd0, 0xd4, 0x4e, 0x86, 0xa6, 0xf6, 0x6d, 0x68, 0x6a, 0x6f, 0xce, 0xcc, - 0xc4, 0xc9, 0x99, 0x99, 0xf8, 0x72, 0x66, 0x26, 0x9e, 0xdd, 0x9f, 0x58, 0x5f, 0x11, 0x2e, 0xfe, - 0xca, 0xbb, 0xac, 0x13, 0x5f, 0x4a, 0xf2, 0xb7, 0x20, 0x99, 0x53, 0x1a, 0xfd, 0x18, 0xe2, 0x9d, - 0x6e, 0xa5, 0x63, 0xe4, 0x9d, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0x19, 0xfd, 0xa3, 0xe8, - 0x06, 0x00, 0x00, + // 751 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcb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xff, 0x30, 0x7d, 0x13, 0xcb, 0xb4, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -469,6 +555,7 @@ type MsgClient interface { StoreDataRequestWasm(ctx context.Context, in *MsgStoreDataRequestWasm, opts ...grpc.CallOption) (*MsgStoreDataRequestWasmResponse, error) StoreOverlayWasm(ctx context.Context, in *MsgStoreOverlayWasm, opts ...grpc.CallOption) (*MsgStoreOverlayWasmResponse, error) InstantiateAndRegisterProxyContract(ctx context.Context, in *MsgInstantiateAndRegisterProxyContract, opts ...grpc.CallOption) (*MsgInstantiateAndRegisterProxyContractResponse, error) + SetMaxWasmSize(ctx context.Context, in *MsgSetMaxWasmSize, opts ...grpc.CallOption) (*MsgSetMaxWasmSizeResponse, error) } type msgClient struct { @@ -506,11 +593,21 @@ func (c *msgClient) InstantiateAndRegisterProxyContract(ctx context.Context, in return out, nil } +func (c *msgClient) SetMaxWasmSize(ctx context.Context, in *MsgSetMaxWasmSize, opts ...grpc.CallOption) (*MsgSetMaxWasmSizeResponse, error) { + out := new(MsgSetMaxWasmSizeResponse) + err := c.cc.Invoke(ctx, "/sedachain.wasm_storage.v1.Msg/SetMaxWasmSize", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { StoreDataRequestWasm(context.Context, *MsgStoreDataRequestWasm) (*MsgStoreDataRequestWasmResponse, error) StoreOverlayWasm(context.Context, *MsgStoreOverlayWasm) (*MsgStoreOverlayWasmResponse, error) InstantiateAndRegisterProxyContract(context.Context, *MsgInstantiateAndRegisterProxyContract) (*MsgInstantiateAndRegisterProxyContractResponse, error) + SetMaxWasmSize(context.Context, *MsgSetMaxWasmSize) (*MsgSetMaxWasmSizeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -526,6 +623,9 @@ func (*UnimplementedMsgServer) StoreOverlayWasm(ctx context.Context, req *MsgSto func (*UnimplementedMsgServer) InstantiateAndRegisterProxyContract(ctx context.Context, req *MsgInstantiateAndRegisterProxyContract) (*MsgInstantiateAndRegisterProxyContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InstantiateAndRegisterProxyContract not implemented") } +func (*UnimplementedMsgServer) SetMaxWasmSize(ctx context.Context, req *MsgSetMaxWasmSize) (*MsgSetMaxWasmSizeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetMaxWasmSize not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -585,6 +685,24 @@ func _Msg_InstantiateAndRegisterProxyContract_Handler(srv interface{}, ctx conte return interceptor(ctx, in, info, handler) } +func _Msg_SetMaxWasmSize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetMaxWasmSize) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetMaxWasmSize(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sedachain.wasm_storage.v1.Msg/SetMaxWasmSize", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetMaxWasmSize(ctx, req.(*MsgSetMaxWasmSize)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "sedachain.wasm_storage.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -601,6 +719,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "InstantiateAndRegisterProxyContract", Handler: _Msg_InstantiateAndRegisterProxyContract_Handler, }, + { + MethodName: "SetMaxWasmSize", + Handler: _Msg_SetMaxWasmSize_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sedachain/wasm_storage/v1/tx.proto", @@ -867,6 +989,57 @@ func (m *MsgInstantiateAndRegisterProxyContractResponse) MarshalToSizedBuffer(dA return len(dAtA) - i, nil } +func (m *MsgSetMaxWasmSize) 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 *MsgSetMaxWasmSize) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMaxWasmSize) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MaxWasmSize != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.MaxWasmSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgSetMaxWasmSizeResponse) 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 *MsgSetMaxWasmSizeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMaxWasmSizeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -998,6 +1171,27 @@ func (m *MsgInstantiateAndRegisterProxyContractResponse) Size() (n int) { return n } +func (m *MsgSetMaxWasmSize) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxWasmSize != 0 { + n += 1 + sovTx(uint64(m.MaxWasmSize)) + } + return n +} + +func (m *MsgSetMaxWasmSizeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1807,6 +2001,125 @@ func (m *MsgInstantiateAndRegisterProxyContractResponse) Unmarshal(dAtA []byte) } return nil } +func (m *MsgSetMaxWasmSize) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetMaxWasmSize: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMaxWasmSize: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxWasmSize", wireType) + } + m.MaxWasmSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxWasmSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetMaxWasmSizeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetMaxWasmSizeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMaxWasmSizeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0