parent
55796fb3e7
commit
0d9faec1f3
|
@ -1,7 +1,6 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||||
|
@ -160,13 +159,13 @@ func (cs ClientState) VerifyClientConsensusState(
|
||||||
proof commitmentexported.Proof,
|
proof commitmentexported.Proof,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight)
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight)
|
||||||
|
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,12 +193,12 @@ func (cs ClientState) VerifyConnectionState(
|
||||||
connectionEnd connectionexported.ConnectionI,
|
connectionEnd connectionexported.ConnectionI,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(connectionID))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(connectionID))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,12 +232,12 @@ func (cs ClientState) VerifyChannelState(
|
||||||
channel channelexported.ChannelI,
|
channel channelexported.ChannelI,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(portID, channelID))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(portID, channelID))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,12 +271,12 @@ func (cs ClientState) VerifyPacketCommitment(
|
||||||
commitmentBytes []byte,
|
commitmentBytes []byte,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(portID, channelID, sequence))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(portID, channelID, sequence))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,12 +300,12 @@ func (cs ClientState) VerifyPacketAcknowledgement(
|
||||||
acknowledgement []byte,
|
acknowledgement []byte,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +329,12 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence(
|
||||||
sequence uint64,
|
sequence uint64,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,12 +357,12 @@ func (cs ClientState) VerifyNextSequenceRecv(
|
||||||
nextSequenceRecv uint64,
|
nextSequenceRecv uint64,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(portID, channelID))
|
if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateVerificationArgs(cs, height, proof, consensusState); err != nil {
|
path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(portID, channelID))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,13 +380,14 @@ func (cs ClientState) VerifyNextSequenceRecv(
|
||||||
func validateVerificationArgs(
|
func validateVerificationArgs(
|
||||||
cs ClientState,
|
cs ClientState,
|
||||||
height uint64,
|
height uint64,
|
||||||
|
prefix commitmentexported.Prefix,
|
||||||
proof commitmentexported.Proof,
|
proof commitmentexported.Proof,
|
||||||
consensusState clientexported.ConsensusState,
|
consensusState clientexported.ConsensusState,
|
||||||
) error {
|
) error {
|
||||||
if cs.GetLatestHeight() < height {
|
if cs.GetLatestHeight() < height {
|
||||||
return sdkerrors.Wrap(
|
return sdkerrors.Wrapf(
|
||||||
sdkerrors.ErrInvalidHeight,
|
sdkerrors.ErrInvalidHeight,
|
||||||
fmt.Sprintf("client state (%s) height < proof height (%d < %d)", cs.ID, cs.GetLatestHeight(), height),
|
"client state (%s) height < proof height (%d < %d)", cs.ID, cs.GetLatestHeight(), height,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,13 +395,32 @@ func validateVerificationArgs(
|
||||||
return clienttypes.ErrClientFrozen
|
return clienttypes.ErrClientFrozen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if prefix == nil {
|
||||||
|
return sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, ok := prefix.(*commitmenttypes.MerklePrefix)
|
||||||
|
if !ok {
|
||||||
|
return sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected *MerklePrefix", prefix)
|
||||||
|
}
|
||||||
|
|
||||||
if proof == nil {
|
if proof == nil {
|
||||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof cannot be empty")
|
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, ok = proof.(commitmenttypes.MerkleProof)
|
||||||
|
if !ok {
|
||||||
|
return sdkerrors.Wrapf(commitmenttypes.ErrInvalidProof, "invalid proof type %T, expected MerkleProof", proof)
|
||||||
|
}
|
||||||
|
|
||||||
if consensusState == nil {
|
if consensusState == nil {
|
||||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty")
|
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, ok = consensusState.(ConsensusState)
|
||||||
|
if !ok {
|
||||||
|
return sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "invalid consensus type %T, expected %T", consensusState, ConsensusState{})
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,9 @@ func NewMsgSubmitClientMisbehaviour(e evidenceexported.Evidence, s sdk.AccAddres
|
||||||
func (msg MsgSubmitClientMisbehaviour) Route() string { return host.RouterKey }
|
func (msg MsgSubmitClientMisbehaviour) Route() string { return host.RouterKey }
|
||||||
|
|
||||||
// Type returns the MsgSubmitClientMisbehaviour's type.
|
// Type returns the MsgSubmitClientMisbehaviour's type.
|
||||||
func (msg MsgSubmitClientMisbehaviour) Type() string { return TypeMsgSubmitClientMisbehaviour }
|
func (msg MsgSubmitClientMisbehaviour) Type() string {
|
||||||
|
return TypeMsgSubmitClientMisbehaviour
|
||||||
|
}
|
||||||
|
|
||||||
// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitClientMisbehaviour.
|
// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitClientMisbehaviour.
|
||||||
func (msg MsgSubmitClientMisbehaviour) ValidateBasic() error {
|
func (msg MsgSubmitClientMisbehaviour) ValidateBasic() error {
|
||||||
|
|
Loading…
Reference in New Issue