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

chore: add upgrade handler to simapp for v6 -> v7 #2842

Merged
merged 31 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bd37d18
refactor: add tendermint manual pruning function
colin-axner Nov 21, 2022
7ad76de
chore: add extra checks into pruning test
colin-axner Nov 21, 2022
5e9f208
chore: add docs and logging for tendermint pruning
colin-axner Nov 21, 2022
5cb1262
Apply suggestions from code review
colin-axner Nov 21, 2022
33c64d6
Apply suggestions from code review
colin-axner Nov 21, 2022
21ab154
Merge branch 'main' into colin/1863-tm-pruning
colin-axner Nov 21, 2022
f6bbe6f
Apply suggestions from code review
colin-axner Nov 21, 2022
f7d8871
Update modules/core/02-client/migrations/store.go
colin-axner Nov 21, 2022
348b21e
chore: move tendermint migrations to 07-tendermint directory
colin-axner Nov 21, 2022
969cc0b
Merge branch 'colin/1863-tm-pruning' of github.com:cosmos/ibc-go into…
colin-axner Nov 21, 2022
4399a42
chore: add changelog entry
colin-axner Nov 21, 2022
78fd0a3
chore: update imports
colin-axner Nov 21, 2022
0f90c1e
refactor: add automatic migrations for 02-client-refactor
colin-axner Nov 23, 2022
9d7c048
review: apply self nits
colin-axner Nov 23, 2022
fa08b63
chore: add changelog entry
colin-axner Nov 23, 2022
ae2b1c2
test: add an additional test for improperly registered codecs
colin-axner Nov 23, 2022
20e4d8d
chore: update migration doc header
colin-axner Nov 23, 2022
bf2a11b
Merge branch 'main' into colin/1863-02-client-migrations
colin-axner Nov 23, 2022
af99600
Merge branch 'main' of github.com:cosmos/ibc-go into colin/1863-02-cl…
colin-axner Nov 23, 2022
b95f5f0
Merge branch 'main' of github.com:cosmos/ibc-go into colin/1863-tm-pr…
colin-axner Nov 23, 2022
6aa58bc
Merge branch 'main' into charly/2437_upgradehandler_6_7
charleenfei Nov 29, 2022
d828218
create upgrade handler and call handler in app.go of simapp
charleenfei Nov 29, 2022
54334ce
Merge branch 'main' into colin/1863-tm-pruning
colin-axner Nov 29, 2022
92b71a4
Merge remote-tracking branch 'upstream/colin/1863-tm-pruning' into ch…
charleenfei Nov 29, 2022
e039aae
Merge branch 'main' into charly/2437_upgradehandler_6_7
charleenfei Nov 30, 2022
fddd991
update to main
charleenfei Nov 30, 2022
d85e8c7
err check for tendermint consensus state pruning
charleenfei Nov 30, 2022
9d732f8
add comments, rm unnecessary moduleName
charleenfei Nov 30, 2022
2b5b10d
fix re: pr comments
charleenfei Nov 30, 2022
3171ca2
Merge branch 'main' into charly/2437_upgradehandler_6_7
charleenfei Nov 30, 2022
e51e87c
Merge branch 'main' into charly/2437_upgradehandler_6_7
charleenfei Nov 30, 2022
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
Prev Previous commit
Next Next commit
refactor: add automatic migrations for 02-client-refactor
  • Loading branch information
colin-axner committed Nov 23, 2022
commit 0f90c1ec39ab4e915aca716e93a096cbcc6ab215
12 changes: 12 additions & 0 deletions modules/core/02-client/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

v100 "github.com/cosmos/ibc-go/v6/modules/core/02-client/legacy/v100"
"github.com/cosmos/ibc-go/v6/modules/core/02-client/migrations/v7"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -25,3 +26,14 @@ func NewMigrator(keeper Keeper) Migrator {
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v100.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}

// Migrate2to3 migrates from version 2 to 3.
// This migration
// - migrates solo machine client states from v2 to v3 protobuf definition
// - prunes solo machine consensus states
// - removes the localhost client
// - asserts that existing tendermint clients are properly registered on the chain codec
// - adds iteration and processed height keys for unexpired tendermint consensus states
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v7.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
263 changes: 263 additions & 0 deletions modules/core/02-client/migrations/v7/solomachine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
package v7

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/v6/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!")
}

// CheckForMisbehaviour panics!
func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, msg exported.ClientMessage) bool {
panic("legacy solo machine is deprecated!")
}

// UpdateStateOnMisbehaviour panics!
func (cs *ClientState) UpdateStateOnMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
) {
panic("legacy solo machine is deprecated!")
}

// VerifyClientMessage panics!
func (cs *ClientState) VerifyClientMessage(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
) error {
panic("legacy solo machine is deprecated!")
}

// UpdateState panis!
func (cs *ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage) []exported.Height {
panic("legacy solo machine is deprecated!")
}

// CheckHeaderAndUpdateState panics!
func (cs *ClientState) CheckHeaderAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
) (exported.ClientState, exported.ConsensusState, error) {
panic("legacy solo machine is deprecated!")
}

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

// CheckSubstituteAndUpdateState panics!
func (cs ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, _ codec.BinaryCodec, _, _ sdk.KVStore,
_ 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,
) 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!")
}

// GetTimestampAtHeight panics!
func (cs ClientState) GetTimestampAtHeight(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
) (uint64, error) {
panic("legacy solo machine is deprecated!")
}

// VerifyMembership panics!
func (cs *ClientState) VerifyMembership(
ctx sdk.Context,
clientStore sdk.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
delayBlockPeriod uint64,
proof []byte,
path exported.Path,
value []byte,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyNonMembership panics!
func (cs *ClientState) VerifyNonMembership(
ctx sdk.Context,
clientStore sdk.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
delayBlockPeriod uint64,
proof []byte,
path exported.Path,
) 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!")
}

// ValidateBasic panics!
func (cs ConsensusState) ValidateBasic() error {
panic("legacy solo machine is deprecated!")
}
Loading