diff --git a/app/app.go b/app/app.go index 790d01c75..f3adc2944 100644 --- a/app/app.go +++ b/app/app.go @@ -100,6 +100,8 @@ import ( axelarParams "github.com/axelarnetwork/axelar-core/app/params" "github.com/axelarnetwork/axelar-core/x/ante" + "github.com/axelarnetwork/axelar-core/x/auxiliary" + auxiliarytypes "github.com/axelarnetwork/axelar-core/x/auxiliary/types" "github.com/axelarnetwork/axelar-core/x/axelarnet" axelarnetclient "github.com/axelarnetwork/axelar-core/x/axelarnet/client" axelarnetKeeper "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" @@ -652,6 +654,7 @@ func initAppModules(keepers *KeeperCache, bApp *bam.BaseApp, encodingConfig axel bApp.Router(), ), permission.NewAppModule(*GetKeeper[permissionKeeper.Keeper](keepers)), + auxiliary.NewAppModule(encodingConfig.Codec, bApp.MsgServiceRouter()), ) return appModules } @@ -692,6 +695,10 @@ func InitCustomAnteDecorators( appOpts servertypes.AppOptions, ) []sdk.AnteDecorator { var anteDecorators []sdk.AnteDecorator + + // unwrap batch messages, must be done before any other custom decorators + anteDecorators = append(anteDecorators, ante.NewBatchDecorator(encodingConfig.Codec)) + // enforce wasm limits earlier in the ante handler chain if IsWasmEnabled() { wasmConfig := mustReadWasmConfig(appOpts) @@ -792,6 +799,7 @@ func orderMigrations() []string { permissionTypes.ModuleName, snapTypes.ModuleName, axelarnetTypes.ModuleName, + auxiliarytypes.ModuleName, ) return migrationOrder } @@ -842,6 +850,7 @@ func orderBeginBlockers() []string { snapTypes.ModuleName, axelarnetTypes.ModuleName, voteTypes.ModuleName, + auxiliarytypes.ModuleName, ) return beginBlockerOrder } @@ -887,6 +896,7 @@ func orderEndBlockers() []string { axelarnetTypes.ModuleName, permissionTypes.ModuleName, voteTypes.ModuleName, + auxiliarytypes.ModuleName, ) return endBlockerOrder } @@ -935,6 +945,7 @@ func orderModulesForGenesis() []string { axelarnetTypes.ModuleName, rewardTypes.ModuleName, permissionTypes.ModuleName, + auxiliarytypes.ModuleName, ) return genesisOrder } @@ -1105,6 +1116,7 @@ func GetModuleBasics() module.BasicManager { axelarnet.AppModuleBasic{}, reward.AppModuleBasic{}, permission.AppModuleBasic{}, + auxiliary.AppModuleBasic{}, } if IsWasmEnabled() { diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index ece9902be..fbee606e1 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,6 +4,25 @@ ## Table of Contents +- [axelar/auxiliary/v1beta1/events.proto](#axelar/auxiliary/v1beta1/events.proto) + - [BatchedMessageFailed](#axelar.auxiliary.v1beta1.BatchedMessageFailed) + +- [axelar/auxiliary/v1beta1/genesis.proto](#axelar/auxiliary/v1beta1/genesis.proto) + - [GenesisState](#axelar.auxiliary.v1beta1.GenesisState) + +- [axelar/permission/exported/v1beta1/types.proto](#axelar/permission/exported/v1beta1/types.proto) + - [Role](#axelar.permission.exported.v1beta1.Role) + + - [File-level Extensions](#axelar/permission/exported/v1beta1/types.proto-extensions) + +- [axelar/auxiliary/v1beta1/tx.proto](#axelar/auxiliary/v1beta1/tx.proto) + - [BatchRequest](#axelar.auxiliary.v1beta1.BatchRequest) + - [BatchResponse](#axelar.auxiliary.v1beta1.BatchResponse) + - [BatchResponse.Response](#axelar.auxiliary.v1beta1.BatchResponse.Response) + +- [axelar/auxiliary/v1beta1/service.proto](#axelar/auxiliary/v1beta1/service.proto) + - [MsgService](#axelar.auxiliary.v1beta1.MsgService) + - [axelar/axelarnet/v1beta1/events.proto](#axelar/axelarnet/v1beta1/events.proto) - [AxelarTransferCompleted](#axelar.axelarnet.v1beta1.AxelarTransferCompleted) - [ContractCallSubmitted](#axelar.axelarnet.v1beta1.ContractCallSubmitted) @@ -122,11 +141,6 @@ - [PendingIBCTransferCountResponse](#axelar.axelarnet.v1beta1.PendingIBCTransferCountResponse) - [PendingIBCTransferCountResponse.TransfersByChainEntry](#axelar.axelarnet.v1beta1.PendingIBCTransferCountResponse.TransfersByChainEntry) -- [axelar/permission/exported/v1beta1/types.proto](#axelar/permission/exported/v1beta1/types.proto) - - [Role](#axelar.permission.exported.v1beta1.Role) - - - [File-level Extensions](#axelar/permission/exported/v1beta1/types.proto-extensions) - - [axelar/axelarnet/v1beta1/tx.proto](#axelar/axelarnet/v1beta1/tx.proto) - [AddCosmosBasedChainRequest](#axelar.axelarnet.v1beta1.AddCosmosBasedChainRequest) - [AddCosmosBasedChainResponse](#axelar.axelarnet.v1beta1.AddCosmosBasedChainResponse) @@ -591,6 +605,191 @@ + +

Top

+ +## axelar/auxiliary/v1beta1/events.proto + + + + + +### BatchedMessageFailed + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `index` | [int32](#int32) | | | +| `error` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## axelar/auxiliary/v1beta1/genesis.proto + + + + + +### GenesisState +GenesisState represents the genesis state + + + + + + + + + + + + + + + + +

Top

+ +## axelar/permission/exported/v1beta1/types.proto + + + + + + + +### Role + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| ROLE_UNSPECIFIED | 0 | | +| ROLE_UNRESTRICTED | 1 | | +| ROLE_CHAIN_MANAGEMENT | 2 | | +| ROLE_ACCESS_CONTROL | 3 | | + + + + + + + +### File-level Extensions +| Extension | Type | Base | Number | Description | +| --------- | ---- | ---- | ------ | ----------- | +| `permission_role` | Role | .google.protobuf.MessageOptions | 50000 | 50000-99999 reserved for use withing individual organizations | + + + + + + + + +

Top

+ +## axelar/auxiliary/v1beta1/tx.proto + + + + + +### BatchRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [bytes](#bytes) | | | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | + + + + + + + + +### BatchResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `responses` | [BatchResponse.Response](#axelar.auxiliary.v1beta1.BatchResponse.Response) | repeated | | + + + + + + + + +### BatchResponse.Response + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `result` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | | | +| `err` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## axelar/auxiliary/v1beta1/service.proto + + + + + + + + + + + +### MsgService +Msg defines the nexus Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Batch` | [BatchRequest](#axelar.auxiliary.v1beta1.BatchRequest) | [BatchResponse](#axelar.auxiliary.v1beta1.BatchResponse) | | POST|/axelar/auxiliary/batch| + + + + +

Top

@@ -2244,44 +2443,6 @@ ParamsRequest represents a message that queries the params - -

Top

- -## axelar/permission/exported/v1beta1/types.proto - - - - - - - -### Role - - -| Name | Number | Description | -| ---- | ------ | ----------- | -| ROLE_UNSPECIFIED | 0 | | -| ROLE_UNRESTRICTED | 1 | | -| ROLE_CHAIN_MANAGEMENT | 2 | | -| ROLE_ACCESS_CONTROL | 3 | | - - - - - - - -### File-level Extensions -| Extension | Type | Base | Number | Description | -| --------- | ---- | ---- | ------ | ----------- | -| `permission_role` | Role | .google.protobuf.MessageOptions | 50000 | 50000-99999 reserved for use withing individual organizations | - - - - - - -

Top

diff --git a/proto/axelar/auxiliary/v1beta1/events.proto b/proto/axelar/auxiliary/v1beta1/events.proto new file mode 100644 index 000000000..90956b702 --- /dev/null +++ b/proto/axelar/auxiliary/v1beta1/events.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package axelar.auxiliary.v1beta1; + +option go_package = "github.com/axelarnetwork/axelar-core/x/auxiliary/types"; +option (gogoproto.messagename_all) = true; + +import "gogoproto/gogo.proto"; + +message BatchedMessageFailed { + int32 index = 1; + string error = 2; +} diff --git a/proto/axelar/auxiliary/v1beta1/genesis.proto b/proto/axelar/auxiliary/v1beta1/genesis.proto new file mode 100644 index 000000000..0d766e10f --- /dev/null +++ b/proto/axelar/auxiliary/v1beta1/genesis.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package axelar.auxiliary.v1beta1; + +option go_package = "github.com/axelarnetwork/axelar-core/x/auxiliary/types"; + +import "gogoproto/gogo.proto"; + +option (gogoproto.goproto_getters_all) = false; + +// GenesisState represents the genesis state +message GenesisState {} diff --git a/proto/axelar/auxiliary/v1beta1/service.proto b/proto/axelar/auxiliary/v1beta1/service.proto new file mode 100644 index 000000000..6d2a08e9b --- /dev/null +++ b/proto/axelar/auxiliary/v1beta1/service.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package axelar.auxiliary.v1beta1; + +option go_package = "github.com/axelarnetwork/axelar-core/x/auxiliary/types"; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "axelar/auxiliary/v1beta1/tx.proto"; + +option (gogoproto.goproto_registration) = true; + +// Msg defines the nexus Msg service. +service MsgService { + rpc Batch(BatchRequest) returns (BatchResponse) { + option (google.api.http) = { + post : "/axelar/auxiliary/batch" + body : "*" + }; + } +} diff --git a/proto/axelar/auxiliary/v1beta1/tx.proto b/proto/axelar/auxiliary/v1beta1/tx.proto new file mode 100644 index 000000000..065016da4 --- /dev/null +++ b/proto/axelar/auxiliary/v1beta1/tx.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package axelar.auxiliary.v1beta1; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; + +import "axelar/permission/exported/v1beta1/types.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/axelarnetwork/axelar-core/x/auxiliary/types"; + +message BatchRequest { + option (permission.exported.v1beta1.permission_role) = ROLE_UNRESTRICTED; + + bytes sender = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + repeated google.protobuf.Any messages = 2 + [ (gogoproto.nullable) = false, (cosmos_proto.accepts_interface) = "cosmos.base.v1beta1.Msg" ]; +} + +message BatchResponse { + message Response { + oneof res { + cosmos.base.abci.v1beta1.Result result = 1; + string err = 2; + } + } + repeated Response responses = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/query.proto b/third_party/proto/ibc/applications/transfer/v1/query.proto index 075c0001c..52f2f2400 100644 --- a/third_party/proto/ibc/applications/transfer/v1/query.proto +++ b/third_party/proto/ibc/applications/transfer/v1/query.proto @@ -11,16 +11,16 @@ option go_package = "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"; // Query provides defines the gRPC querier service. service Query { - // DenomTrace queries a denomination trace information. - rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces/{hash}"; - } - // DenomTraces queries all denomination traces. rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) { option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces"; } + // DenomTrace queries a denomination trace information. + rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { + option (google.api.http).get = "/ibc/apps/transfer/v1/denom_traces/{hash=**}"; + } + // Params queries all parameters of the ibc-transfer module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/ibc/apps/transfer/v1/params"; @@ -28,7 +28,7 @@ service Query { // DenomHash queries a denomination hash information. rpc DenomHash(QueryDenomHashRequest) returns (QueryDenomHashResponse) { - option (google.api.http).get = "/ibc/apps/transfer/v1/denom_hashes/{trace}"; + option (google.api.http).get = "/ibc/apps/transfer/v1/denom_hashes/{trace=**}"; } // EscrowAddress returns the escrow address for a particular port and channel id. diff --git a/utils/events/event_imports_test.go b/utils/events/event_imports_test.go index a7eea9a23..646e60920 100644 --- a/utils/events/event_imports_test.go +++ b/utils/events/event_imports_test.go @@ -3,6 +3,7 @@ package events_test // add types packages for all modules here import ( _ "github.com/axelarnetwork/axelar-core/x/ante/types" + _ "github.com/axelarnetwork/axelar-core/x/auxiliary/types" _ "github.com/axelarnetwork/axelar-core/x/axelarnet/types" _ "github.com/axelarnetwork/axelar-core/x/evm/types" _ "github.com/axelarnetwork/axelar-core/x/multisig/types" diff --git a/x/ante/batch.go b/x/ante/batch.go new file mode 100644 index 000000000..80e7009a4 --- /dev/null +++ b/x/ante/batch.go @@ -0,0 +1,64 @@ +package ante + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + auxiliarytypes "github.com/axelarnetwork/axelar-core/x/auxiliary/types" +) + +// txWithUnwrappedMsgs implements the FeeTx interface +type txWithUnwrappedMsgs struct { + sdk.FeeTx + messages []sdk.Msg +} + +func newTxWithUnwrappedMsgs(tx sdk.Tx) (txWithUnwrappedMsgs, error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return txWithUnwrappedMsgs{}, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "tx must be a FeeTx") + } + + return txWithUnwrappedMsgs{feeTx, unpackMsgs(tx.GetMsgs())}, nil +} + +func (t txWithUnwrappedMsgs) GetMsgs() []sdk.Msg { + return t.messages +} + +// BatchDecorator unwraps batch requests and passes them to the next AnteHandler +type BatchDecorator struct { + cdc codec.Codec +} + +// NewBatchDecorator is the constructor for BatchDecorator +func NewBatchDecorator(cdc codec.Codec) BatchDecorator { + return BatchDecorator{ + cdc, + } +} + +// AnteHandle record qualified refund for the multiSig and vote transactions +func (b BatchDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + tx, err := newTxWithUnwrappedMsgs(tx) + if err != nil { + return ctx, err + } + + return next(ctx, tx, simulate) +} + +func unpackMsgs(msgs []sdk.Msg) []sdk.Msg { + var unpackedMsgs []sdk.Msg + + for _, msg := range msgs { + unpackedMsgs = append(unpackedMsgs, msg) + + if batchReq, ok := msg.(*auxiliarytypes.BatchRequest); ok { + unpackedMsgs = append(unpackedMsgs, batchReq.UnwrapMessages()...) + } + } + + return unpackedMsgs +} diff --git a/x/ante/batch_test.go b/x/ante/batch_test.go new file mode 100644 index 000000000..f5ad3b71b --- /dev/null +++ b/x/ante/batch_test.go @@ -0,0 +1,90 @@ +package ante_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + + appParams "github.com/axelarnetwork/axelar-core/app/params" + "github.com/axelarnetwork/axelar-core/testutils/rand" + "github.com/axelarnetwork/axelar-core/x/ante" + "github.com/axelarnetwork/axelar-core/x/ante/types/mock" + auxiliarytypes "github.com/axelarnetwork/axelar-core/x/auxiliary/types" + evmTypes "github.com/axelarnetwork/axelar-core/x/evm/types" + nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + vote "github.com/axelarnetwork/axelar-core/x/vote/exported" + votetypes "github.com/axelarnetwork/axelar-core/x/vote/types" + . "github.com/axelarnetwork/utils/test" +) + +func TestBatch(t *testing.T) { + var ( + handler sdk.AnteDecorator + tx *mock.FeeTxMock + batchMsg *auxiliarytypes.BatchRequest + unwrappedMsgs []sdk.Msg + ) + + sender := rand.AccAddr() + + givenBatchAnteHandler := Given("the batch ante handler", func() { + encCfg := appParams.MakeEncodingConfig() + handler = ante.NewBatchDecorator(encCfg.Codec) + }) + + givenBatchAnteHandler. + When("messages do not contain batch", func() { + tx = &mock.FeeTxMock{ + GetMsgsFunc: func() []sdk.Msg { + return []sdk.Msg{ + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + } + }, + } + }). + Then("should pass messages as it", func(t *testing.T) { + _, err := handler.AnteHandle(sdk.Context{}, tx, false, + func(_ sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) { + unwrappedMsgs = tx.GetMsgs() + return sdk.Context{}, nil + }) + + assert.NoError(t, err) + assert.Equal(t, 3, len(unwrappedMsgs)) + }). + Run(t) + + givenBatchAnteHandler. + When("a Batch Request is valid", func() { + batchMsg = auxiliarytypes.NewBatchRequest(sender, []sdk.Msg{ + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + }) + }). + Then("should unwrap inner message", func(t *testing.T) { + tx = &mock.FeeTxMock{ + GetMsgsFunc: func() []sdk.Msg { + return []sdk.Msg{ + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + batchMsg, + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + batchMsg, + votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))), + } + }, + } + + _, err := handler.AnteHandle(sdk.Context{}, tx, false, + func(_ sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) { + unwrappedMsgs = tx.GetMsgs() + return sdk.Context{}, nil + }) + + assert.NoError(t, err) + assert.Equal(t, 9, len(unwrappedMsgs)) + }). + Run(t) +} diff --git a/x/ante/types/mock/alias.go b/x/ante/types/mock/alias.go index 0c008c829..5417a97a8 100644 --- a/x/ante/types/mock/alias.go +++ b/x/ante/types/mock/alias.go @@ -5,11 +5,14 @@ import ( "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" ) -//go:generate moq -pkg mock -out ./alias_mock.go . Tx Msg +//go:generate moq -pkg mock -out ./alias_mock.go . Tx FeeTx Msg // Tx alias for mocking type Tx sdk.Tx +// FeeTx alias for mocking +type FeeTx sdk.FeeTx + // Msg alias for mocking type Msg interface { sdk.Msg diff --git a/x/ante/types/mock/alias_mock.go b/x/ante/types/mock/alias_mock.go index f00159342..0cb542adf 100644 --- a/x/ante/types/mock/alias_mock.go +++ b/x/ante/types/mock/alias_mock.go @@ -104,6 +104,250 @@ func (mock *TxMock) ValidateBasicCalls() []struct { return calls } +// Ensure, that FeeTxMock does implement FeeTx. +// If this is not the case, regenerate this file with moq. +var _ FeeTx = &FeeTxMock{} + +// FeeTxMock is a mock implementation of FeeTx. +// +// func TestSomethingThatUsesFeeTx(t *testing.T) { +// +// // make and configure a mocked FeeTx +// mockedFeeTx := &FeeTxMock{ +// FeeGranterFunc: func() sdk.AccAddress { +// panic("mock out the FeeGranter method") +// }, +// FeePayerFunc: func() sdk.AccAddress { +// panic("mock out the FeePayer method") +// }, +// GetFeeFunc: func() sdk.Coins { +// panic("mock out the GetFee method") +// }, +// GetGasFunc: func() uint64 { +// panic("mock out the GetGas method") +// }, +// GetMsgsFunc: func() []sdk.Msg { +// panic("mock out the GetMsgs method") +// }, +// ValidateBasicFunc: func() error { +// panic("mock out the ValidateBasic method") +// }, +// } +// +// // use mockedFeeTx in code that requires FeeTx +// // and then make assertions. +// +// } +type FeeTxMock struct { + // FeeGranterFunc mocks the FeeGranter method. + FeeGranterFunc func() sdk.AccAddress + + // FeePayerFunc mocks the FeePayer method. + FeePayerFunc func() sdk.AccAddress + + // GetFeeFunc mocks the GetFee method. + GetFeeFunc func() sdk.Coins + + // GetGasFunc mocks the GetGas method. + GetGasFunc func() uint64 + + // GetMsgsFunc mocks the GetMsgs method. + GetMsgsFunc func() []sdk.Msg + + // ValidateBasicFunc mocks the ValidateBasic method. + ValidateBasicFunc func() error + + // calls tracks calls to the methods. + calls struct { + // FeeGranter holds details about calls to the FeeGranter method. + FeeGranter []struct { + } + // FeePayer holds details about calls to the FeePayer method. + FeePayer []struct { + } + // GetFee holds details about calls to the GetFee method. + GetFee []struct { + } + // GetGas holds details about calls to the GetGas method. + GetGas []struct { + } + // GetMsgs holds details about calls to the GetMsgs method. + GetMsgs []struct { + } + // ValidateBasic holds details about calls to the ValidateBasic method. + ValidateBasic []struct { + } + } + lockFeeGranter sync.RWMutex + lockFeePayer sync.RWMutex + lockGetFee sync.RWMutex + lockGetGas sync.RWMutex + lockGetMsgs sync.RWMutex + lockValidateBasic sync.RWMutex +} + +// FeeGranter calls FeeGranterFunc. +func (mock *FeeTxMock) FeeGranter() sdk.AccAddress { + if mock.FeeGranterFunc == nil { + panic("FeeTxMock.FeeGranterFunc: method is nil but FeeTx.FeeGranter was just called") + } + callInfo := struct { + }{} + mock.lockFeeGranter.Lock() + mock.calls.FeeGranter = append(mock.calls.FeeGranter, callInfo) + mock.lockFeeGranter.Unlock() + return mock.FeeGranterFunc() +} + +// FeeGranterCalls gets all the calls that were made to FeeGranter. +// Check the length with: +// +// len(mockedFeeTx.FeeGranterCalls()) +func (mock *FeeTxMock) FeeGranterCalls() []struct { +} { + var calls []struct { + } + mock.lockFeeGranter.RLock() + calls = mock.calls.FeeGranter + mock.lockFeeGranter.RUnlock() + return calls +} + +// FeePayer calls FeePayerFunc. +func (mock *FeeTxMock) FeePayer() sdk.AccAddress { + if mock.FeePayerFunc == nil { + panic("FeeTxMock.FeePayerFunc: method is nil but FeeTx.FeePayer was just called") + } + callInfo := struct { + }{} + mock.lockFeePayer.Lock() + mock.calls.FeePayer = append(mock.calls.FeePayer, callInfo) + mock.lockFeePayer.Unlock() + return mock.FeePayerFunc() +} + +// FeePayerCalls gets all the calls that were made to FeePayer. +// Check the length with: +// +// len(mockedFeeTx.FeePayerCalls()) +func (mock *FeeTxMock) FeePayerCalls() []struct { +} { + var calls []struct { + } + mock.lockFeePayer.RLock() + calls = mock.calls.FeePayer + mock.lockFeePayer.RUnlock() + return calls +} + +// GetFee calls GetFeeFunc. +func (mock *FeeTxMock) GetFee() sdk.Coins { + if mock.GetFeeFunc == nil { + panic("FeeTxMock.GetFeeFunc: method is nil but FeeTx.GetFee was just called") + } + callInfo := struct { + }{} + mock.lockGetFee.Lock() + mock.calls.GetFee = append(mock.calls.GetFee, callInfo) + mock.lockGetFee.Unlock() + return mock.GetFeeFunc() +} + +// GetFeeCalls gets all the calls that were made to GetFee. +// Check the length with: +// +// len(mockedFeeTx.GetFeeCalls()) +func (mock *FeeTxMock) GetFeeCalls() []struct { +} { + var calls []struct { + } + mock.lockGetFee.RLock() + calls = mock.calls.GetFee + mock.lockGetFee.RUnlock() + return calls +} + +// GetGas calls GetGasFunc. +func (mock *FeeTxMock) GetGas() uint64 { + if mock.GetGasFunc == nil { + panic("FeeTxMock.GetGasFunc: method is nil but FeeTx.GetGas was just called") + } + callInfo := struct { + }{} + mock.lockGetGas.Lock() + mock.calls.GetGas = append(mock.calls.GetGas, callInfo) + mock.lockGetGas.Unlock() + return mock.GetGasFunc() +} + +// GetGasCalls gets all the calls that were made to GetGas. +// Check the length with: +// +// len(mockedFeeTx.GetGasCalls()) +func (mock *FeeTxMock) GetGasCalls() []struct { +} { + var calls []struct { + } + mock.lockGetGas.RLock() + calls = mock.calls.GetGas + mock.lockGetGas.RUnlock() + return calls +} + +// GetMsgs calls GetMsgsFunc. +func (mock *FeeTxMock) GetMsgs() []sdk.Msg { + if mock.GetMsgsFunc == nil { + panic("FeeTxMock.GetMsgsFunc: method is nil but FeeTx.GetMsgs was just called") + } + callInfo := struct { + }{} + mock.lockGetMsgs.Lock() + mock.calls.GetMsgs = append(mock.calls.GetMsgs, callInfo) + mock.lockGetMsgs.Unlock() + return mock.GetMsgsFunc() +} + +// GetMsgsCalls gets all the calls that were made to GetMsgs. +// Check the length with: +// +// len(mockedFeeTx.GetMsgsCalls()) +func (mock *FeeTxMock) GetMsgsCalls() []struct { +} { + var calls []struct { + } + mock.lockGetMsgs.RLock() + calls = mock.calls.GetMsgs + mock.lockGetMsgs.RUnlock() + return calls +} + +// ValidateBasic calls ValidateBasicFunc. +func (mock *FeeTxMock) ValidateBasic() error { + if mock.ValidateBasicFunc == nil { + panic("FeeTxMock.ValidateBasicFunc: method is nil but FeeTx.ValidateBasic was just called") + } + callInfo := struct { + }{} + mock.lockValidateBasic.Lock() + mock.calls.ValidateBasic = append(mock.calls.ValidateBasic, callInfo) + mock.lockValidateBasic.Unlock() + return mock.ValidateBasicFunc() +} + +// ValidateBasicCalls gets all the calls that were made to ValidateBasic. +// Check the length with: +// +// len(mockedFeeTx.ValidateBasicCalls()) +func (mock *FeeTxMock) ValidateBasicCalls() []struct { +} { + var calls []struct { + } + mock.lockValidateBasic.RLock() + calls = mock.calls.ValidateBasic + mock.lockValidateBasic.RUnlock() + return calls +} + // Ensure, that MsgMock does implement Msg. // If this is not the case, regenerate this file with moq. var _ Msg = &MsgMock{} diff --git a/x/auxiliary/keeper/msg_server.go b/x/auxiliary/keeper/msg_server.go new file mode 100644 index 000000000..d68d68afe --- /dev/null +++ b/x/auxiliary/keeper/msg_server.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "context" + "fmt" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/axelarnetwork/axelar-core/utils/events" + "github.com/axelarnetwork/axelar-core/x/auxiliary/types" +) + +var _ types.MsgServiceServer = msgServer{} + +type msgServer struct { + router *baseapp.MsgServiceRouter +} + +func NewMsgServer(msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer { + return msgServer{ + msgServiceRouter, + } +} + +func (s msgServer) Batch(c context.Context, req *types.BatchRequest) (*types.BatchResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + var results []types.BatchResponse_Response + + for i, message := range req.UnwrapMessages() { + var batchResponse types.BatchResponse_Response + + cacheCtx, writeCache := ctx.CacheContext() + res, err := s.processMessage(cacheCtx, message) + if err != nil { + batchResponse = types.BatchResponse_Response{Res: &types.BatchResponse_Response_Err{Err: err.Error()}} + + events.Emit(ctx, &types.BatchedMessageFailed{ + Index: int32(i), + Error: err.Error(), + }) + } else { + batchResponse = types.BatchResponse_Response{Res: &types.BatchResponse_Response_Result{Result: res}} + + writeCache() + ctx.EventManager().EmitEvents(res.GetEvents()) + } + + results = append(results, batchResponse) + } + + return &types.BatchResponse{ + Responses: results, + }, nil +} + +func (s msgServer) processMessage(ctx sdk.Context, message sdk.Msg) (*sdk.Result, error) { + handler := s.router.Handler(message) + if handler == nil { + return nil, fmt.Errorf("unrecognized message type: %s", sdk.MsgTypeURL(message)) + } + + res, err := handler(ctx, message) + if err != nil { + return nil, fmt.Errorf("execution failed: %s", err) + } + + return res, nil +} diff --git a/x/auxiliary/keeper/msg_server_test.go b/x/auxiliary/keeper/msg_server_test.go new file mode 100644 index 000000000..9a20725d0 --- /dev/null +++ b/x/auxiliary/keeper/msg_server_test.go @@ -0,0 +1,166 @@ +package keeper_test + +import ( + "context" + "fmt" + "testing" + + bam "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc" + + appParams "github.com/axelarnetwork/axelar-core/app/params" + "github.com/axelarnetwork/axelar-core/testutils/fake" + "github.com/axelarnetwork/axelar-core/testutils/rand" + rand2 "github.com/axelarnetwork/axelar-core/testutils/rand" + "github.com/axelarnetwork/axelar-core/x/auxiliary/keeper" + "github.com/axelarnetwork/axelar-core/x/auxiliary/types" + evmTypes "github.com/axelarnetwork/axelar-core/x/evm/types" + nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + vote "github.com/axelarnetwork/axelar-core/x/vote/exported" + votetypes "github.com/axelarnetwork/axelar-core/x/vote/types" + "github.com/axelarnetwork/utils/slices" + . "github.com/axelarnetwork/utils/test" +) + +func TestBatching(t *testing.T) { + var ( + ctx sdk.Context + msgServer types.MsgServiceServer + msgServiceRouter *bam.MsgServiceRouter + + batchRequest *types.BatchRequest + messagehandlerCalled bool + sender sdk.AccAddress + innerMessages []sdk.Msg + ) + + givenMsgServer := Given("an Auxiliary msg server", func() { + ctx = rand2.Context(fake.NewMultiStore()) + msgServiceRouter = bam.NewMsgServiceRouter() + + messagehandlerCalled = false + sender = rand.AccAddr() + innerMessages = slices.Expand2(func() sdk.Msg { + return votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))) + }, int(rand2.I64Between(2, 10))) + + msgServer = keeper.NewMsgServer(msgServiceRouter) + }) + + withBatchRequest := func() GivenStatement { + return Given("a batch request", func() { + batchRequest = types.NewBatchRequest(sender, innerMessages) + }) + + } + + failedHandler := func(ctx context.Context, req interface{}) (interface{}, error) { + messagehandlerCalled = true + return &sdk.Result{}, fmt.Errorf("failed to execute message") + } + + succeededHandler := func(ctx context.Context, req interface{}) (interface{}, error) { + messagehandlerCalled = true + sdk.UnwrapSDKContext(ctx).EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent("executed"), + }) + return &sdk.Result{}, nil + } + + givenMsgServer. + Branch( + withBatchRequest(). + When("handler is not registered", func() {}). + Then("should not revert batch message", func(t *testing.T) { + _, err := msgServer.Batch(sdk.WrapSDKContext(ctx), batchRequest) + assert.NoError(t, err) + assert.False(t, messagehandlerCalled) + + events := ctx.EventManager().Events() + failedMessageEvent := types.BatchedMessageFailed{} + assert.Equal(t, len(innerMessages), len(events)) + assert.True(t, slices.All(events, func(event sdk.Event) bool { + return events[0].Type == failedMessageEvent.XXX_MessageName() + })) + + }), + + withBatchRequest(). + When("failed to executed can fail messages", func() { + registerTestService(msgServiceRouter, failedHandler) + }). + Then("should not revert batch message", func(t *testing.T) { + _, err := msgServer.Batch(sdk.WrapSDKContext(ctx), batchRequest) + assert.NoError(t, err) + assert.True(t, messagehandlerCalled) + + events := ctx.EventManager().Events() + failedMessageEvent := types.BatchedMessageFailed{} + assert.Equal(t, len(innerMessages), len(events)) + assert.True(t, slices.All(events, func(event sdk.Event) bool { + return events[0].Type == failedMessageEvent.XXX_MessageName() + })) + + }), + + withBatchRequest(). + When("executed can fail message", func() { + registerTestService(msgServiceRouter, succeededHandler) + }). + Then("should emit message execution events", func(t *testing.T) { + _, err := msgServer.Batch(sdk.WrapSDKContext(ctx), batchRequest) + assert.NoError(t, err) + assert.True(t, messagehandlerCalled) + + events := ctx.EventManager().Events() + assert.Equal(t, len(batchRequest.Messages), len(events)) + assert.Equal(t, "executed", events[0].Type) + + }), + ). + Run(t) +} + +func registerTestService(msgServiceRouter *bam.MsgServiceRouter, msgHandler func(ctx context.Context, req interface{}) (interface{}, error)) { + encCfg := appParams.MakeEncodingConfig() + encCfg.InterfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &votetypes.VoteRequest{}) + msgServiceRouter.SetInterfaceRegistry(encCfg.InterfaceRegistry) + + handler := func(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(votetypes.VoteRequest) + if err := dec(in); err != nil { + return nil, err + } + + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/axelar.vote.v1beta1.MsgService/Vote", + } + + return interceptor(ctx, in, info, msgHandler) + } + + var serviceDesc = grpc.ServiceDesc{ + ServiceName: "axelar.vote.v1beta1.MsgService", + HandlerType: (*votetypes.MsgServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Vote", + Handler: handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "axelar/vote/v1beta1/service.proto", + } + msgServiceRouter.RegisterService(&serviceDesc, TestMsgServer{}) +} + +type TestMsgServer struct{} + +var _ votetypes.MsgServiceClient = TestMsgServer{} + +func (m TestMsgServer) Vote(_ context.Context, _ *votetypes.VoteRequest, _ ...grpc.CallOption) (*votetypes.VoteResponse, error) { + return &votetypes.VoteResponse{}, nil +} diff --git a/x/auxiliary/module.go b/x/auxiliary/module.go new file mode 100644 index 000000000..b8eb02318 --- /dev/null +++ b/x/auxiliary/module.go @@ -0,0 +1,136 @@ +package auxiliary + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/axelarnetwork/axelar-core/utils/grpc" + "github.com/axelarnetwork/axelar-core/x/auxiliary/keeper" + "github.com/axelarnetwork/axelar-core/x/auxiliary/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic implements module.AppModuleBasic +type AppModuleBasic struct { +} + +// Name returns the name of the module +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the types necessary in this module with the given codec +func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the default genesis state +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + genesis := types.GenesisState{} + return cdc.MustMarshalJSON(&genesis) +} + +// ValidateGenesis checks the given genesis state for validity +func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error { + return nil +} + +// RegisterRESTRoutes registers the REST routes for this module +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} + +// GetTxCmd returns all CLI tx commands for this module +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns all CLI query commands for this module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } + +// AppModule implements module.AppModule +type AppModule struct { + AppModuleBasic + cdc codec.Codec + router *baseapp.MsgServiceRouter +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, router *baseapp.MsgServiceRouter) AppModule { + return AppModule{ + cdc: cdc, + router: router, + } +} + +// RegisterInvariants registers this module's invariants +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) { + // No invariants yet +} + +// InitGenesis initializes the module's keeper from the given genesis state +func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ExportGenesis exports a genesis state from the module's keeper +func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genesis := types.GenesisState{} + + return cdc.MustMarshalJSON(&genesis) +} + +// Route returns the module's route +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, nil) +} + +// QuerierRoute returns this module's query route +func (AppModule) QuerierRoute() string { + return "" +} + +// LegacyQuerierHandler returns a new query handler for this module +func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers module services +func (am AppModule) RegisterServices(cfg module.Configurator) { + logger := func(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) + } + + types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAuxiliary, Logger: logger}, keeper.NewMsgServer(am.router)) +} + +// BeginBlock executes all state transitions this module requires at the beginning of each new block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all state transitions this module requires at the end of each new block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { + return 1 +} diff --git a/x/auxiliary/types/codec.go b/x/auxiliary/types/codec.go new file mode 100644 index 000000000..e2f942e77 --- /dev/null +++ b/x/auxiliary/types/codec.go @@ -0,0 +1,13 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterInterfaces registers types and interfaces with the given registry +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), &BatchRequest{}) + msgservice.RegisterMsgServiceDesc(registry, &_MsgService_serviceDesc) +} diff --git a/x/auxiliary/types/errors.go b/x/auxiliary/types/errors.go new file mode 100644 index 000000000..81fa69879 --- /dev/null +++ b/x/auxiliary/types/errors.go @@ -0,0 +1,12 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// module errors +var ( + // Code 1 is a reserved code for internal errors and should not be used for anything else + _ = sdkerrors.Register(ModuleName, 1, "internal error") + ErrAuxiliary = sdkerrors.Register(ModuleName, 2, "auxiliary module error") +) diff --git a/x/auxiliary/types/events.pb.go b/x/auxiliary/types/events.pb.go new file mode 100644 index 000000000..5eeee42ca --- /dev/null +++ b/x/auxiliary/types/events.pb.go @@ -0,0 +1,359 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: axelar/auxiliary/v1beta1/events.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +type BatchedMessageFailed struct { + Index int32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *BatchedMessageFailed) Reset() { *m = BatchedMessageFailed{} } +func (m *BatchedMessageFailed) String() string { return proto.CompactTextString(m) } +func (*BatchedMessageFailed) ProtoMessage() {} +func (*BatchedMessageFailed) Descriptor() ([]byte, []int) { + return fileDescriptor_6aaa22e2bb7d82c4, []int{0} +} +func (m *BatchedMessageFailed) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchedMessageFailed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchedMessageFailed.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 *BatchedMessageFailed) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchedMessageFailed.Merge(m, src) +} +func (m *BatchedMessageFailed) XXX_Size() int { + return m.Size() +} +func (m *BatchedMessageFailed) XXX_DiscardUnknown() { + xxx_messageInfo_BatchedMessageFailed.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchedMessageFailed proto.InternalMessageInfo + +func (m *BatchedMessageFailed) GetIndex() int32 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *BatchedMessageFailed) GetError() string { + if m != nil { + return m.Error + } + return "" +} + +func (*BatchedMessageFailed) XXX_MessageName() string { + return "axelar.auxiliary.v1beta1.BatchedMessageFailed" +} +func init() { + proto.RegisterType((*BatchedMessageFailed)(nil), "axelar.auxiliary.v1beta1.BatchedMessageFailed") +} + +func init() { + proto.RegisterFile("axelar/auxiliary/v1beta1/events.proto", fileDescriptor_6aaa22e2bb7d82c4) +} + +var fileDescriptor_6aaa22e2bb7d82c4 = []byte{ + // 219 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xac, 0x48, 0xcd, + 0x49, 0x2c, 0xd2, 0x4f, 0x2c, 0xad, 0xc8, 0xcc, 0xc9, 0x4c, 0x2c, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x92, 0x80, 0x28, 0xd3, 0x83, 0x2b, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0x2b, 0xd2, 0x07, 0xb1, 0x20, 0xea, 0x95, 0x9c, 0xb8, 0x44, 0x9c, 0x12, 0x4b, 0x92, + 0x33, 0x52, 0x53, 0x7c, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0xdd, 0x12, 0x33, 0x73, 0x52, 0x53, + 0x84, 0x44, 0xb8, 0x58, 0x33, 0xf3, 0x52, 0x52, 0x2b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x58, 0x83, + 0x20, 0x1c, 0x90, 0x68, 0x6a, 0x51, 0x51, 0x7e, 0x91, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x67, 0x10, + 0x84, 0xe3, 0x14, 0x72, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, + 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe2, 0xb1, 0x1c, 0xe3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, + 0x31, 0x44, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x1c, + 0x97, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0xe5, 0xe9, 0x26, 0xe7, 0x17, 0xa5, 0xea, 0x57, + 0x20, 0x79, 0xac, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x40, 0x63, 0x40, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x6b, 0xdf, 0xe2, 0xd3, 0xf9, 0x00, 0x00, 0x00, +} + +func (m *BatchedMessageFailed) 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 *BatchedMessageFailed) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchedMessageFailed) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x12 + } + if m.Index != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BatchedMessageFailed) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovEvents(uint64(m.Index)) + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *BatchedMessageFailed) 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 ErrIntOverflowEvents + } + 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: BatchedMessageFailed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchedMessageFailed: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/auxiliary/types/genesis.pb.go b/x/auxiliary/types/genesis.pb.go new file mode 100644 index 000000000..00e284129 --- /dev/null +++ b/x/auxiliary/types/genesis.pb.go @@ -0,0 +1,268 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: axelar/auxiliary/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// GenesisState represents the genesis state +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_8b2375ee1af05d34, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "axelar.auxiliary.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("axelar/auxiliary/v1beta1/genesis.proto", fileDescriptor_8b2375ee1af05d34) +} + +var fileDescriptor_8b2375ee1af05d34 = []byte{ + // 174 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xac, 0x48, 0xcd, + 0x49, 0x2c, 0xd2, 0x4f, 0x2c, 0xad, 0xc8, 0xcc, 0xc9, 0x4c, 0x2c, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xa8, 0xd3, 0x83, 0xab, 0xd3, 0x83, 0xaa, 0x93, 0x12, 0x49, 0xcf, + 0x4f, 0xcf, 0x07, 0x2b, 0xd2, 0x07, 0xb1, 0x20, 0xea, 0x95, 0xf8, 0xb8, 0x78, 0xdc, 0x21, 0x06, + 0x04, 0x97, 0x24, 0x96, 0xa4, 0x3a, 0x85, 0x9c, 0x78, 0x28, 0xc7, 0x70, 0xe2, 0x91, 0x1c, 0xe3, + 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, + 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x66, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, + 0xb9, 0xfa, 0x10, 0x8b, 0xf2, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xa1, 0x3c, 0xdd, 0xe4, 0xfc, + 0xa2, 0x54, 0xfd, 0x0a, 0x24, 0x57, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x2d, 0x33, + 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x48, 0x1b, 0xfb, 0x45, 0xc6, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/auxiliary/types/key.go b/x/auxiliary/types/key.go new file mode 100644 index 000000000..9ff500a63 --- /dev/null +++ b/x/auxiliary/types/key.go @@ -0,0 +1,9 @@ +package types + +const ( + // ModuleName is the name of the module + ModuleName = "auxiliary" + + // RouterKey to be used for routing msgs + RouterKey = ModuleName +) diff --git a/x/auxiliary/types/msg_batch.go b/x/auxiliary/types/msg_batch.go new file mode 100644 index 000000000..aa6430588 --- /dev/null +++ b/x/auxiliary/types/msg_batch.go @@ -0,0 +1,98 @@ +package types + +import ( + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/axelarnetwork/utils/funcs" + "github.com/axelarnetwork/utils/slices" +) + +var ( + _ sdk.Msg = &BatchRequest{} + + _ cdctypes.UnpackInterfacesMessage = &BatchRequest{} +) + +// NewBatchRequest is the constructor for BatchRequest +func NewBatchRequest(sender sdk.AccAddress, messages []sdk.Msg) *BatchRequest { + return &BatchRequest{ + Sender: sender, + Messages: slices.Map(messages, func(msg sdk.Msg) cdctypes.Any { return *funcs.Must(cdctypes.NewAnyWithValue(msg)) }), + } +} + +// ValidateBasic executes a stateless message validation +func (m BatchRequest) ValidateBasic() error { + if err := sdk.VerifyAddressFormat(m.Sender); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, sdkerrors.Wrap(err, "sender").Error()) + } + + if len(m.Messages) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty batch") + } + + if anyBatch(m.UnwrapMessages()) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "nested batch requests are not allowed") + } + + for _, msg := range m.UnwrapMessages() { + if !equalAccAddresses(msg.GetSigners(), m.GetSigners()) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message signer mismatch") + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + } + + return nil +} + +// GetSigners returns the set of signers for this message +func (m BatchRequest) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{m.Sender} +} + +// UnpackInterfaces implements UnpackInterfacesMessage +func (m BatchRequest) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { + for _, msg := range m.Messages { + var sdkMsg sdk.Msg + if err := unpacker.UnpackAny(&msg, &sdkMsg); err != nil { + return err + } + } + + return nil +} + +// UnwrapMessages unwrap the batch messages +func (m BatchRequest) UnwrapMessages() []sdk.Msg { + return slices.Map(m.Messages, func(msg cdctypes.Any) sdk.Msg { + return msg.GetCachedValue().(sdk.Msg) + }) +} + +// equalAccAddresses checks the equality of two slices of sdk.AccAddress +func equalAccAddresses(first, second []sdk.AccAddress) bool { + if len(first) != len(second) { + return false + } + + for i := range first { + if !first[i].Equals(second[i]) { + return false + } + } + + return true +} + +// anyBatch checks if any of the messages are a BatchRequest +func anyBatch(msgs []sdk.Msg) bool { + return slices.Any(msgs, func(msg sdk.Msg) bool { + _, ok := msg.(*BatchRequest) + return ok + }) +} diff --git a/x/auxiliary/types/msg_batch_test.go b/x/auxiliary/types/msg_batch_test.go new file mode 100644 index 000000000..620124aa6 --- /dev/null +++ b/x/auxiliary/types/msg_batch_test.go @@ -0,0 +1,33 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + + "github.com/axelarnetwork/axelar-core/testutils/rand" + "github.com/axelarnetwork/axelar-core/x/auxiliary/types" + evmtypes "github.com/axelarnetwork/axelar-core/x/evm/types" +) + +func TestBatchRequest_ValidateBasic(t *testing.T) { + t.Run("should fail with nested batch", func(t *testing.T) { + sender := rand.AccAddr() + + linkRequest := evmtypes.NewLinkRequest(sender, rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5)) + batch := types.NewBatchRequest(sender, []sdk.Msg{linkRequest}) + message := types.NewBatchRequest(sender, []sdk.Msg{linkRequest, batch}) + + assert.ErrorContains(t, message.ValidateBasic(), "nested batch") + }) + + t.Run("should fail with different signers", func(t *testing.T) { + + message := types.NewBatchRequest(rand.AccAddr(), []sdk.Msg{ + evmtypes.NewLinkRequest(rand.AccAddr(), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5)), + }) + + assert.ErrorContains(t, message.ValidateBasic(), "message signer mismatch") + }) +} diff --git a/x/auxiliary/types/service.pb.go b/x/auxiliary/types/service.pb.go new file mode 100644 index 000000000..75d96006e --- /dev/null +++ b/x/auxiliary/types/service.pb.go @@ -0,0 +1,138 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: axelar/auxiliary/v1beta1/service.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + golang_proto "github.com/golang/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = golang_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 + +func init() { + proto.RegisterFile("axelar/auxiliary/v1beta1/service.proto", fileDescriptor_ef1f36cff3796c12) +} +func init() { + golang_proto.RegisterFile("axelar/auxiliary/v1beta1/service.proto", fileDescriptor_ef1f36cff3796c12) +} + +var fileDescriptor_ef1f36cff3796c12 = []byte{ + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xac, 0x48, 0xcd, + 0x49, 0x2c, 0xd2, 0x4f, 0x2c, 0xad, 0xc8, 0xcc, 0xc9, 0x4c, 0x2c, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xa8, 0xd3, 0x83, 0xab, 0xd3, 0x83, 0xaa, 0x93, 0x12, 0x49, 0xcf, + 0x4f, 0xcf, 0x07, 0x2b, 0xd2, 0x07, 0xb1, 0x20, 0xea, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, + 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, + 0x8a, 0xa1, 0xb2, 0x8a, 0x38, 0x6d, 0x2d, 0xa9, 0x80, 0x28, 0x31, 0xea, 0x62, 0xe4, 0xe2, 0xf2, + 0x2d, 0x4e, 0x0f, 0x86, 0xb8, 0x42, 0xa8, 0x86, 0x8b, 0xd5, 0x29, 0xb1, 0x24, 0x39, 0x43, 0x48, + 0x4d, 0x0f, 0x97, 0x4b, 0xf4, 0xc0, 0x0a, 0x82, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0xa4, 0xd4, + 0x09, 0xaa, 0x2b, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0x52, 0x6a, 0xba, 0xfc, 0x64, 0x32, 0x93, + 0x8c, 0x92, 0xb8, 0x3e, 0x86, 0xa3, 0x92, 0x40, 0x0a, 0xad, 0x18, 0xb5, 0x9c, 0x42, 0x4e, 0x3c, + 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x0e, + 0x3c, 0x96, 0x63, 0xbc, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xb3, 0xf4, 0xcc, + 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xa8, 0x19, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, + 0xd9, 0x50, 0x9e, 0x6e, 0x72, 0x7e, 0x51, 0xaa, 0x7e, 0x05, 0x92, 0xc1, 0x25, 0x95, 0x05, 0xa9, + 0xc5, 0x49, 0x6c, 0x60, 0x9f, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x03, 0x3e, 0xeb, + 0x84, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgServiceClient is the client API for MsgService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgServiceClient interface { + Batch(ctx context.Context, in *BatchRequest, opts ...grpc.CallOption) (*BatchResponse, error) +} + +type msgServiceClient struct { + cc grpc1.ClientConn +} + +func NewMsgServiceClient(cc grpc1.ClientConn) MsgServiceClient { + return &msgServiceClient{cc} +} + +func (c *msgServiceClient) Batch(ctx context.Context, in *BatchRequest, opts ...grpc.CallOption) (*BatchResponse, error) { + out := new(BatchResponse) + err := c.cc.Invoke(ctx, "/axelar.auxiliary.v1beta1.MsgService/Batch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServiceServer is the server API for MsgService service. +type MsgServiceServer interface { + Batch(context.Context, *BatchRequest) (*BatchResponse, error) +} + +// UnimplementedMsgServiceServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServiceServer struct { +} + +func (*UnimplementedMsgServiceServer) Batch(ctx context.Context, req *BatchRequest) (*BatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Batch not implemented") +} + +func RegisterMsgServiceServer(s grpc1.Server, srv MsgServiceServer) { + s.RegisterService(&_MsgService_serviceDesc, srv) +} + +func _MsgService_Batch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BatchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServiceServer).Batch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/axelar.auxiliary.v1beta1.MsgService/Batch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServiceServer).Batch(ctx, req.(*BatchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _MsgService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "axelar.auxiliary.v1beta1.MsgService", + HandlerType: (*MsgServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Batch", + Handler: _MsgService_Batch_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "axelar/auxiliary/v1beta1/service.proto", +} diff --git a/x/auxiliary/types/service.pb.gw.go b/x/auxiliary/types/service.pb.gw.go new file mode 100644 index 000000000..e85fa393c --- /dev/null +++ b/x/auxiliary/types/service.pb.gw.go @@ -0,0 +1,164 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: axelar/auxiliary/v1beta1/service.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_MsgService_Batch_0(ctx context.Context, marshaler runtime.Marshaler, client MsgServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BatchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Batch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_MsgService_Batch_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BatchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Batch(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterMsgServiceHandlerServer registers the http handlers for service MsgService to "mux". +// UnaryRPC :call MsgServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterMsgServiceHandlerFromEndpoint instead. +func RegisterMsgServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServiceServer) error { + + mux.Handle("POST", pattern_MsgService_Batch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MsgService_Batch_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_MsgService_Batch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterMsgServiceHandlerFromEndpoint is same as RegisterMsgServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMsgServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterMsgServiceHandler(ctx, mux, conn) +} + +// RegisterMsgServiceHandler registers the http handlers for service MsgService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMsgServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMsgServiceHandlerClient(ctx, mux, NewMsgServiceClient(conn)) +} + +// RegisterMsgServiceHandlerClient registers the http handlers for service MsgService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MsgServiceClient" to call the correct interceptors. +func RegisterMsgServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgServiceClient) error { + + mux.Handle("POST", pattern_MsgService_Batch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MsgService_Batch_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_MsgService_Batch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_MsgService_Batch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"axelar", "auxiliary", "batch"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_MsgService_Batch_0 = runtime.ForwardResponseMessage +) diff --git a/x/auxiliary/types/tx.pb.go b/x/auxiliary/types/tx.pb.go new file mode 100644 index 000000000..43accbaf1 --- /dev/null +++ b/x/auxiliary/types/tx.pb.go @@ -0,0 +1,888 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: axelar/auxiliary/v1beta1/tx.proto + +package types + +import ( + fmt "fmt" + _ "github.com/axelarnetwork/axelar-core/x/permission/exported" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-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 + +type BatchRequest struct { + Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty"` + Messages []types.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages"` +} + +func (m *BatchRequest) Reset() { *m = BatchRequest{} } +func (m *BatchRequest) String() string { return proto.CompactTextString(m) } +func (*BatchRequest) ProtoMessage() {} +func (*BatchRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_01625732e3fafaff, []int{0} +} +func (m *BatchRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchRequest.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 *BatchRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchRequest.Merge(m, src) +} +func (m *BatchRequest) XXX_Size() int { + return m.Size() +} +func (m *BatchRequest) XXX_DiscardUnknown() { + xxx_messageInfo_BatchRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchRequest proto.InternalMessageInfo + +func (m *BatchRequest) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Sender + } + return nil +} + +func (m *BatchRequest) GetMessages() []types.Any { + if m != nil { + return m.Messages + } + return nil +} + +type BatchResponse struct { + Responses []BatchResponse_Response `protobuf:"bytes,1,rep,name=responses,proto3" json:"responses"` +} + +func (m *BatchResponse) Reset() { *m = BatchResponse{} } +func (m *BatchResponse) String() string { return proto.CompactTextString(m) } +func (*BatchResponse) ProtoMessage() {} +func (*BatchResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_01625732e3fafaff, []int{1} +} +func (m *BatchResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchResponse.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 *BatchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchResponse.Merge(m, src) +} +func (m *BatchResponse) XXX_Size() int { + return m.Size() +} +func (m *BatchResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BatchResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchResponse proto.InternalMessageInfo + +func (m *BatchResponse) GetResponses() []BatchResponse_Response { + if m != nil { + return m.Responses + } + return nil +} + +type BatchResponse_Response struct { + // Types that are valid to be assigned to Res: + // *BatchResponse_Response_Result + // *BatchResponse_Response_Err + Res isBatchResponse_Response_Res `protobuf_oneof:"res"` +} + +func (m *BatchResponse_Response) Reset() { *m = BatchResponse_Response{} } +func (m *BatchResponse_Response) String() string { return proto.CompactTextString(m) } +func (*BatchResponse_Response) ProtoMessage() {} +func (*BatchResponse_Response) Descriptor() ([]byte, []int) { + return fileDescriptor_01625732e3fafaff, []int{1, 0} +} +func (m *BatchResponse_Response) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchResponse_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchResponse_Response.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 *BatchResponse_Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchResponse_Response.Merge(m, src) +} +func (m *BatchResponse_Response) XXX_Size() int { + return m.Size() +} +func (m *BatchResponse_Response) XXX_DiscardUnknown() { + xxx_messageInfo_BatchResponse_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchResponse_Response proto.InternalMessageInfo + +type isBatchResponse_Response_Res interface { + isBatchResponse_Response_Res() + MarshalTo([]byte) (int, error) + Size() int +} + +type BatchResponse_Response_Result struct { + Result *types1.Result `protobuf:"bytes,1,opt,name=result,proto3,oneof" json:"result,omitempty"` +} +type BatchResponse_Response_Err struct { + Err string `protobuf:"bytes,2,opt,name=err,proto3,oneof" json:"err,omitempty"` +} + +func (*BatchResponse_Response_Result) isBatchResponse_Response_Res() {} +func (*BatchResponse_Response_Err) isBatchResponse_Response_Res() {} + +func (m *BatchResponse_Response) GetRes() isBatchResponse_Response_Res { + if m != nil { + return m.Res + } + return nil +} + +func (m *BatchResponse_Response) GetResult() *types1.Result { + if x, ok := m.GetRes().(*BatchResponse_Response_Result); ok { + return x.Result + } + return nil +} + +func (m *BatchResponse_Response) GetErr() string { + if x, ok := m.GetRes().(*BatchResponse_Response_Err); ok { + return x.Err + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*BatchResponse_Response) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*BatchResponse_Response_Result)(nil), + (*BatchResponse_Response_Err)(nil), + } +} + +func init() { + proto.RegisterType((*BatchRequest)(nil), "axelar.auxiliary.v1beta1.BatchRequest") + proto.RegisterType((*BatchResponse)(nil), "axelar.auxiliary.v1beta1.BatchResponse") + proto.RegisterType((*BatchResponse_Response)(nil), "axelar.auxiliary.v1beta1.BatchResponse.Response") +} + +func init() { proto.RegisterFile("axelar/auxiliary/v1beta1/tx.proto", fileDescriptor_01625732e3fafaff) } + +var fileDescriptor_01625732e3fafaff = []byte{ + // 438 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x7d, 0x4d, 0x89, 0xda, 0x6b, 0x59, 0xac, 0x4a, 0xb8, 0x19, 0x9c, 0x50, 0x96, 0x2c, + 0xb9, 0x23, 0x45, 0x62, 0xe8, 0x16, 0x4f, 0x65, 0x40, 0x02, 0x8b, 0x89, 0x05, 0x9d, 0xed, 0x87, + 0x6b, 0x35, 0xf1, 0x99, 0x7b, 0x67, 0x70, 0x36, 0x3e, 0x02, 0x9f, 0x05, 0xc1, 0x77, 0x88, 0x98, + 0x3a, 0x32, 0x55, 0x28, 0xf9, 0x16, 0x4c, 0xc8, 0x77, 0x17, 0x27, 0x0c, 0x9d, 0xfc, 0x9e, 0xfd, + 0x7b, 0xef, 0xff, 0xbf, 0xff, 0x99, 0x3e, 0x15, 0x0d, 0xcc, 0x85, 0xe2, 0xa2, 0x6e, 0x8a, 0x79, + 0x21, 0xd4, 0x92, 0x7f, 0x9e, 0x26, 0xa0, 0xc5, 0x94, 0xeb, 0x86, 0x55, 0x4a, 0x6a, 0xe9, 0x07, + 0x16, 0x61, 0x1d, 0xc2, 0x1c, 0x32, 0x38, 0xcf, 0xa5, 0xcc, 0xe7, 0xc0, 0x0d, 0x97, 0xd4, 0x1f, + 0xb9, 0x28, 0x97, 0x76, 0x68, 0x70, 0x96, 0xcb, 0x5c, 0x9a, 0x92, 0xb7, 0x95, 0x7b, 0xcb, 0x9c, + 0x5a, 0x05, 0x6a, 0x51, 0x20, 0x16, 0xb2, 0xe4, 0xd0, 0x54, 0x52, 0x69, 0xc8, 0x76, 0xba, 0xcb, + 0x0a, 0xd0, 0xf1, 0xcf, 0x52, 0x89, 0x0b, 0x89, 0x3c, 0x11, 0x08, 0x5c, 0x24, 0x69, 0xd1, 0x51, + 0x6d, 0xe3, 0xa0, 0x73, 0x0b, 0x7d, 0xb0, 0x6a, 0xb6, 0xb1, 0x9f, 0x2e, 0xbe, 0x13, 0x7a, 0x1a, + 0x09, 0x9d, 0xde, 0xc4, 0xf0, 0xa9, 0x06, 0xd4, 0xfe, 0x2b, 0xda, 0x47, 0x28, 0x33, 0x50, 0x01, + 0x19, 0x91, 0xf1, 0x69, 0x34, 0xfd, 0x7b, 0x3f, 0x9c, 0xe4, 0x85, 0xbe, 0xa9, 0x13, 0x96, 0xca, + 0x85, 0x9b, 0x76, 0x8f, 0x09, 0x66, 0xb7, 0xce, 0xce, 0x2c, 0x4d, 0x67, 0x59, 0xa6, 0x00, 0x31, + 0x76, 0x0b, 0xfc, 0xb7, 0xf4, 0x68, 0x01, 0x88, 0x22, 0x07, 0x0c, 0x0e, 0x46, 0xbd, 0xf1, 0xc9, + 0xe5, 0x19, 0xb3, 0x79, 0xb0, 0x6d, 0x1e, 0x6c, 0x56, 0x2e, 0xa3, 0xe1, 0xea, 0x7e, 0xe8, 0xfd, + 0xfa, 0x31, 0x79, 0xe2, 0x9c, 0xb5, 0x67, 0xd9, 0x26, 0xc8, 0x5e, 0x63, 0x1e, 0x77, 0x6b, 0xae, + 0x0e, 0xbf, 0xfe, 0x0c, 0xc8, 0xc5, 0x8a, 0xd0, 0xc7, 0xce, 0x34, 0x56, 0xb2, 0x44, 0xf0, 0xdf, + 0xd1, 0x63, 0xe5, 0x6a, 0x0c, 0x88, 0xd1, 0x7a, 0xce, 0x1e, 0xba, 0x15, 0xf6, 0xdf, 0x2c, 0xdb, + 0x16, 0xd1, 0x61, 0xeb, 0x23, 0xde, 0x2d, 0x1a, 0x08, 0x7a, 0xd4, 0x29, 0x5c, 0xd1, 0xbe, 0x02, + 0xac, 0xe7, 0xda, 0xe4, 0x72, 0x72, 0x39, 0x62, 0xfb, 0x6e, 0x4d, 0xd8, 0xdb, 0xf5, 0xb1, 0xe1, + 0xae, 0xbd, 0xd8, 0x4d, 0xf8, 0x3e, 0xed, 0x81, 0x52, 0xc1, 0xc1, 0x88, 0x8c, 0x8f, 0xaf, 0xbd, + 0xb8, 0x6d, 0xa2, 0x47, 0xb4, 0xa7, 0x00, 0xa3, 0x37, 0xab, 0x75, 0x48, 0xee, 0xd6, 0x21, 0xf9, + 0xb3, 0x0e, 0xc9, 0xb7, 0x4d, 0xe8, 0xdd, 0x6d, 0x42, 0xef, 0xf7, 0x26, 0xf4, 0xde, 0xbf, 0xdc, + 0x0b, 0xdd, 0x9e, 0xa4, 0x04, 0xfd, 0x45, 0xaa, 0x5b, 0xd7, 0x4d, 0x52, 0xa9, 0x80, 0x37, 0x7b, + 0xff, 0xa5, 0xb9, 0x88, 0xa4, 0x6f, 0xb2, 0x7d, 0xf1, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x31, + 0x05, 0x60, 0xb8, 0x02, 0x00, 0x00, +} + +func (m *BatchRequest) 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 *BatchRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Messages) > 0 { + for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BatchResponse) 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 *BatchResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Responses) > 0 { + for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Responses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *BatchResponse_Response) 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 *BatchResponse_Response) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchResponse_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Res != nil { + { + size := m.Res.Size() + i -= size + if _, err := m.Res.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *BatchResponse_Response_Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchResponse_Response_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Result != nil { + { + size, err := m.Result.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *BatchResponse_Response_Err) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchResponse_Response_Err) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Err) + copy(dAtA[i:], m.Err) + i = encodeVarintTx(dAtA, i, uint64(len(m.Err))) + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BatchRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Messages) > 0 { + for _, e := range m.Messages { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *BatchResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Responses) > 0 { + for _, e := range m.Responses { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *BatchResponse_Response) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Res != nil { + n += m.Res.Size() + } + return n +} + +func (m *BatchResponse_Response_Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != nil { + l = m.Result.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} +func (m *BatchResponse_Response_Err) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Err) + n += 1 + l + sovTx(uint64(l)) + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *BatchRequest) 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: BatchRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) + if m.Sender == nil { + m.Sender = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Messages = append(m.Messages, types.Any{}) + if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *BatchResponse) 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: BatchResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Responses = append(m.Responses, BatchResponse_Response{}) + if err := m.Responses[len(m.Responses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *BatchResponse_Response) 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: Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types1.Result{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Res = &BatchResponse_Response_Result{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Err", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Res = &BatchResponse_Response_Err{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)