x/ibc: solo machine signature format (#7237)
* x/ibc: solo machine signature format * update tests and verification * diversifier updates * update tests * fix lint * Update x/ibc/light-clients/solomachine/types/header_test.go Co-authored-by: Aditya <adityasripal@gmail.com> * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * update test * misbehaviour sign bytes * consensus state tests * fix tests * more fixes Co-authored-by: Aditya <adityasripal@gmail.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
This commit is contained in:
parent
c71c7b9e77
commit
2f25c9a0d8
File diff suppressed because it is too large
Load Diff
|
@ -106,7 +106,6 @@ func local_request_ReflectionService_ListImplementations_0(ctx context.Context,
|
|||
// RegisterReflectionServiceHandlerServer registers the http handlers for service ReflectionService to "mux".
|
||||
// UnaryRPC :call ReflectionServiceServer 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 RegisterReflectionServiceHandlerFromEndpoint instead.
|
||||
func RegisterReflectionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ReflectionServiceServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_ReflectionService_ListAllInterfaces_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -70,7 +70,6 @@ func local_request_SimulateService_Simulate_0(ctx context.Context, marshaler run
|
|||
// 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) {
|
||||
|
|
|
@ -4,21 +4,21 @@ package ibc.lightclients.solomachine.v1;
|
|||
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types";
|
||||
|
||||
import "cosmos/base/crypto/v1beta1/crypto.proto";
|
||||
import "ibc/connection/connection.proto";
|
||||
import "ibc/channel/channel.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
// ClientState defines a solo machine client that tracks the current consensus
|
||||
// state and if the client is frozen.
|
||||
message ClientState {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
// frozen sequence of the solo machine
|
||||
uint64 frozen_sequence = 1
|
||||
[(gogoproto.moretags) = "yaml:\"frozen_sequence\""];
|
||||
ConsensusState consensus_state = 2
|
||||
[(gogoproto.moretags) = "yaml:\"consensus_state\""];
|
||||
uint64 frozen_sequence = 1 [(gogoproto.moretags) = "yaml:\"frozen_sequence\""];
|
||||
ConsensusState consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""];
|
||||
// when set to true, will allow governance to update a solo machine client.
|
||||
// The client will be unfrozen if it is frozen.
|
||||
bool allow_update_after_proposal = 3
|
||||
[(gogoproto.moretags) = "yaml:\"allow_update_after_proposal\""];
|
||||
bool allow_update_after_proposal = 3 [(gogoproto.moretags) = "yaml:\"allow_update_after_proposal\""];
|
||||
}
|
||||
|
||||
// ConsensusState defines a solo machine consensus state
|
||||
|
@ -27,19 +27,22 @@ message ConsensusState {
|
|||
// current sequence of the consensus state
|
||||
uint64 sequence = 1;
|
||||
// public key of the solo machine
|
||||
cosmos.base.crypto.v1beta1.PublicKey public_key = 2
|
||||
[(gogoproto.moretags) = "yaml:\"public_key\""];
|
||||
uint64 timestamp = 3;
|
||||
cosmos.base.crypto.v1beta1.PublicKey public_key = 2 [(gogoproto.moretags) = "yaml:\"public_key\""];
|
||||
// diversifier allows the same public key to be re-used across different solo machine clients
|
||||
// (potentially on different chains) without being considered misbehaviour.
|
||||
string diversifier = 3;
|
||||
uint64 timestamp = 4;
|
||||
}
|
||||
|
||||
// Header defines a solo machine consensus header
|
||||
message Header {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
// sequence to update solo machine public key at
|
||||
uint64 sequence = 1;
|
||||
bytes signature = 2;
|
||||
cosmos.base.crypto.v1beta1.PublicKey new_public_key = 3
|
||||
[(gogoproto.moretags) = "yaml:\"new_public_key\""];
|
||||
uint64 sequence = 1;
|
||||
uint64 timestamp = 2;
|
||||
bytes signature = 3;
|
||||
cosmos.base.crypto.v1beta1.PublicKey new_public_key = 4 [(gogoproto.moretags) = "yaml:\"new_public_key\""];
|
||||
string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""];
|
||||
}
|
||||
|
||||
// Misbehaviour defines misbehaviour for a solo machine which consists
|
||||
|
@ -47,12 +50,10 @@ message Header {
|
|||
message Misbehaviour {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
|
||||
uint64 sequence = 2;
|
||||
SignatureAndData signature_one = 3
|
||||
[(gogoproto.moretags) = "yaml:\"signature_one\""];
|
||||
SignatureAndData signature_two = 4
|
||||
[(gogoproto.moretags) = "yaml:\"signature_two\""];
|
||||
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
|
||||
uint64 sequence = 2;
|
||||
SignatureAndData signature_one = 3 [(gogoproto.moretags) = "yaml:\"signature_one\""];
|
||||
SignatureAndData signature_two = 4 [(gogoproto.moretags) = "yaml:\"signature_two\""];
|
||||
}
|
||||
|
||||
// SignatureAndData contains a signature and the data signed over to create that
|
||||
|
@ -71,3 +72,80 @@ message TimestampedSignature {
|
|||
uint64 timestamp = 2;
|
||||
}
|
||||
|
||||
// SignBytes defines the signed bytes used for signature verification.
|
||||
message SignBytes {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
uint64 sequence = 1;
|
||||
uint64 timestamp = 2;
|
||||
string diversifier = 3;
|
||||
// marshaled data
|
||||
bytes data = 4;
|
||||
}
|
||||
|
||||
// HeaderData returns the SignBytes data for misbehaviour verification.
|
||||
message HeaderData {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// header public key
|
||||
cosmos.base.crypto.v1beta1.PublicKey new_pub_key = 1 [(gogoproto.moretags) = "yaml:\"new_pub_key\""];
|
||||
// header diversifier
|
||||
string new_diversifier = 2 [(gogoproto.moretags) = "yaml:\"new_diversifier\""];
|
||||
}
|
||||
|
||||
// ClientStateData returns the SignBytes data for client state verification.
|
||||
message ClientStateData {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
bytes path = 1;
|
||||
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
|
||||
}
|
||||
|
||||
// ConsensusStateSignBytes returns the SignBytes data for consensus state verification.
|
||||
message ConsensusStateData {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
bytes path = 1;
|
||||
google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""];
|
||||
}
|
||||
|
||||
// ConnectionStateSignBytes returns the SignBytes data for connection state verification.
|
||||
message ConnectionStateData {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
bytes path = 1;
|
||||
ibc.connection.ConnectionEnd connection = 2;
|
||||
}
|
||||
|
||||
// ChannelStateSignBytes returns the SignBytes data for channel state verification.
|
||||
message ChannelStateData {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
bytes path = 1;
|
||||
ibc.channel.Channel channel = 2;
|
||||
}
|
||||
|
||||
// PacketCommitmentSignBytes returns the SignBytes data for packet commitment verification.
|
||||
message PacketCommitmentData {
|
||||
bytes path = 1;
|
||||
bytes commitment = 2;
|
||||
}
|
||||
|
||||
// PacketAcknowledgementSignBytes returns the SignBytes data for acknowledgement verification.
|
||||
message PacketAcknowledgementData {
|
||||
bytes path = 1;
|
||||
bytes acknowledgement = 2;
|
||||
}
|
||||
|
||||
// PacketAcknowledgementAbsenceSignBytes returns the SignBytes data for acknowledgement absence
|
||||
// verification.
|
||||
message PacketAcknowledgementAbsenseData {
|
||||
bytes path = 1;
|
||||
}
|
||||
|
||||
// NextSequenceRecv returns the SignBytes data for verification of the next
|
||||
// sequence to be received.
|
||||
message NextSequenceRecvData {
|
||||
bytes path = 1;
|
||||
uint64 next_seq_recv = 2 [(gogoproto.moretags) = "yaml:\"next_seq_recv\""];
|
||||
}
|
|
@ -106,7 +106,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Account_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -272,7 +272,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -488,7 +488,6 @@ func local_request_Query_CommunityPool_0(ctx context.Context, marshaler runtime.
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -124,7 +124,6 @@ func local_request_Query_AllEvidence_0(ctx context.Context, marshaler runtime.Ma
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Evidence_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -528,7 +528,6 @@ func local_request_Query_TallyResult_0(ctx context.Context, marshaler runtime.Ma
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Proposal_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -142,7 +142,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_DenomTrace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
|
@ -20,7 +16,8 @@ type caseAny struct {
|
|||
expPass bool
|
||||
}
|
||||
|
||||
func TestPackClientState(t *testing.T) {
|
||||
func (suite *TypesTestSuite) TestPackClientState() {
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
clientState exported.ClientState
|
||||
|
@ -28,7 +25,7 @@ func TestPackClientState(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
"solo machine client",
|
||||
ibctesting.NewSolomachine(t, "solomachine").ClientState(),
|
||||
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").ClientState(),
|
||||
true,
|
||||
},
|
||||
{
|
||||
|
@ -53,9 +50,9 @@ func TestPackClientState(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
clientAny, err := types.PackClientState(tc.clientState)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
|
||||
testCasesAny = append(testCasesAny, caseAny{tc.name, clientAny, tc.expPass})
|
||||
|
@ -64,17 +61,15 @@ func TestPackClientState(t *testing.T) {
|
|||
for i, tc := range testCasesAny {
|
||||
cs, err := types.UnpackClientState(tc.any)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
require.Equal(t, testCases[i].clientState, cs, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
suite.Require().Equal(testCases[i].clientState, cs, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackConsensusState(t *testing.T) {
|
||||
chain := ibctesting.NewTestChain(t, "cosmoshub")
|
||||
|
||||
func (suite *TypesTestSuite) TestPackConsensusState() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
consensusState exported.ConsensusState
|
||||
|
@ -82,12 +77,12 @@ func TestPackConsensusState(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
"solo machine consensus",
|
||||
ibctesting.NewSolomachine(t, "solomachine").ConsensusState(),
|
||||
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").ConsensusState(),
|
||||
true,
|
||||
},
|
||||
{
|
||||
"tendermint consensus",
|
||||
chain.LastHeader.ConsensusState(),
|
||||
suite.chain.LastHeader.ConsensusState(),
|
||||
true,
|
||||
},
|
||||
{
|
||||
|
@ -102,9 +97,9 @@ func TestPackConsensusState(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
clientAny, err := types.PackConsensusState(tc.consensusState)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
testCasesAny = append(testCasesAny, caseAny{tc.name, clientAny, tc.expPass})
|
||||
}
|
||||
|
@ -112,17 +107,15 @@ func TestPackConsensusState(t *testing.T) {
|
|||
for i, tc := range testCasesAny {
|
||||
cs, err := types.UnpackConsensusState(tc.any)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
require.Equal(t, testCases[i].consensusState, cs, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
suite.Require().Equal(testCases[i].consensusState, cs, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackHeader(t *testing.T) {
|
||||
chain := ibctesting.NewTestChain(t, "cosmoshub")
|
||||
|
||||
func (suite *TypesTestSuite) TestPackHeader() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
header exported.Header
|
||||
|
@ -130,12 +123,12 @@ func TestPackHeader(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
"solo machine header",
|
||||
ibctesting.NewSolomachine(t, "solomachine").CreateHeader(),
|
||||
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateHeader(),
|
||||
true,
|
||||
},
|
||||
{
|
||||
"tendermint header",
|
||||
chain.LastHeader,
|
||||
suite.chain.LastHeader,
|
||||
true,
|
||||
},
|
||||
{
|
||||
|
@ -150,9 +143,9 @@ func TestPackHeader(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
clientAny, err := types.PackHeader(tc.header)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
|
||||
testCasesAny = append(testCasesAny, caseAny{tc.name, clientAny, tc.expPass})
|
||||
|
@ -161,17 +154,15 @@ func TestPackHeader(t *testing.T) {
|
|||
for i, tc := range testCasesAny {
|
||||
cs, err := types.UnpackHeader(tc.any)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
require.Equal(t, testCases[i].header, cs, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
suite.Require().Equal(testCases[i].header, cs, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackMisbehaviour(t *testing.T) {
|
||||
chain := ibctesting.NewTestChain(t, "cosmoshub")
|
||||
|
||||
func (suite *TypesTestSuite) TestPackMisbehaviour() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
misbehaviour exported.Misbehaviour
|
||||
|
@ -179,12 +170,12 @@ func TestPackMisbehaviour(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
"solo machine misbehaviour",
|
||||
ibctesting.NewSolomachine(t, "solomachine").CreateMisbehaviour(),
|
||||
ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateMisbehaviour(),
|
||||
true,
|
||||
},
|
||||
{
|
||||
"tendermint misbehaviour",
|
||||
ibctmtypes.NewMisbehaviour("tendermint", chain.ChainID, chain.LastHeader, chain.LastHeader),
|
||||
ibctmtypes.NewMisbehaviour("tendermint", suite.chain.ChainID, suite.chain.LastHeader, suite.chain.LastHeader),
|
||||
true,
|
||||
},
|
||||
{
|
||||
|
@ -199,9 +190,9 @@ func TestPackMisbehaviour(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
clientAny, err := types.PackMisbehaviour(tc.misbehaviour)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
|
||||
testCasesAny = append(testCasesAny, caseAny{tc.name, clientAny, tc.expPass})
|
||||
|
@ -210,10 +201,10 @@ func TestPackMisbehaviour(t *testing.T) {
|
|||
for i, tc := range testCasesAny {
|
||||
cs, err := types.UnpackMisbehaviour(tc.any)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
require.Equal(t, testCases[i].misbehaviour, cs, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
suite.Require().Equal(testCases[i].misbehaviour, cs, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() {
|
|||
}{
|
||||
{
|
||||
"solo machine client", func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -145,7 +145,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
|
|||
{
|
||||
"valid - solomachine client",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -154,7 +154,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
|
|||
{
|
||||
"invalid solomachine client",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, &solomachinetypes.ClientState{}, soloMachine.ConsensusState(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -163,7 +163,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() {
|
|||
{
|
||||
"invalid solomachine consensus state",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgCreateClient(soloMachine.ClientID, soloMachine.ClientState(), &solomachinetypes.ConsensusState{}, suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -205,7 +205,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() {
|
|||
}{
|
||||
{
|
||||
"solo machine client", func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -294,7 +294,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
|
|||
{
|
||||
"valid - solomachine header",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -343,7 +343,7 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() {
|
|||
}{
|
||||
{
|
||||
"solo machine client", func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -440,7 +440,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
|
|||
{
|
||||
"valid - solomachine misbehaviour",
|
||||
func() {
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), "solomachine")
|
||||
soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "")
|
||||
msg, err = types.NewMsgSubmitMisbehaviour(soloMachine.ClientID, soloMachine.CreateMisbehaviour(), suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
@ -457,7 +457,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() {
|
|||
{
|
||||
"client-id mismatch",
|
||||
func() {
|
||||
soloMachineMisbehaviour := ibctesting.NewSolomachine(suite.T(), "solomachine").CreateMisbehaviour()
|
||||
soloMachineMisbehaviour := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, "solomachine", "").CreateMisbehaviour()
|
||||
msg, err = types.NewMsgSubmitMisbehaviour("external", soloMachineMisbehaviour, suite.chain.SenderAccount.GetAddress())
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
|
|
|
@ -1,32 +1,28 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
func TestNewUpdateClientProposal(t *testing.T) {
|
||||
func (suite *TypesTestSuite) TestNewUpdateClientProposal() {
|
||||
p, err := types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, clientID, &ibctmtypes.Header{})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, p)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(p)
|
||||
|
||||
p, err = types.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, clientID, nil)
|
||||
require.Error(t, err)
|
||||
require.Nil(t, p)
|
||||
suite.Require().Error(err)
|
||||
suite.Require().Nil(p)
|
||||
}
|
||||
|
||||
func TestValidateBasic(t *testing.T) {
|
||||
func (suite *TypesTestSuite) TestValidateBasic() {
|
||||
// use solo machine header for testing
|
||||
solomachine := ibctesting.NewSolomachine(t, clientID)
|
||||
solomachine := ibctesting.NewSolomachine(suite.T(), suite.chain.Codec, clientID, "")
|
||||
smHeader := solomachine.CreateHeader()
|
||||
header, err := types.PackHeader(smHeader)
|
||||
require.NoError(t, err)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// use a different pointer so we don't modify 'header'
|
||||
smInvalidHeader := solomachine.CreateHeader()
|
||||
|
@ -35,7 +31,7 @@ func TestValidateBasic(t *testing.T) {
|
|||
smInvalidHeader.Sequence = 0
|
||||
|
||||
invalidHeader, err := types.PackHeader(smInvalidHeader)
|
||||
require.NoError(t, err)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
@ -69,9 +65,9 @@ func TestValidateBasic(t *testing.T) {
|
|||
err := tc.proposal.ValidateBasic()
|
||||
|
||||
if tc.expPass {
|
||||
require.NoError(t, err, tc.name)
|
||||
suite.Require().NoError(err, tc.name)
|
||||
} else {
|
||||
require.Error(t, err, tc.name)
|
||||
suite.Require().Error(err, tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,6 @@ func local_request_Query_ConsensusStates_0(ctx context.Context, marshaler runtim
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_ClientState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -128,7 +128,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() {
|
|||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "test/conn1", clientState, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", nil, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
&types.MsgConnectionOpenTry{"ibcconntest", "clienttotesta", invalidAny, counterparty, []string{ibctesting.ConnectionVersion}, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer},
|
||||
{"ibcconntest", "clienttotesta", invalidAny, counterparty, []string{ibctesting.ConnectionVersion}, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer},
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", invalidClient, prefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, emptyPrefix, []string{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
types.NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []string{}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer),
|
||||
|
@ -196,7 +196,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
|
|||
testMsgs := []*types.MsgConnectionOpenAck{
|
||||
types.NewMsgConnectionOpenAck("test/conn1", clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", nil, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
&types.MsgConnectionOpenAck{"ibcconntest", ibctesting.ConnectionVersion, invalidAny, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer},
|
||||
{"ibcconntest", ibctesting.ConnectionVersion, invalidAny, clientHeight, suite.proof, suite.proof, suite.proof, clientHeight, signer},
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", invalidClient, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, emptyProof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
types.NewMsgConnectionOpenAck("ibcconntest", clientState, suite.proof, emptyProof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer),
|
||||
|
|
|
@ -330,7 +330,6 @@ func local_request_Query_ConnectionConsensusState_0(ctx context.Context, marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Connection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -900,7 +900,6 @@ func local_request_Query_NextSequenceReceive_0(ctx context.Context, marshaler ru
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Channel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -83,12 +83,12 @@ func (cs ClientState) VerifyClientState(
|
|||
return err
|
||||
}
|
||||
|
||||
data, err := ClientStateSignBytes(cdc, sequence, signature.Timestamp, path, clientState)
|
||||
signBz, err := ClientStateSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, clientState)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -122,12 +122,12 @@ func (cs ClientState) VerifyClientConsensusState(
|
|||
return err
|
||||
}
|
||||
|
||||
data, err := ConsensusStateSignBytes(cdc, sequence, signature.Timestamp, path, consensusState)
|
||||
signBz, err := ConsensusStateSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, consensusState)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -158,12 +158,12 @@ func (cs ClientState) VerifyConnectionState(
|
|||
return err
|
||||
}
|
||||
|
||||
data, err := ConnectionStateSignBytes(cdc, sequence, signature.Timestamp, path, connectionEnd)
|
||||
signBz, err := ConnectionStateSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, connectionEnd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -195,12 +195,12 @@ func (cs ClientState) VerifyChannelState(
|
|||
return err
|
||||
}
|
||||
|
||||
data, err := ChannelStateSignBytes(cdc, sequence, signature.Timestamp, path, channel)
|
||||
signBz, err := ChannelStateSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -233,9 +233,12 @@ func (cs ClientState) VerifyPacketCommitment(
|
|||
return err
|
||||
}
|
||||
|
||||
data := PacketCommitmentSignBytes(sequence, signature.Timestamp, path, commitmentBytes)
|
||||
signBz, err := PacketCommitmentSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, commitmentBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -268,9 +271,12 @@ func (cs ClientState) VerifyPacketAcknowledgement(
|
|||
return err
|
||||
}
|
||||
|
||||
data := PacketAcknowledgementSignBytes(sequence, signature.Timestamp, path, acknowledgement)
|
||||
signBz, err := PacketAcknowledgementSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, acknowledgement)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -303,9 +309,12 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence(
|
|||
return err
|
||||
}
|
||||
|
||||
data := PacketAcknowledgementAbsenceSignBytes(sequence, signature.Timestamp, path)
|
||||
signBz, err := PacketAcknowledgementAbsenceSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -337,9 +346,12 @@ func (cs ClientState) VerifyNextSequenceRecv(
|
|||
return err
|
||||
}
|
||||
|
||||
data := NextSequenceRecvSignBytes(sequence, signature.Timestamp, path, nextSequenceRecv)
|
||||
signBz, err := NextSequenceRecvSignBytes(cdc, sequence, signature.Timestamp, cs.ConsensusState.Diversifier, path, nextSequenceRecv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), data, signature.Signature); err != nil {
|
||||
if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, signature.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -40,17 +40,22 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() {
|
|||
},
|
||||
{
|
||||
"sequence is zero",
|
||||
types.NewClientState(&types.ConsensusState{0, suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Time}, false),
|
||||
types.NewClientState(&types.ConsensusState{0, suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"timstamp is zero",
|
||||
types.NewClientState(&types.ConsensusState{1, suite.solomachine.ConsensusState().PublicKey, 0}, false),
|
||||
"timestamp is zero",
|
||||
types.NewClientState(&types.ConsensusState{1, suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, 0}, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"diversifier is blank",
|
||||
types.NewClientState(&types.ConsensusState{1, suite.solomachine.ConsensusState().PublicKey, " ", 1}, false),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"pubkey is empty",
|
||||
types.NewClientState(&types.ConsensusState{suite.solomachine.Sequence, nil, suite.solomachine.Time}, false),
|
||||
types.NewClientState(&types.ConsensusState{suite.solomachine.Sequence, nil, suite.solomachine.Diversifier, suite.solomachine.Time}, false),
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
@ -80,7 +85,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value, err := types.ClientStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, path, clientState)
|
||||
value, err := types.ClientStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, clientState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
|
@ -205,7 +210,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value, err := types.ConsensusStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, path, consensusState)
|
||||
value, err := types.ConsensusStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, consensusState)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
|
@ -326,7 +331,7 @@ func (suite *SoloMachineTestSuite) TestVerifyConnectionState() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(testConnectionID))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value, err := types.ConnectionStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, path, conn)
|
||||
value, err := types.ConnectionStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, conn)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
|
@ -409,7 +414,7 @@ func (suite *SoloMachineTestSuite) TestVerifyChannelState() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(testPortID, testChannelID))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value, err := types.ChannelStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, path, ch)
|
||||
value, err := types.ChannelStateSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, ch)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
|
@ -490,7 +495,8 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketCommitment() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(testPortID, testChannelID, suite.solomachine.Sequence))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value := types.PacketCommitmentSignBytes(suite.solomachine.Sequence, suite.solomachine.Time, path, commitmentBytes)
|
||||
value, err := types.PacketCommitmentSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, commitmentBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
suite.Require().NoError(err)
|
||||
|
@ -570,7 +576,8 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(testPortID, testChannelID, suite.solomachine.Sequence))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value := types.PacketAcknowledgementSignBytes(suite.solomachine.Sequence, suite.solomachine.Time, path, ack)
|
||||
value, err := types.PacketAcknowledgementSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, ack)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
suite.Require().NoError(err)
|
||||
|
@ -649,7 +656,8 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgementAbsence() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(testPortID, testChannelID, suite.solomachine.Sequence))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value := types.PacketAcknowledgementAbsenceSignBytes(suite.solomachine.Sequence, suite.solomachine.Time, path)
|
||||
value, err := types.PacketAcknowledgementAbsenceSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
suite.Require().NoError(err)
|
||||
|
@ -729,7 +737,8 @@ func (suite *SoloMachineTestSuite) TestVerifyNextSeqRecv() {
|
|||
path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(testPortID, testChannelID))
|
||||
suite.Require().NoError(err)
|
||||
|
||||
value := types.NextSequenceRecvSignBytes(suite.solomachine.Sequence, suite.solomachine.Time, path, nextSeqRecv)
|
||||
value, err := types.NextSequenceRecvSignBytes(suite.chainA.Codec, suite.solomachine.Sequence, suite.solomachine.Time, suite.solomachine.Diversifier, path, nextSeqRecv)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(value)
|
||||
suite.Require().NoError(err)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
|
@ -51,6 +53,9 @@ func (cs ConsensusState) ValidateBasic() error {
|
|||
if cs.Timestamp == 0 {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be 0")
|
||||
}
|
||||
if cs.Diversifier != "" && strings.TrimSpace(cs.Diversifier) == "" {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "diversifier cannot contain only spaces")
|
||||
}
|
||||
if cs.PublicKey == nil || cs.GetPubKey() == nil || len(cs.GetPubKey().Bytes()) == 0 {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "public key cannot be empty")
|
||||
}
|
||||
|
|
|
@ -29,16 +29,40 @@ func (suite *SoloMachineTestSuite) TestConsensusStateValidateBasic() {
|
|||
{
|
||||
"sequence is zero",
|
||||
&types.ConsensusState{
|
||||
Sequence: 0,
|
||||
PublicKey: suite.solomachine.ConsensusState().PublicKey,
|
||||
Sequence: 0,
|
||||
PublicKey: suite.solomachine.ConsensusState().PublicKey,
|
||||
Timestamp: suite.solomachine.Time,
|
||||
Diversifier: suite.solomachine.Diversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"timestamp is zero",
|
||||
&types.ConsensusState{
|
||||
Sequence: suite.solomachine.Sequence,
|
||||
PublicKey: suite.solomachine.ConsensusState().PublicKey,
|
||||
Timestamp: 0,
|
||||
Diversifier: suite.solomachine.Diversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"diversifier is blank",
|
||||
&types.ConsensusState{
|
||||
Sequence: suite.solomachine.Sequence,
|
||||
PublicKey: suite.solomachine.ConsensusState().PublicKey,
|
||||
Timestamp: suite.solomachine.Time,
|
||||
Diversifier: " ",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"pubkey is nil",
|
||||
&types.ConsensusState{
|
||||
Sequence: suite.solomachine.Sequence,
|
||||
PublicKey: nil,
|
||||
Sequence: suite.solomachine.Sequence,
|
||||
Timestamp: suite.solomachine.Time,
|
||||
Diversifier: suite.solomachine.Diversifier,
|
||||
PublicKey: nil,
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
|
@ -40,6 +42,14 @@ func (h Header) ValidateBasic() error {
|
|||
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "sequence number cannot be zero")
|
||||
}
|
||||
|
||||
if h.Timestamp == 0 {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "timestamp cannot be zero")
|
||||
}
|
||||
|
||||
if h.NewDiversifier != "" && strings.TrimSpace(h.NewDiversifier) == "" {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "diversifier cannot contain only spaces")
|
||||
}
|
||||
|
||||
if len(h.Signature) == 0 {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "signature cannot be empty")
|
||||
}
|
||||
|
|
|
@ -21,27 +21,55 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
|
|||
{
|
||||
"sequence is zero",
|
||||
&types.Header{
|
||||
Sequence: 0,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
Sequence: 0,
|
||||
Timestamp: header.Timestamp,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
NewDiversifier: header.NewDiversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"timestamp is zero",
|
||||
&types.Header{
|
||||
Sequence: header.Sequence,
|
||||
Timestamp: 0,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
NewDiversifier: header.NewDiversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"signature is empty",
|
||||
&types.Header{
|
||||
Sequence: header.Sequence,
|
||||
Signature: []byte{},
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
Sequence: header.Sequence,
|
||||
Timestamp: header.Timestamp,
|
||||
Signature: []byte{},
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
NewDiversifier: header.NewDiversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"diversifier contains only spaces",
|
||||
&types.Header{
|
||||
Sequence: header.Sequence,
|
||||
Timestamp: header.Timestamp,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: header.NewPublicKey,
|
||||
NewDiversifier: " ",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"public key is nil",
|
||||
&types.Header{
|
||||
Sequence: header.Sequence,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: nil,
|
||||
Sequence: header.Sequence,
|
||||
Timestamp: header.Timestamp,
|
||||
Signature: header.Signature,
|
||||
NewPublicKey: nil,
|
||||
NewDiversifier: header.NewDiversifier,
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
|
|
@ -30,7 +30,7 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
|
|||
return nil, sdkerrors.Wrapf(clienttypes.ErrClientFrozen, "client is already frozen")
|
||||
}
|
||||
|
||||
if err := checkMisbehaviour(cs, soloMisbehaviour); err != nil {
|
||||
if err := checkMisbehaviour(cdc, cs, soloMisbehaviour); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -40,19 +40,36 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState(
|
|||
|
||||
// checkMisbehaviour checks if the currently registered public key has signed
|
||||
// over two different messages at the same sequence.
|
||||
//
|
||||
// NOTE: a check that the misbehaviour message data are not equal is done by
|
||||
// misbehaviour.ValidateBasic which is called by the 02-client keeper.
|
||||
func checkMisbehaviour(clientState ClientState, soloMisbehaviour *Misbehaviour) error {
|
||||
func checkMisbehaviour(cdc codec.BinaryMarshaler, clientState ClientState, soloMisbehaviour *Misbehaviour) error {
|
||||
pubKey := clientState.ConsensusState.GetPubKey()
|
||||
|
||||
data := EvidenceSignBytes(soloMisbehaviour.Sequence, soloMisbehaviour.SignatureOne.Data)
|
||||
data, err := MisbehaviourSignBytes(
|
||||
cdc,
|
||||
soloMisbehaviour.Sequence, clientState.ConsensusState.Timestamp,
|
||||
clientState.ConsensusState.Diversifier,
|
||||
soloMisbehaviour.SignatureOne.Data,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check first signature
|
||||
if err := VerifySignature(pubKey, data, soloMisbehaviour.SignatureOne.Signature); err != nil {
|
||||
return sdkerrors.Wrap(err, "misbehaviour signature one failed to be verified")
|
||||
}
|
||||
|
||||
data = EvidenceSignBytes(soloMisbehaviour.Sequence, soloMisbehaviour.SignatureTwo.Data)
|
||||
data, err = MisbehaviourSignBytes(
|
||||
cdc,
|
||||
soloMisbehaviour.Sequence, clientState.ConsensusState.Timestamp,
|
||||
clientState.ConsensusState.Diversifier,
|
||||
soloMisbehaviour.SignatureTwo.Data,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check second signature
|
||||
if err := VerifySignature(pubKey, data, soloMisbehaviour.SignatureTwo.Signature); err != nil {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
)
|
||||
|
||||
func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
||||
|
@ -60,7 +60,14 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
|||
m := suite.solomachine.CreateMisbehaviour()
|
||||
|
||||
msg := []byte("DATA ONE")
|
||||
data := append(sdk.Uint64ToBigEndian(suite.solomachine.Sequence+1), msg...)
|
||||
signBytes := &types.SignBytes{
|
||||
Sequence: suite.solomachine.Sequence + 1,
|
||||
Data: msg,
|
||||
}
|
||||
|
||||
data, err := suite.chainA.Codec.MarshalBinaryBare(signBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(data)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
|
@ -79,7 +86,14 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
|||
m := suite.solomachine.CreateMisbehaviour()
|
||||
|
||||
msg := []byte("DATA TWO")
|
||||
data := append(sdk.Uint64ToBigEndian(suite.solomachine.Sequence+1), msg...)
|
||||
signBytes := &types.SignBytes{
|
||||
Sequence: suite.solomachine.Sequence + 1,
|
||||
Data: msg,
|
||||
}
|
||||
|
||||
data, err := suite.chainA.Codec.MarshalBinaryBare(signBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(data)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
|
@ -100,7 +114,14 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
|||
// Signature One
|
||||
msg := []byte("DATA ONE")
|
||||
// sequence used is plus 1
|
||||
data := append(sdk.Uint64ToBigEndian(suite.solomachine.Sequence+1), msg...)
|
||||
signBytes := &types.SignBytes{
|
||||
Sequence: suite.solomachine.Sequence + 1,
|
||||
Data: msg,
|
||||
}
|
||||
|
||||
data, err := suite.chainA.Codec.MarshalBinaryBare(signBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(data)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
|
@ -110,7 +131,14 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() {
|
|||
// Signature Two
|
||||
msg = []byte("DATA TWO")
|
||||
// sequence used is minus 1
|
||||
data = append(sdk.Uint64ToBigEndian(suite.solomachine.Sequence-1), msg...)
|
||||
|
||||
signBytes = &types.SignBytes{
|
||||
Sequence: suite.solomachine.Sequence - 1,
|
||||
Data: msg,
|
||||
}
|
||||
data, err = suite.chainA.Codec.MarshalBinaryBare(signBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err = suite.solomachine.PrivateKey.Sign(data)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
|
@ -23,193 +22,298 @@ func VerifySignature(pubKey crypto.PubKey, data, signature []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// EvidenceSignBytes returns the sign bytes for verification of misbehaviour.
|
||||
//
|
||||
// Format: {sequence}{data}
|
||||
func EvidenceSignBytes(sequence uint64, data []byte) []byte {
|
||||
return append(
|
||||
sdk.Uint64ToBigEndian(sequence),
|
||||
data...,
|
||||
)
|
||||
// MisbehaviourSignBytes returns the sign bytes for verification of misbehaviour.
|
||||
func MisbehaviourSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
diversifier string,
|
||||
data []byte) ([]byte, error) {
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: data,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// HeaderSignBytes returns the sign bytes for verification of misbehaviour.
|
||||
//
|
||||
// Format: {sequence}{header.newPubKey}
|
||||
func HeaderSignBytes(header *Header) []byte {
|
||||
return append(
|
||||
sdk.Uint64ToBigEndian(header.Sequence),
|
||||
header.GetPubKey().Bytes()...,
|
||||
)
|
||||
func HeaderSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
header *Header,
|
||||
) ([]byte, error) {
|
||||
data := &HeaderData{
|
||||
NewPubKey: header.NewPublicKey,
|
||||
NewDiversifier: header.NewDiversifier,
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: header.Sequence,
|
||||
Timestamp: header.Timestamp,
|
||||
Diversifier: header.NewDiversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// ClientStateSignBytes returns the sign bytes for verification of the
|
||||
// client state.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{client-state}
|
||||
func ClientStateSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
clientState exported.ClientState,
|
||||
) ([]byte, error) {
|
||||
bz, err := codec.MarshalAny(cdc, clientState)
|
||||
any, err := clienttypes.PackClientState(clientState)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + client state
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
bz...,
|
||||
), nil
|
||||
data := &ClientStateData{
|
||||
Path: []byte(path.String()),
|
||||
ClientState: any,
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// ConsensusStateSignBytes returns the sign bytes for verification of the
|
||||
// consensus state.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{consensus-state}
|
||||
func ConsensusStateSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
consensusState exported.ConsensusState,
|
||||
) ([]byte, error) {
|
||||
bz, err := codec.MarshalAny(cdc, consensusState)
|
||||
any, err := clienttypes.PackConsensusState(consensusState)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + consensus state
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
bz...,
|
||||
), nil
|
||||
data := &ConsensusStateData{
|
||||
Path: []byte(path.String()),
|
||||
ConsensusState: any,
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// ConnectionStateSignBytes returns the sign bytes for verification of the
|
||||
// connection state.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{connection-end}
|
||||
func ConnectionStateSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
connectionEnd exported.ConnectionI,
|
||||
) ([]byte, error) {
|
||||
connection, ok := connectionEnd.(connectiontypes.ConnectionEnd)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "invalid connection type %T", connectionEnd)
|
||||
return nil, sdkerrors.Wrapf(
|
||||
connectiontypes.ErrInvalidConnection,
|
||||
"expected type %T, got %T", connectiontypes.ConnectionEnd{}, connectionEnd,
|
||||
)
|
||||
}
|
||||
|
||||
bz, err := cdc.MarshalBinaryBare(&connection)
|
||||
data := &ConnectionStateData{
|
||||
Path: []byte(path.String()),
|
||||
Connection: &connection,
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + connection end
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
bz...,
|
||||
), nil
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// ChannelStateSignBytes returns the sign bytes for verification of the
|
||||
// channel state.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{channel-end}
|
||||
func ChannelStateSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
channelEnd exported.ChannelI,
|
||||
) ([]byte, error) {
|
||||
channel, ok := channelEnd.(channeltypes.Channel)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "invalid channel type %T", channelEnd)
|
||||
return nil, sdkerrors.Wrapf(
|
||||
channeltypes.ErrInvalidChannel,
|
||||
"expected channel type %T, got %T", channeltypes.Channel{}, channelEnd)
|
||||
}
|
||||
|
||||
bz, err := cdc.MarshalBinaryBare(&channel)
|
||||
data := &ChannelStateData{
|
||||
Path: []byte(path.String()),
|
||||
Channel: &channel,
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + channel
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
bz...,
|
||||
), nil
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// PacketCommitmentSignBytes returns the sign bytes for verification of the
|
||||
// packet commitment.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{commitment-bytes}
|
||||
func PacketCommitmentSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
commitmentBytes []byte,
|
||||
) []byte {
|
||||
) ([]byte, error) {
|
||||
data := &PacketCommitmentData{
|
||||
Path: []byte(path.String()),
|
||||
Commitment: commitmentBytes,
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + commitment bytes
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
commitmentBytes...,
|
||||
)
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// PacketAcknowledgementSignBytes returns the sign bytes for verification of
|
||||
// the acknowledgement.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{acknowledgement}
|
||||
func PacketAcknowledgementSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
acknowledgement []byte,
|
||||
) []byte {
|
||||
) ([]byte, error) {
|
||||
data := &PacketAcknowledgementData{
|
||||
Path: []byte(path.String()),
|
||||
Acknowledgement: acknowledgement,
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + acknowledgement
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
acknowledgement...,
|
||||
)
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// PacketAcknowledgementAbsenceSignBytes returns the sign bytes for verification
|
||||
// of the absence of an acknowledgement.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}
|
||||
func PacketAcknowledgementAbsenceSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
) []byte {
|
||||
// value = sequence + timestamp + path
|
||||
return combineSequenceTimestampPath(sequence, timestamp, path)
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
) ([]byte, error) {
|
||||
data := &PacketAcknowledgementAbsenseData{
|
||||
Path: []byte(path.String()),
|
||||
}
|
||||
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
||||
// NextSequenceRecv returns the sign bytes for verification of the next
|
||||
// NextSequenceRecvSignBytes returns the sign bytes for verification of the next
|
||||
// sequence to be received.
|
||||
//
|
||||
// Format: {sequence}{timestamp}{path}{next-sequence-recv}
|
||||
func NextSequenceRecvSignBytes(
|
||||
cdc codec.BinaryMarshaler,
|
||||
sequence, timestamp uint64,
|
||||
path commitmenttypes.MerklePath,
|
||||
diversifier string,
|
||||
path commitmenttypes.MerklePath, // nolint: interfacer
|
||||
nextSequenceRecv uint64,
|
||||
) []byte {
|
||||
) ([]byte, error) {
|
||||
data := &NextSequenceRecvData{
|
||||
Path: []byte(path.String()),
|
||||
NextSeqRecv: nextSequenceRecv,
|
||||
}
|
||||
|
||||
// sequence + timestamp + path + nextSequenceRecv
|
||||
return append(
|
||||
combineSequenceTimestampPath(sequence, timestamp, path),
|
||||
sdk.Uint64ToBigEndian(nextSequenceRecv)...,
|
||||
)
|
||||
}
|
||||
dataBz, err := cdc.MarshalBinaryBare(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// combineSequenceTimestampPath combines the sequence, the timestamp and
|
||||
// the path into one byte slice.
|
||||
func combineSequenceTimestampPath(sequence, timestamp uint64, path commitmenttypes.MerklePath) []byte {
|
||||
bz := append(sdk.Uint64ToBigEndian(sequence), sdk.Uint64ToBigEndian(timestamp)...)
|
||||
return append(
|
||||
bz,
|
||||
[]byte(path.String())...,
|
||||
)
|
||||
signBytes := &SignBytes{
|
||||
Sequence: sequence,
|
||||
Timestamp: timestamp,
|
||||
Diversifier: diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
return cdc.MarshalBinaryBare(signBytes)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,11 +27,11 @@ type SoloMachineTestSuite struct {
|
|||
}
|
||||
|
||||
func (suite *SoloMachineTestSuite) SetupTest() {
|
||||
suite.solomachine = ibctesting.NewSolomachine(suite.T(), "testingsolomachine")
|
||||
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
|
||||
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
|
||||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
|
||||
|
||||
suite.solomachine = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "testingsolomachine", "testing")
|
||||
suite.store = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), exported.ClientTypeSoloMachine)
|
||||
|
||||
bz, err := codec.MarshalAny(suite.chainA.Codec, suite.solomachine.ClientState())
|
||||
|
|
|
@ -23,7 +23,7 @@ func (cs ClientState) CheckHeaderAndUpdateState(
|
|||
)
|
||||
}
|
||||
|
||||
if err := checkHeader(&cs, smHeader); err != nil {
|
||||
if err := checkHeader(cdc, &cs, smHeader); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ func (cs ClientState) CheckHeaderAndUpdateState(
|
|||
}
|
||||
|
||||
// checkHeader checks if the Solo Machine update signature is valid.
|
||||
func checkHeader(clientState *ClientState, header *Header) error {
|
||||
func checkHeader(cdc codec.BinaryMarshaler, clientState *ClientState, header *Header) error {
|
||||
// assert update sequence is current sequence
|
||||
if header.Sequence != clientState.ConsensusState.Sequence {
|
||||
return sdkerrors.Wrapf(
|
||||
|
@ -42,7 +42,11 @@ func checkHeader(clientState *ClientState, header *Header) error {
|
|||
}
|
||||
|
||||
// assert currently registered public key signed over the new public key with correct sequence
|
||||
data := HeaderSignBytes(header)
|
||||
data, err := HeaderSignBytes(cdc, header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := VerifySignature(clientState.ConsensusState.GetPubKey(), data, header.Signature); err != nil {
|
||||
return sdkerrors.Wrap(ErrInvalidHeader, err.Error())
|
||||
}
|
||||
|
@ -54,8 +58,10 @@ func checkHeader(clientState *ClientState, header *Header) error {
|
|||
func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) {
|
||||
consensusState := &ConsensusState{
|
||||
// increment sequence number
|
||||
Sequence: clientState.ConsensusState.Sequence + 1,
|
||||
PublicKey: header.NewPublicKey,
|
||||
Sequence: clientState.ConsensusState.Sequence + 1,
|
||||
PublicKey: header.NewPublicKey,
|
||||
Diversifier: header.NewDiversifier,
|
||||
Timestamp: header.Timestamp,
|
||||
}
|
||||
|
||||
clientState.ConsensusState = consensusState
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
|
@ -69,9 +70,29 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() {
|
|||
cs := suite.solomachine.ClientState()
|
||||
h := suite.solomachine.CreateHeader()
|
||||
|
||||
publicKey, err := std.DefaultPublicKeyCodec{}.Encode(suite.solomachine.PublicKey)
|
||||
suite.NoError(err)
|
||||
|
||||
data := &types.HeaderData{
|
||||
NewPubKey: publicKey,
|
||||
NewDiversifier: h.NewDiversifier,
|
||||
}
|
||||
|
||||
dataBz, err := suite.chainA.Codec.MarshalBinaryBare(data)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// generate invalid signature
|
||||
data := append(sdk.Uint64ToBigEndian(cs.ConsensusState.Sequence), suite.solomachine.PublicKey.Bytes()...)
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(data)
|
||||
signBytes := &types.SignBytes{
|
||||
Sequence: cs.ConsensusState.Sequence,
|
||||
Timestamp: suite.solomachine.Time,
|
||||
Diversifier: suite.solomachine.Diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
signBz, err := suite.chainA.Codec.MarshalBinaryBare(signBytes)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
sig, err := suite.solomachine.PrivateKey.Sign(signBz)
|
||||
suite.Require().NoError(err)
|
||||
h.Signature = sig
|
||||
|
||||
|
|
|
@ -372,6 +372,7 @@ func (chain *TestChain) GetFirstTestConnection(clientID, counterpartyClientID st
|
|||
}
|
||||
|
||||
// ConstructMsgCreateClient constructs a message to create a new client state (tendermint or solomachine).
|
||||
// NOTE: a solo machine client will be created with an empty diversifier.
|
||||
func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, clientID string, clientType string) *clienttypes.MsgCreateClient {
|
||||
var (
|
||||
clientState exported.ClientState
|
||||
|
@ -388,7 +389,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client
|
|||
)
|
||||
consensusState = counterparty.LastHeader.ConsensusState()
|
||||
case exported.ClientTypeSoloMachine:
|
||||
solo := NewSolomachine(chain.t, clientID)
|
||||
solo := NewSolomachine(chain.t, chain.Codec, clientID, "")
|
||||
clientState = solo.ClientState()
|
||||
consensusState = solo.ConsensusState()
|
||||
default:
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
||||
solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types"
|
||||
|
@ -19,41 +19,48 @@ import (
|
|||
type Solomachine struct {
|
||||
t *testing.T
|
||||
|
||||
ClientID string
|
||||
PrivateKey crypto.PrivKey
|
||||
PublicKey crypto.PubKey
|
||||
Sequence uint64
|
||||
Time uint64
|
||||
cdc codec.BinaryMarshaler
|
||||
ClientID string
|
||||
PrivateKey crypto.PrivKey
|
||||
PublicKey crypto.PubKey
|
||||
Sequence uint64
|
||||
Time uint64
|
||||
Diversifier string
|
||||
}
|
||||
|
||||
// NewSolomachine returns a new solomachine instance with a generated private/public
|
||||
// key pair and a sequence starting at 1.
|
||||
func NewSolomachine(t *testing.T, clientID string) *Solomachine {
|
||||
func NewSolomachine(t *testing.T, cdc codec.BinaryMarshaler, clientID, diversifier string) *Solomachine {
|
||||
privKey := ed25519.GenPrivKey()
|
||||
|
||||
return &Solomachine{
|
||||
t: t,
|
||||
ClientID: clientID,
|
||||
PrivateKey: privKey,
|
||||
PublicKey: privKey.PubKey(),
|
||||
Sequence: 1,
|
||||
Time: 10,
|
||||
t: t,
|
||||
cdc: cdc,
|
||||
ClientID: clientID,
|
||||
PrivateKey: privKey,
|
||||
PublicKey: privKey.PubKey(),
|
||||
Sequence: 1,
|
||||
Time: 10,
|
||||
Diversifier: diversifier,
|
||||
}
|
||||
}
|
||||
|
||||
// default usage does not allow update after governance proposal
|
||||
// ClientState returns a new solo machine ClientState instance. Default usage does not allow update
|
||||
// after governance proposal
|
||||
func (solo *Solomachine) ClientState() *solomachinetypes.ClientState {
|
||||
return solomachinetypes.NewClientState(solo.ConsensusState(), false)
|
||||
}
|
||||
|
||||
// ConsensusState returns a new solo machine ConsensusState instance
|
||||
func (solo *Solomachine) ConsensusState() *solomachinetypes.ConsensusState {
|
||||
publicKey, err := std.DefaultPublicKeyCodec{}.Encode(solo.PublicKey)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
return &solomachinetypes.ConsensusState{
|
||||
Sequence: solo.Sequence,
|
||||
PublicKey: publicKey,
|
||||
Timestamp: solo.Time,
|
||||
Sequence: solo.Sequence,
|
||||
PublicKey: publicKey,
|
||||
Diversifier: solo.Diversifier,
|
||||
Timestamp: solo.Time,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,17 +74,37 @@ func (solo *Solomachine) GetHeight() exported.Height {
|
|||
func (solo *Solomachine) CreateHeader() *solomachinetypes.Header {
|
||||
// generate new private key and signature for header
|
||||
newPrivKey := ed25519.GenPrivKey()
|
||||
data := append(sdk.Uint64ToBigEndian(solo.Sequence), newPrivKey.PubKey().Bytes()...)
|
||||
signature, err := solo.PrivateKey.Sign(data)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
publicKey, err := std.DefaultPublicKeyCodec{}.Encode(newPrivKey.PubKey())
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
data := &solomachinetypes.HeaderData{
|
||||
NewPubKey: publicKey,
|
||||
NewDiversifier: solo.Diversifier,
|
||||
}
|
||||
|
||||
dataBz, err := solo.cdc.MarshalBinaryBare(data)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
signBytes := &solomachinetypes.SignBytes{
|
||||
Sequence: solo.Sequence,
|
||||
Timestamp: solo.Time,
|
||||
Diversifier: solo.Diversifier,
|
||||
Data: dataBz,
|
||||
}
|
||||
|
||||
signBz, err := solo.cdc.MarshalBinaryBare(signBytes)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
signature, err := solo.PrivateKey.Sign(signBz)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
header := &solomachinetypes.Header{
|
||||
Sequence: solo.Sequence,
|
||||
Signature: signature,
|
||||
NewPublicKey: publicKey,
|
||||
Sequence: solo.Sequence,
|
||||
Timestamp: solo.Time,
|
||||
Signature: signature,
|
||||
NewPublicKey: publicKey,
|
||||
NewDiversifier: solo.Diversifier,
|
||||
}
|
||||
|
||||
// assumes successful header update
|
||||
|
@ -94,7 +121,17 @@ func (solo *Solomachine) CreateMisbehaviour() *solomachinetypes.Misbehaviour {
|
|||
dataOne := []byte("DATA ONE")
|
||||
dataTwo := []byte("DATA TWO")
|
||||
|
||||
sig, err := solo.PrivateKey.Sign(append(sdk.Uint64ToBigEndian(solo.Sequence), dataOne...))
|
||||
signBytes := &solomachinetypes.SignBytes{
|
||||
Sequence: solo.Sequence,
|
||||
Timestamp: solo.Time,
|
||||
Diversifier: solo.Diversifier,
|
||||
Data: dataOne,
|
||||
}
|
||||
|
||||
signBz, err := solo.cdc.MarshalBinaryBare(signBytes)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
sig, err := solo.PrivateKey.Sign(signBz)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
signatureOne := solomachinetypes.SignatureAndData{
|
||||
|
@ -102,7 +139,17 @@ func (solo *Solomachine) CreateMisbehaviour() *solomachinetypes.Misbehaviour {
|
|||
Data: dataOne,
|
||||
}
|
||||
|
||||
sig, err = solo.PrivateKey.Sign(append(sdk.Uint64ToBigEndian(solo.Sequence), dataTwo...))
|
||||
signBytes = &solomachinetypes.SignBytes{
|
||||
Sequence: solo.Sequence,
|
||||
Timestamp: solo.Time,
|
||||
Diversifier: solo.Diversifier,
|
||||
Data: dataTwo,
|
||||
}
|
||||
|
||||
signBz, err = solo.cdc.MarshalBinaryBare(signBytes)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
sig, err = solo.PrivateKey.Sign(signBz)
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
signatureTwo := solomachinetypes.SignatureAndData{
|
||||
|
|
|
@ -88,7 +88,6 @@ func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runti
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -70,7 +70,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -142,7 +142,6 @@ func local_request_Query_SigningInfos_0(ctx context.Context, marshaler runtime.M
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -874,7 +874,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Validators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
|
@ -106,7 +106,6 @@ func local_request_Query_AppliedPlan_0(ctx context.Context, marshaler runtime.Ma
|
|||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer 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 RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_CurrentPlan_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
|
|
Loading…
Reference in New Issue