From 1003f1353d55d9f5e164321b0a7ab058aaca5448 Mon Sep 17 00:00:00 2001 From: Haiyi Zhong Date: Fri, 15 Mar 2024 18:42:51 -0400 Subject: [PATCH] address comments --- app/app.go | 5 +- docs/proto/proto-docs.md | 8 +- proto/axelar/batcher/v1beta1/tx.proto | 9 +- x/ante/batch.go | 86 +++++++++++ x/batcher/keeper/msg_server.go | 75 +++++----- x/batcher/module.go | 15 +- x/batcher/types/msg_batch.go | 9 +- x/batcher/types/tx.pb.go | 197 +++++++++++++------------- 8 files changed, 242 insertions(+), 162 deletions(-) create mode 100644 x/ante/batch.go diff --git a/app/app.go b/app/app.go index 377affa48..28a508459 100644 --- a/app/app.go +++ b/app/app.go @@ -659,7 +659,7 @@ func initAppModules(keepers *KeeperCache, bApp *bam.BaseApp, encodingConfig axel bApp.Router(), ), permission.NewAppModule(*getKeeper[permissionKeeper.Keeper](keepers)), - batcher.NewAppModule(encodingConfig.Codec, bApp.MsgServiceRouter(), initMessageAnteDecorators(encodingConfig, keepers)), + batcher.NewAppModule(encodingConfig.Codec, bApp.MsgServiceRouter()), ) return appModules @@ -716,6 +716,9 @@ func initAnteHandlers(encodingConfig axelarParams.EncodingConfig, keys map[strin initMessageAnteDecorators(encodingConfig, keepers).ToAnteHandler()), ) + batchAntehandler := sdk.ChainAnteDecorators(anteDecorators...) + anteDecorators = append(anteDecorators, ante.NewBatchDecorator(encodingConfig.Codec, batchAntehandler)) + return sdk.ChainAnteDecorators(anteDecorators...) } diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 31676b907..261a8359f 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -2762,8 +2762,7 @@ GenesisState represents the genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `sender` | [bytes](#bytes) | | | -| `must_succeed_messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | -| `can_fail_messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | @@ -2776,6 +2775,11 @@ GenesisState represents the genesis state +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `results` | [cosmos.base.abci.v1beta1.Result](#cosmos.base.abci.v1beta1.Result) | repeated | | + + diff --git a/proto/axelar/batcher/v1beta1/tx.proto b/proto/axelar/batcher/v1beta1/tx.proto index 0df9470d7..725d29bce 100644 --- a/proto/axelar/batcher/v1beta1/tx.proto +++ b/proto/axelar/batcher/v1beta1/tx.proto @@ -5,6 +5,7 @@ import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "axelar/permission/exported/v1beta1/types.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; option go_package = "github.com/axelarnetwork/axelar-core/x/batcher/types"; @@ -13,10 +14,10 @@ message BatchRequest { bytes sender = 1 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - repeated google.protobuf.Any must_succeed_messages = 2 - [ (gogoproto.nullable) = false ]; - repeated google.protobuf.Any can_fail_messages = 3 + repeated google.protobuf.Any messages = 2 [ (gogoproto.nullable) = false ]; } -message BatchResponse {} +message BatchResponse { + repeated cosmos.base.abci.v1beta1.Result results = 1; +} diff --git a/x/ante/batch.go b/x/ante/batch.go new file mode 100644 index 000000000..1e7752988 --- /dev/null +++ b/x/ante/batch.go @@ -0,0 +1,86 @@ +package ante + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + batchertypes "github.com/axelarnetwork/axelar-core/x/batcher/types" +) + +// messageWrapper implements the Tx interface for a slice of sdk messages +type messageWrapper struct { + messages []sdk.Msg +} + +func (m messageWrapper) ValidateBasic() error { + for _, message := range m.messages { + if err := message.ValidateBasic(); err != nil { + return err + } + } + + return nil +} + +func (m messageWrapper) GetMsgs() []sdk.Msg { + return m.messages +} + +func (m messageWrapper) Append(msg sdk.Msg) messageWrapper { + m.messages = append(m.messages, msg) + + return m +} + +// BatchDecorator runs anteHandler on the inner messages of a batch request +type BatchDecorator struct { + cdc codec.Codec + anteHandler sdk.AnteHandler +} + +// NewBatchDecorator is the constructor for BatchDecorator +func NewBatchDecorator(cdc codec.Codec, anteHandler sdk.AnteHandler) BatchDecorator { + return BatchDecorator{ + cdc, + anteHandler, + } +} + +// 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) { + msgs := tx.GetMsgs() + + for _, msg := range msgs { + switch req := msg.(type) { + case *batchertypes.BatchRequest: + var messages messageWrapper + var err error + + for _, m := range req.Messages { + var sdkMsg sdk.Msg + if err = b.cdc.UnpackAny(&m, &sdkMsg); err != nil { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("unpack failed: %s", err)) + } + + if !msg.GetSigners()[0].Equals(req.Sender) { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("message signer mismatch")) + } + + messages = messages.Append(sdkMsg) + } + + ctx, err = b.anteHandler(ctx, messages, simulate) + if err != nil { + return ctx, err + } + default: + continue + } + + } + + return next(ctx, tx, simulate) +} diff --git a/x/batcher/keeper/msg_server.go b/x/batcher/keeper/msg_server.go index 44613485b..1b34dad0f 100644 --- a/x/batcher/keeper/msg_server.go +++ b/x/batcher/keeper/msg_server.go @@ -9,7 +9,6 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/axelarnetwork/axelar-core/x/ante" "github.com/axelarnetwork/axelar-core/x/batcher/types" "github.com/axelarnetwork/utils/funcs" ) @@ -17,60 +16,27 @@ import ( var _ types.MsgServiceServer = msgServer{} type msgServer struct { - cdc codec.Codec - router *baseapp.MsgServiceRouter - anteHandle ante.MessageAnteHandler + cdc codec.Codec + router *baseapp.MsgServiceRouter } -func NewMsgServer(cdc codec.Codec, msgServiceRouter *baseapp.MsgServiceRouter, anteHandle ante.MessageAnteHandler) types.MsgServiceServer { +func NewMsgServer(cdc codec.Codec, msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer { return msgServer{ cdc, msgServiceRouter, - anteHandle, } } func (s msgServer) Batch(c context.Context, req *types.BatchRequest) (*types.BatchResponse, error) { ctx := sdk.UnwrapSDKContext(c) - processMessage := func(ctx sdk.Context, i int, message *cdctypes.Any) (*sdk.Result, error) { - sdkMsg, err := unpackInnerMessage(s.cdc, message) - if err != nil { - return nil, fmt.Errorf("unpack failed at index %d: %s", i, err) - } - - if err = req.ValidateInnerMessage(sdkMsg); err != nil { - return nil, fmt.Errorf("message validation failed at index %d: %s", i, err) - } - - handler := s.router.Handler(sdkMsg) - if handler == nil { - return nil, fmt.Errorf("unrecognized message type at index %d: %s", i, sdkMsg) - } - - ctx, err = s.anteHandle(ctx, []sdk.Msg{sdkMsg}, false) - if err != nil { - return nil, fmt.Errorf("antehandler failed for message at index %d: %s", i, err) - } - - res, err := handler(ctx, sdkMsg) - if err != nil { - return nil, fmt.Errorf("execution failed for message at index %d: %s", i, err) - } - - return res, nil - } - - for i, message := range req.MustSucceedMessages { - if _, err := processMessage(ctx, i, &message); err != nil { - return nil, err - } - } - + var results []*sdk.Result var failedMessages []types.FailedMessages_FailedMessage - for i, message := range req.CanFailMessages { + + for i, message := range req.Messages { cacheCtx, writeCache := ctx.CacheContext() - res, err := processMessage(cacheCtx, i, &message) + + res, err := s.processMessage(cacheCtx, &message) if err != nil { failedMessages = append(failedMessages, types.FailedMessages_FailedMessage{ Index: int32(i), @@ -80,6 +46,8 @@ func (s msgServer) Batch(c context.Context, req *types.BatchRequest) (*types.Bat writeCache() ctx.EventManager().EmitEvents(res.GetEvents()) } + + results = append(results, res) } if len(failedMessages) > 0 { @@ -88,7 +56,28 @@ func (s msgServer) Batch(c context.Context, req *types.BatchRequest) (*types.Bat })) } - return &types.BatchResponse{}, nil + return &types.BatchResponse{ + Results: results, + }, nil +} + +func (s msgServer) processMessage(ctx sdk.Context, message *cdctypes.Any) (*sdk.Result, error) { + sdkMsg, err := unpackInnerMessage(s.cdc, message) + if err != nil { + return nil, fmt.Errorf("unpack failed: %s", err) + } + + handler := s.router.Handler(sdkMsg) + if handler == nil { + return nil, fmt.Errorf("unrecognized message type: %s", sdk.MsgTypeURL(sdkMsg)) + } + + res, err := handler(ctx, sdkMsg) + if err != nil { + return nil, fmt.Errorf("execution failed: %s", err) + } + + return res, nil } func unpackInnerMessage(cdc codec.Codec, any *cdctypes.Any) (sdk.Msg, error) { diff --git a/x/batcher/module.go b/x/batcher/module.go index 693fd25f7..7839948d4 100644 --- a/x/batcher/module.go +++ b/x/batcher/module.go @@ -17,7 +17,6 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/axelarnetwork/axelar-core/utils/grpc" - "github.com/axelarnetwork/axelar-core/x/ante" "github.com/axelarnetwork/axelar-core/x/batcher/keeper" "github.com/axelarnetwork/axelar-core/x/batcher/types" ) @@ -70,17 +69,15 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } // AppModule implements module.AppModule type AppModule struct { AppModuleBasic - cdc codec.Codec - router *baseapp.MsgServiceRouter - anteHandle ante.MessageAnteHandler + cdc codec.Codec + router *baseapp.MsgServiceRouter } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, router *baseapp.MsgServiceRouter, anteHandle ante.MessageAnteHandler) AppModule { +func NewAppModule(cdc codec.Codec, router *baseapp.MsgServiceRouter) AppModule { return AppModule{ - cdc: cdc, - router: router, - anteHandle: anteHandle, + cdc: cdc, + router: router, } } @@ -122,7 +119,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrBatcher, Logger: logger}, keeper.NewMsgServer(am.cdc, am.router, am.anteHandle)) + types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrBatcher, Logger: logger}, keeper.NewMsgServer(am.cdc, am.router)) } // BeginBlock executes all state transitions this module requires at the beginning of each new block diff --git a/x/batcher/types/msg_batch.go b/x/batcher/types/msg_batch.go index a59ed749b..98c3a8b13 100644 --- a/x/batcher/types/msg_batch.go +++ b/x/batcher/types/msg_batch.go @@ -12,7 +12,7 @@ import ( ) // NewBatchRequest is the constructor for BatchRequest -func NewBatchRequest(sender sdk.AccAddress, mustSucceedMessages []sdk.Msg, canFailMessages []sdk.Msg) *BatchRequest { +func NewBatchRequest(sender sdk.AccAddress, messages []sdk.Msg) *BatchRequest { f := func(msg sdk.Msg) types.Any { messageAny, err := cdctypes.NewAnyWithValue(msg) if err != nil { @@ -22,9 +22,8 @@ func NewBatchRequest(sender sdk.AccAddress, mustSucceedMessages []sdk.Msg, canFa } return &BatchRequest{ - Sender: sender, - MustSucceedMessages: slices.Map(mustSucceedMessages, f), - CanFailMessages: slices.Map(canFailMessages, f), + Sender: sender, + Messages: slices.Map(messages, f), } } @@ -44,7 +43,7 @@ func (m BatchRequest) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, sdkerrors.Wrap(err, "sender").Error()) } - if len(m.MustSucceedMessages) == 0 && len(m.CanFailMessages) == 0 { + if len(m.Messages) == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty batch") } diff --git a/x/batcher/types/tx.pb.go b/x/batcher/types/tx.pb.go index 5e8835535..5782dc174 100644 --- a/x/batcher/types/tx.pb.go +++ b/x/batcher/types/tx.pb.go @@ -8,6 +8,7 @@ import ( _ "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" io "io" @@ -27,9 +28,8 @@ var _ = math.Inf 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"` - MustSucceedMessages []types.Any `protobuf:"bytes,2,rep,name=must_succeed_messages,json=mustSucceedMessages,proto3" json:"must_succeed_messages"` - CanFailMessages []types.Any `protobuf:"bytes,3,rep,name=can_fail_messages,json=canFailMessages,proto3" json:"can_fail_messages"` + 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{} } @@ -72,21 +72,15 @@ func (m *BatchRequest) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress return nil } -func (m *BatchRequest) GetMustSucceedMessages() []types.Any { +func (m *BatchRequest) GetMessages() []types.Any { if m != nil { - return m.MustSucceedMessages - } - return nil -} - -func (m *BatchRequest) GetCanFailMessages() []types.Any { - if m != nil { - return m.CanFailMessages + return m.Messages } return nil } type BatchResponse struct { + Results []*types1.Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` } func (m *BatchResponse) Reset() { *m = BatchResponse{} } @@ -122,6 +116,13 @@ func (m *BatchResponse) XXX_DiscardUnknown() { var xxx_messageInfo_BatchResponse proto.InternalMessageInfo +func (m *BatchResponse) GetResults() []*types1.Result { + if m != nil { + return m.Results + } + return nil +} + func init() { proto.RegisterType((*BatchRequest)(nil), "axelar.batcher.v1beta1.BatchRequest") proto.RegisterType((*BatchResponse)(nil), "axelar.batcher.v1beta1.BatchResponse") @@ -130,30 +131,30 @@ func init() { func init() { proto.RegisterFile("axelar/batcher/v1beta1/tx.proto", fileDescriptor_2b64ca7fe92fc14d) } var fileDescriptor_2b64ca7fe92fc14d = []byte{ - // 359 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x6f, 0xda, 0x40, - 0x18, 0x86, 0xed, 0x82, 0x18, 0x5c, 0x2a, 0x54, 0x97, 0x56, 0x94, 0xc1, 0x20, 0x26, 0x16, 0xee, - 0x44, 0xdb, 0xa9, 0x1b, 0x1e, 0x90, 0x3a, 0x94, 0x81, 0x6e, 0x5d, 0xd0, 0xf9, 0xfc, 0x61, 0x2c, - 0xec, 0x3b, 0xe7, 0xbe, 0x73, 0x62, 0xb6, 0xfc, 0x84, 0xfc, 0x99, 0xfc, 0x07, 0x46, 0xc6, 0x4c, - 0x28, 0x82, 0x1f, 0x11, 0x29, 0x53, 0x84, 0x7d, 0x84, 0x6c, 0x99, 0xfc, 0xf9, 0xf4, 0xbe, 0xcf, - 0x7b, 0xef, 0x77, 0x4e, 0x8f, 0x15, 0x90, 0x30, 0x45, 0x03, 0xa6, 0xf9, 0x0a, 0x14, 0xbd, 0x1e, - 0x07, 0xa0, 0xd9, 0x98, 0xea, 0x82, 0x64, 0x4a, 0x6a, 0xe9, 0x7e, 0xab, 0x04, 0xc4, 0x08, 0x88, - 0x11, 0x74, 0xbf, 0x47, 0x52, 0x46, 0x09, 0xd0, 0x52, 0x15, 0xe4, 0x4b, 0xca, 0xc4, 0xa6, 0xb2, - 0x74, 0xdb, 0x91, 0x8c, 0x64, 0x39, 0xd2, 0xd3, 0x64, 0x4e, 0x89, 0x49, 0xca, 0x40, 0xa5, 0x31, - 0x62, 0x2c, 0x05, 0x85, 0x22, 0x93, 0x4a, 0x43, 0x78, 0x49, 0xdd, 0x64, 0x80, 0x95, 0x7e, 0xf0, - 0x64, 0x3b, 0x4d, 0xff, 0x14, 0x3a, 0x87, 0xab, 0x1c, 0x50, 0xbb, 0x7f, 0x9c, 0x06, 0x82, 0x08, - 0x41, 0x75, 0xec, 0xbe, 0x3d, 0x6c, 0xfa, 0xe3, 0xe7, 0x7d, 0x6f, 0x14, 0xc5, 0x7a, 0x95, 0x07, - 0x84, 0xcb, 0x94, 0x72, 0x89, 0xa9, 0x44, 0xf3, 0x19, 0x61, 0xb8, 0x36, 0xb8, 0x09, 0xe7, 0x93, - 0x30, 0x54, 0x80, 0x38, 0x37, 0x00, 0x77, 0xe6, 0x7c, 0x4d, 0x73, 0xd4, 0x0b, 0xcc, 0x39, 0x07, - 0x08, 0x17, 0x29, 0x20, 0xb2, 0x08, 0xb0, 0xf3, 0xa1, 0x5f, 0x1b, 0x7e, 0xfc, 0xd1, 0x26, 0x55, - 0x39, 0x72, 0x2e, 0x47, 0x26, 0x62, 0xe3, 0xd7, 0xb7, 0xfb, 0x9e, 0x35, 0xff, 0x72, 0x32, 0xfe, - 0xab, 0x7c, 0x7f, 0x8d, 0xcd, 0x9d, 0x3a, 0x9f, 0x39, 0x13, 0x8b, 0x25, 0x8b, 0x93, 0x0b, 0xab, - 0xf6, 0x2e, 0xab, 0xc5, 0x99, 0x98, 0xb2, 0x38, 0x39, 0x73, 0x7e, 0xd7, 0x6f, 0xef, 0x3b, 0xf6, - 0xa0, 0xe5, 0x7c, 0x32, 0xc5, 0x31, 0x93, 0x02, 0xc1, 0x9f, 0x6d, 0x0f, 0x9e, 0xbd, 0x3b, 0x78, - 0xf6, 0xe3, 0xc1, 0xb3, 0xef, 0x8e, 0x9e, 0xb5, 0x3b, 0x7a, 0xd6, 0xc3, 0xd1, 0xb3, 0xfe, 0xff, - 0x7a, 0xd3, 0xbf, 0xda, 0xaf, 0x00, 0x7d, 0x23, 0xd5, 0xda, 0xfc, 0x8d, 0xb8, 0x54, 0x40, 0x8b, - 0xd7, 0xe7, 0x2d, 0x37, 0x12, 0x34, 0xca, 0xbb, 0xfc, 0x7c, 0x09, 0x00, 0x00, 0xff, 0xff, 0x8a, - 0x4c, 0xee, 0xd1, 0xfd, 0x01, 0x00, 0x00, + // 357 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xbd, 0x4e, 0xeb, 0x30, + 0x14, 0x80, 0xe3, 0x7b, 0xab, 0xde, 0xab, 0xdc, 0xde, 0x25, 0xaa, 0x50, 0xe8, 0x90, 0x56, 0x65, + 0xe9, 0x52, 0x5b, 0x05, 0xc4, 0xd0, 0xad, 0xd9, 0x10, 0x12, 0x43, 0x46, 0x36, 0x27, 0x39, 0xa4, + 0x51, 0x9b, 0x38, 0xf8, 0x38, 0x90, 0x6e, 0x3c, 0x02, 0x1b, 0x4f, 0xc2, 0x3b, 0x74, 0xec, 0xc8, + 0x54, 0xa1, 0xf6, 0x2d, 0x98, 0x50, 0x62, 0xb7, 0x30, 0xf9, 0x1c, 0xeb, 0x3b, 0x3f, 0x9f, 0x6d, + 0xf7, 0x79, 0x05, 0x4b, 0x2e, 0x59, 0xc8, 0x55, 0x34, 0x07, 0xc9, 0x1e, 0x27, 0x21, 0x28, 0x3e, + 0x61, 0xaa, 0xa2, 0x85, 0x14, 0x4a, 0x38, 0x27, 0x1a, 0xa0, 0x06, 0xa0, 0x06, 0xe8, 0x9d, 0x26, + 0x42, 0x24, 0x4b, 0x60, 0x0d, 0x15, 0x96, 0xf7, 0x8c, 0xe7, 0x2b, 0x5d, 0xd2, 0xeb, 0x26, 0x22, + 0x11, 0x4d, 0xc8, 0xea, 0xc8, 0xdc, 0x52, 0x33, 0xa9, 0x00, 0x99, 0xa5, 0x88, 0xa9, 0xc8, 0x19, + 0x54, 0x85, 0x90, 0x0a, 0xe2, 0xef, 0xa9, 0xab, 0x02, 0xd0, 0xf0, 0x67, 0x91, 0xc0, 0x4c, 0x20, + 0x0b, 0x39, 0x02, 0xe3, 0x61, 0x94, 0x1e, 0xa9, 0x3a, 0xd1, 0xd0, 0xf0, 0x95, 0xd8, 0x1d, 0xbf, + 0xde, 0x2c, 0x80, 0x87, 0x12, 0x50, 0x39, 0xd7, 0x76, 0x1b, 0x21, 0x8f, 0x41, 0xba, 0x64, 0x40, + 0x46, 0x1d, 0x7f, 0xf2, 0xb9, 0xed, 0x8f, 0x93, 0x54, 0xcd, 0xcb, 0x90, 0x46, 0x22, 0x63, 0xa6, + 0xa9, 0x3e, 0xc6, 0x18, 0x2f, 0xcc, 0xcc, 0x59, 0x14, 0xcd, 0xe2, 0x58, 0x02, 0x62, 0x60, 0x1a, + 0x38, 0x57, 0xf6, 0xdf, 0x0c, 0x10, 0x79, 0x02, 0xe8, 0xfe, 0x1a, 0xfc, 0x1e, 0xfd, 0x3b, 0xef, + 0x52, 0x2d, 0x4d, 0x0f, 0xd2, 0x74, 0x96, 0xaf, 0xfc, 0xd6, 0x7a, 0xdb, 0xb7, 0x82, 0x23, 0x3b, + 0x6d, 0x3d, 0xbf, 0xb9, 0x64, 0x78, 0x63, 0xff, 0x37, 0x8b, 0x61, 0x21, 0x72, 0x04, 0x67, 0x6a, + 0xff, 0x91, 0x80, 0xe5, 0x52, 0xa1, 0x4b, 0x9a, 0x6e, 0x03, 0xaa, 0xb7, 0xa0, 0xb5, 0x21, 0x6d, + 0xa4, 0x8c, 0x21, 0x0d, 0x1a, 0x30, 0x38, 0x14, 0xf8, 0xb7, 0xeb, 0x9d, 0x47, 0x36, 0x3b, 0x8f, + 0x7c, 0xec, 0x3c, 0xf2, 0xb2, 0xf7, 0xac, 0xcd, 0xde, 0xb3, 0xde, 0xf7, 0x9e, 0x75, 0x77, 0xf9, + 0xc3, 0x4d, 0x3f, 0x70, 0x0e, 0xea, 0x49, 0xc8, 0x85, 0xc9, 0xc6, 0x91, 0x90, 0xc0, 0xaa, 0xe3, + 0xff, 0x36, 0xb6, 0x61, 0xbb, 0x11, 0xb8, 0xf8, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xef, 0x39, + 0x98, 0xfe, 0x01, 0x00, 0x00, } func (m *BatchRequest) Marshal() (dAtA []byte, err error) { @@ -176,24 +177,10 @@ func (m *BatchRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.CanFailMessages) > 0 { - for iNdEx := len(m.CanFailMessages) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Messages) > 0 { + for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.CanFailMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.MustSucceedMessages) > 0 { - for iNdEx := len(m.MustSucceedMessages) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MustSucceedMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -234,6 +221,20 @@ func (m *BatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[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 } @@ -258,14 +259,8 @@ func (m *BatchRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.MustSucceedMessages) > 0 { - for _, e := range m.MustSucceedMessages { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.CanFailMessages) > 0 { - for _, e := range m.CanFailMessages { + if len(m.Messages) > 0 { + for _, e := range m.Messages { l = e.Size() n += 1 + l + sovTx(uint64(l)) } @@ -279,6 +274,12 @@ func (m *BatchResponse) Size() (n int) { } var l int _ = l + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -353,41 +354,7 @@ func (m *BatchRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MustSucceedMessages", 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.MustSucceedMessages = append(m.MustSucceedMessages, types.Any{}) - if err := m.MustSucceedMessages[len(m.MustSucceedMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CanFailMessages", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -414,8 +381,8 @@ func (m *BatchRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CanFailMessages = append(m.CanFailMessages, types.Any{}) - if err := m.CanFailMessages[len(m.CanFailMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 @@ -469,6 +436,40 @@ func (m *BatchResponse) Unmarshal(dAtA []byte) error { 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 Results", 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.Results = append(m.Results, &types1.Result{}) + if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])