Merge branch 'master' into adr_gov_split_vote
This commit is contained in:
commit
09d977e334
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -40,7 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||
|
||||
* (x/staking) [\#7499](https://github.com/cosmos/cosmos-sdk/pull/7499) `BondStatus` is now a protobuf `enum` instead of an `int32`, and JSON serialized using its protobuf name, so expect names like `BOND_STATUS_UNBONDING` as opposed to `Unbonding`.
|
||||
* (x/evidence) [\#7538](https://github.com/cosmos/cosmos-sdk/pull/7538) The ABCI's `Result.Data` field of `MsgSubmitEvidence` does not contain the raw evidence's hash, but the encoded `MsgSubmitEvidenceResponse` struct.
|
||||
* (x/upgrade) [#7697](https://github.com/cosmos/cosmos-sdk/pull/7697) Rename flag name "--time" to "--upgrade-time", "--info" to "--upgrade-info", to keep it consistent with help message.
|
||||
* (x/upgrade) [#7697](https://github.com/cosmos/cosmos-sdk/pull/7697) Rename flag name "--time" to "--upgrade-time", "--info" to "--upgrade-info", to keep it consistent with help message.
|
||||
|
||||
### API Breaking
|
||||
|
||||
|
@ -51,16 +51,19 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||
* `Validator.ConsensusPubkey` type changed from `string` to `codectypes.Any`.
|
||||
* `MsgCreateValidator.Pubkey` type changed from `string` to `codectypes.Any`.
|
||||
* Deprecating and renaming `MakeEncodingConfig` to `MakeTestEncodingConfig` (both in `simapp` and `simapp/params` packages).
|
||||
* (tx) [\#7688](https://github.com/cosmos/cosmos-sdk/pull/7688) The gRPC simulate service method has been moved from `cosmos.base.v1beta1.simulate` to `cosmos.tx.v1beta1`, as a method in the Tx service.
|
||||
|
||||
### Features
|
||||
|
||||
* (codec) [\#7519](https://github.com/cosmos/cosmos-sdk/pull/7519) `InterfaceRegistry` now inherits `jsonpb.AnyResolver`, and has a `RegisterCustomTypeURL` method to support ADR 031 packing of `Any`s. `AnyResolver` is now a required parameter to `RejectUnknownFields`.
|
||||
* (baseapp) [\#7519](https://github.com/cosmos/cosmos-sdk/pull/7519) Add `ServiceMsgRouter` to BaseApp to handle routing of protobuf service `Msg`s. The two new types defined in ADR 031, `sdk.ServiceMsg` and `sdk.MsgRequest` are introduced with this router.
|
||||
* (tx) [\#7688](https://github.com/cosmos/cosmos-sdk/pull/7688) Add a new Tx gRPC service with methods `Simulate` and `GetTx` (by hash).
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (kvstore) [\#7415](https://github.com/cosmos/cosmos-sdk/pull/7415) Allow new stores to be registered during on-chain upgrades.
|
||||
* (client) [\#7699](https://github.com/cosmos/cosmos-sdk/pull/7699) Fix panic in context when setting invalid nodeURI. `WithNodeURI` does not set the `Client` in the context.
|
||||
* (x/gov) [#7641](https://github.com/cosmos/cosmos-sdk/pull/7641) Fix tally calculation precision error.
|
||||
|
||||
|
||||
## [v0.40.0-rc0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.40.0-rc0) - 2020-10-13
|
||||
|
@ -651,6 +654,7 @@ generalized genesis accounts through the `GenesisAccount` interface.
|
|||
* (sdk) [\#4758](https://github.com/cosmos/cosmos-sdk/issues/4758) update `x/genaccounts` to match module spec
|
||||
* (simulation) [\#4824](https://github.com/cosmos/cosmos-sdk/issues/4824) `PrintAllInvariants` flag will print all failed invariants
|
||||
* (simulation) [\#4490](https://github.com/cosmos/cosmos-sdk/issues/4490) add `InitialBlockHeight` flag to resume a simulation from a given block
|
||||
|
||||
* Support exporting the simulation stats to a given JSON file
|
||||
* (simulation) [\#4847](https://github.com/cosmos/cosmos-sdk/issues/4847), [\#4838](https://github.com/cosmos/cosmos-sdk/pull/4838) and [\#4869](https://github.com/cosmos/cosmos-sdk/pull/4869) `SimApp` and simulation refactors:
|
||||
* Implement `SimulationManager` for executing modules' simulation functionalities in a modularized way
|
||||
|
@ -964,6 +968,7 @@ that error is that the account doesn't exist.
|
|||
* (simulation) PrintAllInvariants flag will print all failed invariants
|
||||
* (simulation) Add `InitialBlockHeight` flag to resume a simulation from a given block
|
||||
* (simulation) [\#4670](https://github.com/cosmos/cosmos-sdk/issues/4670) Update simulation statistics to JSON format
|
||||
|
||||
- Support exporting the simulation stats to a given JSON file
|
||||
* [\#4775](https://github.com/cosmos/cosmos-sdk/issues/4775) Refactor CI config
|
||||
* Upgrade IAVL to v0.12.4
|
||||
|
@ -1569,8 +1574,9 @@ BREAKING CHANGES
|
|||
FEATURES
|
||||
|
||||
* Gaia REST API
|
||||
* [\#2358](https://github.com/cosmos/cosmos-sdk/issues/2358) Add distribution module REST interface
|
||||
|
||||
|
||||
* [\#2358](https://github.com/cosmos/cosmos-sdk/issues/2358) Add distribution module REST interface
|
||||
|
||||
* Gaia CLI (`gaiacli`)
|
||||
* [\#3429](https://github.com/cosmos/cosmos-sdk/issues/3429) Support querying
|
||||
for all delegator distribution rewards.
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"google.golang.org/grpc/encoding/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
@ -128,14 +127,3 @@ func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.In
|
|||
reflection.NewReflectionServiceServer(interfaceRegistry),
|
||||
)
|
||||
}
|
||||
|
||||
// RegisterSimulateService registers the simulate service on the gRPC router.
|
||||
func (qrt *GRPCQueryRouter) RegisterSimulateService(
|
||||
simulateFn simulate.BaseAppSimulateFn,
|
||||
interfaceRegistry codectypes.InterfaceRegistry,
|
||||
) {
|
||||
simulate.RegisterSimulateServiceServer(
|
||||
qrt,
|
||||
simulate.NewSimulateServer(simulateFn, interfaceRegistry),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url": "./tmp-swagger-gen/ibc/channel/query.swagger.json",
|
||||
"url": "./tmp-swagger-gen/ibc/core/channel/v1/query.swagger.json",
|
||||
"operationIds": {
|
||||
"rename": {
|
||||
"Params": "IBCChannelParams"
|
||||
|
@ -102,7 +102,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url": "./tmp-swagger-gen/ibc/client/query.swagger.json",
|
||||
"url": "./tmp-swagger-gen/ibc/core/client/v1/query.swagger.json",
|
||||
"operationIds": {
|
||||
"rename": {
|
||||
"Params": "IBCClientParams"
|
||||
|
@ -110,7 +110,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url": "./tmp-swagger-gen/ibc/connection/query.swagger.json",
|
||||
"url": "./tmp-swagger-gen/ibc/core/connection/v1/query.swagger.json",
|
||||
"operationIds": {
|
||||
"rename": {
|
||||
"Params": "IBCConnectionParams"
|
||||
|
@ -118,7 +118,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url": "./tmp-swagger-gen/ibc/transfer/query.swagger.json",
|
||||
"url": "./tmp-swagger-gen/ibc/applications/transfer/v1/query.swagger.json",
|
||||
"operationIds": {
|
||||
"rename": {
|
||||
"Params": "IBCTransferParams"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,55 +0,0 @@
|
|||
package simulate
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// BaseAppSimulateFn is the signature of the Baseapp#Simulate function.
|
||||
type BaseAppSimulateFn func(txBytes []byte) (sdk.GasInfo, *sdk.Result, error)
|
||||
|
||||
type simulateServer struct {
|
||||
simulate BaseAppSimulateFn
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
}
|
||||
|
||||
// NewSimulateServer creates a new SimulateServer.
|
||||
func NewSimulateServer(simulate BaseAppSimulateFn, interfaceRegistry codectypes.InterfaceRegistry) SimulateServiceServer {
|
||||
return simulateServer{
|
||||
simulate: simulate,
|
||||
interfaceRegistry: interfaceRegistry,
|
||||
}
|
||||
}
|
||||
|
||||
var _ SimulateServiceServer = simulateServer{}
|
||||
|
||||
// Simulate implements the SimulateService.Simulate RPC method.
|
||||
func (s simulateServer) Simulate(ctx context.Context, req *SimulateRequest) (*SimulateResponse, error) {
|
||||
if req.Tx == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid empty tx")
|
||||
}
|
||||
|
||||
err := req.Tx.UnpackInterfaces(s.interfaceRegistry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
txBytes, err := req.Tx.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gasInfo, result, err := s.simulate(txBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SimulateResponse{
|
||||
GasInfo: &gasInfo,
|
||||
Result: result,
|
||||
}, nil
|
||||
}
|
|
@ -1,679 +0,0 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cosmos/base/simulate/v1beta1/simulate.proto
|
||||
|
||||
package simulate
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
tx "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/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"
|
||||
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
|
||||
|
||||
// SimulateRequest is the request type for the SimulateServiceService.Simulate
|
||||
// RPC method.
|
||||
type SimulateRequest struct {
|
||||
// tx is the transaction to simulate.
|
||||
Tx *tx.Tx `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SimulateRequest) Reset() { *m = SimulateRequest{} }
|
||||
func (m *SimulateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*SimulateRequest) ProtoMessage() {}
|
||||
func (*SimulateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_503c836d80bb2d47, []int{0}
|
||||
}
|
||||
func (m *SimulateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SimulateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SimulateRequest.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 *SimulateRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimulateRequest.Merge(m, src)
|
||||
}
|
||||
func (m *SimulateRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SimulateRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimulateRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SimulateRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *SimulateRequest) GetTx() *tx.Tx {
|
||||
if m != nil {
|
||||
return m.Tx
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SimulateResponse is the response type for the
|
||||
// SimulateServiceService.SimulateRPC method.
|
||||
type SimulateResponse struct {
|
||||
// gas_info is the information about gas used in the simulation.
|
||||
GasInfo *types.GasInfo `protobuf:"bytes,1,opt,name=gas_info,json=gasInfo,proto3" json:"gas_info,omitempty"`
|
||||
// result is the result of the simulation.
|
||||
Result *types.Result `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SimulateResponse) Reset() { *m = SimulateResponse{} }
|
||||
func (m *SimulateResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*SimulateResponse) ProtoMessage() {}
|
||||
func (*SimulateResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_503c836d80bb2d47, []int{1}
|
||||
}
|
||||
func (m *SimulateResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SimulateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SimulateResponse.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 *SimulateResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimulateResponse.Merge(m, src)
|
||||
}
|
||||
func (m *SimulateResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SimulateResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimulateResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SimulateResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *SimulateResponse) GetGasInfo() *types.GasInfo {
|
||||
if m != nil {
|
||||
return m.GasInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SimulateResponse) GetResult() *types.Result {
|
||||
if m != nil {
|
||||
return m.Result
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*SimulateRequest)(nil), "cosmos.base.simulate.v1beta1.SimulateRequest")
|
||||
proto.RegisterType((*SimulateResponse)(nil), "cosmos.base.simulate.v1beta1.SimulateResponse")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("cosmos/base/simulate/v1beta1/simulate.proto", fileDescriptor_503c836d80bb2d47)
|
||||
}
|
||||
|
||||
var fileDescriptor_503c836d80bb2d47 = []byte{
|
||||
// 351 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xbf, 0x4b, 0xf3, 0x40,
|
||||
0x18, 0xc7, 0x7b, 0x19, 0xfa, 0x96, 0x7b, 0x87, 0xf7, 0x25, 0x20, 0x94, 0x50, 0x42, 0x8d, 0x28,
|
||||
0x05, 0xe9, 0x1d, 0xad, 0x4b, 0x07, 0x27, 0x17, 0x11, 0xb7, 0xd4, 0xc9, 0x45, 0x2e, 0xf1, 0x1a,
|
||||
0x0f, 0xd3, 0xbb, 0x98, 0x7b, 0x52, 0x32, 0x3b, 0x3a, 0x09, 0x4e, 0xfe, 0x11, 0xfe, 0x1f, 0x8e,
|
||||
0x05, 0x17, 0x47, 0x69, 0xfd, 0x43, 0xa4, 0xc9, 0x25, 0x2d, 0x82, 0xd2, 0x29, 0xb9, 0xe7, 0xf9,
|
||||
0x7c, 0xbf, 0xcf, 0x2f, 0x7c, 0x18, 0x2a, 0x3d, 0x55, 0x9a, 0x06, 0x4c, 0x73, 0xaa, 0xc5, 0x34,
|
||||
0x8b, 0x19, 0x70, 0x3a, 0x1b, 0x04, 0x1c, 0xd8, 0xa0, 0x0e, 0x90, 0x24, 0x55, 0xa0, 0xec, 0x4e,
|
||||
0x09, 0x93, 0x15, 0x4c, 0xea, 0x9c, 0x81, 0x9d, 0x4e, 0xa4, 0x54, 0x14, 0x73, 0xca, 0x12, 0x41,
|
||||
0x99, 0x94, 0x0a, 0x18, 0x08, 0x25, 0x75, 0xa9, 0x75, 0xf6, 0x36, 0x0b, 0xb1, 0x20, 0x14, 0x75,
|
||||
0x91, 0xd5, 0xc3, 0x40, 0x8e, 0x81, 0x20, 0xaf, 0xb3, 0x90, 0x97, 0x39, 0x6f, 0x84, 0xff, 0x8d,
|
||||
0x4d, 0x49, 0x9f, 0xdf, 0x65, 0x5c, 0x83, 0xbd, 0x8f, 0x2d, 0xc8, 0xdb, 0xa8, 0x8b, 0x7a, 0x7f,
|
||||
0x87, 0x3b, 0xc4, 0x34, 0x07, 0x79, 0xd5, 0x11, 0xb9, 0xc8, 0x7d, 0x0b, 0x72, 0xef, 0x01, 0xe1,
|
||||
0xff, 0x6b, 0xa9, 0x4e, 0x94, 0xd4, 0xdc, 0x3e, 0xc6, 0xad, 0x88, 0xe9, 0x2b, 0x21, 0x27, 0xca,
|
||||
0x38, 0xec, 0x92, 0xcd, 0xf1, 0x8a, 0xae, 0x2a, 0xa3, 0x53, 0xa6, 0xcf, 0xe4, 0x44, 0xf9, 0x7f,
|
||||
0xa2, 0xf2, 0xc7, 0x1e, 0xe1, 0x66, 0xca, 0x75, 0x16, 0x43, 0xdb, 0x2a, 0xb4, 0xdd, 0x9f, 0xb5,
|
||||
0x7e, 0xc1, 0xf9, 0x86, 0x1f, 0xbe, 0xa0, 0xf5, 0x1c, 0x63, 0x9e, 0xce, 0x44, 0xc8, 0xed, 0x67,
|
||||
0x84, 0x5b, 0x55, 0xcc, 0xee, 0x93, 0xdf, 0xb6, 0x4c, 0xbe, 0xed, 0xc0, 0x21, 0xdb, 0xe2, 0xe5,
|
||||
0xdc, 0x1e, 0xb9, 0x7f, 0xfb, 0x7c, 0xb2, 0x7a, 0xde, 0x01, 0xdd, 0xea, 0xf2, 0x27, 0xe7, 0xaf,
|
||||
0x0b, 0x17, 0xcd, 0x17, 0x2e, 0xfa, 0x58, 0xb8, 0xe8, 0x71, 0xe9, 0x36, 0xe6, 0x4b, 0xb7, 0xf1,
|
||||
0xbe, 0x74, 0x1b, 0x97, 0x83, 0x48, 0xc0, 0x4d, 0x16, 0x90, 0x50, 0x4d, 0x2b, 0xaf, 0xf2, 0xd3,
|
||||
0xd7, 0xd7, 0xb7, 0x34, 0x8c, 0x05, 0x97, 0x40, 0xa3, 0x34, 0x09, 0x6b, 0xb3, 0xa0, 0x59, 0x9c,
|
||||
0xf2, 0xe8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x16, 0xed, 0x90, 0x76, 0x02, 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
|
||||
|
||||
// SimulateServiceClient is the client API for SimulateService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type SimulateServiceClient interface {
|
||||
// Simulate simulates executing a transaction for estimating gas usage.
|
||||
Simulate(ctx context.Context, in *SimulateRequest, opts ...grpc.CallOption) (*SimulateResponse, error)
|
||||
}
|
||||
|
||||
type simulateServiceClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewSimulateServiceClient(cc grpc1.ClientConn) SimulateServiceClient {
|
||||
return &simulateServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *simulateServiceClient) Simulate(ctx context.Context, in *SimulateRequest, opts ...grpc.CallOption) (*SimulateResponse, error) {
|
||||
out := new(SimulateResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.base.simulate.v1beta1.SimulateService/Simulate", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SimulateServiceServer is the server API for SimulateService service.
|
||||
type SimulateServiceServer interface {
|
||||
// Simulate simulates executing a transaction for estimating gas usage.
|
||||
Simulate(context.Context, *SimulateRequest) (*SimulateResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedSimulateServiceServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedSimulateServiceServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedSimulateServiceServer) Simulate(ctx context.Context, req *SimulateRequest) (*SimulateResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Simulate not implemented")
|
||||
}
|
||||
|
||||
func RegisterSimulateServiceServer(s grpc1.Server, srv SimulateServiceServer) {
|
||||
s.RegisterService(&_SimulateService_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _SimulateService_Simulate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SimulateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SimulateServiceServer).Simulate(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.base.simulate.v1beta1.SimulateService/Simulate",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SimulateServiceServer).Simulate(ctx, req.(*SimulateRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _SimulateService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.base.simulate.v1beta1.SimulateService",
|
||||
HandlerType: (*SimulateServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Simulate",
|
||||
Handler: _SimulateService_Simulate_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/base/simulate/v1beta1/simulate.proto",
|
||||
}
|
||||
|
||||
func (m *SimulateRequest) 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 *SimulateRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SimulateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.Tx != nil {
|
||||
{
|
||||
size, err := m.Tx.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSimulate(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SimulateResponse) 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 *SimulateResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SimulateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.Result != nil {
|
||||
{
|
||||
size, err := m.Result.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSimulate(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.GasInfo != nil {
|
||||
{
|
||||
size, err := m.GasInfo.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSimulate(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintSimulate(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovSimulate(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *SimulateRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Tx != nil {
|
||||
l = m.Tx.Size()
|
||||
n += 1 + l + sovSimulate(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SimulateResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.GasInfo != nil {
|
||||
l = m.GasInfo.Size()
|
||||
n += 1 + l + sovSimulate(uint64(l))
|
||||
}
|
||||
if m.Result != nil {
|
||||
l = m.Result.Size()
|
||||
n += 1 + l + sovSimulate(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovSimulate(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozSimulate(x uint64) (n int) {
|
||||
return sovSimulate(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *SimulateRequest) 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 ErrIntOverflowSimulate
|
||||
}
|
||||
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: SimulateRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SimulateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Tx", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSimulate
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Tx == nil {
|
||||
m.Tx = &tx.Tx{}
|
||||
}
|
||||
if err := m.Tx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSimulate(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SimulateResponse) 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 ErrIntOverflowSimulate
|
||||
}
|
||||
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: SimulateResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SimulateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field GasInfo", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSimulate
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.GasInfo == nil {
|
||||
m.GasInfo = &types.GasInfo{}
|
||||
}
|
||||
if err := m.GasInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
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 ErrIntOverflowSimulate
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Result == nil {
|
||||
m.Result = &types.Result{}
|
||||
}
|
||||
if err := m.Result.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSimulate(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthSimulate
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipSimulate(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, ErrIntOverflowSimulate
|
||||
}
|
||||
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, ErrIntOverflowSimulate
|
||||
}
|
||||
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, ErrIntOverflowSimulate
|
||||
}
|
||||
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, ErrInvalidLengthSimulate
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupSimulate
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthSimulate
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthSimulate = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowSimulate = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupSimulate = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
|
@ -1,166 +0,0 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: cosmos/base/simulate/v1beta1/simulate.proto
|
||||
|
||||
/*
|
||||
Package simulate is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package simulate
|
||||
|
||||
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
|
||||
|
||||
var (
|
||||
filter_SimulateService_Simulate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_SimulateService_Simulate_0(ctx context.Context, marshaler runtime.Marshaler, client SimulateServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SimulateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SimulateService_Simulate_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Simulate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_SimulateService_Simulate_0(ctx context.Context, marshaler runtime.Marshaler, server SimulateServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SimulateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SimulateService_Simulate_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Simulate(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterSimulateServiceHandlerServer registers the http handlers for service SimulateService to "mux".
|
||||
// UnaryRPC :call SimulateServiceServer 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 RegisterSimulateServiceHandlerFromEndpoint instead.
|
||||
func RegisterSimulateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SimulateServiceServer) error {
|
||||
|
||||
mux.Handle("POST", pattern_SimulateService_Simulate_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_SimulateService_Simulate_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_SimulateService_Simulate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterSimulateServiceHandlerFromEndpoint is same as RegisterSimulateServiceHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterSimulateServiceHandlerFromEndpoint(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 RegisterSimulateServiceHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterSimulateServiceHandler registers the http handlers for service SimulateService to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterSimulateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterSimulateServiceHandlerClient(ctx, mux, NewSimulateServiceClient(conn))
|
||||
}
|
||||
|
||||
// RegisterSimulateServiceHandlerClient registers the http handlers for service SimulateService
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SimulateServiceClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SimulateServiceClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "SimulateServiceClient" to call the correct interceptors.
|
||||
func RegisterSimulateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SimulateServiceClient) error {
|
||||
|
||||
mux.Handle("POST", pattern_SimulateService_Simulate_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_SimulateService_Simulate_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_SimulateService_Simulate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_SimulateService_Simulate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 2}, []string{"cosmos", "base", "simulate", "v1beta1"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_SimulateService_Simulate_0 = runtime.ForwardResponseMessage
|
||||
)
|
|
@ -1,119 +0,0 @@
|
|||
package simulate_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
app *simapp.SimApp
|
||||
clientCtx client.Context
|
||||
queryClient simulate.SimulateServiceClient
|
||||
sdkCtx sdk.Context
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
app := simapp.Setup(true)
|
||||
sdkCtx := app.BaseApp.NewContext(true, tmproto.Header{})
|
||||
|
||||
app.AccountKeeper.SetParams(sdkCtx, authtypes.DefaultParams())
|
||||
app.BankKeeper.SetParams(sdkCtx, banktypes.DefaultParams())
|
||||
|
||||
// Set up TxConfig.
|
||||
encodingConfig := simapp.MakeTestEncodingConfig()
|
||||
clientCtx := client.Context{}.WithTxConfig(encodingConfig.TxConfig)
|
||||
|
||||
// Create new simulation server.
|
||||
srv := simulate.NewSimulateServer(app.BaseApp.Simulate, encodingConfig.InterfaceRegistry)
|
||||
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(sdkCtx, app.InterfaceRegistry())
|
||||
simulate.RegisterSimulateServiceServer(queryHelper, srv)
|
||||
queryClient := simulate.NewSimulateServiceClient(queryHelper)
|
||||
|
||||
s.app = app
|
||||
s.clientCtx = clientCtx
|
||||
s.queryClient = queryClient
|
||||
s.sdkCtx = sdkCtx
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestSimulateService() {
|
||||
// Create an account with some funds.
|
||||
priv1, _, addr1 := testdata.KeyTestPubAddr()
|
||||
acc1 := s.app.AccountKeeper.NewAccountWithAddress(s.sdkCtx, addr1)
|
||||
err := acc1.SetAccountNumber(0)
|
||||
s.Require().NoError(err)
|
||||
s.app.AccountKeeper.SetAccount(s.sdkCtx, acc1)
|
||||
s.app.BankKeeper.SetBalances(s.sdkCtx, addr1, sdk.Coins{
|
||||
sdk.NewInt64Coin("atom", 10000000),
|
||||
})
|
||||
|
||||
// Create a test x/bank MsgSend.
|
||||
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||
_, _, addr2 := testdata.KeyTestPubAddr()
|
||||
msg := banktypes.NewMsgSend(addr1, addr2, coins)
|
||||
feeAmount := testdata.NewTestFeeAmount()
|
||||
gasLimit := testdata.NewTestGasLimit()
|
||||
memo := "foo"
|
||||
accSeq, accNum := uint64(0), uint64(0)
|
||||
|
||||
// Create a txBuilder.
|
||||
txBuilder := s.clientCtx.TxConfig.NewTxBuilder()
|
||||
txBuilder.SetMsgs(msg)
|
||||
txBuilder.SetMemo(memo)
|
||||
txBuilder.SetFeeAmount(feeAmount)
|
||||
txBuilder.SetGasLimit(gasLimit)
|
||||
// 1st round: set empty signature
|
||||
sigV2 := signing.SignatureV2{
|
||||
PubKey: priv1.PubKey(),
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: s.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
|
||||
Signature: nil,
|
||||
},
|
||||
}
|
||||
txBuilder.SetSignatures(sigV2)
|
||||
// 2nd round: actually sign
|
||||
sigV2, err = tx.SignWithPrivKey(
|
||||
s.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
|
||||
authsigning.SignerData{ChainID: s.sdkCtx.ChainID(), AccountNumber: accNum, Sequence: accSeq},
|
||||
txBuilder, priv1, s.clientCtx.TxConfig, accSeq,
|
||||
)
|
||||
txBuilder.SetSignatures(sigV2)
|
||||
|
||||
any, ok := txBuilder.(codectypes.IntoAny)
|
||||
s.Require().True(ok)
|
||||
cached := any.AsAny().GetCachedValue()
|
||||
txTx, ok := cached.(*txtypes.Tx)
|
||||
s.Require().True(ok)
|
||||
res, err := s.queryClient.Simulate(
|
||||
context.Background(),
|
||||
&simulate.SimulateRequest{Tx: txTx},
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Check the result and gas used are correct.
|
||||
s.Require().Equal(len(res.GetResult().GetEvents()), 4) // 1 transfer, 3 messages.
|
||||
s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
|
||||
}
|
||||
|
||||
func TestSimulateTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
sim "github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
|
@ -279,7 +278,7 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
|
|||
return nil, fmt.Errorf("cannot simulate amino tx")
|
||||
}
|
||||
|
||||
simReq := sim.SimulateRequest{Tx: protoTx}
|
||||
simReq := tx.SimulateRequest{Tx: protoTx}
|
||||
|
||||
return simReq.Marshal()
|
||||
}
|
||||
|
@ -288,21 +287,23 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
|
|||
// simulation response obtained by the query and the adjusted gas amount.
|
||||
func CalculateGas(
|
||||
queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, msgs ...sdk.Msg,
|
||||
) (sim.SimulateResponse, uint64, error) {
|
||||
) (tx.SimulateResponse, uint64, error) {
|
||||
txBytes, err := BuildSimTx(txf, msgs...)
|
||||
if err != nil {
|
||||
return sim.SimulateResponse{}, 0, err
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
}
|
||||
|
||||
bz, _, err := queryFunc("/cosmos.base.simulate.v1beta1.SimulateService/Simulate", txBytes)
|
||||
// TODO This should use the generated tx service Client.
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/7726
|
||||
bz, _, err := queryFunc("/cosmos.tx.v1beta1.Service/Simulate", txBytes)
|
||||
if err != nil {
|
||||
return sim.SimulateResponse{}, 0, err
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
}
|
||||
|
||||
var simRes sim.SimulateResponse
|
||||
var simRes tx.SimulateResponse
|
||||
|
||||
if err := simRes.Unmarshal(bz); err != nil {
|
||||
return sim.SimulateResponse{}, 0, err
|
||||
return tx.SimulateResponse{}, 0, err
|
||||
}
|
||||
|
||||
return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ func TestCalculateGas(t *testing.T) {
|
|||
if wantErr {
|
||||
return nil, 0, errors.New("query failed")
|
||||
}
|
||||
simRes := &simulate.SimulateResponse{
|
||||
simRes := &txtypes.SimulateResponse{
|
||||
GasInfo: &sdk.GasInfo{GasUsed: gasUsed, GasWanted: gasUsed},
|
||||
Result: &sdk.Result{Data: []byte("tx data"), Log: "log"},
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ keepers. Thus, the `OnRecvPacket` callback only needs to worry about making the
|
|||
changes given the packet data without worrying about whether the packet is valid or not.
|
||||
|
||||
Modules must return an acknowledgement as a byte string and return it to the IBC handler.
|
||||
The IBC handler will then commit this acknowledgment of the packet so that a relayer may relay the
|
||||
The IBC handler will then commit this acknowledgement of the packet so that a relayer may relay the
|
||||
acknowledgement back to the sender module.
|
||||
|
||||
```go
|
||||
|
@ -354,7 +354,7 @@ with some additional data that could be useful for remediation if the packet pro
|
|||
|
||||
Since the modules are responsible for agreeing on an encoding/decoding standard for packet data and
|
||||
acknowledgements, IBC will pass in the acknowledgements as `[]byte` to this callback. The callback
|
||||
is responsible for decoding the acknowledgment and processing it.
|
||||
is responsible for decoding the acknowledgement and processing it.
|
||||
|
||||
```go
|
||||
OnAcknowledgementPacket(
|
||||
|
|
|
@ -7,3 +7,4 @@ parent:
|
|||
|
||||
- [Modules](../../x/README.md)
|
||||
- [Simulation](./simulation.md)
|
||||
- [Cosmos Upgrade Manager](./cosmovisor.md)
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
# Cosmosvisor Quick Start
|
||||
|
||||
`cosmovisor` is a small process manager around Cosmos SDK binaries that uses the upgrade module to allow
|
||||
for smooth and configurable management of upgrading binaries as a live chain is upgraded, and can be
|
||||
used to simplify validator operations while doing upgrades or to make syncing a full node for genesis
|
||||
simple. The `cosmovisor` program monitors the stdout of Cosmos SDK application's executable to look for
|
||||
messages from the upgrade module indicating a pending or required upgrade and act appropriately.
|
||||
|
||||
## Installation
|
||||
|
||||
Run:
|
||||
|
||||
`go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor`
|
||||
|
||||
## Command Line Arguments And Environment Variables
|
||||
|
||||
All arguments passed to the `cosmovisor` program will be passed to the current daemon binary (as a subprocess).
|
||||
It will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. Because of that, it cannot accept
|
||||
any command line arguments, nor print anything to output (unless it terminates unexpectedly before executing a
|
||||
binary).
|
||||
|
||||
`cosmovisor` reads its configuration from environment variables:
|
||||
|
||||
* `DAEMON_HOME` is the location where upgrade binaries should be kept (e.g. `$HOME/.gaiad` or `$HOME/.xrnd`).
|
||||
* `DAEMON_NAME` is the name of the binary itself (eg. `xrnd`, `gaiad`, `simd`, etc).
|
||||
* `DAEMON_ALLOW_DOWNLOAD_BINARIES` (*optional*) if set to `true` will enable auto-downloading of new binaries
|
||||
(for security reasons, this is intended for full nodes rather than validators).
|
||||
* `DAEMON_RESTART_AFTER_UPGRADE` (*optional*) if set to `true` it will restart the sub-process with the same
|
||||
command line arguments and flags (but new binary) after a successful upgrade. By default, `cosmovisor` dies
|
||||
afterwards and allows the supervisor to restart it if needed. Note that this will not auto-restart the child
|
||||
if there was an error.
|
||||
|
||||
## Data Folder Layout
|
||||
|
||||
`$DAEMON_HOME/cosmovisor` is expected to belong completely to `cosmovisor` and
|
||||
subprocesses the controlled by it. The folder content is organised as follows:
|
||||
|
||||
```
|
||||
.
|
||||
├── current -> genesis or upgrades/<name>
|
||||
├── genesis
|
||||
│ └── bin
|
||||
│ └── $DAEMON_NAME
|
||||
└── upgrades
|
||||
└── <name>
|
||||
└── bin
|
||||
└── $DAEMON_NAME
|
||||
```
|
||||
|
||||
Each version of the Cosmos SDK application is stored under either `genesis` or `upgrades/<name>`, which holds `bin/$DAEMON_NAME`
|
||||
along with any other needed files such as auxiliary client programs or libraries. `current` is a symbolic link to the currently
|
||||
active folder (so `current/bin/$DAEMON_NAME` is the currently active binary).
|
||||
|
||||
*Note: the `name` variable in `upgrades/<name>` holds the URI-encoded name of the upgrade as specified in the upgrade module plan.*
|
||||
|
||||
Please note that `$DAEMON_HOME/cosmovisor` just stores the *binaries* and associated *program code*.
|
||||
The `cosmovisor` binary can be stored in any typical location (eg `/usr/local/bin`). The actual blockchain
|
||||
program will store it's data under their default data directory (e.g. `$HOME/.gaiad`) which is independent of
|
||||
the `$DAEMON_HOME`. You can choose to set `$DAEMON_HOME` to the actual binary's home directory and then end up
|
||||
with a configuation like the following, but this is left as a choice to the system admininstrator for best
|
||||
directory layout:
|
||||
|
||||
```
|
||||
.gaiad
|
||||
├── config
|
||||
├── data
|
||||
└── cosmovisor
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The system administrator admin is responsible for:
|
||||
* installing the `cosmovisor` binary and configure the host's init system (e.g. `systemd`, `launchd`, etc) along with the environmental variables appropriately;
|
||||
* installing the `genesis` folder manually;
|
||||
* installing the `upgrades/<name>` folders manually.
|
||||
|
||||
`cosmovisor` will set the `current` link to point to `genesis` at first start (when no `current` link exists) and handles
|
||||
binaries switch overs at the correct points in time, so that the system administrator can prepare days in advance and relax at upgrade time.
|
||||
|
||||
Note that blockchain applications that wish to support upgrades may package up a genesis `cosmovisor` tarball with this information,
|
||||
just as they prepare the genesis binary tarball. In fact, they may offer a tarball will all upgrades up to current point for easy download
|
||||
for those who wish to sync a fullnode from start.
|
||||
|
||||
The `DAEMON` specific code and operations (e.g. tendermint config, the application db, syncing blocks, etc) are performed as normal.
|
||||
Application binaries' directives such as command-line flags and environment variables work normally.
|
||||
|
||||
## Example: simd
|
||||
|
||||
The following instructions provide a demonstration of `cosmovisor`'s integration with the `simd` application
|
||||
shipped along the Cosmos SDK's source code.
|
||||
|
||||
First compile `simd`:
|
||||
|
||||
```
|
||||
cd cosmos-sdk/
|
||||
make build
|
||||
```
|
||||
|
||||
Create a new key and setup the `simd` node:
|
||||
|
||||
```
|
||||
rm -rf $HOME/.simapp
|
||||
./build/simd keys --keyring-backend=test add validator
|
||||
./build/simd init testing --chain-id test
|
||||
./build/simd add-genesis-account --keyring-backend=test $(./build/simd keys --keyring-backend=test show validator -a) 1000000000stake,1000000000validatortoken
|
||||
./build/simd gentx --keyring-backend test --chain-id test validator
|
||||
./build/simd collect-gentxs
|
||||
```
|
||||
|
||||
Set the required environment variables:
|
||||
|
||||
```
|
||||
export DAEMON_NAME=simd # binary name
|
||||
export DAEMON_HOME=$HOME/.simapp # daemon's home directory
|
||||
```
|
||||
|
||||
Create the `cosmovisor`’s genesis folders and deploy the binary:
|
||||
|
||||
```
|
||||
mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin
|
||||
cp ./build/simd $DAEMON_HOME/cosmovisor/genesis/bin
|
||||
```
|
||||
|
||||
For the sake of this demonstration, we would amend `voting_params.voting_period` in `.simapp/config/genesis.json` to a reduced time ~5 minutes (300s) and eventually launch `cosmosvisor`:
|
||||
|
||||
```
|
||||
cosmovisor start
|
||||
```
|
||||
|
||||
Submit a software upgrade proposal:
|
||||
|
||||
```
|
||||
./build/simd tx gov submit-proposal software-upgrade test1 --title "upgrade-demo" --description "upgrade" --from validator --upgrade-height 100 --deposit 10000000stake --chain-id test --keyring-backend test -y
|
||||
```
|
||||
|
||||
Query the proposal to ensure it was correctly broadcast and added to a block:
|
||||
|
||||
```
|
||||
./build/simd query gov proposal 1
|
||||
```
|
||||
|
||||
Submit a `Yes` vote for the upgrade proposal:
|
||||
|
||||
```
|
||||
./build/simd tx gov vote 1 yes --from validator --keyring-backend test --chain-id test -y
|
||||
```
|
||||
|
||||
For the sake of this demonstration, we will hardcode a modification in `simapp` to simulate a code change.
|
||||
In `simapp/app.go`, find the line containing the upgrade Keeper initialisation, it should look like
|
||||
`app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)`.
|
||||
After that line, add the following snippet:
|
||||
|
||||
```
|
||||
app.UpgradeKeeper.SetUpgradeHandler("test1", func(ctx sdk.Context, plan upgradetypes.Plan) {
|
||||
// Add some coins to a random account
|
||||
addr, err := sdk.AccAddressFromBech32("cosmos18cgkqduwuh253twzmhedesw3l7v3fm37sppt58")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = app.BankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.Coin{Denom: "stake", Amount: sdk.NewInt(345600000)}})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Now recompile a new binary and place it in `$DAEMON_HOME/cosmosvisor/upgrades/test1/bin`:
|
||||
|
||||
```
|
||||
make build
|
||||
cp ./build/simd $DAEMON_HOME/cosmovisor/upgrades/test1/bin
|
||||
```
|
||||
|
||||
The upgrade will occur automatically at height 100.
|
|
@ -1,33 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package cosmos.base.simulate.v1beta1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/abci/v1beta1/abci.proto";
|
||||
import "cosmos/tx/v1beta1/tx.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/simulate";
|
||||
|
||||
// SimulateService defines a gRPC service for simulating transactions.
|
||||
// It may also support querying and broadcasting in the future.
|
||||
service SimulateService {
|
||||
// Simulate simulates executing a transaction for estimating gas usage.
|
||||
rpc Simulate(SimulateRequest) returns (SimulateResponse) {
|
||||
option (google.api.http).post = "/cosmos/base/simulate/v1beta1/simulate";
|
||||
}
|
||||
}
|
||||
|
||||
// SimulateRequest is the request type for the SimulateServiceService.Simulate
|
||||
// RPC method.
|
||||
message SimulateRequest {
|
||||
// tx is the transaction to simulate.
|
||||
cosmos.tx.v1beta1.Tx tx = 1;
|
||||
}
|
||||
|
||||
// SimulateResponse is the response type for the
|
||||
// SimulateServiceService.SimulateRPC method.
|
||||
message SimulateResponse {
|
||||
// gas_info is the information about gas used in the simulation.
|
||||
cosmos.base.abci.v1beta1.GasInfo gas_info = 1;
|
||||
// result is the result of the simulation.
|
||||
cosmos.base.abci.v1beta1.Result result = 2;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
syntax = "proto3";
|
||||
package cosmos.tx.v1beta1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/abci/v1beta1/abci.proto";
|
||||
import "cosmos/tx/v1beta1/tx.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/types/tx";
|
||||
|
||||
// Service defines a gRPC service for interacting with transactions.
|
||||
service Service {
|
||||
// Simulate simulates executing a transaction for estimating gas usage.
|
||||
rpc Simulate(SimulateRequest) returns (SimulateResponse) {
|
||||
option (google.api.http).post = "/cosmos/tx/v1beta1/simulate";
|
||||
}
|
||||
// GetTx fetches a tx by hash.
|
||||
rpc GetTx(GetTxRequest) returns (GetTxResponse) {
|
||||
option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}";
|
||||
}
|
||||
}
|
||||
|
||||
// SimulateRequest is the request type for the Service.Simulate
|
||||
// RPC method.
|
||||
message SimulateRequest {
|
||||
// tx is the transaction to simulate.
|
||||
cosmos.tx.v1beta1.Tx tx = 1;
|
||||
}
|
||||
|
||||
// SimulateResponse is the response type for the
|
||||
// Service.SimulateRPC method.
|
||||
message SimulateResponse {
|
||||
// gas_info is the information about gas used in the simulation.
|
||||
cosmos.base.abci.v1beta1.GasInfo gas_info = 1;
|
||||
// result is the result of the simulation.
|
||||
cosmos.base.abci.v1beta1.Result result = 2;
|
||||
}
|
||||
|
||||
// GetTx is the request type for the Service.GetTx
|
||||
// RPC method.
|
||||
message GetTxRequest {
|
||||
// hash is the tx hash to query, encoded as a hex string.
|
||||
string hash = 1;
|
||||
}
|
||||
|
||||
// GetTxResponse is the response type for the Service.GetTx method.
|
||||
message GetTxResponse {
|
||||
// tx is the queried transaction.
|
||||
cosmos.tx.v1beta1.Tx tx = 1;
|
||||
}
|
|
@ -114,9 +114,11 @@ message Packet {
|
|||
uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
|
||||
}
|
||||
|
||||
// PacketAckCommitment defines the genesis type necessary to retrieve and store
|
||||
// acknowlegements.
|
||||
message PacketAckCommitment {
|
||||
// PacketState defines the generic type necessary to retrieve and store
|
||||
// packet commitments, acknowledgements, and receipts.
|
||||
// Caller is responsible for knowing the context necessary to interpret this
|
||||
// state as a commitment, acknowledgement, or a receipt.
|
||||
message PacketState {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// channel port identifier.
|
||||
|
@ -125,8 +127,8 @@ message PacketAckCommitment {
|
|||
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
// packet sequence.
|
||||
uint64 sequence = 3;
|
||||
// packet commitment hash.
|
||||
bytes hash = 4;
|
||||
// embedded data that represents packet state.
|
||||
bytes data = 4;
|
||||
}
|
||||
|
||||
// Acknowledgement is the recommended acknowledgement format to be used by
|
||||
|
@ -142,4 +144,4 @@ message Acknowledgement {
|
|||
bytes result = 21;
|
||||
string error = 22;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ import "ibc/core/channel/v1/channel.proto";
|
|||
// GenesisState defines the ibc channel submodule's genesis state.
|
||||
message GenesisState {
|
||||
repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false];
|
||||
repeated PacketAckCommitment acknowledgements = 2
|
||||
[(gogoproto.casttype) = "PacketAckCommitment", (gogoproto.nullable) = false];
|
||||
repeated PacketAckCommitment commitments = 3 [(gogoproto.nullable) = false];
|
||||
repeated PacketSequence send_sequences = 4
|
||||
repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false];
|
||||
repeated PacketState commitments = 3 [(gogoproto.nullable) = false];
|
||||
repeated PacketState receipts = 4 [(gogoproto.nullable) = false];
|
||||
repeated PacketSequence send_sequences = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"send_sequences\""];
|
||||
repeated PacketSequence recv_sequences = 5
|
||||
repeated PacketSequence recv_sequences = 6
|
||||
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"recv_sequences\""];
|
||||
repeated PacketSequence ack_sequences = 6
|
||||
repeated PacketSequence ack_sequences = 7
|
||||
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"ack_sequences\""];
|
||||
}
|
||||
|
||||
|
|
|
@ -47,29 +47,41 @@ service Query {
|
|||
"/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}";
|
||||
}
|
||||
|
||||
// PacketCommitments returns the all the packet commitments hashes associated
|
||||
// PacketCommitments returns all the packet commitments hashes associated
|
||||
// with a channel.
|
||||
rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments";
|
||||
}
|
||||
|
||||
// PacketReceipt queries if a given packet sequence has been received on the queried chain
|
||||
rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}";
|
||||
}
|
||||
|
||||
// PacketAcknowledgement queries a stored packet acknowledgement hash.
|
||||
rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}";
|
||||
}
|
||||
|
||||
// UnreceivedPackets returns all the unrelayed IBC packets associated with a
|
||||
// PacketAcknowledgements returns all the packet acknowledgements associated
|
||||
// with a channel.
|
||||
rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements";
|
||||
}
|
||||
|
||||
|
||||
// UnreceivedPackets returns all the unreceived IBC packets associated with a
|
||||
// channel and sequences.
|
||||
rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/"
|
||||
"{packet_commitment_sequences}/unreceived_packets";
|
||||
}
|
||||
|
||||
// UnrelayedAcks returns all the unrelayed IBC acknowledgements associated with a
|
||||
// UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a
|
||||
// channel and sequences.
|
||||
rpc UnrelayedAcks(QueryUnrelayedAcksRequest) returns (QueryUnrelayedAcksResponse) {
|
||||
rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) {
|
||||
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/"
|
||||
"{packet_commitment_sequences}/unrelayed_acks";
|
||||
"{packet_ack_sequences}/unreceived_acks";
|
||||
}
|
||||
|
||||
// NextSequenceReceive returns the next receive sequence for a given channel.
|
||||
|
@ -192,7 +204,7 @@ message QueryPacketCommitmentRequest {
|
|||
}
|
||||
|
||||
// QueryPacketCommitmentResponse defines the client query response for a packet
|
||||
// which also includes a proof, its path and the height form which the proof was
|
||||
// which also includes a proof and the height from which the proof was
|
||||
// retrieved
|
||||
message QueryPacketCommitmentResponse {
|
||||
// packet associated with the request fields
|
||||
|
@ -217,13 +229,36 @@ message QueryPacketCommitmentsRequest {
|
|||
// QueryPacketCommitmentsResponse is the request type for the
|
||||
// Query/QueryPacketCommitments RPC method
|
||||
message QueryPacketCommitmentsResponse {
|
||||
repeated ibc.core.channel.v1.PacketAckCommitment commitments = 1;
|
||||
repeated ibc.core.channel.v1.PacketState commitments = 1;
|
||||
// pagination response
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
// query block height
|
||||
ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryPacketReceiptRequest is the request type for the
|
||||
// Query/PacketReceipt RPC method
|
||||
message QueryPacketReceiptRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1;
|
||||
// channel unique identifier
|
||||
string channel_id = 2;
|
||||
// packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// QueryPacketReceiptResponse defines the client query response for a packet receipt
|
||||
// which also includes a proof, and the height from which the proof was
|
||||
// retrieved
|
||||
message QueryPacketReceiptResponse {
|
||||
// success flag for if receipt exists
|
||||
bool received = 2;
|
||||
// merkle proof of existence
|
||||
bytes proof = 3;
|
||||
// height at which the proof was retrieved
|
||||
ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryPacketAcknowledgementRequest is the request type for the
|
||||
// Query/PacketAcknowledgement RPC method
|
||||
message QueryPacketAcknowledgementRequest {
|
||||
|
@ -236,7 +271,7 @@ message QueryPacketAcknowledgementRequest {
|
|||
}
|
||||
|
||||
// QueryPacketAcknowledgementResponse defines the client query response for a
|
||||
// packet which also includes a proof, its path and the height form which the
|
||||
// packet which also includes a proof and the height from which the
|
||||
// proof was retrieved
|
||||
message QueryPacketAcknowledgementResponse {
|
||||
// packet associated with the request fields
|
||||
|
@ -247,6 +282,27 @@ message QueryPacketAcknowledgementResponse {
|
|||
ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryPacketAcknowledgementsRequest is the request type for the
|
||||
// Query/QueryPacketCommitments RPC method
|
||||
message QueryPacketAcknowledgementsRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1;
|
||||
// channel unique identifier
|
||||
string channel_id = 2;
|
||||
// pagination request
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 3;
|
||||
}
|
||||
|
||||
// QueryPacketAcknowledgemetsResponse is the request type for the
|
||||
// Query/QueryPacketAcknowledgements RPC method
|
||||
message QueryPacketAcknowledgementsResponse {
|
||||
repeated ibc.core.channel.v1.PacketState acknowledgements = 1;
|
||||
// pagination response
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
// query block height
|
||||
ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryUnreceivedPacketsRequest is the request type for the
|
||||
// Query/UnreceivedPackets RPC method
|
||||
message QueryUnreceivedPacketsRequest {
|
||||
|
@ -267,21 +323,21 @@ message QueryUnreceivedPacketsResponse {
|
|||
ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryUnrelayedAcksRequest is the request type for the
|
||||
// Query/UnrelayedAcks RPC method
|
||||
message QueryUnrelayedAcksRequest {
|
||||
// QueryUnreceivedAcks is the request type for the
|
||||
// Query/UnreceivedAcks RPC method
|
||||
message QueryUnreceivedAcksRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1;
|
||||
// channel unique identifier
|
||||
string channel_id = 2;
|
||||
// list of commitment sequences
|
||||
repeated uint64 packet_commitment_sequences = 3;
|
||||
// list of acknowledgement sequences
|
||||
repeated uint64 packet_ack_sequences = 3;
|
||||
}
|
||||
|
||||
// QueryUnrelayedAcksResponse is the response type for the
|
||||
// Query/UnrelayedAcks RPC method
|
||||
message QueryUnrelayedAcksResponse {
|
||||
// list of unrelayed acknowledgement sequences
|
||||
// QueryUnreceivedAcksResponse is the response type for the
|
||||
// Query/UnreceivedAcks RPC method
|
||||
message QueryUnreceivedAcksResponse {
|
||||
// list of unreceived acknowledgement sequences
|
||||
repeated uint64 sequences = 1;
|
||||
// query block height
|
||||
ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false];
|
||||
|
|
|
@ -231,6 +231,9 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
|
|||
return err
|
||||
}
|
||||
|
||||
// Add the tx service to the gRPC router.
|
||||
app.RegisterTxService(clientCtx)
|
||||
|
||||
var apiSrv *api.Server
|
||||
|
||||
config := config.GetConfig(ctx.Viper)
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
)
|
||||
|
@ -37,6 +38,10 @@ type (
|
|||
// RegisterGRPCServer registers gRPC services directly with the gRPC
|
||||
// server.
|
||||
RegisterGRPCServer(grpc.Server)
|
||||
|
||||
// RegisterTxService registers the gRPC Query service for tx (such as tx
|
||||
// simulation, fetching txs by hash...).
|
||||
RegisterTxService(clientCtx client.Context)
|
||||
}
|
||||
|
||||
// AppCreator is a function that allows us to lazily initialize an
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
@ -32,6 +33,7 @@ import (
|
|||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
|
@ -134,7 +136,10 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
var _ App = (*SimApp)(nil)
|
||||
var (
|
||||
_ App = (*SimApp)(nil)
|
||||
_ servertypes.Application = (*SimApp)(nil)
|
||||
)
|
||||
|
||||
// SimApp extends an ABCI application, but with most of its parameters exported.
|
||||
// They are exported for convenience in creating helper functions, as object
|
||||
|
@ -204,7 +209,6 @@ func NewSimApp(
|
|||
bApp.SetCommitMultiStoreTracer(traceStore)
|
||||
bApp.SetAppVersion(version.Version)
|
||||
bApp.SetInterfaceRegistry(interfaceRegistry)
|
||||
bApp.GRPCQueryRouter().RegisterSimulateService(bApp.Simulate, interfaceRegistry)
|
||||
|
||||
keys := sdk.NewKVStoreKeys(
|
||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
||||
|
@ -544,10 +548,14 @@ func (app *SimApp) SimulationManager() *module.SimulationManager {
|
|||
func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
||||
clientCtx := apiSvr.ClientCtx
|
||||
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
|
||||
// Register legacy tx routes.
|
||||
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
|
||||
// Register new tx routes from grpc-gateway.
|
||||
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
|
||||
|
||||
// Register legacy and grpc-gateway routes for all modules.
|
||||
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
|
||||
ModuleBasics.RegisterGRPCGatewayRoutes(apiSvr.ClientCtx, apiSvr.GRPCRouter)
|
||||
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
|
||||
|
||||
// register swagger API from root so that other applications can override easily
|
||||
if apiConfig.Swagger {
|
||||
|
@ -555,6 +563,11 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon
|
|||
}
|
||||
}
|
||||
|
||||
// RegisterTxService implements the Application.RegisterTxService method.
|
||||
func (app *SimApp) RegisterTxService(clientCtx client.Context) {
|
||||
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
|
||||
}
|
||||
|
||||
// RegisterSwaggerAPI registers swagger route with API Server
|
||||
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
|
||||
statikFS, err := fs.New()
|
||||
|
|
|
@ -59,10 +59,16 @@ func startInProcess(cfg Config, val *Validator) error {
|
|||
val.RPCClient = local.New(tmNode)
|
||||
}
|
||||
|
||||
if val.APIAddress != "" {
|
||||
// We'll need a RPC client if the validator exposes a gRPC or REST endpoint.
|
||||
if val.APIAddress != "" || val.AppConfig.GRPC.Enable {
|
||||
val.ClientCtx = val.ClientCtx.
|
||||
WithClient(val.RPCClient)
|
||||
|
||||
// Add the tx service in the gRPC router.
|
||||
app.RegisterTxService(val.ClientCtx)
|
||||
}
|
||||
|
||||
if val.APIAddress != "" {
|
||||
apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server"))
|
||||
app.RegisterAPIRoutes(apiSrv, val.AppConfig.API)
|
||||
|
||||
|
|
|
@ -478,6 +478,14 @@ func (s *decimalTestSuite) TestDecEncoding() {
|
|||
}
|
||||
}
|
||||
|
||||
// Showcase that different orders of operations causes different results.
|
||||
func (s *decimalTestSuite) TestOperationOrders() {
|
||||
n1 := sdk.NewDec(10)
|
||||
n2 := sdk.NewDec(1000000010)
|
||||
s.Require().Equal(n1.Mul(n2).Quo(n2), sdk.NewDec(10))
|
||||
s.Require().NotEqual(n1.Mul(n2).Quo(n2), n1.Quo(n2).Mul(n2))
|
||||
}
|
||||
|
||||
func BenchmarkMarshalTo(b *testing.B) {
|
||||
bis := []struct {
|
||||
in sdk.Dec
|
||||
|
|
|
@ -277,11 +277,11 @@ func (m *Manager) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|||
// RegisterRoutes registers all module routes and module querier routes
|
||||
func (m *Manager) RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter, legacyQuerierCdc *codec.LegacyAmino) {
|
||||
for _, module := range m.Modules {
|
||||
if !module.Route().Empty() {
|
||||
router.AddRoute(module.Route())
|
||||
if r := module.Route(); !r.Empty() {
|
||||
router.AddRoute(r)
|
||||
}
|
||||
if module.QuerierRoute() != "" {
|
||||
queryRouter.AddRoute(module.QuerierRoute(), module.LegacyQuerierHandler(legacyQuerierCdc))
|
||||
if r := module.QuerierRoute(); r != "" {
|
||||
queryRouter.AddRoute(r, module.LegacyQuerierHandler(legacyQuerierCdc))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,19 +147,15 @@ func TestManager_RegisterRoutes(t *testing.T) {
|
|||
require.Equal(t, 2, len(mm.Modules))
|
||||
|
||||
router := mocks.NewMockRouter(mockCtrl)
|
||||
handler1, handler2 := sdk.Handler(func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
return nil, nil
|
||||
}), sdk.Handler(func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
return nil, nil
|
||||
})
|
||||
route1 := sdk.NewRoute("route1", handler1)
|
||||
route2 := sdk.NewRoute("route2", handler2)
|
||||
mockAppModule1.EXPECT().Route().Times(2).Return(route1)
|
||||
mockAppModule2.EXPECT().Route().Times(2).Return(route2)
|
||||
router.EXPECT().AddRoute(gomock.Any()).Times(2) // Use of Any due to limitations to compare Functions as the sdk.Handler
|
||||
noopHandler := sdk.Handler(func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { return nil, nil })
|
||||
route1 := sdk.NewRoute("route1", noopHandler)
|
||||
route2 := sdk.NewRoute("", noopHandler)
|
||||
mockAppModule1.EXPECT().Route().Times(1).Return(route1)
|
||||
mockAppModule2.EXPECT().Route().Times(1).Return(route2)
|
||||
router.EXPECT().AddRoute(gomock.Any()).Times(1) // Use of Any due to limitations to compare Functions as the sdk.Handler
|
||||
|
||||
queryRouter := mocks.NewMockQueryRouter(mockCtrl)
|
||||
mockAppModule1.EXPECT().QuerierRoute().Times(2).Return("querierRoute1")
|
||||
mockAppModule1.EXPECT().QuerierRoute().Times(1).Return("querierRoute1")
|
||||
mockAppModule2.EXPECT().QuerierRoute().Times(1).Return("")
|
||||
handler3 := sdk.Querier(nil)
|
||||
amino := codec.NewLegacyAmino()
|
||||
|
|
|
@ -40,7 +40,7 @@ type Route struct {
|
|||
|
||||
// NewRoute returns an instance of Route.
|
||||
func NewRoute(p string, h Handler) Route {
|
||||
return Route{path: p, handler: h}
|
||||
return Route{path: strings.TrimSpace(p), handler: h}
|
||||
}
|
||||
|
||||
// Path returns the path the route has assigned.
|
||||
|
@ -55,7 +55,7 @@ func (r Route) Handler() Handler {
|
|||
|
||||
// Empty returns true only if both handler and path are not empty.
|
||||
func (r Route) Empty() bool {
|
||||
return r.handler == nil || r.path == strings.TrimSpace("")
|
||||
return r.handler == nil || r.path == ""
|
||||
}
|
||||
|
||||
// QueryRouter provides queryables for each query path.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,264 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: cosmos/tx/v1beta1/service.proto
|
||||
|
||||
/*
|
||||
Package tx is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package tx
|
||||
|
||||
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
|
||||
|
||||
var (
|
||||
filter_Service_Simulate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Service_Simulate_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SimulateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_Simulate_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Simulate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Service_Simulate_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SimulateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_Simulate_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Simulate(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Service_GetTx_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq GetTxRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["hash"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
|
||||
}
|
||||
|
||||
protoReq.Hash, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetTx(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Service_GetTx_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq GetTxRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["hash"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash")
|
||||
}
|
||||
|
||||
protoReq.Hash, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetTx(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterServiceHandlerServer registers the http handlers for service Service to "mux".
|
||||
// UnaryRPC :call ServiceServer 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 RegisterServiceHandlerFromEndpoint instead.
|
||||
func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error {
|
||||
|
||||
mux.Handle("POST", pattern_Service_Simulate_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_Service_Simulate_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Service_Simulate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Service_GetTx_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_Service_GetTx_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Service_GetTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterServiceHandlerFromEndpoint is same as RegisterServiceHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterServiceHandlerFromEndpoint(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 RegisterServiceHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterServiceHandler registers the http handlers for service Service to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterServiceHandlerClient(ctx, mux, NewServiceClient(conn))
|
||||
}
|
||||
|
||||
// RegisterServiceHandlerClient registers the http handlers for service Service
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "ServiceClient" to call the correct interceptors.
|
||||
func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error {
|
||||
|
||||
mux.Handle("POST", pattern_Service_Simulate_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_Service_Simulate_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Service_Simulate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Service_GetTx_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_Service_GetTx_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Service_GetTx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Service_Simulate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "simulate"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Service_GetTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3}, []string{"cosmos", "tx", "v1beta1", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Service_Simulate_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Service_GetTx_0 = runtime.ForwardResponseMessage
|
||||
)
|
|
@ -6,12 +6,12 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -47,8 +47,9 @@ func DecodeTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
stdTx, ok := convertToStdTx(w, clientCtx, txBytes)
|
||||
if !ok {
|
||||
stdTx, err := convertToStdTx(w, clientCtx, txBytes)
|
||||
if err != nil {
|
||||
// Error is already returned by convertToStdTx.
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,22 +62,22 @@ func DecodeTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
// convertToStdTx converts tx proto binary bytes retrieved from Tendermint into
|
||||
// a StdTx. Returns the StdTx, as well as a flag denoting if the function
|
||||
// successfully converted or not.
|
||||
func convertToStdTx(w http.ResponseWriter, clientCtx client.Context, txBytes []byte) (legacytx.StdTx, bool) {
|
||||
func convertToStdTx(w http.ResponseWriter, clientCtx client.Context, txBytes []byte) (legacytx.StdTx, error) {
|
||||
txI, err := clientCtx.TxConfig.TxDecoder()(txBytes)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return legacytx.StdTx{}, false
|
||||
return legacytx.StdTx{}, err
|
||||
}
|
||||
|
||||
tx, ok := txI.(signing.Tx)
|
||||
if !ok {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("%+v is not backwards compatible with %T", tx, legacytx.StdTx{}))
|
||||
return legacytx.StdTx{}, false
|
||||
return legacytx.StdTx{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (signing.Tx)(nil), txI)
|
||||
}
|
||||
|
||||
stdTx, err := clienttx.ConvertTxToStdTx(clientCtx.LegacyAmino, tx)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return legacytx.StdTx{}, false
|
||||
return legacytx.StdTx{}, err
|
||||
}
|
||||
|
||||
return stdTx, true
|
||||
return stdTx, nil
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
|
@ -102,6 +103,10 @@ func QueryTxsRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
for _, txRes := range searchResult.Txs {
|
||||
packStdTxResponse(w, clientCtx, txRes)
|
||||
}
|
||||
|
||||
rest.PostProcessResponseBare(w, clientCtx, searchResult)
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +133,9 @@ func QueryTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
// We just unmarshalled from Tendermint, we take the proto Tx's raw
|
||||
// bytes, and convert them into a StdTx to be displayed.
|
||||
txBytes := output.Tx.Value
|
||||
stdTx, ok := convertToStdTx(w, clientCtx, txBytes)
|
||||
if !ok {
|
||||
err = packStdTxResponse(w, clientCtx, output)
|
||||
if err != nil {
|
||||
// Error is already returned by packStdTxResponse.
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -140,7 +143,7 @@ func QueryTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
rest.WriteErrorResponse(w, http.StatusNotFound, fmt.Sprintf("no transaction found with hash %s", hashHexStr))
|
||||
}
|
||||
|
||||
rest.PostProcessResponseBare(w, clientCtx, stdTx)
|
||||
rest.PostProcessResponseBare(w, clientCtx, output)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,3 +164,21 @@ func queryParamsHandler(clientCtx client.Context) http.HandlerFunc {
|
|||
rest.PostProcessResponse(w, clientCtx, res)
|
||||
}
|
||||
}
|
||||
|
||||
// packStdTxResponse takes a sdk.TxResponse, converts the Tx into a StdTx, and
|
||||
// packs the StdTx again into the sdk.TxResponse Any. Amino then takes care of
|
||||
// seamlessly JSON-outputting the Any.
|
||||
func packStdTxResponse(w http.ResponseWriter, clientCtx client.Context, txRes *sdk.TxResponse) error {
|
||||
// We just unmarshalled from Tendermint, we take the proto Tx's raw
|
||||
// bytes, and convert them into a StdTx to be displayed.
|
||||
txBytes := txRes.Tx.Value
|
||||
stdTx, err := convertToStdTx(w, clientCtx, txBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pack the amino stdTx into the TxResponse's Any.
|
||||
txRes.Tx = codectypes.UnsafePackAny(stdTx)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -4,17 +4,19 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
|
||||
rest2 "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
|
||||
|
@ -26,6 +28,9 @@ type IntegrationTestSuite struct {
|
|||
|
||||
cfg network.Config
|
||||
network *network.Network
|
||||
|
||||
stdTx legacytx.StdTx
|
||||
stdTxRes sdk.TxResponse
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
|
@ -37,8 +42,23 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||
s.cfg = cfg
|
||||
s.network = network.New(s.T(), cfg)
|
||||
|
||||
_, err := s.network.WaitForHeight(1)
|
||||
kb := s.network.Validators[0].ClientCtx.Keyring
|
||||
_, _, err := kb.NewMnemonic("newAccount", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
_, err = s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Broadcast a StdTx used for tests.
|
||||
s.stdTx = s.createTestStdTx(s.network.Validators[0], 0, 1)
|
||||
res, err := s.broadcastReq(s.stdTx, "block")
|
||||
s.Require().NoError(err)
|
||||
|
||||
// NOTE: this uses amino explicitly, don't migrate it!
|
||||
s.Require().NoError(s.cfg.LegacyAmino.UnmarshalJSON(res, &s.stdTxRes))
|
||||
s.Require().Equal(uint32(0), s.stdTxRes.Code)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
|
@ -107,25 +127,73 @@ func (s *IntegrationTestSuite) TestBroadcastTxRequest() {
|
|||
func (s *IntegrationTestSuite) TestQueryTxByHash() {
|
||||
val0 := s.network.Validators[0]
|
||||
|
||||
// Create and broadcast a tx.
|
||||
stdTx := s.createTestStdTx(val0, 1) // Validator's sequence starts at 1.
|
||||
res, err := s.broadcastReq(stdTx, "block")
|
||||
s.Require().NoError(err)
|
||||
var txRes sdk.TxResponse
|
||||
// NOTE: this uses amino explicitly, don't migrate it!
|
||||
s.Require().NoError(s.cfg.LegacyAmino.UnmarshalJSON(res, &txRes))
|
||||
// We broadcasted a StdTx in SetupSuite.
|
||||
// we just check for a non-empty TxHash here, the actual hash will depend on the underlying tx configuration
|
||||
s.Require().NotEmpty(txRes.TxHash)
|
||||
s.Require().NotEmpty(s.stdTxRes.TxHash)
|
||||
|
||||
s.network.WaitForNextBlock()
|
||||
|
||||
// We now fetch the tx by has on the `/tx/{hash}` route.
|
||||
txJSON, err := rest.GetRequest(fmt.Sprintf("%s/txs/%s", val0.APIAddress, txRes.TxHash))
|
||||
// We now fetch the tx by hash on the `/tx/{hash}` route.
|
||||
txJSON, err := rest.GetRequest(fmt.Sprintf("%s/txs/%s", val0.APIAddress, s.stdTxRes.TxHash))
|
||||
s.Require().NoError(err)
|
||||
|
||||
// txJSON should contain the whole tx, we just make sure that our custom
|
||||
// memo is there.
|
||||
s.Require().True(strings.Contains(string(txJSON), stdTx.Memo))
|
||||
s.Require().Contains(string(txJSON), s.stdTx.Memo)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestQueryTxByHeight() {
|
||||
val0 := s.network.Validators[0]
|
||||
|
||||
// We broadcasted a StdTx in SetupSuite.
|
||||
// we just check for a non-empty height here, as we'll need to for querying.
|
||||
s.Require().NotEmpty(s.stdTxRes.Height)
|
||||
|
||||
// We now fetch the tx on `/txs` route, filtering by `tx.height`
|
||||
txJSON, err := rest.GetRequest(fmt.Sprintf("%s/txs?limit=10&page=1&tx.height=%d", val0.APIAddress, s.stdTxRes.Height))
|
||||
s.Require().NoError(err)
|
||||
|
||||
// txJSON should contain the whole tx, we just make sure that our custom
|
||||
// memo is there.
|
||||
s.Require().Contains(string(txJSON), s.stdTx.Memo)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestQueryTxByHashWithServiceMessage() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
|
||||
|
||||
// Right after this line, we're sending a tx. Might need to wait a block
|
||||
// to refresh sequences.
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
out, err := bankcli.ServiceMsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
val.Address,
|
||||
sdk.NewCoins(sendTokens),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit),
|
||||
)
|
||||
|
||||
s.Require().NoError(err)
|
||||
var txRes sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes))
|
||||
s.Require().Equal(uint32(0), txRes.Code)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
txJSON, err := rest.GetRequest(fmt.Sprintf("%s/txs/%s", val.APIAddress, txRes.TxHash))
|
||||
s.Require().NoError(err)
|
||||
|
||||
var txResAmino sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(txJSON, &txResAmino))
|
||||
stdTx, ok := txResAmino.Tx.GetCachedValue().(legacytx.StdTx)
|
||||
s.Require().True(ok)
|
||||
msgs := stdTx.GetMsgs()
|
||||
s.Require().Equal(len(msgs), 1)
|
||||
_, ok = msgs[0].(*types.MsgSend)
|
||||
s.Require().True(ok)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestMultipleSyncBroadcastTxRequests() {
|
||||
|
@ -153,9 +221,8 @@ func (s *IntegrationTestSuite) TestMultipleSyncBroadcastTxRequests() {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.desc), func() {
|
||||
|
||||
// broadcast test with sync mode, as we want to run CheckTx to verify account sequence is correct
|
||||
stdTx := s.createTestStdTx(s.network.Validators[0], tc.sequence)
|
||||
stdTx := s.createTestStdTx(s.network.Validators[1], 1, tc.sequence)
|
||||
res, err := s.broadcastReq(stdTx, "sync")
|
||||
s.Require().NoError(err)
|
||||
|
||||
|
@ -180,7 +247,7 @@ func (s *IntegrationTestSuite) TestMultipleSyncBroadcastTxRequests() {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sequence uint64) legacytx.StdTx {
|
||||
func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, accNum, sequence uint64) legacytx.StdTx {
|
||||
txConfig := legacytx.StdTxConfig{Cdc: s.cfg.LegacyAmino}
|
||||
|
||||
msg := &types.MsgSend{
|
||||
|
@ -204,6 +271,7 @@ func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sequence
|
|||
WithKeybase(val.ClientCtx.Keyring).
|
||||
WithTxConfig(txConfig).
|
||||
WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON).
|
||||
WithAccountNumber(accNum).
|
||||
WithSequence(sequence)
|
||||
|
||||
// sign Tx (offline mode so we can manually set sequence number)
|
||||
|
|
|
@ -29,7 +29,25 @@ func (s *StdTxBuilder) GetTx() authsigning.Tx {
|
|||
|
||||
// SetMsgs implements TxBuilder.SetMsgs
|
||||
func (s *StdTxBuilder) SetMsgs(msgs ...sdk.Msg) error {
|
||||
s.Msgs = msgs
|
||||
stdTxMsgs := make([]sdk.Msg, len(msgs))
|
||||
|
||||
for i, msg := range msgs {
|
||||
switch msg := msg.(type) {
|
||||
case sdk.ServiceMsg:
|
||||
// Since ServiceMsg isn't registered with amino, we unpack msg.Request
|
||||
// into a Msg so that it's handled gracefully for the legacy
|
||||
// GET /txs/{hash} and /txs endpoints.
|
||||
sdkMsg, ok := msg.Request.(sdk.Msg)
|
||||
if !ok {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting %T at %d to implement sdk.Msg", msg.Request, i)
|
||||
}
|
||||
stdTxMsgs[i] = sdkMsg
|
||||
default:
|
||||
// legacy sdk.Msg
|
||||
stdTxMsgs[i] = msg
|
||||
}
|
||||
}
|
||||
s.Msgs = stdTxMsgs
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package tx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
|
||||
gogogrpc "github.com/gogo/protobuf/grpc"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
)
|
||||
|
||||
// baseAppSimulateFn is the signature of the Baseapp#Simulate function.
|
||||
type baseAppSimulateFn func(txBytes []byte) (sdk.GasInfo, *sdk.Result, error)
|
||||
|
||||
// txServer is the server for the protobuf Tx service.
|
||||
type txServer struct {
|
||||
clientCtx client.Context
|
||||
simulate baseAppSimulateFn
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
}
|
||||
|
||||
// NewTxServer creates a new Tx service server.
|
||||
func NewTxServer(clientCtx client.Context, simulate baseAppSimulateFn, interfaceRegistry codectypes.InterfaceRegistry) txtypes.ServiceServer {
|
||||
return txServer{
|
||||
clientCtx: clientCtx,
|
||||
simulate: simulate,
|
||||
interfaceRegistry: interfaceRegistry,
|
||||
}
|
||||
}
|
||||
|
||||
var _ txtypes.ServiceServer = txServer{}
|
||||
|
||||
// Simulate implements the ServiceServer.Simulate RPC method.
|
||||
func (s txServer) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (*txtypes.SimulateResponse, error) {
|
||||
if req.Tx == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid empty tx")
|
||||
}
|
||||
|
||||
err := req.Tx.UnpackInterfaces(s.interfaceRegistry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
txBytes, err := req.Tx.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gasInfo, result, err := s.simulate(txBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &txtypes.SimulateResponse{
|
||||
GasInfo: &gasInfo,
|
||||
Result: result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetTx implements the ServiceServer.GetTx RPC method.
|
||||
func (s txServer) GetTx(ctx context.Context, req *txtypes.GetTxRequest) (*txtypes.GetTxResponse, error) {
|
||||
// We get hash as a hex string in the request, convert it to bytes.
|
||||
hash, err := hex.DecodeString(req.Hash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO We should also check the proof flag in gRPC header.
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/7036.
|
||||
result, err := s.clientCtx.Client.Tx(ctx, hash, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create a proto codec, we need it to unmarshal the tx bytes.
|
||||
cdc := codec.NewProtoCodec(s.clientCtx.InterfaceRegistry)
|
||||
var protoTx txtypes.Tx
|
||||
|
||||
if err := cdc.UnmarshalBinaryBare(result.Tx, &protoTx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &txtypes.GetTxResponse{
|
||||
Tx: &protoTx,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RegisterTxService registers the tx service on the gRPC router.
|
||||
func RegisterTxService(
|
||||
qrt gogogrpc.Server,
|
||||
clientCtx client.Context,
|
||||
simulateFn baseAppSimulateFn,
|
||||
interfaceRegistry codectypes.InterfaceRegistry,
|
||||
) {
|
||||
txtypes.RegisterServiceServer(
|
||||
qrt,
|
||||
NewTxServer(clientCtx, simulateFn, interfaceRegistry),
|
||||
)
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes mounts the tx service's GRPC-gateway routes on the
|
||||
// given Mux.
|
||||
func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) {
|
||||
txtypes.RegisterServiceHandlerClient(context.Background(), mux, txtypes.NewServiceClient(clientConn))
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package tx_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cfg network.Config
|
||||
network *network.Network
|
||||
|
||||
queryClient tx.ServiceClient
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.T().Log("setting up integration test suite")
|
||||
|
||||
cfg := network.DefaultConfig()
|
||||
cfg.NumValidators = 1
|
||||
|
||||
s.cfg = cfg
|
||||
s.network = network.New(s.T(), cfg)
|
||||
|
||||
s.Require().NotNil(s.network)
|
||||
|
||||
_, err := s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.queryClient = tx.NewServiceClient(s.network.Validators[0].ClientCtx)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
s.T().Log("tearing down integration test suite")
|
||||
s.network.Cleanup()
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestSimulate() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
// prepare txBuilder with msg
|
||||
txBuilder := val.ClientCtx.TxConfig.NewTxBuilder()
|
||||
feeAmount := sdk.Coins{sdk.NewInt64Coin(s.cfg.BondDenom, 10)}
|
||||
gasLimit := testdata.NewTestGasLimit()
|
||||
s.Require().NoError(
|
||||
txBuilder.SetMsgs(&banktypes.MsgSend{
|
||||
FromAddress: val.Address.String(),
|
||||
ToAddress: val.Address.String(),
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin(s.cfg.BondDenom, 10)},
|
||||
}),
|
||||
)
|
||||
txBuilder.SetFeeAmount(feeAmount)
|
||||
txBuilder.SetGasLimit(gasLimit)
|
||||
txBuilder.SetMemo("foobar")
|
||||
|
||||
// setup txFactory
|
||||
txFactory := clienttx.Factory{}.
|
||||
WithChainID(val.ClientCtx.ChainID).
|
||||
WithKeybase(val.ClientCtx.Keyring).
|
||||
WithTxConfig(val.ClientCtx.TxConfig).
|
||||
WithSignMode(signing.SignMode_SIGN_MODE_DIRECT)
|
||||
|
||||
// Sign Tx.
|
||||
err := authclient.SignTx(txFactory, val.ClientCtx, val.Moniker, txBuilder, false)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Convert the txBuilder to a tx.Tx.
|
||||
protoTx, err := txBuilderToProtoTx(txBuilder)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Run the simulate gRPC query.
|
||||
res, err := s.queryClient.Simulate(
|
||||
context.Background(),
|
||||
&tx.SimulateRequest{Tx: protoTx},
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Check the result and gas used are correct.
|
||||
s.Require().Equal(len(res.GetResult().GetEvents()), 4) // 1 transfer, 3 messages.
|
||||
s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
|
||||
}
|
||||
|
||||
func (s IntegrationTestSuite) TestGetTx() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
// Create a new MsgSend tx from val to itself.
|
||||
out, err := bankcli.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
val.Address,
|
||||
sdk.NewCoins(
|
||||
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)),
|
||||
),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit),
|
||||
fmt.Sprintf("--%s=foobar", flags.FlagMemo),
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
var txRes sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes))
|
||||
s.Require().Equal(uint32(0), txRes.Code)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Query the tx via gRPC.
|
||||
grpcRes, err := s.queryClient.GetTx(
|
||||
context.Background(),
|
||||
&tx.GetTxRequest{Hash: txRes.TxHash},
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal("foobar", grpcRes.Tx.Body.Memo)
|
||||
|
||||
// Query the tx via grpc-gateway.
|
||||
restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/%s", val.APIAddress, txRes.TxHash))
|
||||
s.Require().NoError(err)
|
||||
var getTxRes tx.GetTxResponse
|
||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getTxRes))
|
||||
s.Require().Equal("foobar", getTxRes.Tx.Body.Memo)
|
||||
}
|
||||
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
||||
|
||||
// txBuilderToProtoTx converts a txBuilder into a proto tx.Tx.
|
||||
func txBuilderToProtoTx(txBuilder client.TxBuilder) (*tx.Tx, error) { // nolint
|
||||
intoAnyTx, ok := txBuilder.(codectypes.IntoAny)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (codectypes.IntoAny)(nil), intoAnyTx)
|
||||
}
|
||||
|
||||
any := intoAnyTx.AsAny().GetCachedValue()
|
||||
if any == nil {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "any's cached value is empty")
|
||||
}
|
||||
|
||||
protoTx, ok := any.(*tx.Tx)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (codectypes.IntoAny)(nil), intoAnyTx)
|
||||
}
|
||||
|
||||
return protoTx, nil
|
||||
}
|
|
@ -57,8 +57,8 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal types.Proposal) (passes boo
|
|||
val.DelegatorDeductions = val.DelegatorDeductions.Add(delegation.GetShares())
|
||||
currValidators[valAddrStr] = val
|
||||
|
||||
delegatorShare := delegation.GetShares().Quo(val.DelegatorShares)
|
||||
votingPower := delegatorShare.MulInt(val.BondedTokens)
|
||||
// delegation shares * bonded / total shares
|
||||
votingPower := delegation.GetShares().MulInt(val.BondedTokens).Quo(val.DelegatorShares)
|
||||
|
||||
results[vote.Option] = results[vote.Option].Add(votingPower)
|
||||
totalVotingPower = totalVotingPower.Add(votingPower)
|
||||
|
@ -78,8 +78,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal types.Proposal) (passes boo
|
|||
}
|
||||
|
||||
sharesAfterDeductions := val.DelegatorShares.Sub(val.DelegatorDeductions)
|
||||
fractionAfterDeductions := sharesAfterDeductions.Quo(val.DelegatorShares)
|
||||
votingPower := fractionAfterDeductions.MulInt(val.BondedTokens)
|
||||
votingPower := sharesAfterDeductions.MulInt(val.BondedTokens).Quo(val.DelegatorShares)
|
||||
|
||||
results[val.Vote] = results[val.Vote].Add(votingPower)
|
||||
totalVotingPower = totalVotingPower.Add(votingPower)
|
||||
|
|
|
@ -159,6 +159,11 @@ func (k Keeper) IterateDenomTraces(ctx sdk.Context, cb func(denomTrace types.Den
|
|||
}
|
||||
}
|
||||
|
||||
// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function
|
||||
func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool {
|
||||
return k.scopedKeeper.AuthenticateCapability(ctx, cap, name)
|
||||
}
|
||||
|
||||
// ClaimCapability allows the transfer module that can claim a capability that IBC module
|
||||
// passes to it
|
||||
func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error {
|
||||
|
|
|
@ -245,9 +245,15 @@ func (am AppModule) OnChanOpenTry(
|
|||
return sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version)
|
||||
}
|
||||
|
||||
// Claim channel capability passed back by IBC module
|
||||
if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
|
||||
return err
|
||||
// Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos
|
||||
// (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry)
|
||||
// If module can already authenticate the capability then module already owns it so we don't need to claim
|
||||
// Otherwise, module does not have channel capability and we must claim it from IBC
|
||||
if !am.keeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) {
|
||||
// Only claim channel capability passed back by IBC module if we do not already own it
|
||||
if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -108,6 +108,12 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {
|
|||
{
|
||||
"success", func() {}, true,
|
||||
},
|
||||
{
|
||||
"capability already claimed in INIT should pass", func() {
|
||||
err := suite.chainA.App.ScopedTransferKeeper.ClaimCapability(suite.chainA.GetContext(), chanCap, host.ChannelCapabilityPath(testChannel.PortID, testChannel.ID))
|
||||
suite.Require().NoError(err)
|
||||
}, true,
|
||||
},
|
||||
{
|
||||
"invalid order - ORDERED", func() {
|
||||
channel.Ordering = channeltypes.ORDERED
|
||||
|
@ -128,12 +134,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {
|
|||
counterpartyVersion = "version"
|
||||
}, false,
|
||||
},
|
||||
{
|
||||
"capability already claimed", func() {
|
||||
err := suite.chainA.App.ScopedTransferKeeper.ClaimCapability(suite.chainA.GetContext(), chanCap, host.ChannelCapabilityPath(testChannel.PortID, testChannel.ID))
|
||||
suite.Require().NoError(err)
|
||||
}, false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
|
@ -24,8 +24,10 @@ func GetQueryCmd() *cobra.Command {
|
|||
GetCmdQueryChannelClientState(),
|
||||
GetCmdQueryPacketCommitment(),
|
||||
GetCmdQueryPacketCommitments(),
|
||||
GetCmdQueryPacketReceipt(),
|
||||
GetCmdQueryPacketAcknowledgement(),
|
||||
GetCmdQueryUnreceivedPackets(),
|
||||
GetCmdQueryUnrelayedAcks(),
|
||||
GetCmdQueryUnreceivedAcks(),
|
||||
GetCmdQueryNextSequenceReceive(),
|
||||
// TODO: next sequence Send ?
|
||||
)
|
||||
|
|
|
@ -211,14 +211,14 @@ func GetCmdQueryPacketCommitments() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryPacketCommitment defines the command to query a channel end
|
||||
// GetCmdQueryPacketCommitment defines the command to query a packet commitment
|
||||
func GetCmdQueryPacketCommitment() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "packet-commitment [port-id] [channel-id] [sequence]",
|
||||
Short: "Query a packet commitment",
|
||||
Long: "Query a packet commitment",
|
||||
Example: fmt.Sprintf(
|
||||
"%s query %s %s end [port-id] [channel-id]", version.AppName, host.ModuleName, types.SubModuleName,
|
||||
"%s query %s %s packet-commitment [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
@ -252,6 +252,88 @@ func GetCmdQueryPacketCommitment() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryPacketReceipt defines the command to query a packet receipt
|
||||
func GetCmdQueryPacketReceipt() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "packet-receipt [port-id] [channel-id] [sequence]",
|
||||
Short: "Query a packet receipt",
|
||||
Long: "Query a packet receipt",
|
||||
Example: fmt.Sprintf(
|
||||
"%s query %s %s packet-receipt [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
|
||||
seq, err := strconv.ParseUint(args[2], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := utils.QueryPacketReceipt(clientCtx, portID, channelID, seq, prove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryPacketAcknowledgement defines the command to query a packet acknowledgement
|
||||
func GetCmdQueryPacketAcknowledgement() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "packet-ack [port-id] [channel-id] [sequence]",
|
||||
Short: "Query a packet acknowledgement",
|
||||
Long: "Query a packet acknowledgement",
|
||||
Example: fmt.Sprintf(
|
||||
"%s query %s %s packet-ack [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
|
||||
seq, err := strconv.ParseUint(args[2], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := utils.QueryPacketAcknowledgement(clientCtx, portID, channelID, seq, prove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryUnreceivedPackets defines the command to query all the unreceived
|
||||
// packets on the receiving chain
|
||||
func GetCmdQueryUnreceivedPackets() *cobra.Command {
|
||||
|
@ -264,7 +346,7 @@ The return value represents:
|
|||
- Unreceived packet commitments: no acknowledgement exists on receiving chain for the given packet commitment sequence on sending chain.
|
||||
`,
|
||||
Example: fmt.Sprintf("%s query %s %s unreceived-packets [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(3),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
|
||||
|
@ -304,18 +386,18 @@ The return value represents:
|
|||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryUnrelayedAcks defines the command to query all the unrelayed acks on the original sending chain
|
||||
func GetCmdQueryUnrelayedAcks() *cobra.Command {
|
||||
// GetCmdQueryUnreceivedAcks defines the command to query all the unreceived acks on the original sending chain
|
||||
func GetCmdQueryUnreceivedAcks() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "unrelayed-acks [port-id] [channel-id]",
|
||||
Short: "Query all the unrelayed acks associated with a channel",
|
||||
Long: `Given a list of packet commitment sequences from counterparty, determine if an ack on executing chain has not been relayed to counterparty.
|
||||
Use: "unreceived-acks [port-id] [channel-id]",
|
||||
Short: "Query all the unreceived acks associated with a channel",
|
||||
Long: `Given a list of acknowledgement sequences from counterparty, determine if an ack on the counterparty chain has been received on the executing chain.
|
||||
|
||||
The return value represents:
|
||||
- Unrelayed packet acknowledgement: packet commitment exists on original sending chain and ack exists on receiving (executing) chain.
|
||||
- Unreceived packet acknowledgement: packet commitment exists on original sending (executing) chain and ack exists on receiving chain.
|
||||
`,
|
||||
Example: fmt.Sprintf("%s query %s %s unrelayed-acks [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(3),
|
||||
Example: fmt.Sprintf("%s query %s %s unreceived-acks [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
|
||||
|
@ -334,13 +416,13 @@ The return value represents:
|
|||
seqs[i] = uint64(seqSlice[i])
|
||||
}
|
||||
|
||||
req := &types.QueryUnrelayedAcksRequest{
|
||||
PortId: args[0],
|
||||
ChannelId: args[1],
|
||||
PacketCommitmentSequences: seqs,
|
||||
req := &types.QueryUnreceivedAcksRequest{
|
||||
PortId: args[0],
|
||||
ChannelId: args[1],
|
||||
PacketAckSequences: seqs,
|
||||
}
|
||||
|
||||
res, err := queryClient.UnrelayedAcks(context.Background(), req)
|
||||
res, err := queryClient.UnreceivedAcks(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -15,45 +15,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
|
||||
)
|
||||
|
||||
// QueryPacketCommitment returns a packet commitment.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryPacketCommitment(
|
||||
clientCtx client.Context, portID, channelID string,
|
||||
sequence uint64, prove bool,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
if prove {
|
||||
return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryPacketCommitmentRequest{
|
||||
PortId: portID,
|
||||
ChannelId: channelID,
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
return queryClient.PacketCommitment(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryPacketCommitmentABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
key := host.KeyPacketCommitment(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// check if packet commitment exists
|
||||
if len(value) == 0 {
|
||||
return nil, sdkerrors.Wrapf(types.ErrPacketCommitmentNotFound, "portID (%s), channelID (%s), sequence (%d)", portID, channelID, sequence)
|
||||
}
|
||||
|
||||
return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil
|
||||
}
|
||||
|
||||
// QueryChannel returns a channel end.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
|
@ -231,3 +192,109 @@ func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID strin
|
|||
|
||||
return types.NewQueryNextSequenceReceiveResponse(sequence, proofBz, proofHeight), nil
|
||||
}
|
||||
|
||||
// QueryPacketCommitment returns a packet commitment.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryPacketCommitment(
|
||||
clientCtx client.Context, portID, channelID string,
|
||||
sequence uint64, prove bool,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
if prove {
|
||||
return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryPacketCommitmentRequest{
|
||||
PortId: portID,
|
||||
ChannelId: channelID,
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
return queryClient.PacketCommitment(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryPacketCommitmentABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
key := host.KeyPacketCommitment(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// check if packet commitment exists
|
||||
if len(value) == 0 {
|
||||
return nil, sdkerrors.Wrapf(types.ErrPacketCommitmentNotFound, "portID (%s), channelID (%s), sequence (%d)", portID, channelID, sequence)
|
||||
}
|
||||
|
||||
return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil
|
||||
}
|
||||
|
||||
// QueryPacketReceipt returns data about a packet receipt.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryPacketReceipt(
|
||||
clientCtx client.Context, portID, channelID string,
|
||||
sequence uint64, prove bool,
|
||||
) (*types.QueryPacketReceiptResponse, error) {
|
||||
if prove {
|
||||
return queryPacketReceiptABCI(clientCtx, portID, channelID, sequence)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryPacketReceiptRequest{
|
||||
PortId: portID,
|
||||
ChannelId: channelID,
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
return queryClient.PacketReceipt(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryPacketReceiptABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketReceiptResponse, error) {
|
||||
key := host.KeyPacketReceipt(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewQueryPacketReceiptResponse(value != nil, proofBz, proofHeight), nil
|
||||
}
|
||||
|
||||
// QueryPacketAcknowledgement returns the data about a packet acknowledgement.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client
|
||||
func QueryPacketAcknowledgement(clientCtx client.Context, portID, channelID string, sequence uint64, prove bool) (*types.QueryPacketAcknowledgementResponse, error) {
|
||||
if prove {
|
||||
return queryPacketAcknowledgementABCI(clientCtx, portID, channelID, sequence)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryPacketAcknowledgementRequest{
|
||||
PortId: portID,
|
||||
ChannelId: channelID,
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
return queryClient.PacketAcknowledgement(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryPacketAcknowledgementABCI(clientCtx client.Context, portID, channelID string, sequence uint64) (*types.QueryPacketAcknowledgementResponse, error) {
|
||||
key := host.KeyPacketAcknowledgement(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(value) == 0 {
|
||||
return nil, sdkerrors.Wrapf(types.ErrInvalidAcknowledgement, "portID (%s), channelID (%s), sequence (%d)", portID, channelID, sequence)
|
||||
}
|
||||
|
||||
return types.NewQueryPacketAcknowledgementResponse(value, proofBz, proofHeight), nil
|
||||
}
|
||||
|
|
|
@ -14,10 +14,13 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
|||
k.SetChannel(ctx, channel.PortId, channel.ChannelId, ch)
|
||||
}
|
||||
for _, ack := range gs.Acknowledgements {
|
||||
k.SetPacketAcknowledgement(ctx, ack.PortId, ack.ChannelId, ack.Sequence, ack.Hash)
|
||||
k.SetPacketAcknowledgement(ctx, ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
|
||||
}
|
||||
for _, commitment := range gs.Commitments {
|
||||
k.SetPacketCommitment(ctx, commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Hash)
|
||||
k.SetPacketCommitment(ctx, commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Data)
|
||||
}
|
||||
for _, receipt := range gs.Receipts {
|
||||
k.SetPacketReceipt(ctx, receipt.PortId, receipt.ChannelId, receipt.Sequence)
|
||||
}
|
||||
for _, ss := range gs.SendSequences {
|
||||
k.SetNextSequenceSend(ctx, ss.PortId, ss.ChannelId, ss.Sequence)
|
||||
|
@ -36,6 +39,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
|
|||
Channels: k.GetAllChannels(ctx),
|
||||
Acknowledgements: k.GetAllPacketAcks(ctx),
|
||||
Commitments: k.GetAllPacketCommitments(ctx),
|
||||
Receipts: k.GetAllPacketReceipts(ctx),
|
||||
SendSequences: k.GetAllPacketSendSeqs(ctx),
|
||||
RecvSequences: k.GetAllPacketRecvSeqs(ctx),
|
||||
AckSequences: k.GetAllPacketAckSeqs(ctx),
|
||||
|
|
|
@ -237,7 +237,7 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
|
|||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
commitments := []*types.PacketAckCommitment{}
|
||||
commitments := []*types.PacketState{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketCommitmentPrefixPath(req.PortId, req.ChannelId)))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
|
@ -248,7 +248,7 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
|
|||
return err
|
||||
}
|
||||
|
||||
commitment := types.NewPacketAckCommitment(req.PortId, req.ChannelId, sequence, value)
|
||||
commitment := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
|
||||
commitments = append(commitments, &commitment)
|
||||
return nil
|
||||
})
|
||||
|
@ -265,6 +265,28 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
|
|||
}, nil
|
||||
}
|
||||
|
||||
// PacketReceipt implements the Query/PacketReceipt gRPC method
|
||||
func (q Keeper) PacketReceipt(c context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortId, req.ChannelId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req.Sequence == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0")
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
_, recvd := q.GetPacketReceipt(ctx, req.PortId, req.ChannelId, req.Sequence)
|
||||
|
||||
selfHeight := clienttypes.GetSelfHeight(ctx)
|
||||
return types.NewQueryPacketReceiptResponse(recvd, nil, selfHeight), nil
|
||||
}
|
||||
|
||||
// PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method
|
||||
func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) {
|
||||
if req == nil {
|
||||
|
@ -290,9 +312,49 @@ func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketA
|
|||
return types.NewQueryPacketAcknowledgementResponse(acknowledgementBz, nil, selfHeight), nil
|
||||
}
|
||||
|
||||
// PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method
|
||||
func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacketAcknowledgementsRequest) (*types.QueryPacketAcknowledgementsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortId, req.ChannelId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
acks := []*types.PacketState{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketAcknowledgementPrefixPath(req.PortId, req.ChannelId)))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
keySplit := strings.Split(string(key), "/")
|
||||
|
||||
sequence, err := strconv.ParseUint(keySplit[len(keySplit)-1], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ack := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
|
||||
acks = append(acks, &ack)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
selfHeight := clienttypes.GetSelfHeight(ctx)
|
||||
return &types.QueryPacketAcknowledgementsResponse{
|
||||
Acknowledgements: acks,
|
||||
Pagination: pageRes,
|
||||
Height: selfHeight,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given
|
||||
// a list of counterparty packet commitments, the querier checks if the packet
|
||||
// has already been received by checking if an acknowledgement exists on this
|
||||
// has already been received by checking if a receipt exists on this
|
||||
// chain for the packet sequence. All packets that haven't been received yet
|
||||
// are returned in the response
|
||||
// Usage: To use this method correctly, first query all packet commitments on
|
||||
|
@ -306,9 +368,6 @@ func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketA
|
|||
// commitments is correct and will not function properly if the list
|
||||
// is not up to date. Ideally the query height should equal the latest height
|
||||
// on the counterparty's client which represents this chain.
|
||||
// TODO: Replace GetPacketAcknowledgement with GetPacketReceipt once async
|
||||
// acknowledgements issue is implemented.
|
||||
// Issue #7254: https://github.com/cosmos/cosmos-sdk/issues/7254
|
||||
func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedPacketsRequest) (*types.QueryUnreceivedPacketsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
|
@ -327,8 +386,8 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP
|
|||
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
|
||||
}
|
||||
|
||||
// if acknowledgement exists on the receiving chain, then packet has already been received
|
||||
if _, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq); !found {
|
||||
// if packet receipt exists on the receiving chain, then packet has already been received
|
||||
if _, found := q.GetPacketReceipt(ctx, req.PortId, req.ChannelId, seq); !found {
|
||||
unreceivedSequences = append(unreceivedSequences, seq)
|
||||
}
|
||||
|
||||
|
@ -341,24 +400,24 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP
|
|||
}, nil
|
||||
}
|
||||
|
||||
// UnrelayedAcks implements the Query/UnrelayedAcks gRPC method. Given
|
||||
// UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given
|
||||
// a list of counterparty packet acknowledgements, the querier checks if the packet
|
||||
// has already been received by checking if the packet commitment still exists on this
|
||||
// chain (original sender) for the packet sequence.
|
||||
// All acknowledgmeents that haven't been received yet are returned in the response.
|
||||
// Usage: To use this method correctly, first query all packet commitments on
|
||||
// the sending chain using the Query/PacketCommitments gRPC method.
|
||||
// Then input the returned sequences into the QueryUnrelayedPacketsRequest
|
||||
// and send the request to this Query/UnrelayedPackets on the **receiving**
|
||||
// Usage: To use this method correctly, first query all packet acknowledgements on
|
||||
// the original receiving chain (ie the chain that wrote the acks) using the Query/PacketAcknowledgements gRPC method.
|
||||
// Then input the returned sequences into the QueryUnreceivedAcksRequest
|
||||
// and send the request to this Query/UnreceivedAcks on the **original sending**
|
||||
// chain. This gRPC method will then return the list of packet sequences whose
|
||||
// acknowledgements are already written on the receiving chain but haven't yet
|
||||
// been relayed back to the sending chain.
|
||||
// been received back to the sending chain.
|
||||
//
|
||||
// NOTE: The querier makes the assumption that the provided list of packet
|
||||
// acknowledgements is correct and will not function properly if the list
|
||||
// is not up to date. Ideally the query height should equal the latest height
|
||||
// on the counterparty's client which represents this chain.
|
||||
func (q Keeper) UnrelayedAcks(c context.Context, req *types.QueryUnrelayedAcksRequest) (*types.QueryUnrelayedAcksResponse, error) {
|
||||
func (q Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcksRequest) (*types.QueryUnreceivedAcksResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
@ -369,24 +428,24 @@ func (q Keeper) UnrelayedAcks(c context.Context, req *types.QueryUnrelayedAcksRe
|
|||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
var unrelayedSequences = []uint64{}
|
||||
var unreceivedSequences = []uint64{}
|
||||
|
||||
for i, seq := range req.PacketCommitmentSequences {
|
||||
for i, seq := range req.PacketAckSequences {
|
||||
if seq == 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
|
||||
}
|
||||
|
||||
// if packet commitment still exists on the original sending chain, then packet ack has not been received
|
||||
// since processing the ack will delete the packet commitment
|
||||
if _, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq); found {
|
||||
unrelayedSequences = append(unrelayedSequences, seq)
|
||||
if commitment := q.GetPacketCommitment(ctx, req.PortId, req.ChannelId, seq); len(commitment) != 0 {
|
||||
unreceivedSequences = append(unreceivedSequences, seq)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
selfHeight := clienttypes.GetSelfHeight(ctx)
|
||||
return &types.QueryUnrelayedAcksResponse{
|
||||
Sequences: unrelayedSequences,
|
||||
return &types.QueryUnreceivedAcksResponse{
|
||||
Sequences: unreceivedSequences,
|
||||
Height: selfHeight,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -649,7 +649,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() {
|
|||
func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
||||
var (
|
||||
req *types.QueryPacketCommitmentsRequest
|
||||
expCommitments = []*types.PacketAckCommitment{}
|
||||
expCommitments = []*types.PacketState{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -677,7 +677,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
|||
{
|
||||
"success, empty res",
|
||||
func() {
|
||||
expCommitments = []*types.PacketAckCommitment{}
|
||||
expCommitments = []*types.PacketState{}
|
||||
|
||||
req = &types.QueryPacketCommitmentsRequest{
|
||||
PortId: "test-port-id",
|
||||
|
@ -696,11 +696,11 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
|||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
expCommitments = make([]*types.PacketAckCommitment, 9)
|
||||
expCommitments = make([]*types.PacketState, 9)
|
||||
|
||||
for i := uint64(0); i < 9; i++ {
|
||||
commitment := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Hash)
|
||||
commitment := types.NewPacketState(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Data)
|
||||
expCommitments[i] = &commitment
|
||||
}
|
||||
|
||||
|
@ -738,6 +738,108 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryPacketReceipt() {
|
||||
var (
|
||||
req *types.QueryPacketReceiptRequest
|
||||
expReceived bool
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryPacketReceiptRequest{
|
||||
PortId: "",
|
||||
ChannelId: "test-channel-id",
|
||||
Sequence: 1,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryPacketReceiptRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "",
|
||||
Sequence: 1,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"invalid sequence",
|
||||
func() {
|
||||
req = &types.QueryPacketReceiptRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "test-channel-id",
|
||||
Sequence: 0,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success: receipt not found",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
|
||||
|
||||
req = &types.QueryPacketReceiptRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
Sequence: 3,
|
||||
}
|
||||
expReceived = false
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success: receipt found",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
|
||||
|
||||
req = &types.QueryPacketReceiptRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
Sequence: 1,
|
||||
}
|
||||
expReceived = true
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.PacketReceipt(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expReceived, res.Received)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() {
|
||||
var (
|
||||
req *types.QueryPacketAcknowledgementRequest
|
||||
|
@ -835,6 +937,98 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
|
||||
var (
|
||||
req *types.QueryPacketAcknowledgementsRequest
|
||||
expAcknowledgements = []*types.PacketState{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid ID",
|
||||
func() {
|
||||
req = &types.QueryPacketAcknowledgementsRequest{
|
||||
PortId: "",
|
||||
ChannelId: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success, empty res",
|
||||
func() {
|
||||
expAcknowledgements = []*types.PacketState{}
|
||||
|
||||
req = &types.QueryPacketAcknowledgementsRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "test-channel-id",
|
||||
Pagination: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 2,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
expAcknowledgements = make([]*types.PacketState, 9)
|
||||
|
||||
for i := uint64(0); i < 9; i++ {
|
||||
ack := types.NewPacketState(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
|
||||
expAcknowledgements[i] = &ack
|
||||
}
|
||||
|
||||
req = &types.QueryPacketAcknowledgementsRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
Pagination: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 11,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.PacketAcknowledgements(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expAcknowledgements, res.Acknowledgements)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
|
||||
var (
|
||||
req *types.QueryUnreceivedPacketsRequest
|
||||
|
@ -885,7 +1079,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"basic success unrelayed packet commitments",
|
||||
"basic success unreceived packet commitments",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
|
@ -901,13 +1095,11 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
|
|||
true,
|
||||
},
|
||||
{
|
||||
"basic success unrelayed packet commitments, nothing to relay",
|
||||
"basic success unreceived packet commitments, nothing to relay",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
// ack exists
|
||||
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
|
||||
|
||||
expSeq = []uint64{}
|
||||
req = &types.QueryUnreceivedPacketsRequest{
|
||||
|
@ -919,19 +1111,18 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
|
|||
true,
|
||||
},
|
||||
{
|
||||
"success multiple unrelayed packet commitments",
|
||||
"success multiple unreceived packet commitments",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
expSeq = []uint64{} // reset
|
||||
packetCommitments := []uint64{}
|
||||
|
||||
// set ack for every other sequence
|
||||
// set packet receipt for every other sequence
|
||||
for seq := uint64(1); seq < 10; seq++ {
|
||||
packetCommitments = append(packetCommitments, seq)
|
||||
|
||||
if seq%2 == 0 {
|
||||
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, seq, []byte("hash"))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, ack.Hash)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq)
|
||||
} else {
|
||||
expSeq = append(expSeq, seq)
|
||||
}
|
||||
|
@ -967,9 +1158,9 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
||||
func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() {
|
||||
var (
|
||||
req *types.QueryUnrelayedAcksRequest
|
||||
req *types.QueryUnreceivedAcksRequest
|
||||
expSeq = []uint64{}
|
||||
)
|
||||
|
||||
|
@ -988,7 +1179,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
|||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: "",
|
||||
ChannelId: "test-channel-id",
|
||||
}
|
||||
|
@ -998,7 +1189,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
|||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "",
|
||||
}
|
||||
|
@ -1008,70 +1199,65 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
|||
{
|
||||
"invalid seq",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "test-channel-id",
|
||||
PacketCommitmentSequences: []uint64{0},
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: "test-port-id",
|
||||
ChannelId: "test-channel-id",
|
||||
PacketAckSequences: []uint64{0},
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"basic success unrelayed packet acks",
|
||||
"basic success unreceived packet acks",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
// ack exists
|
||||
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, []byte("commitment"))
|
||||
|
||||
expSeq = []uint64{1}
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketCommitmentSequences: []uint64{1},
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketAckSequences: []uint64{1},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"basic success unrelayed packet acknowledgements, nothing to relay",
|
||||
"basic success unreceived packet acknowledgements, nothing to relay",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
// no ack exists
|
||||
|
||||
expSeq = []uint64{}
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketCommitmentSequences: []uint64{1},
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketAckSequences: []uint64{1},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success multiple unrelayed packet acknowledgements",
|
||||
"success multiple unreceived packet acknowledgements",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
expSeq = []uint64{} // reset
|
||||
packetCommitments := []uint64{}
|
||||
packetAcks := []uint64{}
|
||||
|
||||
// set ack for every other sequence
|
||||
// set packet commitment for every other sequence
|
||||
for seq := uint64(1); seq < 10; seq++ {
|
||||
packetCommitments = append(packetCommitments, seq)
|
||||
packetAcks = append(packetAcks, seq)
|
||||
|
||||
if seq%2 == 0 {
|
||||
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, seq, []byte("hash"))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, ack.Hash)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("commitement"))
|
||||
expSeq = append(expSeq, seq)
|
||||
}
|
||||
}
|
||||
|
||||
req = &types.QueryUnrelayedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketCommitmentSequences: packetCommitments,
|
||||
req = &types.QueryUnreceivedAcksRequest{
|
||||
PortId: channelA.PortID,
|
||||
ChannelId: channelA.ID,
|
||||
PacketAckSequences: packetAcks,
|
||||
}
|
||||
},
|
||||
true,
|
||||
|
@ -1085,7 +1271,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
|||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.UnrelayedAcks(ctx, req)
|
||||
res, err := suite.chainA.QueryServer.UnreceivedAcks(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
|
|
|
@ -258,9 +258,9 @@ func (k Keeper) IteratePacketCommitment(ctx sdk.Context, cb func(portID, channel
|
|||
}
|
||||
|
||||
// GetAllPacketCommitments returns all stored PacketCommitments objects.
|
||||
func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketAckCommitment) {
|
||||
func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketState) {
|
||||
k.IteratePacketCommitment(ctx, func(portID, channelID string, sequence uint64, hash []byte) bool {
|
||||
pc := types.NewPacketAckCommitment(portID, channelID, sequence, hash)
|
||||
pc := types.NewPacketState(portID, channelID, sequence, hash)
|
||||
commitments = append(commitments, pc)
|
||||
return false
|
||||
})
|
||||
|
@ -278,15 +278,34 @@ func (k Keeper) IteratePacketCommitmentAtChannel(ctx sdk.Context, portID, channe
|
|||
|
||||
// GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified
|
||||
// port ID and channel ID.
|
||||
func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketAckCommitment) {
|
||||
func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketState) {
|
||||
k.IteratePacketCommitmentAtChannel(ctx, portID, channelID, func(_, _ string, sequence uint64, hash []byte) bool {
|
||||
pc := types.NewPacketAckCommitment(portID, channelID, sequence, hash)
|
||||
pc := types.NewPacketState(portID, channelID, sequence, hash)
|
||||
commitments = append(commitments, pc)
|
||||
return false
|
||||
})
|
||||
return commitments
|
||||
}
|
||||
|
||||
// IteratePacketReceipt provides an iterator over all PacketReceipt objects. For each
|
||||
// receipt, cb will be called. If the cb returns true, the iterator will close
|
||||
// and stop.
|
||||
func (k Keeper) IteratePacketReceipt(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix))
|
||||
k.iterateHashes(ctx, iterator, cb)
|
||||
}
|
||||
|
||||
// GetAllPacketReceipts returns all stored PacketReceipt objects.
|
||||
func (k Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketState) {
|
||||
k.IteratePacketReceipt(ctx, func(portID, channelID string, sequence uint64, receipt []byte) bool {
|
||||
packetReceipt := types.NewPacketState(portID, channelID, sequence, receipt)
|
||||
receipts = append(receipts, packetReceipt)
|
||||
return false
|
||||
})
|
||||
return receipts
|
||||
}
|
||||
|
||||
// IteratePacketAcknowledgement provides an iterator over all PacketAcknowledgement objects. For each
|
||||
// aknowledgement, cb will be called. If the cb returns true, the iterator will close
|
||||
// and stop.
|
||||
|
@ -297,9 +316,9 @@ func (k Keeper) IteratePacketAcknowledgement(ctx sdk.Context, cb func(portID, ch
|
|||
}
|
||||
|
||||
// GetAllPacketAcks returns all stored PacketAcknowledgements objects.
|
||||
func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketAckCommitment) {
|
||||
func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) {
|
||||
k.IteratePacketAcknowledgement(ctx, func(portID, channelID string, sequence uint64, ack []byte) bool {
|
||||
packetAck := types.NewPacketAckCommitment(portID, channelID, sequence, ack)
|
||||
packetAck := types.NewPacketState(portID, channelID, sequence, ack)
|
||||
acks = append(acks, packetAck)
|
||||
return false
|
||||
})
|
||||
|
|
|
@ -143,51 +143,69 @@ func (suite KeeperTestSuite) TestGetAllSequences() {
|
|||
suite.Equal(expSeqs, ackSeqs)
|
||||
}
|
||||
|
||||
// TestGetAllCommitmentsAcks creates a set of acks and packet commitments on two different
|
||||
// TestGetAllPacketState creates a set of acks, packet commitments, and receipts on two different
|
||||
// channels on chain A and tests their retrieval.
|
||||
func (suite KeeperTestSuite) TestGetAllCommitmentsAcks() {
|
||||
func (suite KeeperTestSuite) TestGetAllPacketState() {
|
||||
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
channelA1, _ := suite.coordinator.CreateMockChannels(suite.chainA, suite.chainB, connA, connB, types.UNORDERED)
|
||||
|
||||
// channel 0 acks
|
||||
ack1 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 1, []byte("ack"))
|
||||
ack2 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
|
||||
ack1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte("ack"))
|
||||
ack2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
|
||||
|
||||
// duplicate ack
|
||||
ack2dup := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
|
||||
ack2dup := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
|
||||
|
||||
// channel 1 acks
|
||||
ack3 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 1, []byte("ack"))
|
||||
ack3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte("ack"))
|
||||
|
||||
// create channel 0 receipts
|
||||
rec1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte(""))
|
||||
rec2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte(""))
|
||||
|
||||
// channel 1 receipts
|
||||
rec3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte(""))
|
||||
rec4 := types.NewPacketState(channelA1.PortID, channelA1.ID, 2, []byte(""))
|
||||
|
||||
// channel 0 packet commitments
|
||||
comm1 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 1, []byte("hash"))
|
||||
comm2 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("hash"))
|
||||
comm1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte("hash"))
|
||||
comm2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("hash"))
|
||||
|
||||
// channel 1 packet commitments
|
||||
comm3 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 1, []byte("hash"))
|
||||
comm4 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 2, []byte("hash"))
|
||||
comm3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte("hash"))
|
||||
comm4 := types.NewPacketState(channelA1.PortID, channelA1.ID, 2, []byte("hash"))
|
||||
|
||||
expAcks := []types.PacketAckCommitment{ack1, ack2, ack3}
|
||||
expCommitments := []types.PacketAckCommitment{comm1, comm2, comm3, comm4}
|
||||
expAcks := []types.PacketState{ack1, ack2, ack3}
|
||||
expReceipts := []types.PacketState{rec1, rec2, rec3, rec4}
|
||||
expCommitments := []types.PacketState{comm1, comm2, comm3, comm4}
|
||||
|
||||
ctxA := suite.chainA.GetContext()
|
||||
|
||||
// set acknowledgements
|
||||
for _, ack := range []types.PacketAckCommitment{ack1, ack2, ack2dup, ack3} {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, ack.PortId, ack.ChannelId, ack.Sequence, ack.Hash)
|
||||
for _, ack := range []types.PacketState{ack1, ack2, ack2dup, ack3} {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
|
||||
}
|
||||
|
||||
// set packet receipts
|
||||
for _, rec := range expReceipts {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(ctxA, rec.PortId, rec.ChannelId, rec.Sequence)
|
||||
}
|
||||
|
||||
// set packet commitments
|
||||
for _, comm := range expCommitments {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(ctxA, comm.PortId, comm.ChannelId, comm.Sequence, comm.Hash)
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(ctxA, comm.PortId, comm.ChannelId, comm.Sequence, comm.Data)
|
||||
}
|
||||
|
||||
acks := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketAcks(ctxA)
|
||||
receipts := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketReceipts(ctxA)
|
||||
commitments := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketCommitments(ctxA)
|
||||
|
||||
suite.Require().Len(acks, len(expAcks))
|
||||
suite.Require().Len(commitments, len(expCommitments))
|
||||
suite.Require().Len(receipts, len(expReceipts))
|
||||
|
||||
suite.Require().Equal(expAcks, acks)
|
||||
suite.Require().Equal(expReceipts, receipts)
|
||||
suite.Require().Equal(expCommitments, commitments)
|
||||
}
|
||||
|
||||
|
@ -275,7 +293,7 @@ func (suite *KeeperTestSuite) TestGetAllPacketCommitmentsAtChannel() {
|
|||
suite.True(expectedSeqs[packet.Sequence])
|
||||
suite.Equal(channelA.PortID, packet.PortId)
|
||||
suite.Equal(channelA.ID, packet.ChannelId)
|
||||
suite.Equal(hash, packet.Hash)
|
||||
suite.Equal(hash, packet.Data)
|
||||
|
||||
// prevent duplicates from passing checks
|
||||
expectedSeqs[packet.Sequence] = false
|
||||
|
|
|
@ -299,31 +299,33 @@ func (m *Packet) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Packet proto.InternalMessageInfo
|
||||
|
||||
// PacketAckCommitment defines the genesis type necessary to retrieve and store
|
||||
// acknowlegements.
|
||||
type PacketAckCommitment struct {
|
||||
// PacketState defines the generic type necessary to retrieve and store
|
||||
// packet commitments, acknowledgements, and receipts.
|
||||
// Caller is responsible for knowing the context necessary to interpret this
|
||||
// state as a commitment, acknowledgement, or a receipt.
|
||||
type PacketState struct {
|
||||
// channel port identifier.
|
||||
PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"`
|
||||
// channel unique identifier.
|
||||
ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"`
|
||||
// packet sequence.
|
||||
Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
|
||||
// packet commitment hash.
|
||||
Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
// embedded data that represents packet state.
|
||||
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Reset() { *m = PacketAckCommitment{} }
|
||||
func (m *PacketAckCommitment) String() string { return proto.CompactTextString(m) }
|
||||
func (*PacketAckCommitment) ProtoMessage() {}
|
||||
func (*PacketAckCommitment) Descriptor() ([]byte, []int) {
|
||||
func (m *PacketState) Reset() { *m = PacketState{} }
|
||||
func (m *PacketState) String() string { return proto.CompactTextString(m) }
|
||||
func (*PacketState) ProtoMessage() {}
|
||||
func (*PacketState) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c3a07336710636a0, []int{4}
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Unmarshal(b []byte) error {
|
||||
func (m *PacketState) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *PacketState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PacketAckCommitment.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_PacketState.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
|
@ -333,17 +335,17 @@ func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte,
|
|||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PacketAckCommitment.Merge(m, src)
|
||||
func (m *PacketState) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PacketState.Merge(m, src)
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Size() int {
|
||||
func (m *PacketState) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PacketAckCommitment.DiscardUnknown(m)
|
||||
func (m *PacketState) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PacketState.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo
|
||||
var xxx_messageInfo_PacketState proto.InternalMessageInfo
|
||||
|
||||
// Acknowledgement is the recommended acknowledgement format to be used by
|
||||
// app-specific protocols.
|
||||
|
@ -446,72 +448,71 @@ func init() {
|
|||
proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v1.IdentifiedChannel")
|
||||
proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v1.Counterparty")
|
||||
proto.RegisterType((*Packet)(nil), "ibc.core.channel.v1.Packet")
|
||||
proto.RegisterType((*PacketAckCommitment)(nil), "ibc.core.channel.v1.PacketAckCommitment")
|
||||
proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v1.PacketState")
|
||||
proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) }
|
||||
|
||||
var fileDescriptor_c3a07336710636a0 = []byte{
|
||||
// 916 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcd, 0x6e, 0xdb, 0x46,
|
||||
0x10, 0x16, 0x25, 0xea, 0x6f, 0x2c, 0xc9, 0xf2, 0xba, 0x56, 0x58, 0x36, 0x11, 0x15, 0xa2, 0x07,
|
||||
0x23, 0x45, 0xa4, 0x38, 0x0d, 0xda, 0x22, 0xa7, 0x5a, 0x3f, 0x81, 0x89, 0x06, 0x92, 0x41, 0xc9,
|
||||
0x87, 0xe6, 0xa2, 0xd2, 0xe4, 0x56, 0x22, 0x2c, 0x71, 0x55, 0x72, 0x65, 0xd7, 0x6f, 0x10, 0xe8,
|
||||
0xd4, 0x17, 0x10, 0x50, 0xa0, 0xe8, 0xb5, 0xd7, 0xbe, 0x42, 0x8e, 0x39, 0xf6, 0x24, 0x14, 0xf6,
|
||||
0xa1, 0x77, 0xbd, 0x40, 0x0b, 0xee, 0x2e, 0xf5, 0xe3, 0x04, 0x39, 0xf6, 0x94, 0x13, 0x77, 0xbe,
|
||||
0xef, 0x9b, 0x99, 0x8f, 0x3b, 0x03, 0x12, 0x1e, 0xba, 0xe7, 0x76, 0xcd, 0x26, 0x3e, 0xae, 0xd9,
|
||||
0x43, 0xcb, 0xf3, 0xf0, 0xa8, 0x76, 0x79, 0x14, 0x1d, 0xab, 0x13, 0x9f, 0x50, 0x82, 0xf6, 0xdd,
|
||||
0x73, 0xbb, 0x1a, 0x4a, 0xaa, 0x11, 0x7e, 0x79, 0xa4, 0x7e, 0x32, 0x20, 0x03, 0xc2, 0xf8, 0x5a,
|
||||
0x78, 0xe2, 0x52, 0x55, 0x5b, 0x57, 0x1b, 0xb9, 0xd8, 0xa3, 0xac, 0x18, 0x3b, 0x71, 0x81, 0xfe,
|
||||
0x7b, 0x1c, 0xd2, 0x0d, 0x5e, 0x05, 0x3d, 0x81, 0x64, 0x40, 0x2d, 0x8a, 0x15, 0xa9, 0x22, 0x1d,
|
||||
0x16, 0x9e, 0xaa, 0xd5, 0xf7, 0xf4, 0xa9, 0x76, 0x43, 0x85, 0xc9, 0x85, 0xe8, 0x2b, 0xc8, 0x10,
|
||||
0xdf, 0xc1, 0xbe, 0xeb, 0x0d, 0x94, 0xf8, 0x07, 0x92, 0x3a, 0xa1, 0xc8, 0x5c, 0x69, 0xd1, 0x77,
|
||||
0x90, 0xb3, 0xc9, 0xd4, 0xa3, 0xd8, 0x9f, 0x58, 0x3e, 0xbd, 0x56, 0x12, 0x15, 0xe9, 0x70, 0xe7,
|
||||
0xe9, 0xc3, 0xf7, 0xe6, 0x36, 0x36, 0x84, 0x75, 0xf9, 0xcd, 0x42, 0x8b, 0x99, 0x5b, 0xc9, 0xa8,
|
||||
0x01, 0xbb, 0x36, 0xf1, 0x3c, 0x6c, 0x53, 0x97, 0x78, 0xfd, 0x21, 0x99, 0x04, 0x8a, 0x5c, 0x49,
|
||||
0x1c, 0x66, 0xeb, 0xea, 0x72, 0xa1, 0x95, 0xae, 0xad, 0xf1, 0xe8, 0xb9, 0x7e, 0x47, 0xa0, 0x9b,
|
||||
0x85, 0x35, 0x72, 0x42, 0x26, 0x01, 0x52, 0x20, 0x7d, 0x89, 0xfd, 0xc0, 0x25, 0x9e, 0x92, 0xac,
|
||||
0x48, 0x87, 0x59, 0x33, 0x0a, 0x9f, 0xcb, 0xaf, 0x7f, 0xd5, 0x62, 0xfa, 0x3f, 0x71, 0xd8, 0x33,
|
||||
0x1c, 0xec, 0x51, 0xf7, 0x47, 0x17, 0x3b, 0x1f, 0x6f, 0xec, 0x03, 0x37, 0x86, 0xee, 0x41, 0x7a,
|
||||
0x42, 0x7c, 0xda, 0x77, 0x1d, 0x25, 0xc5, 0x98, 0x54, 0x18, 0x1a, 0x0e, 0x7a, 0x00, 0x20, 0x6c,
|
||||
0x86, 0x5c, 0x9a, 0x71, 0x59, 0x81, 0x18, 0x8e, 0xb8, 0xe9, 0x2b, 0xc8, 0x6d, 0xbe, 0x00, 0xfa,
|
||||
0x62, 0x5d, 0x2d, 0xbc, 0xe5, 0x6c, 0x1d, 0x2d, 0x17, 0x5a, 0x81, 0x9b, 0x14, 0x84, 0xbe, 0xea,
|
||||
0xf0, 0x6c, 0xab, 0x43, 0x9c, 0xe9, 0x0f, 0x96, 0x0b, 0x6d, 0x4f, 0xbc, 0xd4, 0x8a, 0xd3, 0xdf,
|
||||
0x6d, 0xfc, 0x6f, 0x02, 0x52, 0xa7, 0x96, 0x7d, 0x81, 0x29, 0x52, 0x21, 0x13, 0xe0, 0x9f, 0xa6,
|
||||
0xd8, 0xb3, 0xf9, 0x68, 0x65, 0x73, 0x15, 0xa3, 0xaf, 0x61, 0x27, 0x20, 0x53, 0xdf, 0xc6, 0xfd,
|
||||
0xb0, 0xa7, 0xe8, 0x51, 0x5a, 0x2e, 0x34, 0xc4, 0x7b, 0x6c, 0x90, 0xba, 0x09, 0x3c, 0x3a, 0x25,
|
||||
0x3e, 0x45, 0xdf, 0x42, 0x41, 0x70, 0xa2, 0x33, 0x1b, 0x62, 0xb6, 0xfe, 0xe9, 0x72, 0xa1, 0x1d,
|
||||
0x6c, 0xe5, 0x0a, 0x5e, 0x37, 0xf3, 0x1c, 0x88, 0xd6, 0xed, 0x05, 0x14, 0x1d, 0x1c, 0x50, 0xd7,
|
||||
0xb3, 0xd8, 0x5c, 0x58, 0x7f, 0x99, 0xd5, 0xf8, 0x6c, 0xb9, 0xd0, 0xee, 0xf1, 0x1a, 0x77, 0x15,
|
||||
0xba, 0xb9, 0xbb, 0x01, 0x31, 0x27, 0x1d, 0xd8, 0xdf, 0x54, 0x45, 0x76, 0xd8, 0x18, 0xeb, 0xe5,
|
||||
0xe5, 0x42, 0x53, 0xdf, 0x2d, 0xb5, 0xf2, 0x84, 0x36, 0xd0, 0xc8, 0x18, 0x02, 0xd9, 0xb1, 0xa8,
|
||||
0xc5, 0xc6, 0x9d, 0x33, 0xd9, 0x19, 0xfd, 0x00, 0x05, 0xea, 0x8e, 0x31, 0x99, 0xd2, 0xfe, 0x10,
|
||||
0xbb, 0x83, 0x21, 0x65, 0x03, 0xdf, 0xd9, 0xda, 0x77, 0xfe, 0x25, 0xba, 0x3c, 0xaa, 0x9e, 0x30,
|
||||
0x45, 0xfd, 0x41, 0xb8, 0xac, 0xeb, 0xeb, 0xd8, 0xce, 0xd7, 0xcd, 0xbc, 0x00, 0xb8, 0x1a, 0x19,
|
||||
0xb0, 0x17, 0x29, 0xc2, 0x67, 0x40, 0xad, 0xf1, 0x44, 0xc9, 0x84, 0xe3, 0xaa, 0xdf, 0x5f, 0x2e,
|
||||
0x34, 0x65, 0xbb, 0xc8, 0x4a, 0xa2, 0x9b, 0x45, 0x81, 0xf5, 0x22, 0x48, 0x6c, 0xc0, 0x1f, 0x12,
|
||||
0xec, 0xf3, 0x0d, 0x38, 0xb6, 0x2f, 0x1a, 0x64, 0x3c, 0x76, 0xe9, 0x18, 0x7b, 0xf4, 0x7f, 0x58,
|
||||
0xc1, 0xad, 0x8d, 0x4b, 0xdc, 0xd9, 0x38, 0x04, 0xf2, 0xd0, 0x0a, 0x86, 0x6c, 0xd4, 0x39, 0x93,
|
||||
0x9d, 0x85, 0xe1, 0x0e, 0xec, 0x1e, 0xdb, 0x17, 0x1e, 0xb9, 0x1a, 0x61, 0x67, 0x80, 0x99, 0x57,
|
||||
0x05, 0x52, 0x3e, 0x0e, 0xa6, 0x23, 0xaa, 0x1c, 0x84, 0xf2, 0x93, 0x98, 0x29, 0x62, 0x54, 0x82,
|
||||
0x24, 0xf6, 0x7d, 0xe2, 0x2b, 0xa5, 0xd0, 0xd3, 0x49, 0xcc, 0xe4, 0x61, 0x1d, 0x20, 0xe3, 0xe3,
|
||||
0x60, 0x42, 0xbc, 0x00, 0x3f, 0xfa, 0x53, 0x82, 0x64, 0x57, 0x7c, 0xa8, 0xb4, 0x6e, 0xef, 0xb8,
|
||||
0xd7, 0xea, 0x9f, 0xb5, 0x8d, 0xb6, 0xd1, 0x33, 0x8e, 0x5f, 0x1a, 0xaf, 0x5a, 0xcd, 0xfe, 0x59,
|
||||
0xbb, 0x7b, 0xda, 0x6a, 0x18, 0x2f, 0x8c, 0x56, 0xb3, 0x18, 0x53, 0xf7, 0x66, 0xf3, 0x4a, 0x7e,
|
||||
0x4b, 0x80, 0x14, 0x00, 0x9e, 0x17, 0x82, 0x45, 0x49, 0xcd, 0xcc, 0xe6, 0x15, 0x39, 0x3c, 0xa3,
|
||||
0x32, 0xe4, 0x39, 0xd3, 0x33, 0xbf, 0xef, 0x9c, 0xb6, 0xda, 0xc5, 0xb8, 0xba, 0x33, 0x9b, 0x57,
|
||||
0xd2, 0x22, 0x5c, 0x67, 0x32, 0x32, 0xc1, 0x33, 0x19, 0x73, 0x1f, 0x72, 0x9c, 0x69, 0xbc, 0xec,
|
||||
0x74, 0x5b, 0xcd, 0xa2, 0xac, 0xc2, 0x6c, 0x5e, 0x49, 0xf1, 0x48, 0x95, 0x5f, 0xff, 0x56, 0x8e,
|
||||
0x3d, 0xba, 0x82, 0x24, 0xfb, 0x66, 0xa2, 0xcf, 0xa1, 0xd4, 0x31, 0x9b, 0x2d, 0xb3, 0xdf, 0xee,
|
||||
0xb4, 0x5b, 0x77, 0xfc, 0xb2, 0x92, 0x21, 0x8e, 0x74, 0xd8, 0xe5, 0xaa, 0xb3, 0x36, 0x7b, 0xb6,
|
||||
0x9a, 0x45, 0x49, 0xcd, 0xcf, 0xe6, 0x95, 0xec, 0x0a, 0x08, 0x0d, 0x73, 0x4d, 0xa4, 0x10, 0x86,
|
||||
0x45, 0xc8, 0x1b, 0xd7, 0xcd, 0x37, 0x37, 0x65, 0xe9, 0xed, 0x4d, 0x59, 0xfa, 0xfb, 0xa6, 0x2c,
|
||||
0xfd, 0x72, 0x5b, 0x8e, 0xbd, 0xbd, 0x2d, 0xc7, 0xfe, 0xba, 0x2d, 0xc7, 0x5e, 0x7d, 0x33, 0x70,
|
||||
0xe9, 0x70, 0x7a, 0x5e, 0xb5, 0xc9, 0xb8, 0x66, 0x93, 0x60, 0x4c, 0x02, 0xf1, 0x78, 0x1c, 0x38,
|
||||
0x17, 0xb5, 0x9f, 0x6b, 0xab, 0x7f, 0xf3, 0x93, 0x67, 0x8f, 0xa3, 0x9f, 0x3d, 0xbd, 0x9e, 0xe0,
|
||||
0xe0, 0x3c, 0xc5, 0x7e, 0xce, 0x5f, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xef, 0x9f, 0xe3,
|
||||
0x0d, 0x08, 0x00, 0x00,
|
||||
// 904 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcb, 0x6e, 0xdb, 0x46,
|
||||
0x14, 0x15, 0x25, 0xea, 0x75, 0x65, 0xc9, 0xf2, 0xa4, 0x56, 0x58, 0x36, 0x11, 0x15, 0xa2, 0x0b,
|
||||
0x23, 0x45, 0xa4, 0x38, 0x0d, 0xda, 0x22, 0xab, 0x5a, 0x8f, 0xc0, 0x44, 0x03, 0xc9, 0xa0, 0xe4,
|
||||
0x45, 0xb3, 0x51, 0x65, 0x72, 0x2a, 0x11, 0x96, 0x38, 0x2a, 0x39, 0xb2, 0xeb, 0x3f, 0x08, 0xb4,
|
||||
0xea, 0x0f, 0x08, 0x28, 0x50, 0xb4, 0xbf, 0xd0, 0x5f, 0xc8, 0x32, 0xcb, 0xae, 0x88, 0xc2, 0x5e,
|
||||
0x74, 0xaf, 0x1f, 0x68, 0xc1, 0x99, 0xa1, 0x1e, 0x4e, 0xe0, 0x65, 0x57, 0x59, 0x71, 0xee, 0x39,
|
||||
0xe7, 0x3e, 0x74, 0xef, 0xd5, 0x0c, 0x3c, 0x72, 0xce, 0xac, 0x9a, 0x45, 0x3c, 0x5c, 0xb3, 0x46,
|
||||
0x03, 0xd7, 0xc5, 0xe3, 0xda, 0xc5, 0x61, 0x74, 0xac, 0x4e, 0x3d, 0x42, 0x09, 0xba, 0xe7, 0x9c,
|
||||
0x59, 0xd5, 0x50, 0x52, 0x8d, 0xf0, 0x8b, 0x43, 0xf5, 0x93, 0x21, 0x19, 0x12, 0xc6, 0xd7, 0xc2,
|
||||
0x13, 0x97, 0xaa, 0xda, 0x3a, 0xda, 0xd8, 0xc1, 0x2e, 0x65, 0xc1, 0xd8, 0x89, 0x0b, 0xf4, 0xdf,
|
||||
0xe3, 0x90, 0x6e, 0xf0, 0x28, 0xe8, 0x29, 0x24, 0x7d, 0x3a, 0xa0, 0x58, 0x91, 0x2a, 0xd2, 0x41,
|
||||
0xe1, 0x99, 0x5a, 0xfd, 0x40, 0x9e, 0x6a, 0x37, 0x54, 0x98, 0x5c, 0x88, 0xbe, 0x82, 0x0c, 0xf1,
|
||||
0x6c, 0xec, 0x39, 0xee, 0x50, 0x89, 0xdf, 0xe1, 0xd4, 0x09, 0x45, 0xe6, 0x4a, 0x8b, 0xbe, 0x83,
|
||||
0x1d, 0x8b, 0xcc, 0x5c, 0x8a, 0xbd, 0xe9, 0xc0, 0xa3, 0x57, 0x4a, 0xa2, 0x22, 0x1d, 0xe4, 0x9e,
|
||||
0x3d, 0xfa, 0xa0, 0x6f, 0x63, 0x43, 0x58, 0x97, 0xdf, 0x06, 0x5a, 0xcc, 0xdc, 0x72, 0x46, 0x0d,
|
||||
0xd8, 0xb5, 0x88, 0xeb, 0x62, 0x8b, 0x3a, 0xc4, 0xed, 0x8f, 0xc8, 0xd4, 0x57, 0xe4, 0x4a, 0xe2,
|
||||
0x20, 0x5b, 0x57, 0x97, 0x81, 0x56, 0xba, 0x1a, 0x4c, 0xc6, 0x2f, 0xf4, 0x5b, 0x02, 0xdd, 0x2c,
|
||||
0xac, 0x91, 0x63, 0x32, 0xf5, 0x91, 0x02, 0xe9, 0x0b, 0xec, 0xf9, 0x0e, 0x71, 0x95, 0x64, 0x45,
|
||||
0x3a, 0xc8, 0x9a, 0x91, 0xf9, 0x42, 0x7e, 0xf3, 0xab, 0x16, 0xd3, 0xff, 0x89, 0xc3, 0x9e, 0x61,
|
||||
0x63, 0x97, 0x3a, 0x3f, 0x3a, 0xd8, 0xfe, 0xd8, 0xb1, 0x3b, 0x3a, 0x86, 0xee, 0x43, 0x7a, 0x4a,
|
||||
0x3c, 0xda, 0x77, 0x6c, 0x25, 0xc5, 0x98, 0x54, 0x68, 0x1a, 0x36, 0x7a, 0x08, 0x20, 0xca, 0x0c,
|
||||
0xb9, 0x34, 0xe3, 0xb2, 0x02, 0x31, 0x6c, 0xd1, 0xe9, 0x4b, 0xd8, 0xd9, 0xfc, 0x01, 0xe8, 0x8b,
|
||||
0x75, 0xb4, 0xb0, 0xcb, 0xd9, 0x3a, 0x5a, 0x06, 0x5a, 0x81, 0x17, 0x29, 0x08, 0x7d, 0x95, 0xe1,
|
||||
0xf9, 0x56, 0x86, 0x38, 0xd3, 0xef, 0x2f, 0x03, 0x6d, 0x4f, 0xfc, 0xa8, 0x15, 0xa7, 0xbf, 0x9f,
|
||||
0xf8, 0xdf, 0x04, 0xa4, 0x4e, 0x06, 0xd6, 0x39, 0xa6, 0x48, 0x85, 0x8c, 0x8f, 0x7f, 0x9a, 0x61,
|
||||
0xd7, 0xe2, 0xa3, 0x95, 0xcd, 0x95, 0x8d, 0xbe, 0x86, 0x9c, 0x4f, 0x66, 0x9e, 0x85, 0xfb, 0x61,
|
||||
0x4e, 0x91, 0xa3, 0xb4, 0x0c, 0x34, 0xc4, 0x73, 0x6c, 0x90, 0xba, 0x09, 0xdc, 0x3a, 0x21, 0x1e,
|
||||
0x45, 0xdf, 0x42, 0x41, 0x70, 0x22, 0x33, 0x1b, 0x62, 0xb6, 0xfe, 0xe9, 0x32, 0xd0, 0xf6, 0xb7,
|
||||
0x7c, 0x05, 0xaf, 0x9b, 0x79, 0x0e, 0x44, 0xeb, 0xf6, 0x12, 0x8a, 0x36, 0xf6, 0xa9, 0xe3, 0x0e,
|
||||
0xd8, 0x5c, 0x58, 0x7e, 0x99, 0xc5, 0xf8, 0x6c, 0x19, 0x68, 0xf7, 0x79, 0x8c, 0xdb, 0x0a, 0xdd,
|
||||
0xdc, 0xdd, 0x80, 0x58, 0x25, 0x1d, 0xb8, 0xb7, 0xa9, 0x8a, 0xca, 0x61, 0x63, 0xac, 0x97, 0x97,
|
||||
0x81, 0xa6, 0xbe, 0x1f, 0x6a, 0x55, 0x13, 0xda, 0x40, 0xa3, 0xc2, 0x10, 0xc8, 0xf6, 0x80, 0x0e,
|
||||
0xd8, 0xb8, 0x77, 0x4c, 0x76, 0x46, 0x3f, 0x40, 0x81, 0x3a, 0x13, 0x4c, 0x66, 0xb4, 0x3f, 0xc2,
|
||||
0xce, 0x70, 0x44, 0xd9, 0xc0, 0x73, 0x5b, 0xfb, 0xce, 0x6f, 0xa2, 0x8b, 0xc3, 0xea, 0x31, 0x53,
|
||||
0xd4, 0x1f, 0x86, 0xcb, 0xba, 0x6e, 0xc7, 0xb6, 0xbf, 0x6e, 0xe6, 0x05, 0xc0, 0xd5, 0xc8, 0x80,
|
||||
0xbd, 0x48, 0x11, 0x7e, 0x7d, 0x3a, 0x98, 0x4c, 0x95, 0x4c, 0x38, 0xae, 0xfa, 0x83, 0x65, 0xa0,
|
||||
0x29, 0xdb, 0x41, 0x56, 0x12, 0xdd, 0x2c, 0x0a, 0xac, 0x17, 0x41, 0x62, 0x03, 0xfe, 0x90, 0x20,
|
||||
0xc7, 0x37, 0x80, 0xfd, 0x67, 0xff, 0x87, 0xd5, 0xdb, 0xda, 0xb4, 0xc4, 0xad, 0x4d, 0x8b, 0xba,
|
||||
0x2a, 0xaf, 0xbb, 0x2a, 0x0a, 0xed, 0xc0, 0xee, 0x91, 0x75, 0xee, 0x92, 0xcb, 0x31, 0xb6, 0x87,
|
||||
0x78, 0x82, 0x5d, 0x8a, 0x14, 0x48, 0x79, 0xd8, 0x9f, 0x8d, 0xa9, 0xb2, 0x1f, 0xca, 0x8f, 0x63,
|
||||
0xa6, 0xb0, 0x51, 0x09, 0x92, 0xd8, 0xf3, 0x88, 0xa7, 0x94, 0xc2, 0x9a, 0x8e, 0x63, 0x26, 0x37,
|
||||
0xeb, 0x00, 0x19, 0x0f, 0xfb, 0x53, 0xe2, 0xfa, 0xf8, 0xf1, 0x9f, 0x12, 0x24, 0xbb, 0xe2, 0x82,
|
||||
0xd2, 0xba, 0xbd, 0xa3, 0x5e, 0xab, 0x7f, 0xda, 0x36, 0xda, 0x46, 0xcf, 0x38, 0x7a, 0x65, 0xbc,
|
||||
0x6e, 0x35, 0xfb, 0xa7, 0xed, 0xee, 0x49, 0xab, 0x61, 0xbc, 0x34, 0x5a, 0xcd, 0x62, 0x4c, 0xdd,
|
||||
0x9b, 0x2f, 0x2a, 0xf9, 0x2d, 0x01, 0x52, 0x00, 0xb8, 0x5f, 0x08, 0x16, 0x25, 0x35, 0x33, 0x5f,
|
||||
0x54, 0xe4, 0xf0, 0x8c, 0xca, 0x90, 0xe7, 0x4c, 0xcf, 0xfc, 0xbe, 0x73, 0xd2, 0x6a, 0x17, 0xe3,
|
||||
0x6a, 0x6e, 0xbe, 0xa8, 0xa4, 0x85, 0xb9, 0xf6, 0x64, 0x64, 0x82, 0x7b, 0x32, 0xe6, 0x01, 0xec,
|
||||
0x70, 0xa6, 0xf1, 0xaa, 0xd3, 0x6d, 0x35, 0x8b, 0xb2, 0x0a, 0xf3, 0x45, 0x25, 0xc5, 0x2d, 0x55,
|
||||
0x7e, 0xf3, 0x5b, 0x39, 0xf6, 0xf8, 0x12, 0x92, 0xec, 0xae, 0x44, 0x9f, 0x43, 0xa9, 0x63, 0x36,
|
||||
0x5b, 0x66, 0xbf, 0xdd, 0x69, 0xb7, 0x6e, 0xd5, 0xcb, 0x42, 0x86, 0x38, 0xd2, 0x61, 0x97, 0xab,
|
||||
0x4e, 0xdb, 0xec, 0xdb, 0x6a, 0x16, 0x25, 0x35, 0x3f, 0x5f, 0x54, 0xb2, 0x2b, 0x20, 0x2c, 0x98,
|
||||
0x6b, 0x22, 0x85, 0x28, 0x58, 0x98, 0x3c, 0x71, 0xdd, 0x7c, 0x7b, 0x5d, 0x96, 0xde, 0x5d, 0x97,
|
||||
0xa5, 0xbf, 0xaf, 0xcb, 0xd2, 0x2f, 0x37, 0xe5, 0xd8, 0xbb, 0x9b, 0x72, 0xec, 0xaf, 0x9b, 0x72,
|
||||
0xec, 0xf5, 0x37, 0x43, 0x87, 0x8e, 0x66, 0x67, 0x55, 0x8b, 0x4c, 0x6a, 0x16, 0xf1, 0x27, 0xc4,
|
||||
0x17, 0x9f, 0x27, 0xbe, 0x7d, 0x5e, 0xfb, 0xb9, 0xb6, 0x7a, 0x93, 0x9f, 0x3e, 0x7f, 0x12, 0x3d,
|
||||
0xf2, 0xf4, 0x6a, 0x8a, 0xfd, 0xb3, 0x14, 0x7b, 0x94, 0xbf, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff,
|
||||
0xd7, 0x33, 0x69, 0x35, 0x05, 0x08, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Channel) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -761,7 +762,7 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Marshal() (dAtA []byte, err error) {
|
||||
func (m *PacketState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
|
@ -771,20 +772,20 @@ func (m *PacketAckCommitment) Marshal() (dAtA []byte, err error) {
|
|||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PacketState) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Hash) > 0 {
|
||||
i -= len(m.Hash)
|
||||
copy(dAtA[i:], m.Hash)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.Hash)))
|
||||
if len(m.Data) > 0 {
|
||||
i -= len(m.Data)
|
||||
copy(dAtA[i:], m.Data)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.Data)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
|
@ -1003,7 +1004,7 @@ func (m *Packet) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Size() (n int) {
|
||||
func (m *PacketState) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -1020,7 +1021,7 @@ func (m *PacketAckCommitment) Size() (n int) {
|
|||
if m.Sequence != 0 {
|
||||
n += 1 + sovChannel(uint64(m.Sequence))
|
||||
}
|
||||
l = len(m.Hash)
|
||||
l = len(m.Data)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
|
@ -1911,7 +1912,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
|
||||
func (m *PacketState) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
|
@ -1934,10 +1935,10 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
|
|||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: PacketAckCommitment: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: PacketState: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: PacketAckCommitment: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: PacketState: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
|
@ -2025,7 +2026,7 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
|
@ -2052,9 +2053,9 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Hash == nil {
|
||||
m.Hash = []byte{}
|
||||
m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Data == nil {
|
||||
m.Data = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
|
|
|
@ -7,21 +7,21 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
|
||||
)
|
||||
|
||||
// NewPacketAckCommitment creates a new PacketAckCommitment instance.
|
||||
func NewPacketAckCommitment(portID, channelID string, seq uint64, hash []byte) PacketAckCommitment {
|
||||
return PacketAckCommitment{
|
||||
// NewPacketState creates a new PacketState instance.
|
||||
func NewPacketState(portID, channelID string, seq uint64, data []byte) PacketState {
|
||||
return PacketState{
|
||||
PortId: portID,
|
||||
ChannelId: channelID,
|
||||
Sequence: seq,
|
||||
Hash: hash,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
// Validate performs basic validation of fields returning an error upon any
|
||||
// failure.
|
||||
func (pa PacketAckCommitment) Validate() error {
|
||||
if len(pa.Hash) == 0 {
|
||||
return errors.New("hash bytes cannot be empty")
|
||||
func (pa PacketState) Validate() error {
|
||||
if pa.Data == nil {
|
||||
return errors.New("data bytes cannot be nil")
|
||||
}
|
||||
return validateGenFields(pa.PortId, pa.ChannelId, pa.Sequence)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (ps PacketSequence) Validate() error {
|
|||
|
||||
// NewGenesisState creates a GenesisState instance.
|
||||
func NewGenesisState(
|
||||
channels []IdentifiedChannel, acks, commitments []PacketAckCommitment,
|
||||
channels []IdentifiedChannel, acks, receipts, commitments []PacketState,
|
||||
sendSeqs, recvSeqs, ackSeqs []PacketSequence,
|
||||
) GenesisState {
|
||||
return GenesisState{
|
||||
|
@ -60,8 +60,9 @@ func NewGenesisState(
|
|||
func DefaultGenesisState() GenesisState {
|
||||
return GenesisState{
|
||||
Channels: []IdentifiedChannel{},
|
||||
Acknowledgements: []PacketAckCommitment{},
|
||||
Commitments: []PacketAckCommitment{},
|
||||
Acknowledgements: []PacketState{},
|
||||
Receipts: []PacketState{},
|
||||
Commitments: []PacketState{},
|
||||
SendSequences: []PacketSequence{},
|
||||
RecvSequences: []PacketSequence{},
|
||||
AckSequences: []PacketSequence{},
|
||||
|
@ -81,12 +82,24 @@ func (gs GenesisState) Validate() error {
|
|||
if err := ack.Validate(); err != nil {
|
||||
return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", ack, i, err)
|
||||
}
|
||||
if len(ack.Data) == 0 {
|
||||
return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", ack, i)
|
||||
}
|
||||
}
|
||||
|
||||
for i, receipt := range gs.Receipts {
|
||||
if err := receipt.Validate(); err != nil {
|
||||
return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", receipt, i, err)
|
||||
}
|
||||
}
|
||||
|
||||
for i, commitment := range gs.Commitments {
|
||||
if err := commitment.Validate(); err != nil {
|
||||
return fmt.Errorf("invalid commitment %v index %d: %w", commitment, i, err)
|
||||
}
|
||||
if len(commitment.Data) == 0 {
|
||||
return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", commitment, i)
|
||||
}
|
||||
}
|
||||
|
||||
for i, ss := range gs.SendSequences {
|
||||
|
|
|
@ -25,12 +25,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
|||
|
||||
// GenesisState defines the ibc channel submodule's genesis state.
|
||||
type GenesisState struct {
|
||||
Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"`
|
||||
Acknowledgements []PacketAckCommitment `protobuf:"bytes,2,rep,name=acknowledgements,proto3,casttype=PacketAckCommitment" json:"acknowledgements"`
|
||||
Commitments []PacketAckCommitment `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"`
|
||||
SendSequences []PacketSequence `protobuf:"bytes,4,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences" yaml:"send_sequences"`
|
||||
RecvSequences []PacketSequence `protobuf:"bytes,5,rep,name=recv_sequences,json=recvSequences,proto3" json:"recv_sequences" yaml:"recv_sequences"`
|
||||
AckSequences []PacketSequence `protobuf:"bytes,6,rep,name=ack_sequences,json=ackSequences,proto3" json:"ack_sequences" yaml:"ack_sequences"`
|
||||
Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"`
|
||||
Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"`
|
||||
Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"`
|
||||
Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"`
|
||||
SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences" yaml:"send_sequences"`
|
||||
RecvSequences []PacketSequence `protobuf:"bytes,6,rep,name=recv_sequences,json=recvSequences,proto3" json:"recv_sequences" yaml:"recv_sequences"`
|
||||
AckSequences []PacketSequence `protobuf:"bytes,7,rep,name=ack_sequences,json=ackSequences,proto3" json:"ack_sequences" yaml:"ack_sequences"`
|
||||
}
|
||||
|
||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||
|
@ -73,20 +74,27 @@ func (m *GenesisState) GetChannels() []IdentifiedChannel {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetAcknowledgements() []PacketAckCommitment {
|
||||
func (m *GenesisState) GetAcknowledgements() []PacketState {
|
||||
if m != nil {
|
||||
return m.Acknowledgements
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetCommitments() []PacketAckCommitment {
|
||||
func (m *GenesisState) GetCommitments() []PacketState {
|
||||
if m != nil {
|
||||
return m.Commitments
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetReceipts() []PacketState {
|
||||
if m != nil {
|
||||
return m.Receipts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetSendSequences() []PacketSequence {
|
||||
if m != nil {
|
||||
return m.SendSequences
|
||||
|
@ -178,37 +186,37 @@ func init() {
|
|||
func init() { proto.RegisterFile("ibc/core/channel/v1/genesis.proto", fileDescriptor_cb06ec201f452595) }
|
||||
|
||||
var fileDescriptor_cb06ec201f452595 = []byte{
|
||||
// 470 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6f, 0xd3, 0x30,
|
||||
0x18, 0x86, 0x9b, 0xb5, 0x94, 0xcd, 0x5b, 0x2b, 0xe6, 0x6d, 0x52, 0x28, 0x90, 0x94, 0x20, 0xa1,
|
||||
0x4a, 0x68, 0x09, 0x83, 0x1d, 0x10, 0x37, 0xb2, 0x03, 0xea, 0x6d, 0xf2, 0x6e, 0x48, 0x68, 0x4a,
|
||||
0x9d, 0x6f, 0x99, 0x95, 0x26, 0xee, 0x6a, 0xaf, 0xb0, 0x5f, 0x01, 0x3f, 0x6b, 0xc7, 0x1d, 0x39,
|
||||
0x45, 0xa8, 0xfd, 0x03, 0xa8, 0x47, 0x4e, 0xc8, 0x89, 0x9b, 0xb5, 0x5a, 0x84, 0x60, 0xa7, 0xc4,
|
||||
0x7e, 0xdf, 0xef, 0x79, 0x7c, 0xf9, 0xd0, 0x73, 0x36, 0xa0, 0x1e, 0xe5, 0x63, 0xf0, 0xe8, 0x79,
|
||||
0x90, 0xa6, 0x30, 0xf4, 0x26, 0x07, 0x5e, 0x04, 0x29, 0x08, 0x26, 0xdc, 0xd1, 0x98, 0x4b, 0x8e,
|
||||
0x77, 0xd8, 0x80, 0xba, 0xaa, 0xe2, 0xea, 0x8a, 0x3b, 0x39, 0xe8, 0xec, 0x46, 0x3c, 0xe2, 0x79,
|
||||
0xee, 0xa9, 0xbf, 0xa2, 0xda, 0xa9, 0xa4, 0x2d, 0xa6, 0xf2, 0x8a, 0xf3, 0xab, 0x81, 0xb6, 0x3e,
|
||||
0x16, 0xfc, 0x13, 0x19, 0x48, 0xc0, 0x9f, 0xd1, 0xba, 0x6e, 0x08, 0xd3, 0xe8, 0xd6, 0x7b, 0x9b,
|
||||
0x6f, 0x5e, 0xba, 0x15, 0x46, 0xb7, 0x1f, 0x42, 0x2a, 0xd9, 0x19, 0x83, 0xf0, 0xa8, 0xb8, 0xf4,
|
||||
0x1f, 0x5f, 0x67, 0x76, 0xed, 0x77, 0x66, 0x6f, 0xdf, 0x89, 0x48, 0x89, 0xc4, 0x17, 0xe8, 0x51,
|
||||
0x40, 0xe3, 0x94, 0x7f, 0x19, 0x42, 0x18, 0x41, 0x02, 0xa9, 0x14, 0xe6, 0x5a, 0xae, 0xe9, 0x55,
|
||||
0x6a, 0x8e, 0x03, 0x1a, 0x83, 0xfc, 0x40, 0xe3, 0x23, 0x9e, 0x24, 0x4c, 0xaa, 0x01, 0xff, 0x89,
|
||||
0x16, 0xed, 0x54, 0x84, 0xe4, 0x0e, 0x1e, 0x1f, 0xa3, 0x4d, 0x5a, 0xe6, 0xc2, 0xac, 0xff, 0xa7,
|
||||
0xad, 0xa1, 0x6c, 0x64, 0x19, 0x81, 0x19, 0x6a, 0x0b, 0x48, 0xc3, 0x53, 0x01, 0x17, 0x97, 0x90,
|
||||
0x52, 0x10, 0x66, 0x23, 0x87, 0xbe, 0xf8, 0x0b, 0xf4, 0x44, 0x77, 0xfd, 0x67, 0x8a, 0x37, 0xcf,
|
||||
0xec, 0xbd, 0xab, 0x20, 0x19, 0xbe, 0x77, 0x56, 0x41, 0x0e, 0x69, 0xa9, 0x8b, 0x45, 0x39, 0x57,
|
||||
0x8d, 0x81, 0x4e, 0x96, 0x54, 0x0f, 0xee, 0xad, 0x5a, 0x05, 0x39, 0xa4, 0xa5, 0x2e, 0x6e, 0x55,
|
||||
0x67, 0xa8, 0x15, 0xd0, 0x78, 0xc9, 0xd4, 0xfc, 0x77, 0xd3, 0x53, 0x6d, 0xda, 0x2d, 0x4c, 0x2b,
|
||||
0x1c, 0x87, 0x6c, 0x05, 0x34, 0x2e, 0x3d, 0xce, 0x37, 0x03, 0xb5, 0x57, 0xc7, 0xf1, 0x2b, 0xf4,
|
||||
0x70, 0xc4, 0xc7, 0xf2, 0x94, 0x85, 0xa6, 0xd1, 0x35, 0x7a, 0x1b, 0x3e, 0x9e, 0x67, 0x76, 0xbb,
|
||||
0x60, 0xe9, 0xc0, 0x21, 0x4d, 0xf5, 0xd7, 0x0f, 0xf1, 0x21, 0x42, 0xfa, 0x21, 0xaa, 0xbf, 0x96,
|
||||
0xf7, 0xf7, 0xe6, 0x99, 0xbd, 0x5d, 0xf4, 0x6f, 0x33, 0x87, 0x6c, 0xe8, 0x43, 0x3f, 0xc4, 0x1d,
|
||||
0xb4, 0xbe, 0x78, 0x91, 0x59, 0xef, 0x1a, 0xbd, 0x06, 0x29, 0xcf, 0x3e, 0xb9, 0x9e, 0x5a, 0xc6,
|
||||
0xcd, 0xd4, 0x32, 0x7e, 0x4e, 0x2d, 0xe3, 0xfb, 0xcc, 0xaa, 0xdd, 0xcc, 0xac, 0xda, 0x8f, 0x99,
|
||||
0x55, 0xfb, 0xf4, 0x2e, 0x62, 0xf2, 0xfc, 0x72, 0xe0, 0x52, 0x9e, 0x78, 0x94, 0x8b, 0x84, 0x0b,
|
||||
0xfd, 0xd9, 0x17, 0x61, 0xec, 0x7d, 0xf5, 0xca, 0x05, 0x7b, 0x7d, 0xb8, 0xbf, 0xd8, 0x31, 0x79,
|
||||
0x35, 0x02, 0x31, 0x68, 0xe6, 0xfb, 0xf5, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x0a,
|
||||
0xe5, 0x3b, 0xd2, 0x03, 0x00, 0x00,
|
||||
// 471 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x31, 0x6f, 0xd3, 0x40,
|
||||
0x14, 0xc7, 0xe3, 0x26, 0x4d, 0xd3, 0x6b, 0x13, 0xd1, 0xa3, 0x95, 0x4c, 0x04, 0x76, 0x30, 0x12,
|
||||
0x8a, 0x84, 0x6a, 0x53, 0xe8, 0x80, 0x18, 0xcd, 0x00, 0xd9, 0xd0, 0xb1, 0x21, 0xa1, 0xca, 0x39,
|
||||
0xbf, 0xba, 0x27, 0xc7, 0xbe, 0xe0, 0xbb, 0x06, 0xfa, 0x21, 0x10, 0x7c, 0xac, 0x8e, 0x1d, 0x99,
|
||||
0x2c, 0x94, 0x7c, 0x83, 0x8c, 0x4c, 0xc8, 0xe7, 0x8b, 0x9b, 0xa8, 0x11, 0x22, 0x4c, 0xf6, 0xbd,
|
||||
0xf7, 0x7f, 0xbf, 0xdf, 0x5b, 0x1e, 0x7a, 0xcc, 0x86, 0xd4, 0xa3, 0x3c, 0x03, 0x8f, 0x5e, 0x04,
|
||||
0x69, 0x0a, 0x23, 0x6f, 0x72, 0xe2, 0x45, 0x90, 0x82, 0x60, 0xc2, 0x1d, 0x67, 0x5c, 0x72, 0x7c,
|
||||
0x9f, 0x0d, 0xa9, 0x5b, 0x44, 0x5c, 0x1d, 0x71, 0x27, 0x27, 0xdd, 0xc3, 0x88, 0x47, 0x5c, 0xf5,
|
||||
0xbd, 0xe2, 0xaf, 0x8c, 0x76, 0xd7, 0xd2, 0x16, 0x53, 0x2a, 0xe2, 0x7c, 0xdb, 0x46, 0xfb, 0x6f,
|
||||
0x4b, 0xfe, 0x07, 0x19, 0x48, 0xc0, 0x9f, 0x50, 0x4b, 0x27, 0x84, 0x69, 0xf4, 0xea, 0xfd, 0xbd,
|
||||
0x17, 0x4f, 0xdd, 0x35, 0x46, 0x77, 0x10, 0x42, 0x2a, 0xd9, 0x39, 0x83, 0xf0, 0x4d, 0x59, 0xf4,
|
||||
0x1f, 0x5c, 0xe7, 0x76, 0xed, 0x77, 0x6e, 0x1f, 0xdc, 0x69, 0x91, 0x0a, 0x89, 0x09, 0xba, 0x17,
|
||||
0xd0, 0x38, 0xe5, 0x5f, 0x46, 0x10, 0x46, 0x90, 0x40, 0x2a, 0x85, 0xb9, 0xa5, 0x34, 0xbd, 0xb5,
|
||||
0x9a, 0xf7, 0x01, 0x8d, 0x41, 0xaa, 0xd5, 0xfc, 0x46, 0x21, 0x20, 0x77, 0xe6, 0xf1, 0x3b, 0xb4,
|
||||
0x47, 0x79, 0x92, 0x30, 0x59, 0xe2, 0xea, 0x1b, 0xe1, 0x96, 0x47, 0xb1, 0x8f, 0x5a, 0x19, 0x50,
|
||||
0x60, 0x63, 0x29, 0xcc, 0xc6, 0x46, 0x98, 0x6a, 0x0e, 0x33, 0xd4, 0x11, 0x90, 0x86, 0x67, 0x02,
|
||||
0x3e, 0x5f, 0x42, 0x4a, 0x41, 0x98, 0xdb, 0x8a, 0xf4, 0xe4, 0x6f, 0x24, 0x9d, 0xf5, 0x1f, 0x15,
|
||||
0xb0, 0x79, 0x6e, 0x1f, 0x5d, 0x05, 0xc9, 0xe8, 0xb5, 0xb3, 0x0a, 0x72, 0x48, 0xbb, 0x28, 0x2c,
|
||||
0xc2, 0x4a, 0x95, 0x01, 0x9d, 0x2c, 0xa9, 0x9a, 0xff, 0xad, 0x5a, 0x05, 0x39, 0xa4, 0x5d, 0x14,
|
||||
0x6e, 0x55, 0xe7, 0xa8, 0x1d, 0xd0, 0x78, 0xc9, 0xb4, 0xf3, 0xef, 0xa6, 0x87, 0xda, 0x74, 0x58,
|
||||
0x9a, 0x56, 0x38, 0x0e, 0xd9, 0x0f, 0x68, 0x5c, 0x79, 0x9c, 0xef, 0x06, 0xea, 0xac, 0x8e, 0xe3,
|
||||
0x67, 0x68, 0x67, 0xcc, 0x33, 0x79, 0xc6, 0x42, 0xd3, 0xe8, 0x19, 0xfd, 0x5d, 0x1f, 0xcf, 0x73,
|
||||
0xbb, 0x53, 0xb2, 0x74, 0xc3, 0x21, 0xcd, 0xe2, 0x6f, 0x10, 0xe2, 0x53, 0x84, 0xf4, 0x22, 0x45,
|
||||
0x7e, 0x4b, 0xe5, 0x8f, 0xe6, 0xb9, 0x7d, 0x50, 0xe6, 0x6f, 0x7b, 0x0e, 0xd9, 0xd5, 0x8f, 0x41,
|
||||
0x88, 0xbb, 0xa8, 0xb5, 0xd8, 0xc8, 0xac, 0xf7, 0x8c, 0x7e, 0x83, 0x54, 0x6f, 0x9f, 0x5c, 0x4f,
|
||||
0x2d, 0xe3, 0x66, 0x6a, 0x19, 0xbf, 0xa6, 0x96, 0xf1, 0x63, 0x66, 0xd5, 0x6e, 0x66, 0x56, 0xed,
|
||||
0xe7, 0xcc, 0xaa, 0x7d, 0x7c, 0x15, 0x31, 0x79, 0x71, 0x39, 0x74, 0x29, 0x4f, 0x3c, 0xca, 0x45,
|
||||
0xc2, 0x85, 0xfe, 0x1c, 0x8b, 0x30, 0xf6, 0xbe, 0x7a, 0xd5, 0xf5, 0x3d, 0x3f, 0x3d, 0x5e, 0x1c,
|
||||
0xa0, 0xbc, 0x1a, 0x83, 0x18, 0x36, 0xd5, 0xf1, 0xbd, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x70,
|
||||
0xac, 0x09, 0x09, 0xef, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -242,7 +250,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
}
|
||||
if len(m.RecvSequences) > 0 {
|
||||
|
@ -256,7 +264,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
}
|
||||
if len(m.SendSequences) > 0 {
|
||||
|
@ -270,6 +278,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
}
|
||||
if len(m.Receipts) > 0 {
|
||||
for iNdEx := len(m.Receipts) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Receipts[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
|
@ -395,6 +417,12 @@ func (m *GenesisState) Size() (n int) {
|
|||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.Receipts) > 0 {
|
||||
for _, e := range m.Receipts {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
if len(m.SendSequences) > 0 {
|
||||
for _, e := range m.SendSequences {
|
||||
l = e.Size()
|
||||
|
@ -534,7 +562,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Acknowledgements = append(m.Acknowledgements, PacketAckCommitment{})
|
||||
m.Acknowledgements = append(m.Acknowledgements, PacketState{})
|
||||
if err := m.Acknowledgements[len(m.Acknowledgements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -568,12 +596,46 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Commitments = append(m.Commitments, PacketAckCommitment{})
|
||||
m.Commitments = append(m.Commitments, PacketState{})
|
||||
if err := m.Commitments[len(m.Commitments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Receipts = append(m.Receipts, PacketState{})
|
||||
if err := m.Receipts[len(m.Receipts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SendSequences", wireType)
|
||||
}
|
||||
|
@ -607,7 +669,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field RecvSequences", wireType)
|
||||
}
|
||||
|
@ -641,7 +703,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AckSequences", wireType)
|
||||
}
|
||||
|
|
|
@ -48,11 +48,14 @@ func TestValidateGenesis(t *testing.T) {
|
|||
),
|
||||
),
|
||||
},
|
||||
[]types.PacketAckCommitment{
|
||||
types.NewPacketAckCommitment(testPort2, testChannel2, 1, []byte("ack")),
|
||||
[]types.PacketState{
|
||||
types.NewPacketState(testPort2, testChannel2, 1, []byte("ack")),
|
||||
},
|
||||
[]types.PacketAckCommitment{
|
||||
types.NewPacketAckCommitment(testPort1, testChannel1, 1, []byte("commit_hash")),
|
||||
[]types.PacketState{
|
||||
types.NewPacketState(testPort2, testChannel2, 1, []byte("")),
|
||||
},
|
||||
[]types.PacketState{
|
||||
types.NewPacketState(testPort1, testChannel1, 1, []byte("commit_hash")),
|
||||
},
|
||||
[]types.PacketSequence{
|
||||
types.NewPacketSequence(testPort1, testChannel1, 1),
|
||||
|
@ -82,8 +85,8 @@ func TestValidateGenesis(t *testing.T) {
|
|||
{
|
||||
name: "invalid ack",
|
||||
genState: types.GenesisState{
|
||||
Acknowledgements: []types.PacketAckCommitment{
|
||||
types.NewPacketAckCommitment(testPort2, testChannel2, 1, nil),
|
||||
Acknowledgements: []types.PacketState{
|
||||
types.NewPacketState(testPort2, testChannel2, 1, nil),
|
||||
},
|
||||
},
|
||||
expPass: false,
|
||||
|
@ -91,8 +94,8 @@ func TestValidateGenesis(t *testing.T) {
|
|||
{
|
||||
name: "invalid commitment",
|
||||
genState: types.GenesisState{
|
||||
Commitments: []types.PacketAckCommitment{
|
||||
types.NewPacketAckCommitment(testPort1, testChannel1, 1, nil),
|
||||
Commitments: []types.PacketState{
|
||||
types.NewPacketState(testPort1, testChannel1, 1, nil),
|
||||
},
|
||||
},
|
||||
expPass: false,
|
||||
|
|
|
@ -45,6 +45,17 @@ func NewQueryPacketCommitmentResponse(
|
|||
}
|
||||
}
|
||||
|
||||
// NewQueryPacketReceiptResponse creates a new QueryPacketReceiptResponse instance
|
||||
func NewQueryPacketReceiptResponse(
|
||||
recvd bool, proof []byte, height clienttypes.Height,
|
||||
) *QueryPacketReceiptResponse {
|
||||
return &QueryPacketReceiptResponse{
|
||||
Received: recvd,
|
||||
Proof: proof,
|
||||
ProofHeight: height,
|
||||
}
|
||||
}
|
||||
|
||||
// NewQueryPacketAcknowledgementResponse creates a new QueryPacketAcknowledgementResponse instance
|
||||
func NewQueryPacketAcknowledgementResponse(
|
||||
acknowledgement []byte, proof []byte, height clienttypes.Height,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -603,6 +603,104 @@ func local_request_Query_PacketCommitments_0(ctx context.Context, marshaler runt
|
|||
|
||||
}
|
||||
|
||||
func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryPacketReceiptRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["channel_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
|
||||
}
|
||||
|
||||
protoReq.ChannelId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["port_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
|
||||
}
|
||||
|
||||
protoReq.PortId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["sequence"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence")
|
||||
}
|
||||
|
||||
protoReq.Sequence, err = runtime.Uint64(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err)
|
||||
}
|
||||
|
||||
msg, err := client.PacketReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryPacketReceiptRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["channel_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
|
||||
}
|
||||
|
||||
protoReq.ChannelId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["port_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
|
||||
}
|
||||
|
||||
protoReq.PortId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["sequence"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence")
|
||||
}
|
||||
|
||||
protoReq.Sequence, err = runtime.Uint64(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err)
|
||||
}
|
||||
|
||||
msg, err := server.PacketReceipt(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryPacketAcknowledgementRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
@ -701,6 +799,100 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler
|
|||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_PacketAcknowledgements_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0, "port_id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
|
||||
)
|
||||
|
||||
func request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryPacketAcknowledgementsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["channel_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
|
||||
}
|
||||
|
||||
protoReq.ChannelId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["port_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
|
||||
}
|
||||
|
||||
protoReq.PortId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.PacketAcknowledgements(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryPacketAcknowledgementsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["channel_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
|
||||
}
|
||||
|
||||
protoReq.ChannelId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["port_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
|
||||
}
|
||||
|
||||
protoReq.PortId, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.PacketAcknowledgements(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryUnreceivedPacketsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
@ -799,8 +991,8 @@ func local_request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runt
|
|||
|
||||
}
|
||||
|
||||
func request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryUnrelayedAcksRequest
|
||||
func request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryUnreceivedAcksRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
|
@ -832,24 +1024,24 @@ func request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marsha
|
|||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["packet_commitment_sequences"]
|
||||
val, ok = pathParams["packet_ack_sequences"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_commitment_sequences")
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences")
|
||||
}
|
||||
|
||||
protoReq.PacketCommitmentSequences, err = runtime.Uint64Slice(val, ",")
|
||||
protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",")
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_commitment_sequences", err)
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err)
|
||||
}
|
||||
|
||||
msg, err := client.UnrelayedAcks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
msg, err := client.UnreceivedAcks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryUnrelayedAcksRequest
|
||||
func local_request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryUnreceivedAcksRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
|
@ -881,18 +1073,18 @@ func local_request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.
|
|||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
|
||||
}
|
||||
|
||||
val, ok = pathParams["packet_commitment_sequences"]
|
||||
val, ok = pathParams["packet_ack_sequences"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_commitment_sequences")
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences")
|
||||
}
|
||||
|
||||
protoReq.PacketCommitmentSequences, err = runtime.Uint64Slice(val, ",")
|
||||
protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",")
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_commitment_sequences", err)
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err)
|
||||
}
|
||||
|
||||
msg, err := server.UnrelayedAcks(ctx, &protoReq)
|
||||
msg, err := server.UnreceivedAcks(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
@ -1119,6 +1311,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketReceipt_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_Query_PacketReceipt_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
@ -1139,6 +1351,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketAcknowledgements_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_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
@ -1159,7 +1391,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_UnrelayedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("GET", pattern_Query_UnreceivedAcks_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)
|
||||
|
@ -1168,14 +1400,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_UnrelayedAcks_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_UnrelayedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
|
@ -1380,6 +1612,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketReceipt_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_Query_PacketReceipt_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
@ -1400,6 +1652,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_PacketAcknowledgements_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_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
@ -1420,7 +1692,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_UnrelayedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("GET", pattern_Query_UnreceivedAcks_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)
|
||||
|
@ -1429,14 +1701,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_UnrelayedAcks_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_UnrelayedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
|
@ -1478,11 +1750,15 @@ var (
|
|||
|
||||
pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_UnrelayedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unrelayed_acks"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_NextSequenceReceive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "next_sequence"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
@ -1502,11 +1778,15 @@ var (
|
|||
|
||||
forward_Query_PacketCommitments_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_PacketAcknowledgements_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_UnreceivedPackets_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_UnrelayedAcks_0 = runtime.ForwardResponseMessage
|
||||
forward_Query_UnreceivedAcks_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_NextSequenceReceive_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
|
|
@ -144,6 +144,11 @@ func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string
|
|||
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/acknowledgements/%d", sequence)
|
||||
}
|
||||
|
||||
// PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path.
|
||||
func PacketAcknowledgementPrefixPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID)
|
||||
}
|
||||
|
||||
// PacketReceiptPath defines the packet receipt store path
|
||||
func PacketReceiptPath(portID, channelID string, sequence uint64) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence)
|
||||
|
|
|
@ -115,11 +115,14 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
|||
),
|
||||
),
|
||||
},
|
||||
[]channeltypes.PacketAckCommitment{
|
||||
channeltypes.NewPacketAckCommitment(port2, channel2, 1, []byte("ack")),
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port2, channel2, 1, []byte("ack")),
|
||||
},
|
||||
[]channeltypes.PacketAckCommitment{
|
||||
channeltypes.NewPacketAckCommitment(port1, channel1, 1, []byte("commit_hash")),
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port2, channel2, 1, []byte("")),
|
||||
},
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port1, channel1, 1, []byte("commit_hash")),
|
||||
},
|
||||
[]channeltypes.PacketSequence{
|
||||
channeltypes.NewPacketSequence(port1, channel1, 1),
|
||||
|
@ -174,8 +177,8 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
|||
ClientGenesis: clienttypes.DefaultGenesisState(),
|
||||
ConnectionGenesis: connectiontypes.DefaultGenesisState(),
|
||||
ChannelGenesis: channeltypes.GenesisState{
|
||||
Acknowledgements: []channeltypes.PacketAckCommitment{
|
||||
channeltypes.NewPacketAckCommitment("(portID)", channel1, 1, []byte("ack")),
|
||||
Acknowledgements: []channeltypes.PacketState{
|
||||
channeltypes.NewPacketState("(portID)", channel1, 1, []byte("ack")),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -249,11 +252,14 @@ func (suite *IBCTestSuite) TestInitGenesis() {
|
|||
),
|
||||
),
|
||||
},
|
||||
[]channeltypes.PacketAckCommitment{
|
||||
channeltypes.NewPacketAckCommitment(port2, channel2, 1, []byte("ack")),
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port2, channel2, 1, []byte("ack")),
|
||||
},
|
||||
[]channeltypes.PacketAckCommitment{
|
||||
channeltypes.NewPacketAckCommitment(port1, channel1, 1, []byte("commit_hash")),
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port2, channel2, 1, []byte("")),
|
||||
},
|
||||
[]channeltypes.PacketState{
|
||||
channeltypes.NewPacketState(port1, channel1, 1, []byte("commit_hash")),
|
||||
},
|
||||
[]channeltypes.PacketSequence{
|
||||
channeltypes.NewPacketSequence(port1, channel1, 1),
|
||||
|
|
|
@ -88,19 +88,29 @@ func (q Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPack
|
|||
return q.ChannelKeeper.PacketCommitments(c, req)
|
||||
}
|
||||
|
||||
// PacketReceipt implements the IBC QueryServer interface
|
||||
func (q Keeper) PacketReceipt(c context.Context, req *channeltypes.QueryPacketReceiptRequest) (*channeltypes.QueryPacketReceiptResponse, error) {
|
||||
return q.ChannelKeeper.PacketReceipt(c, req)
|
||||
}
|
||||
|
||||
// PacketAcknowledgement implements the IBC QueryServer interface
|
||||
func (q Keeper) PacketAcknowledgement(c context.Context, req *channeltypes.QueryPacketAcknowledgementRequest) (*channeltypes.QueryPacketAcknowledgementResponse, error) {
|
||||
return q.ChannelKeeper.PacketAcknowledgement(c, req)
|
||||
}
|
||||
|
||||
// PacketAcknowledgements implements the IBC QueryServer interface
|
||||
func (q Keeper) PacketAcknowledgements(c context.Context, req *channeltypes.QueryPacketAcknowledgementsRequest) (*channeltypes.QueryPacketAcknowledgementsResponse, error) {
|
||||
return q.ChannelKeeper.PacketAcknowledgements(c, req)
|
||||
}
|
||||
|
||||
// UnreceivedPackets implements the IBC QueryServer interface
|
||||
func (q Keeper) UnreceivedPackets(c context.Context, req *channeltypes.QueryUnreceivedPacketsRequest) (*channeltypes.QueryUnreceivedPacketsResponse, error) {
|
||||
return q.ChannelKeeper.UnreceivedPackets(c, req)
|
||||
}
|
||||
|
||||
// UnrelayedAcks implements the IBC QueryServer interface
|
||||
func (q Keeper) UnrelayedAcks(c context.Context, req *channeltypes.QueryUnrelayedAcksRequest) (*channeltypes.QueryUnrelayedAcksResponse, error) {
|
||||
return q.ChannelKeeper.UnrelayedAcks(c, req)
|
||||
// UnreceivedAcks implements the IBC QueryServer interface
|
||||
func (q Keeper) UnreceivedAcks(c context.Context, req *channeltypes.QueryUnreceivedAcksRequest) (*channeltypes.QueryUnreceivedAcksResponse, error) {
|
||||
return q.ChannelKeeper.UnreceivedAcks(c, req)
|
||||
}
|
||||
|
||||
// NextSequenceReceive implements the IBC QueryServer interface
|
||||
|
|
|
@ -375,7 +375,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() {
|
|||
host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("different"),
|
||||
)
|
||||
},
|
||||
ack: []byte("acknowledgment"),
|
||||
ack: []byte("acknowledgement"),
|
||||
expPass: false,
|
||||
},
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue