Skip to content

Commit

Permalink
Add in-place and genesis migrations (#205)
Browse files Browse the repository at this point in the history
* add in-place migrations

Prunes solomachines and expired tendermint consensus states via an x/upgrade

* update migrations

fix iteration bug
remove solo machine connections
remove solo machine channels

* migrate solomachine from v1 to v2 during in place migration

Regenerate v1 solo machine definition in 02-client legacy
Migrate from v1 to v2 solo machine client state
Prune v1 solo machine consensus states

* fix build

* add genesis migration

* code cleanup

* add store migration test for expired tendermint consensus states

* finish adding in place migration store tests

* add genesis test for solo machines

* fix genesis migration bug, add tendermint tests

* test fix, changelog, migration docs

* Apply suggestions from code review

* Update docs/migrations/ibc-migration-043.md

* apply Aditya's review suggestions

* fix tests

* add genesis json unmarshal test

Test that the legacy solo machines can be successfully unmarshalled.
This requires registering an implementation for the legacy solo machine. An implemenation which panics has been added.
This implementation should only be registered against a clientCtx during a migrate cli cmd. The implementation is only briefly used in order to decode the previous solo machine set in genesis.

* add migration support for max expected time per block

* fix docs

* fix bug found by Aditya

The genesis client metadata was being set independently for each unexpired height. It needed to be moved outside the unexpired for loop

* remove unnecessary code

* apply Aditya review suggestions, fix bug

There was a bug in adding consensus metadata since it relied on the iteration key not yet set.
This is fixed by using traditional iteration using the consensus state key, setting metadata for all consensus states, and then pruning expired consensus states. The store test has been updated to set create two tendermint clients

Co-authored-by: Aditya <[email protected]>
  • Loading branch information
colin-axner and AdityaSripal authored Jun 17, 2021
1 parent 2548ab5 commit 2e95805
Show file tree
Hide file tree
Showing 24 changed files with 6,148 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (core/02-client) [\#205](https://github.com/cosmos/ibc-go/pull/205) Add in-place and genesis migrations from SDK v0.42.0 to ibc-go v1.0.0. Solo machine protobuf defintions are migrated from v1 to v2. All solo machine consensus states are pruned. All expired tendermint consensus states are pruned.
* (modules/core) [\#184](https://github.com/cosmos/ibc-go/pull/184) Improve error messages. Uses unique error codes to indicate already relayed packets.
* (07-tendermint) [\#182](https://github.com/cosmos/ibc-go/pull/182) Remove duplicate checks in upgrade logic.
* (modules/core/04-channel) [\#7949](https://github.com/cosmos/cosmos-sdk/issues/7949) Standardized channel `Acknowledgement` moved to its own file. Codec registration redundancy removed.
Expand Down
340 changes: 339 additions & 1 deletion docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@
- [ibc/lightclients/localhost/v1/localhost.proto](#ibc/lightclients/localhost/v1/localhost.proto)
- [ClientState](#ibc.lightclients.localhost.v1.ClientState)

- [ibc/lightclients/solomachine/v1/solomachine.proto](#ibc/lightclients/solomachine/v1/solomachine.proto)
- [ChannelStateData](#ibc.lightclients.solomachine.v1.ChannelStateData)
- [ClientState](#ibc.lightclients.solomachine.v1.ClientState)
- [ClientStateData](#ibc.lightclients.solomachine.v1.ClientStateData)
- [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)
- [PacketReceiptAbsenceData](#ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData)
- [SignBytes](#ibc.lightclients.solomachine.v1.SignBytes)
- [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData)
- [TimestampedSignatureData](#ibc.lightclients.solomachine.v1.TimestampedSignatureData)

- [DataType](#ibc.lightclients.solomachine.v1.DataType)

- [ibc/lightclients/solomachine/v2/solomachine.proto](#ibc/lightclients/solomachine/v2/solomachine.proto)
- [ChannelStateData](#ibc.lightclients.solomachine.v2.ChannelStateData)
- [ClientState](#ibc.lightclients.solomachine.v2.ClientState)
Expand Down Expand Up @@ -2405,7 +2425,7 @@ Params defines the set of Connection parameters.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `max_expected_time_per_block` | [uint64](#uint64) | | maximum expected time per block, used to enforce block delay. This parameter should reflect the largest amount of time that the chain might reasonably take to produce the next block under normal operating conditions. A safe choice is 3-5x the expected time per block. |
| `max_expected_time_per_block` | [uint64](#uint64) | | maximum expected time per block (in nanoseconds), used to enforce block delay. This parameter should reflect the largest amount of time that the chain might reasonably take to produce the next block under normal operating conditions. A safe choice is 3-5x the expected time per block. |



Expand Down Expand Up @@ -2919,6 +2939,324 @@ access to keys outside the client prefix.



<a name="ibc/lightclients/solomachine/v1/solomachine.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/lightclients/solomachine/v1/solomachine.proto



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

### ChannelStateData
ChannelStateData returns the SignBytes data for channel state
verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `channel` | [ibc.core.channel.v1.Channel](#ibc.core.channel.v1.Channel) | | |






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

### ClientState
ClientState defines a solo machine client that tracks the current consensus
state and if the client is frozen.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `sequence` | [uint64](#uint64) | | latest sequence of the client state |
| `frozen_sequence` | [uint64](#uint64) | | frozen sequence of the solo machine |
| `consensus_state` | [ConsensusState](#ibc.lightclients.solomachine.v1.ConsensusState) | | |
| `allow_update_after_proposal` | [bool](#bool) | | when set to true, will allow governance to update a solo machine client. The client will be unfrozen if it is frozen. |






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

### ClientStateData
ClientStateData returns the SignBytes data for client state verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | |






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

### ConnectionStateData
ConnectionStateData returns the SignBytes data for connection state
verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `connection` | [ibc.core.connection.v1.ConnectionEnd](#ibc.core.connection.v1.ConnectionEnd) | | |






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

### ConsensusState
ConsensusState defines a solo machine consensus state. The sequence of a
consensus state is contained in the "height" key used in storing the
consensus state.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public key of the solo machine |
| `diversifier` | [string](#string) | | diversifier allows the same public key to be re-used across different solo machine clients (potentially on different chains) without being considered misbehaviour. |
| `timestamp` | [uint64](#uint64) | | |






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

### ConsensusStateData
ConsensusStateData returns the SignBytes data for consensus state
verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | |






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

### Header
Header defines a solo machine consensus header


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `sequence` | [uint64](#uint64) | | sequence to update solo machine public key at |
| `timestamp` | [uint64](#uint64) | | |
| `signature` | [bytes](#bytes) | | |
| `new_public_key` | [google.protobuf.Any](#google.protobuf.Any) | | |
| `new_diversifier` | [string](#string) | | |






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

### HeaderData
HeaderData returns the SignBytes data for update verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `new_pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | header public key |
| `new_diversifier` | [string](#string) | | header diversifier |






<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
NextSequenceRecvData returns the SignBytes data for verification of the next
sequence to be received.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `next_seq_recv` | [uint64](#uint64) | | |






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

### PacketAcknowledgementData
PacketAcknowledgementData returns the SignBytes data for acknowledgement
verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `acknowledgement` | [bytes](#bytes) | | |






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

### PacketCommitmentData
PacketCommitmentData returns the SignBytes data for packet commitment
verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |
| `commitment` | [bytes](#bytes) | | |






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

### PacketReceiptAbsenceData
PacketReceiptAbsenceData returns the SignBytes data for
packet receipt absence verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `path` | [bytes](#bytes) | | |






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

### SignBytes
SignBytes defines the signed bytes used for signature verification.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `sequence` | [uint64](#uint64) | | |
| `timestamp` | [uint64](#uint64) | | |
| `diversifier` | [string](#string) | | |
| `data_type` | [DataType](#ibc.lightclients.solomachine.v1.DataType) | | type of the data used |
| `data` | [bytes](#bytes) | | marshaled data |






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

### SignatureAndData
SignatureAndData contains a signature and the data signed over to create that
signature.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `signature` | [bytes](#bytes) | | |
| `data_type` | [DataType](#ibc.lightclients.solomachine.v1.DataType) | | |
| `data` | [bytes](#bytes) | | |
| `timestamp` | [uint64](#uint64) | | |






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

### TimestampedSignatureData
TimestampedSignatureData contains the signature data and the timestamp of the
signature.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `signature_data` | [bytes](#bytes) | | |
| `timestamp` | [uint64](#uint64) | | |





<!-- end messages -->


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

### DataType
DataType defines the type of solo machine proof being created. This is done
to preserve uniqueness of different data sign byte encodings.

| Name | Number | Description |
| ---- | ------ | ----------- |
| DATA_TYPE_UNINITIALIZED_UNSPECIFIED | 0 | Default State |
| DATA_TYPE_CLIENT_STATE | 1 | Data type for client state verification |
| DATA_TYPE_CONSENSUS_STATE | 2 | Data type for consensus state verification |
| DATA_TYPE_CONNECTION_STATE | 3 | Data type for connection state verification |
| DATA_TYPE_CHANNEL_STATE | 4 | Data type for channel state verification |
| DATA_TYPE_PACKET_COMMITMENT | 5 | Data type for packet commitment verification |
| DATA_TYPE_PACKET_ACKNOWLEDGEMENT | 6 | Data type for packet acknowledgement verification |
| DATA_TYPE_PACKET_RECEIPT_ABSENCE | 7 | Data type for packet receipt absence verification |
| DATA_TYPE_NEXT_SEQUENCE_RECV | 8 | Data type for next sequence recv verification |
| DATA_TYPE_HEADER | 9 | Data type for header verification |


<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/lightclients/solomachine/v2/solomachine.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
Loading

0 comments on commit 2e95805

Please sign in to comment.