Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONOTMERGE] chore: add 668 functions to solomachine client #907

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@
- [ChannelStateData](#ibc.lightclients.solomachine.v1.ChannelStateData)
- [ClientState](#ibc.lightclients.solomachine.v1.ClientState)
- [ClientStateData](#ibc.lightclients.solomachine.v1.ClientStateData)
- [ConflictingSignaturesHeader](#ibc.lightclients.solomachine.v1.ConflictingSignaturesHeader)
- [ConnectionStateData](#ibc.lightclients.solomachine.v1.ConnectionStateData)
- [ConsensusState](#ibc.lightclients.solomachine.v1.ConsensusState)
- [ConsensusStateData](#ibc.lightclients.solomachine.v1.ConsensusStateData)
- [Header](#ibc.lightclients.solomachine.v1.Header)
- [HeaderData](#ibc.lightclients.solomachine.v1.HeaderData)
- [Misbehaviour](#ibc.lightclients.solomachine.v1.Misbehaviour)
- [NextSequenceRecvData](#ibc.lightclients.solomachine.v1.NextSequenceRecvData)
- [PacketAcknowledgementData](#ibc.lightclients.solomachine.v1.PacketAcknowledgementData)
- [PacketCommitmentData](#ibc.lightclients.solomachine.v1.PacketCommitmentData)
Expand All @@ -242,12 +242,12 @@
- [ChannelStateData](#ibc.lightclients.solomachine.v2.ChannelStateData)
- [ClientState](#ibc.lightclients.solomachine.v2.ClientState)
- [ClientStateData](#ibc.lightclients.solomachine.v2.ClientStateData)
- [ConflictingSignaturesHeader](#ibc.lightclients.solomachine.v2.ConflictingSignaturesHeader)
- [ConnectionStateData](#ibc.lightclients.solomachine.v2.ConnectionStateData)
- [ConsensusState](#ibc.lightclients.solomachine.v2.ConsensusState)
- [ConsensusStateData](#ibc.lightclients.solomachine.v2.ConsensusStateData)
- [Header](#ibc.lightclients.solomachine.v2.Header)
- [HeaderData](#ibc.lightclients.solomachine.v2.HeaderData)
- [Misbehaviour](#ibc.lightclients.solomachine.v2.Misbehaviour)
- [NextSequenceRecvData](#ibc.lightclients.solomachine.v2.NextSequenceRecvData)
- [PacketAcknowledgementData](#ibc.lightclients.solomachine.v2.PacketAcknowledgementData)
- [PacketCommitmentData](#ibc.lightclients.solomachine.v2.PacketCommitmentData)
Expand All @@ -261,9 +261,9 @@
- [ibc/lightclients/tendermint/v1/tendermint.proto](#ibc/lightclients/tendermint/v1/tendermint.proto)
- [ClientState](#ibc.lightclients.tendermint.v1.ClientState)
- [ConsensusState](#ibc.lightclients.tendermint.v1.ConsensusState)
- [DuplicateHeaderHeader](#ibc.lightclients.tendermint.v1.DuplicateHeaderHeader)
- [Fraction](#ibc.lightclients.tendermint.v1.Fraction)
- [Header](#ibc.lightclients.tendermint.v1.Header)
- [Misbehaviour](#ibc.lightclients.tendermint.v1.Misbehaviour)

- [Scalar Value Types](#scalar-value-types)

Expand Down Expand Up @@ -3309,6 +3309,25 @@ ClientStateData returns the SignBytes data for client state verification.



<a name="ibc.lightclients.solomachine.v1.ConflictingSignaturesHeader"></a>

### ConflictingSignaturesHeader
ConflictingSignaturesHeader defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v1.ConnectionStateData"></a>

### ConnectionStateData
Expand Down Expand Up @@ -3397,25 +3416,6 @@ HeaderData returns the SignBytes data for update verification.



<a name="ibc.lightclients.solomachine.v1.Misbehaviour"></a>

### Misbehaviour
Misbehaviour defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v1.NextSequenceRecvData"></a>

### NextSequenceRecvData
Expand Down Expand Up @@ -3627,6 +3627,25 @@ ClientStateData returns the SignBytes data for client state verification.



<a name="ibc.lightclients.solomachine.v2.ConflictingSignaturesHeader"></a>

### ConflictingSignaturesHeader
ConflictingSignaturesHeader defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v2.ConnectionStateData"></a>

### ConnectionStateData
Expand Down Expand Up @@ -3715,25 +3734,6 @@ HeaderData returns the SignBytes data for update verification.



<a name="ibc.lightclients.solomachine.v2.Misbehaviour"></a>

### Misbehaviour
Misbehaviour defines misbehaviour for a solo machine which consists
of a sequence and two signatures over different messages at that sequence.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `sequence` | [uint64](#uint64) | | |
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v2.SignatureAndData) | | |






<a name="ibc.lightclients.solomachine.v2.NextSequenceRecvData"></a>

### NextSequenceRecvData
Expand Down Expand Up @@ -3936,6 +3936,24 @@ ConsensusState defines the consensus state from Tendermint.



<a name="ibc.lightclients.tendermint.v1.DuplicateHeaderHeader"></a>

### DuplicateHeaderHeader
DuplicateHeaderHeader is a wrapper over two conflicting Headers
that implements Header interface expected by ICS-02


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `header_1` | [Header](#ibc.lightclients.tendermint.v1.Header) | | |
| `header_2` | [Header](#ibc.lightclients.tendermint.v1.Header) | | |






<a name="ibc.lightclients.tendermint.v1.Fraction"></a>

### Fraction
Expand Down Expand Up @@ -3981,24 +3999,6 @@ trusted validator set at the TrustedHeight.




<a name="ibc.lightclients.tendermint.v1.Misbehaviour"></a>

### Misbehaviour
Misbehaviour is a wrapper over two conflicting Headers
that implements Misbehaviour interface expected by ICS-02


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | |
| `header_1` | [Header](#ibc.lightclients.tendermint.v1.Header) | | |
| `header_2` | [Header](#ibc.lightclients.tendermint.v1.Header) | | |





<!-- end messages -->

<!-- end enums -->
Expand Down
13 changes: 7 additions & 6 deletions modules/core/02-client/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,21 @@ func NewUpdateClientCmd() *cobra.Command {
// future updates.
func NewSubmitMisbehaviourCmd() *cobra.Command {
return &cobra.Command{
Use: "misbehaviour [path/to/misbehaviour.json]",
Use: "misbehaviour [clientID] [path/to/misbehaviour.json]",
Short: "submit a client misbehaviour",
Long: "submit a client misbehaviour to prevent future updates",
Example: fmt.Sprintf("%s tx ibc %s misbehaviour [path/to/misbehaviour.json] --from node0 --home ../node0/<app>cli --chain-id $CID", version.AppName, types.SubModuleName),
Args: cobra.ExactArgs(1),
Example: fmt.Sprintf("%s tx ibc %s misbehaviour [clientID] [path/to/misbehaviour.json] --from node0 --home ../node0/<app>cli --chain-id $CID", version.AppName, types.SubModuleName),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)

var misbehaviour exported.Misbehaviour
misbehaviourContentOrFileName := args[0]
var misbehaviour exported.Header
clientID := args[0]
misbehaviourContentOrFileName := args[1]
if err := cdc.UnmarshalInterfaceJSON([]byte(misbehaviourContentOrFileName), &misbehaviour); err != nil {

// check for file path if JSON input is not provided
Expand All @@ -156,7 +157,7 @@ func NewSubmitMisbehaviourCmd() *cobra.Command {
}
}

msg, err := types.NewMsgSubmitMisbehaviour(misbehaviour.GetClientID(), misbehaviour, clientCtx.GetFromAddress().String())
msg, err := types.NewMsgSubmitMisbehaviour(clientID, misbehaviour, clientCtx.GetFromAddress().String())
if err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e

// CheckMisbehaviourAndUpdateState checks for client misbehaviour and freezes the
// client if so.
func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, misbehaviour exported.Misbehaviour) error {
clientState, found := k.GetClientState(ctx, misbehaviour.GetClientID())
func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, clientID string, misbehaviour exported.Header) error {
clientState, found := k.GetClientState(ctx, clientID)
if !found {
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.GetClientID())
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", clientID)
}

clientStore := k.ClientStore(ctx, misbehaviour.GetClientID())
clientStore := k.ClientStore(ctx, clientID)

if status := clientState.Status(ctx, clientStore, k.cdc); status != exported.Active {
return sdkerrors.Wrapf(types.ErrClientNotActive, "cannot process misbehaviour for client (%s) with status %s", misbehaviour.GetClientID(), status)
return sdkerrors.Wrapf(types.ErrClientNotActive, "cannot process misbehaviour for client (%s) with status %s", clientID, status)
}

if err := misbehaviour.ValidateBasic(); err != nil {
Expand All @@ -209,21 +209,21 @@ func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, misbehaviour ex
return err
}

k.SetClientState(ctx, misbehaviour.GetClientID(), clientState)
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", misbehaviour.GetClientID())
k.SetClientState(ctx, clientID, clientState)
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID)

defer func() {
telemetry.IncrCounterWithLabels(
[]string{"ibc", "client", "misbehaviour"},
1,
[]metrics.Label{
telemetry.NewLabel(types.LabelClientType, misbehaviour.ClientType()),
telemetry.NewLabel(types.LabelClientID, misbehaviour.GetClientID()),
telemetry.NewLabel(types.LabelClientID, clientID),
},
)
}()

EmitSubmitMisbehaviourEvent(ctx, misbehaviour.GetClientID(), clientState)
EmitSubmitMisbehaviourEvent(ctx, clientID, clientState)

return nil
}
2 changes: 1 addition & 1 deletion modules/core/02-client/legacy/v100/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (cs *ClientState) CheckHeaderAndUpdateState(

// CheckMisbehaviourAndUpdateState panics!
func (cs ClientState) CheckMisbehaviourAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Misbehaviour,
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (exported.ClientState, error) {
panic("legacy solo machine is deprecated!")
}
Expand Down
Loading