Skip to content

Commit 2e95805

Browse files
Add in-place and genesis migrations (#205)
* 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 <adityasripal@gmail.com>
1 parent 2548ab5 commit 2e95805

File tree

24 files changed

+6148
-14
lines changed

24 files changed

+6148
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7272

7373
### Improvements
7474

75+
* (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.
7576
* (modules/core) [\#184](https://github.com/cosmos/ibc-go/pull/184) Improve error messages. Uses unique error codes to indicate already relayed packets.
7677
* (07-tendermint) [\#182](https://github.com/cosmos/ibc-go/pull/182) Remove duplicate checks in upgrade logic.
7778
* (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.

docs/ibc/proto-docs.md

Lines changed: 339 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@
195195
- [ibc/lightclients/localhost/v1/localhost.proto](#ibc/lightclients/localhost/v1/localhost.proto)
196196
- [ClientState](#ibc.lightclients.localhost.v1.ClientState)
197197

198+
- [ibc/lightclients/solomachine/v1/solomachine.proto](#ibc/lightclients/solomachine/v1/solomachine.proto)
199+
- [ChannelStateData](#ibc.lightclients.solomachine.v1.ChannelStateData)
200+
- [ClientState](#ibc.lightclients.solomachine.v1.ClientState)
201+
- [ClientStateData](#ibc.lightclients.solomachine.v1.ClientStateData)
202+
- [ConnectionStateData](#ibc.lightclients.solomachine.v1.ConnectionStateData)
203+
- [ConsensusState](#ibc.lightclients.solomachine.v1.ConsensusState)
204+
- [ConsensusStateData](#ibc.lightclients.solomachine.v1.ConsensusStateData)
205+
- [Header](#ibc.lightclients.solomachine.v1.Header)
206+
- [HeaderData](#ibc.lightclients.solomachine.v1.HeaderData)
207+
- [Misbehaviour](#ibc.lightclients.solomachine.v1.Misbehaviour)
208+
- [NextSequenceRecvData](#ibc.lightclients.solomachine.v1.NextSequenceRecvData)
209+
- [PacketAcknowledgementData](#ibc.lightclients.solomachine.v1.PacketAcknowledgementData)
210+
- [PacketCommitmentData](#ibc.lightclients.solomachine.v1.PacketCommitmentData)
211+
- [PacketReceiptAbsenceData](#ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData)
212+
- [SignBytes](#ibc.lightclients.solomachine.v1.SignBytes)
213+
- [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData)
214+
- [TimestampedSignatureData](#ibc.lightclients.solomachine.v1.TimestampedSignatureData)
215+
216+
- [DataType](#ibc.lightclients.solomachine.v1.DataType)
217+
198218
- [ibc/lightclients/solomachine/v2/solomachine.proto](#ibc/lightclients/solomachine/v2/solomachine.proto)
199219
- [ChannelStateData](#ibc.lightclients.solomachine.v2.ChannelStateData)
200220
- [ClientState](#ibc.lightclients.solomachine.v2.ClientState)
@@ -2405,7 +2425,7 @@ Params defines the set of Connection parameters.
24052425

24062426
| Field | Type | Label | Description |
24072427
| ----- | ---- | ----- | ----------- |
2408-
| `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. |
2428+
| `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. |
24092429

24102430

24112431

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

29202940

29212941

2942+
<a name="ibc/lightclients/solomachine/v1/solomachine.proto"></a>
2943+
<p align="right"><a href="#top">Top</a></p>
2944+
2945+
## ibc/lightclients/solomachine/v1/solomachine.proto
2946+
2947+
2948+
2949+
<a name="ibc.lightclients.solomachine.v1.ChannelStateData"></a>
2950+
2951+
### ChannelStateData
2952+
ChannelStateData returns the SignBytes data for channel state
2953+
verification.
2954+
2955+
2956+
| Field | Type | Label | Description |
2957+
| ----- | ---- | ----- | ----------- |
2958+
| `path` | [bytes](#bytes) | | |
2959+
| `channel` | [ibc.core.channel.v1.Channel](#ibc.core.channel.v1.Channel) | | |
2960+
2961+
2962+
2963+
2964+
2965+
2966+
<a name="ibc.lightclients.solomachine.v1.ClientState"></a>
2967+
2968+
### ClientState
2969+
ClientState defines a solo machine client that tracks the current consensus
2970+
state and if the client is frozen.
2971+
2972+
2973+
| Field | Type | Label | Description |
2974+
| ----- | ---- | ----- | ----------- |
2975+
| `sequence` | [uint64](#uint64) | | latest sequence of the client state |
2976+
| `frozen_sequence` | [uint64](#uint64) | | frozen sequence of the solo machine |
2977+
| `consensus_state` | [ConsensusState](#ibc.lightclients.solomachine.v1.ConsensusState) | | |
2978+
| `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. |
2979+
2980+
2981+
2982+
2983+
2984+
2985+
<a name="ibc.lightclients.solomachine.v1.ClientStateData"></a>
2986+
2987+
### ClientStateData
2988+
ClientStateData returns the SignBytes data for client state verification.
2989+
2990+
2991+
| Field | Type | Label | Description |
2992+
| ----- | ---- | ----- | ----------- |
2993+
| `path` | [bytes](#bytes) | | |
2994+
| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | |
2995+
2996+
2997+
2998+
2999+
3000+
3001+
<a name="ibc.lightclients.solomachine.v1.ConnectionStateData"></a>
3002+
3003+
### ConnectionStateData
3004+
ConnectionStateData returns the SignBytes data for connection state
3005+
verification.
3006+
3007+
3008+
| Field | Type | Label | Description |
3009+
| ----- | ---- | ----- | ----------- |
3010+
| `path` | [bytes](#bytes) | | |
3011+
| `connection` | [ibc.core.connection.v1.ConnectionEnd](#ibc.core.connection.v1.ConnectionEnd) | | |
3012+
3013+
3014+
3015+
3016+
3017+
3018+
<a name="ibc.lightclients.solomachine.v1.ConsensusState"></a>
3019+
3020+
### ConsensusState
3021+
ConsensusState defines a solo machine consensus state. The sequence of a
3022+
consensus state is contained in the "height" key used in storing the
3023+
consensus state.
3024+
3025+
3026+
| Field | Type | Label | Description |
3027+
| ----- | ---- | ----- | ----------- |
3028+
| `public_key` | [google.protobuf.Any](#google.protobuf.Any) | | public key of the solo machine |
3029+
| `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. |
3030+
| `timestamp` | [uint64](#uint64) | | |
3031+
3032+
3033+
3034+
3035+
3036+
3037+
<a name="ibc.lightclients.solomachine.v1.ConsensusStateData"></a>
3038+
3039+
### ConsensusStateData
3040+
ConsensusStateData returns the SignBytes data for consensus state
3041+
verification.
3042+
3043+
3044+
| Field | Type | Label | Description |
3045+
| ----- | ---- | ----- | ----------- |
3046+
| `path` | [bytes](#bytes) | | |
3047+
| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | |
3048+
3049+
3050+
3051+
3052+
3053+
3054+
<a name="ibc.lightclients.solomachine.v1.Header"></a>
3055+
3056+
### Header
3057+
Header defines a solo machine consensus header
3058+
3059+
3060+
| Field | Type | Label | Description |
3061+
| ----- | ---- | ----- | ----------- |
3062+
| `sequence` | [uint64](#uint64) | | sequence to update solo machine public key at |
3063+
| `timestamp` | [uint64](#uint64) | | |
3064+
| `signature` | [bytes](#bytes) | | |
3065+
| `new_public_key` | [google.protobuf.Any](#google.protobuf.Any) | | |
3066+
| `new_diversifier` | [string](#string) | | |
3067+
3068+
3069+
3070+
3071+
3072+
3073+
<a name="ibc.lightclients.solomachine.v1.HeaderData"></a>
3074+
3075+
### HeaderData
3076+
HeaderData returns the SignBytes data for update verification.
3077+
3078+
3079+
| Field | Type | Label | Description |
3080+
| ----- | ---- | ----- | ----------- |
3081+
| `new_pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | header public key |
3082+
| `new_diversifier` | [string](#string) | | header diversifier |
3083+
3084+
3085+
3086+
3087+
3088+
3089+
<a name="ibc.lightclients.solomachine.v1.Misbehaviour"></a>
3090+
3091+
### Misbehaviour
3092+
Misbehaviour defines misbehaviour for a solo machine which consists
3093+
of a sequence and two signatures over different messages at that sequence.
3094+
3095+
3096+
| Field | Type | Label | Description |
3097+
| ----- | ---- | ----- | ----------- |
3098+
| `client_id` | [string](#string) | | |
3099+
| `sequence` | [uint64](#uint64) | | |
3100+
| `signature_one` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |
3101+
| `signature_two` | [SignatureAndData](#ibc.lightclients.solomachine.v1.SignatureAndData) | | |
3102+
3103+
3104+
3105+
3106+
3107+
3108+
<a name="ibc.lightclients.solomachine.v1.NextSequenceRecvData"></a>
3109+
3110+
### NextSequenceRecvData
3111+
NextSequenceRecvData returns the SignBytes data for verification of the next
3112+
sequence to be received.
3113+
3114+
3115+
| Field | Type | Label | Description |
3116+
| ----- | ---- | ----- | ----------- |
3117+
| `path` | [bytes](#bytes) | | |
3118+
| `next_seq_recv` | [uint64](#uint64) | | |
3119+
3120+
3121+
3122+
3123+
3124+
3125+
<a name="ibc.lightclients.solomachine.v1.PacketAcknowledgementData"></a>
3126+
3127+
### PacketAcknowledgementData
3128+
PacketAcknowledgementData returns the SignBytes data for acknowledgement
3129+
verification.
3130+
3131+
3132+
| Field | Type | Label | Description |
3133+
| ----- | ---- | ----- | ----------- |
3134+
| `path` | [bytes](#bytes) | | |
3135+
| `acknowledgement` | [bytes](#bytes) | | |
3136+
3137+
3138+
3139+
3140+
3141+
3142+
<a name="ibc.lightclients.solomachine.v1.PacketCommitmentData"></a>
3143+
3144+
### PacketCommitmentData
3145+
PacketCommitmentData returns the SignBytes data for packet commitment
3146+
verification.
3147+
3148+
3149+
| Field | Type | Label | Description |
3150+
| ----- | ---- | ----- | ----------- |
3151+
| `path` | [bytes](#bytes) | | |
3152+
| `commitment` | [bytes](#bytes) | | |
3153+
3154+
3155+
3156+
3157+
3158+
3159+
<a name="ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData"></a>
3160+
3161+
### PacketReceiptAbsenceData
3162+
PacketReceiptAbsenceData returns the SignBytes data for
3163+
packet receipt absence verification.
3164+
3165+
3166+
| Field | Type | Label | Description |
3167+
| ----- | ---- | ----- | ----------- |
3168+
| `path` | [bytes](#bytes) | | |
3169+
3170+
3171+
3172+
3173+
3174+
3175+
<a name="ibc.lightclients.solomachine.v1.SignBytes"></a>
3176+
3177+
### SignBytes
3178+
SignBytes defines the signed bytes used for signature verification.
3179+
3180+
3181+
| Field | Type | Label | Description |
3182+
| ----- | ---- | ----- | ----------- |
3183+
| `sequence` | [uint64](#uint64) | | |
3184+
| `timestamp` | [uint64](#uint64) | | |
3185+
| `diversifier` | [string](#string) | | |
3186+
| `data_type` | [DataType](#ibc.lightclients.solomachine.v1.DataType) | | type of the data used |
3187+
| `data` | [bytes](#bytes) | | marshaled data |
3188+
3189+
3190+
3191+
3192+
3193+
3194+
<a name="ibc.lightclients.solomachine.v1.SignatureAndData"></a>
3195+
3196+
### SignatureAndData
3197+
SignatureAndData contains a signature and the data signed over to create that
3198+
signature.
3199+
3200+
3201+
| Field | Type | Label | Description |
3202+
| ----- | ---- | ----- | ----------- |
3203+
| `signature` | [bytes](#bytes) | | |
3204+
| `data_type` | [DataType](#ibc.lightclients.solomachine.v1.DataType) | | |
3205+
| `data` | [bytes](#bytes) | | |
3206+
| `timestamp` | [uint64](#uint64) | | |
3207+
3208+
3209+
3210+
3211+
3212+
3213+
<a name="ibc.lightclients.solomachine.v1.TimestampedSignatureData"></a>
3214+
3215+
### TimestampedSignatureData
3216+
TimestampedSignatureData contains the signature data and the timestamp of the
3217+
signature.
3218+
3219+
3220+
| Field | Type | Label | Description |
3221+
| ----- | ---- | ----- | ----------- |
3222+
| `signature_data` | [bytes](#bytes) | | |
3223+
| `timestamp` | [uint64](#uint64) | | |
3224+
3225+
3226+
3227+
3228+
3229+
<!-- end messages -->
3230+
3231+
3232+
<a name="ibc.lightclients.solomachine.v1.DataType"></a>
3233+
3234+
### DataType
3235+
DataType defines the type of solo machine proof being created. This is done
3236+
to preserve uniqueness of different data sign byte encodings.
3237+
3238+
| Name | Number | Description |
3239+
| ---- | ------ | ----------- |
3240+
| DATA_TYPE_UNINITIALIZED_UNSPECIFIED | 0 | Default State |
3241+
| DATA_TYPE_CLIENT_STATE | 1 | Data type for client state verification |
3242+
| DATA_TYPE_CONSENSUS_STATE | 2 | Data type for consensus state verification |
3243+
| DATA_TYPE_CONNECTION_STATE | 3 | Data type for connection state verification |
3244+
| DATA_TYPE_CHANNEL_STATE | 4 | Data type for channel state verification |
3245+
| DATA_TYPE_PACKET_COMMITMENT | 5 | Data type for packet commitment verification |
3246+
| DATA_TYPE_PACKET_ACKNOWLEDGEMENT | 6 | Data type for packet acknowledgement verification |
3247+
| DATA_TYPE_PACKET_RECEIPT_ABSENCE | 7 | Data type for packet receipt absence verification |
3248+
| DATA_TYPE_NEXT_SEQUENCE_RECV | 8 | Data type for next sequence recv verification |
3249+
| DATA_TYPE_HEADER | 9 | Data type for header verification |
3250+
3251+
3252+
<!-- end enums -->
3253+
3254+
<!-- end HasExtensions -->
3255+
3256+
<!-- end services -->
3257+
3258+
3259+
29223260
<a name="ibc/lightclients/solomachine/v2/solomachine.proto"></a>
29233261
<p align="right"><a href="#top">Top</a></p>
29243262

0 commit comments

Comments
 (0)