-
Notifications
You must be signed in to change notification settings - Fork 625
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
Add in-place and genesis migrations #205
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4f874d9
add in-place migrations
colin-axner f8ca013
update migrations
colin-axner 29c1c48
migrate solomachine from v1 to v2 during in place migration
colin-axner db0db21
fix build
colin-axner 972ca3c
add genesis migration
colin-axner 314aaba
code cleanup
colin-axner 40a30fa
Merge branch 'main' into colin/11-migration-scripts
colin-axner 863fdbd
add store migration test for expired tendermint consensus states
colin-axner a36801f
Merge branch 'colin/11-migration-scripts' of github.com:cosmos/ibc-go…
colin-axner 863b50a
finish adding in place migration store tests
colin-axner 545056e
add genesis test for solo machines
colin-axner 40484bb
fix genesis migration bug, add tendermint tests
colin-axner a24618d
test fix, changelog, migration docs
colin-axner 6d9bcdd
Apply suggestions from code review
colin-axner 6c6fc52
Merge branch 'main' into colin/11-migration-scripts
colin-axner a67102f
Update docs/migrations/ibc-migration-043.md
AdityaSripal 7e1f40f
apply Aditya's review suggestions
colin-axner 3896a2a
Merge branch 'colin/11-migration-scripts' of github.com:cosmos/ibc-go…
colin-axner 7edac1e
fix tests
colin-axner e326f74
add genesis json unmarshal test
colin-axner a970700
Merge branch 'main' into colin/11-migration-scripts
colin-axner 7ceca61
add migration support for max expected time per block
colin-axner ca070bd
Merge branch 'colin/11-migration-scripts' of github.com:cosmos/ibc-go…
colin-axner 0fcd0c4
fix docs
colin-axner 900b907
fix bug found by Aditya
colin-axner fed9443
remove unnecessary code
colin-axner e595b11
apply Aditya review suggestions, fix bug
colin-axner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
package v100 | ||
|
||
import ( | ||
ics23 "github.com/confio/ics23/go" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/modules/core/exported" | ||
) | ||
|
||
// NOTE: this is a mock implmentation for exported.ClientState. This implementation | ||
// should only be registered on the InterfaceRegistry during cli command genesis migration. | ||
// This implementation is only used to successfully unmarshal the previous solo machine | ||
// client state and consensus state and migrate them to the new implementations. When the proto | ||
// codec unmarshals, it calls UnpackInterfaces() to create a cached value of the any. The | ||
// UnpackInterfaces function for IdenitifiedClientState will attempt to unpack the any to | ||
// exported.ClientState. If the solomachine v1 type is not registered against the exported.ClientState | ||
// the unmarshal will fail. This implementation will panic on every interface function. | ||
// The same is done for the ConsensusState. | ||
|
||
// Interface implementation checks. | ||
var ( | ||
_, _ codectypes.UnpackInterfacesMessage = &ClientState{}, &ConsensusState{} | ||
_ exported.ClientState = (*ClientState)(nil) | ||
_ exported.ConsensusState = &ConsensusState{} | ||
) | ||
|
||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
registry.RegisterImplementations( | ||
(*exported.ClientState)(nil), | ||
&ClientState{}, | ||
) | ||
registry.RegisterImplementations( | ||
(*exported.ConsensusState)(nil), | ||
&ConsensusState{}, | ||
) | ||
} | ||
|
||
// UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method | ||
func (cs ClientState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { | ||
return cs.ConsensusState.UnpackInterfaces(unpacker) | ||
} | ||
|
||
// UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method | ||
func (cs ConsensusState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { | ||
return unpacker.UnpackAny(cs.PublicKey, new(cryptotypes.PubKey)) | ||
} | ||
|
||
// ClientType panics! | ||
func (cs ClientState) ClientType() string { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// GetLatestHeight panics! | ||
func (cs ClientState) GetLatestHeight() exported.Height { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// Status panics! | ||
func (cs ClientState) Status(_ sdk.Context, _ sdk.KVStore, _ codec.BinaryCodec) exported.Status { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// Validate panics! | ||
func (cs ClientState) Validate() error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// GetProofSpecs panics! | ||
func (cs ClientState) GetProofSpecs() []*ics23.ProofSpec { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// ZeroCustomFields panics! | ||
func (cs ClientState) ZeroCustomFields() exported.ClientState { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// Initialize panics! | ||
func (cs ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, consState exported.ConsensusState) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// ExportMetadata panics! | ||
func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// CheckHeaderAndUpdateState panics! | ||
func (cs *ClientState) CheckHeaderAndUpdateState( | ||
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header, | ||
) (exported.ClientState, exported.ConsensusState, error) { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// CheckMisbehaviourAndUpdateState panics! | ||
func (cs ClientState) CheckMisbehaviourAndUpdateState( | ||
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Misbehaviour, | ||
) (exported.ClientState, error) { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// CheckSubstituteAndUpdateState panics! | ||
func (cs ClientState) CheckSubstituteAndUpdateState( | ||
ctx sdk.Context, _ codec.BinaryCodec, _, _ sdk.KVStore, | ||
_ exported.ClientState, | ||
) (exported.ClientState, error) { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyUpgradeAndUpdateState panics! | ||
func (cs ClientState) VerifyUpgradeAndUpdateState( | ||
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, | ||
_ exported.ClientState, _ exported.ConsensusState, _, _ []byte, | ||
) (exported.ClientState, exported.ConsensusState, error) { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyClientState panics! | ||
func (cs ClientState) VerifyClientState( | ||
store sdk.KVStore, cdc codec.BinaryCodec, | ||
_ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyClientConsensusState panics! | ||
func (cs ClientState) VerifyClientConsensusState( | ||
sdk.KVStore, codec.BinaryCodec, | ||
exported.Height, string, exported.Height, exported.Prefix, | ||
[]byte, exported.ConsensusState, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyConnectionState panics! | ||
func (cs ClientState) VerifyConnectionState( | ||
sdk.KVStore, codec.BinaryCodec, exported.Height, | ||
exported.Prefix, []byte, string, exported.ConnectionI, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyChannelState panics! | ||
func (cs ClientState) VerifyChannelState( | ||
sdk.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix, | ||
[]byte, string, string, exported.ChannelI, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyPacketCommitment panics! | ||
func (cs ClientState) VerifyPacketCommitment( | ||
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height, | ||
uint64, uint64, exported.Prefix, []byte, | ||
string, string, uint64, []byte, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyPacketAcknowledgement panics! | ||
func (cs ClientState) VerifyPacketAcknowledgement( | ||
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height, | ||
uint64, uint64, exported.Prefix, []byte, | ||
string, string, uint64, []byte, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyPacketReceiptAbsence panics! | ||
func (cs ClientState) VerifyPacketReceiptAbsence( | ||
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height, | ||
uint64, uint64, exported.Prefix, []byte, | ||
string, string, uint64, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// VerifyNextSequenceRecv panics! | ||
func (cs ClientState) VerifyNextSequenceRecv( | ||
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height, | ||
uint64, uint64, exported.Prefix, []byte, | ||
string, string, uint64, | ||
) error { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// ClientType panics! | ||
func (ConsensusState) ClientType() string { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// GetTimestamp panics! | ||
func (cs ConsensusState) GetTimestamp() uint64 { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// GetRoot panics! | ||
func (cs ConsensusState) GetRoot() exported.Root { | ||
panic("legacy solo machine is deprecated!") | ||
} | ||
|
||
// ValidateBasic panics! | ||
func (cs ConsensusState) ValidateBasic() error { | ||
panic("legacy solo machine is deprecated!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's really no way around this. go semantic versioning will help a lot in the future