From 8cc9a02587c96f819d346673e40b4b683f3c0f5b Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 22 Aug 2024 16:30:27 +0200 Subject: [PATCH] chore: remove x/metaprotocols module --- app/modules.go | 7 - proto/gaia/metaprotocols/extensions.proto | 19 - tests/e2e/chain.go | 2 - tests/e2e/e2e_bank_test.go | 120 ------ x/metaprotocols/README.md | 62 ---- x/metaprotocols/module.go | 94 ----- x/metaprotocols/types/codec.go | 19 - x/metaprotocols/types/extensions.pb.go | 430 ---------------------- x/metaprotocols/types/keys.go | 5 - 9 files changed, 758 deletions(-) delete mode 100644 proto/gaia/metaprotocols/extensions.proto delete mode 100644 x/metaprotocols/README.md delete mode 100644 x/metaprotocols/module.go delete mode 100644 x/metaprotocols/types/codec.go delete mode 100644 x/metaprotocols/types/extensions.pb.go delete mode 100644 x/metaprotocols/types/keys.go diff --git a/app/modules.go b/app/modules.go index 10de2dc2..4731bb47 100644 --- a/app/modules.go +++ b/app/modules.go @@ -42,8 +42,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" atomoneappparams "github.com/atomone-hub/atomone/app/params" - "github.com/atomone-hub/atomone/x/metaprotocols" - metaprotocolstypes "github.com/atomone-hub/atomone/x/metaprotocols/types" ) var maccPerms = map[string][]string{ @@ -84,7 +82,6 @@ var ModuleBasics = module.NewBasicManager( evidence.AppModuleBasic{}, vesting.AppModuleBasic{}, consensus.AppModuleBasic{}, - metaprotocols.AppModuleBasic{}, ) func appModules( @@ -117,7 +114,6 @@ func appModules( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), sdkparams.NewAppModule(app.ParamsKeeper), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - metaprotocols.NewAppModule(), } } @@ -178,7 +174,6 @@ func orderBeginBlockers() []string { paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, - metaprotocolstypes.ModuleName, } } @@ -209,7 +204,6 @@ func orderEndBlockers() []string { upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, - metaprotocolstypes.ModuleName, } } @@ -240,6 +234,5 @@ func orderInitBlockers() []string { upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, - metaprotocolstypes.ModuleName, } } diff --git a/proto/gaia/metaprotocols/extensions.proto b/proto/gaia/metaprotocols/extensions.proto deleted file mode 100644 index 868ee0b7..00000000 --- a/proto/gaia/metaprotocols/extensions.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -package gaia.metaprotocols; - -option go_package = "github.com/cosmos/gaia/x/metaprotocols/types"; - -// ExtensionData is a data structure that can be used in transaction extensions. -message ExtensionData { - // protocol_id is the identifier of the protocol - // the field is not used internally but it is validated for correctness - string protocol_id = 1; - - // protocol_version is the identifier of the protocol version - // the field is not used internally but it is validated for correctness - string protocol_version = 2; - - // arbitrary bytes data that can be used to store any data - // the field is not used internally but it is validated and must be provided - bytes data = 3; -} diff --git a/tests/e2e/chain.go b/tests/e2e/chain.go index 03178f30..2e366888 100644 --- a/tests/e2e/chain.go +++ b/tests/e2e/chain.go @@ -22,7 +22,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" atomoneparams "github.com/atomone-hub/atomone/app/params" - metaprotocoltypes "github.com/atomone-hub/atomone/x/metaprotocols/types" ) const ( @@ -51,7 +50,6 @@ func init() { upgradetypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) distribtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) - metaprotocoltypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) cdc = encodingConfig.Marshaler txConfig = encodingConfig.TxConfig diff --git a/tests/e2e/e2e_bank_test.go b/tests/e2e/e2e_bank_test.go index 14c0b620..1af799b0 100644 --- a/tests/e2e/e2e_bank_test.go +++ b/tests/e2e/e2e_bank_test.go @@ -2,15 +2,9 @@ package e2e import ( "fmt" - "path/filepath" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - extensiontypes "github.com/atomone-hub/atomone/x/metaprotocols/types" ) func (s *IntegrationTestSuite) testBankTokenTransfer() { @@ -102,117 +96,3 @@ func (s *IntegrationTestSuite) testBankTokenTransfer() { ) }) } - -// tests the bank send command with populated non_critical_extension_options field -// the Tx should succeed if the data can be properly encoded and decoded -// the tx is signed and broadcast using atomoned tx sign and broadcast commands -func (s *IntegrationTestSuite) bankSendWithNonCriticalExtensionOptions() { - s.Run("transfer_with_non_critical_extension_options", func() { - c := s.chainA - - submitterAccount := c.genesisAccounts[1] - submitterAddress, err := submitterAccount.keyInfo.GetAddress() - s.Require().NoError(err) - sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(100)))) - - // valid non-critical extension options - ext := &extensiontypes.ExtensionData{ - ProtocolId: "test-protocol", - ProtocolVersion: "1", - Data: []byte("Hello Cosmos"), - } - - extAny, err := codectypes.NewAnyWithValue(ext) - s.Require().NoError(err) - s.Require().NotNil(extAny) - - txBuilder := encodingConfig.TxConfig.NewTxBuilder() - - s.Require().NoError(txBuilder.SetMsgs(sendMsg)) - - txBuilder.SetMemo("non-critical-ext-message-test") - txBuilder.SetFeeAmount(sdk.NewCoins(standardFees)) - txBuilder.SetGasLimit(200000) - - // add extension options - tx := txBuilder.GetTx() - if etx, ok := tx.(authTx.ExtensionOptionsTxBuilder); ok { - etx.SetNonCriticalExtensionOptions(extAny) - } - - bz, err := encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - s.Require().NotNil(bz) - - txWithExt, err := decodeTx(bz) - s.Require().NoError(err) - s.Require().NotNil(txWithExt) - - rawTx, err := cdc.MarshalJSON(txWithExt) - s.Require().NoError(err) - s.Require().NotNil(rawTx) - - unsignedFname := "unsigned_non_critical_extension_option_tx.json" - unsignedJSONFile := filepath.Join(c.validators[0].configDir(), unsignedFname) - err = writeFile(unsignedJSONFile, rawTx) - s.Require().NoError(err) - - signedTx, err := s.signTxFileOnline(c, 0, submitterAddress.String(), unsignedFname) - s.Require().NoError(err) - s.Require().NotNil(signedTx) - - signedFname := "signed_non_critical_extension_option_tx.json" - signedJSONFile := filepath.Join(c.validators[0].configDir(), signedFname) - err = writeFile(signedJSONFile, signedTx) - s.Require().NoError(err) - - // if there's no errors the non_critical_extension_options field was properly encoded and decoded - out, err := s.broadcastTxFile(c, 0, submitterAddress.String(), signedFname) - s.Require().NoError(err) - s.Require().NotNil(out) - }) -} - -// tests the bank send command with invalid non_critical_extension_options field -// the tx should always fail to decode the extension options since no concrete type is registered for the provided extension field -func (s *IntegrationTestSuite) failedBankSendWithNonCriticalExtensionOptions() { - s.Run("fail_encoding_invalid_non_critical_extension_options", func() { - c := s.chainA - - submitterAccount := c.genesisAccounts[1] - submitterAddress, err := submitterAccount.keyInfo.GetAddress() - s.Require().NoError(err) - sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(100)))) - - // the message does not matter, as long as it is in the interface registry - ext := &banktypes.MsgMultiSend{} - - extAny, err := codectypes.NewAnyWithValue(ext) - s.Require().NoError(err) - s.Require().NotNil(extAny) - - txBuilder := encodingConfig.TxConfig.NewTxBuilder() - - s.Require().NoError(txBuilder.SetMsgs(sendMsg)) - - txBuilder.SetMemo("fail-non-critical-ext-message") - txBuilder.SetFeeAmount(sdk.NewCoins(standardFees)) - txBuilder.SetGasLimit(200000) - - // add extension options - tx := txBuilder.GetTx() - if etx, ok := tx.(authTx.ExtensionOptionsTxBuilder); ok { - etx.SetNonCriticalExtensionOptions(extAny) - } - - bz, err := encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - s.Require().NotNil(bz) - - // decode fails because the provided extension option does not implement the correct TxExtensionOptionI interface - txWithExt, err := decodeTx(bz) - s.Require().Error(err) - s.Require().ErrorContains(err, "failed to decode tx: no concrete type registered for type URL /cosmos.bank.v1beta1.MsgMultiSend against interface *tx.TxExtensionOptionI") - s.Require().Nil(txWithExt) - }) -} diff --git a/x/metaprotocols/README.md b/x/metaprotocols/README.md deleted file mode 100644 index e91c2b61..00000000 --- a/x/metaprotocols/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# x/metaprotocols module - -The `x/metaprotocols` module adds support for encoding and decoding additional fields attached to transactions. - -`extension_options` and `non_critical_extension_options` are optional fields that can be used to attach data to valid transactions. The fields are validated by the blockchain, but they are not used in any way. The fields pass validation if they are provided as empty lists (`[ ]`) or they use a list of `ExtensionData` types. - -The application does not use the attached data but it does ensure that the correct type is provided and that it can be successfully unmarshalled. The attached data will be part of a block. - -Here is an example of a correctly formed `non_critical_extension_options` field: - -```json -{ - "@type": "/gaia.metaprotocols.ExtensionData", // must be this exact string - "protocol_id": "some-protocol", - "protocol_version": "1", - "data": "" -} -``` - -Here is an example of a correctly populated `non_critical_extension_options` on a `bank.MsgSend` transaction: - -```json -{ - "body": { - "messages": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from_address": "cosmos1ehpqg9sj09037uhe56sqktk30asn47asthyr22", - "to_address": "cosmos1ehpqg9sj09037uhe56sqktk30asn47asthyr22", - "amount": [ - { - "denom": "uatom", - "amount": "100" - } - ] - } - ], - "memo": "memo_smaller_than_512_bytes", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [ - { - "@type": "/gaia.metaprotocols.ExtensionData", - "protocol_id": "some-protocol", - "protocol_version": "1", - "data": "" - } - ] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} -``` diff --git a/x/metaprotocols/module.go b/x/metaprotocols/module.go deleted file mode 100644 index 22b6a93b..00000000 --- a/x/metaprotocols/module.go +++ /dev/null @@ -1,94 +0,0 @@ -package metaprotocols - -import ( - "encoding/json" - - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/cometbft/cometbft/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/atomone-hub/atomone/x/metaprotocols/types" -) - -const consensusVersion uint64 = 1 - -var ( - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleGenesis = AppModule{} - _ module.AppModule = AppModule{} -) - -type AppModuleBasic struct{} - -func (a AppModuleBasic) Name() string { - return types.ModuleName -} - -// DefaultGenesis is an empty object -func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { - return []byte("{}") -} - -func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, _ json.RawMessage) error { - return nil -} - -func (a AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage { - return a.DefaultGenesis(cdc) -} - -func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate { - return nil -} - -func (AppModule) ConsensusVersion() uint64 { return consensusVersion } - -func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - types.RegisterInterfaces(registry) -} - -func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { -} - -func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { -} - -func (a AppModuleBasic) GetTxCmd() *cobra.Command { - return nil -} - -func (a AppModuleBasic) GetQueryCmd() *cobra.Command { - return nil -} - -func (a AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { -} - -type AppModule struct { - AppModuleBasic -} - -func NewAppModule() *AppModule { - return &AppModule{} -} - -func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) { -} - -func (a AppModule) RegisterServices(_ module.Configurator) { -} - -func (a AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) { -} - -func (a AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return nil -} diff --git a/x/metaprotocols/types/codec.go b/x/metaprotocols/types/codec.go deleted file mode 100644 index da955927..00000000 --- a/x/metaprotocols/types/codec.go +++ /dev/null @@ -1,19 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec/types" - tx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/authz" -) - -// RegisterInterfaces adds the x/metaprotocols module's interfaces to the provided InterfaceRegistry -// The ExtendedData interface is registered so that the TxExtensionOptionsI can be properly encoded and decoded -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations( - (*tx.TxExtensionOptionI)(nil), - &ExtensionData{}, - // needs to be registered to allow parsing of historic data stored in TxExtensionOptions - // the app does not interact with this message in any way but it performs an unmarshal which must not fail - &authz.MsgRevoke{}, - ) -} diff --git a/x/metaprotocols/types/extensions.pb.go b/x/metaprotocols/types/extensions.pb.go deleted file mode 100644 index 74b5a83d..00000000 --- a/x/metaprotocols/types/extensions.pb.go +++ /dev/null @@ -1,430 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: gaia/metaprotocols/extensions.proto - -package types - -import ( - fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// ExtensionData is a data structure that can be used in transaction extensions. -type ExtensionData struct { - // protocol_id is the identifier of the protocol - // the field is not used internally but it is validated for correctness - ProtocolId string `protobuf:"bytes,1,opt,name=protocol_id,json=protocolId,proto3" json:"protocol_id,omitempty"` - // protocol_version is the identifier of the protocol version - // the field is not used internally but it is validated for correctness - ProtocolVersion string `protobuf:"bytes,2,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` - // arbitrary bytes data that can be used to store any data - // the field is not used internally but it is validated and must be provided - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *ExtensionData) Reset() { *m = ExtensionData{} } -func (m *ExtensionData) String() string { return proto.CompactTextString(m) } -func (*ExtensionData) ProtoMessage() {} -func (*ExtensionData) Descriptor() ([]byte, []int) { - return fileDescriptor_2f741ff82d908382, []int{0} -} -func (m *ExtensionData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExtensionData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExtensionData.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 *ExtensionData) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExtensionData.Merge(m, src) -} -func (m *ExtensionData) XXX_Size() int { - return m.Size() -} -func (m *ExtensionData) XXX_DiscardUnknown() { - xxx_messageInfo_ExtensionData.DiscardUnknown(m) -} - -var xxx_messageInfo_ExtensionData proto.InternalMessageInfo - -func (m *ExtensionData) GetProtocolId() string { - if m != nil { - return m.ProtocolId - } - return "" -} - -func (m *ExtensionData) GetProtocolVersion() string { - if m != nil { - return m.ProtocolVersion - } - return "" -} - -func (m *ExtensionData) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func init() { - proto.RegisterType((*ExtensionData)(nil), "gaia.metaprotocols.ExtensionData") -} - -func init() { - proto.RegisterFile("gaia/metaprotocols/extensions.proto", fileDescriptor_2f741ff82d908382) -} - -var fileDescriptor_2f741ff82d908382 = []byte{ - // 197 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0x4f, 0xcc, 0x4c, - 0xd4, 0xcf, 0x4d, 0x2d, 0x49, 0x2c, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0x29, 0xd6, 0x4f, - 0xad, 0x28, 0x49, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0x2b, 0xd6, 0x03, 0x0b, 0x0a, 0x09, 0x81, 0x14, - 0xe9, 0xa1, 0x28, 0x52, 0xca, 0xe7, 0xe2, 0x75, 0x85, 0xa9, 0x73, 0x49, 0x2c, 0x49, 0x14, 0x92, - 0xe7, 0xe2, 0x86, 0xc9, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x71, 0xc1, - 0x84, 0x3c, 0x53, 0x84, 0x34, 0xb9, 0x04, 0xe0, 0x0a, 0xca, 0x52, 0x8b, 0x40, 0x1a, 0x25, 0x98, - 0xc0, 0xaa, 0xf8, 0x61, 0xe2, 0x61, 0x10, 0x61, 0x21, 0x21, 0x2e, 0x96, 0x94, 0xc4, 0x92, 0x44, - 0x09, 0x66, 0x05, 0x46, 0x0d, 0x9e, 0x20, 0x30, 0xdb, 0xc9, 0xed, 0xc4, 0x23, 0x39, 0xc6, 0x0b, - 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, - 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0xf5, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0xc1, 0xbe, 0xaa, 0x40, 0xf3, 0x57, 0x49, 0x65, - 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x58, 0xc0, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf2, 0x06, 0x68, - 0x90, 0xfa, 0x00, 0x00, 0x00, -} - -func (m *ExtensionData) 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 *ExtensionData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExtensionData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintExtensions(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x1a - } - if len(m.ProtocolVersion) > 0 { - i -= len(m.ProtocolVersion) - copy(dAtA[i:], m.ProtocolVersion) - i = encodeVarintExtensions(dAtA, i, uint64(len(m.ProtocolVersion))) - i-- - dAtA[i] = 0x12 - } - if len(m.ProtocolId) > 0 { - i -= len(m.ProtocolId) - copy(dAtA[i:], m.ProtocolId) - i = encodeVarintExtensions(dAtA, i, uint64(len(m.ProtocolId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintExtensions(dAtA []byte, offset int, v uint64) int { - offset -= sovExtensions(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExtensionData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProtocolId) - if l > 0 { - n += 1 + l + sovExtensions(uint64(l)) - } - l = len(m.ProtocolVersion) - if l > 0 { - n += 1 + l + sovExtensions(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovExtensions(uint64(l)) - } - return n -} - -func sovExtensions(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozExtensions(x uint64) (n int) { - return sovExtensions(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExtensionData) 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 ErrIntOverflowExtensions - } - 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: ExtensionData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExtensionData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowExtensions - } - 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 ErrInvalidLengthExtensions - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthExtensions - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProtocolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowExtensions - } - 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 ErrInvalidLengthExtensions - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthExtensions - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProtocolVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowExtensions - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthExtensions - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthExtensions - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipExtensions(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthExtensions - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipExtensions(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowExtensions - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowExtensions - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowExtensions - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthExtensions - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupExtensions - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthExtensions - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthExtensions = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowExtensions = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupExtensions = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/metaprotocols/types/keys.go b/x/metaprotocols/types/keys.go deleted file mode 100644 index 52df9320..00000000 --- a/x/metaprotocols/types/keys.go +++ /dev/null @@ -1,5 +0,0 @@ -package types - -const ( - ModuleName = "metaprotocols" -)