From 40f3fdd35220efbdd34f75312513b63464a3d470 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Mon, 19 Dec 2022 09:52:08 +0800 Subject: [PATCH 01/71] on-chain upgrade to consumer chain wip --- app/consumer-democracy/app.go | 10 +- .../ccv/consumer/v1/genesis.proto | 6 + .../ccv/provider/v1/provider.proto | 2 + x/ccv/consumer/keeper/genesis.go | 6 + x/ccv/consumer/keeper/relay.go | 1 + x/ccv/consumer/types/genesis.pb.go | 367 +++++++++++++++--- x/ccv/democracy/staking/expected_keepers.go | 11 + x/ccv/democracy/staking/module.go | 28 +- x/ccv/provider/types/provider.pb.go | 299 +++++++++----- 9 files changed, 561 insertions(+), 169 deletions(-) create mode 100644 x/ccv/democracy/staking/expected_keepers.go diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 5f5106f7ec..fa4eb46a32 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -483,7 +483,7 @@ func New( ccvmint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName), - ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), @@ -506,6 +506,7 @@ func New( ccvdistrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, + ibcconsumertypes.ModuleName, // Note: consumer initiation before staking module ccvstakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -517,11 +518,11 @@ func New( vestingtypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, - ibcconsumertypes.ModuleName, ) app.MM.SetOrderEndBlockers( crisistypes.ModuleName, ccvgovtypes.ModuleName, + ibcconsumertypes.ModuleName, // Note: consumer initiation before staking module ccvstakingtypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, @@ -537,7 +538,6 @@ func New( vestingtypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, - ibcconsumertypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -550,6 +550,7 @@ func New( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, + ibcconsumertypes.ModuleName, // Note: consumer initiation before staking module ccvdistrtypes.ModuleName, ccvstakingtypes.ModuleName, slashingtypes.ModuleName, @@ -564,7 +565,6 @@ func New( vestingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, - ibcconsumertypes.ModuleName, ) app.MM.RegisterInvariants(&app.CrisisKeeper) @@ -584,7 +584,7 @@ func New( feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), ccvgov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, IsProposalWhitelisted), ccvmint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), params.NewAppModule(app.ParamsKeeper), diff --git a/proto/interchain_security/ccv/consumer/v1/genesis.proto b/proto/interchain_security/ccv/consumer/v1/genesis.proto index a755dd7eb8..d6344807f6 100644 --- a/proto/interchain_security/ccv/consumer/v1/genesis.proto +++ b/proto/interchain_security/ccv/consumer/v1/genesis.proto @@ -39,6 +39,12 @@ message GenesisState { // LastTransmissionBlockHeight nil on new chain, filled in on restart. interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight last_transmission_block_height = 12 [ (gogoproto.nullable) = false ]; + // TODO: preCCV could be replaced by params.Enabled + bool preCCV = 13; // flag indicating whether the consumer CCV module starts in pre-CCV state + google.protobuf.Duration unbonding_period = 14; // the unbonding period on the consumer chain. + string conn_id = 15; // the ID of the connection end on the consumer chain on top of which the CCV channel will be established. + string counterparty_client_id = 16; // the ID of the client of the consumer chain on the provider chain. + string transfer_channel_id = 17; // the ID of a token transfer channel used for the Reward Distribution sub-protocol. } // MaturingVSCPacket defines the genesis information for the diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 87a0058b4c..cdb24198e4 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -59,6 +59,8 @@ message ConsumerAdditionProposal { // This param is a part of the cosmos sdk staking module. In the case of // a ccv enabled consumer chain, the ccv module acts as the staking module. int64 historical_entries = 13; + string conn_id = 15; // the ID of the connection end on the consumer chain on top of which the CCV channel will be established. + string transfer_channel_id = 16; // the ID of a token transfer channel used for the Reward Distribution sub-protocol. } // ConsumerRemovalProposal is a governance proposal on the provider chain to remove (and stop) a consumer chain. diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 088ce6adc4..14b0c9c9d1 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -17,6 +17,12 @@ import ( // 2. A consumer chain restarts after a client to the provider was created, but the CCV channel handshake is still in progress // 3. A consumer chain restarts after the CCV channel handshake was completed. func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) []abci.ValidatorUpdate { + // PreCCV is true when consumer chain used to be running on non-consumer chain, and when it is in the progress of upgrading + // to consumer chain, where consumer chain upgrade is done. + if state.PreCCV { + return []abci.ValidatorUpdate{} + } + k.SetParams(ctx, state.Params) // TODO: Remove enabled flag and find a better way to setup e2e tests // See: https://github.com/cosmos/interchain-security/issues/339 diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 05b48085f7..f4afc24047 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -24,6 +24,7 @@ import ( // Note: CCV uses an ordered IBC channel, meaning VSC packet changes will be accumulated (and later // processed by ApplyCCValidatorChanges) s.t. more recent val power changes overwrite older ones. func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, newChanges ccv.ValidatorSetChangePacketData) exported.Acknowledgement { + // TODO: validator set update on receive packet // get the provider channel providerChannel, found := k.GetProviderChannel(ctx) if found && providerChannel != packet.DestinationChannel { diff --git a/x/ccv/consumer/types/genesis.pb.go b/x/ccv/consumer/types/genesis.pb.go index 0573a6471b..9c39b640df 100644 --- a/x/ccv/consumer/types/genesis.pb.go +++ b/x/ccv/consumer/types/genesis.pb.go @@ -10,7 +10,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types1 "github.com/tendermint/tendermint/abci/types" - _ "google.golang.org/protobuf/types/known/durationpb" + durationpb "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" @@ -49,6 +49,11 @@ type GenesisState struct { PendingConsumerPackets ConsumerPackets `protobuf:"bytes,11,opt,name=pending_consumer_packets,json=pendingConsumerPackets,proto3" json:"pending_consumer_packets"` // LastTransmissionBlockHeight nil on new chain, filled in on restart. LastTransmissionBlockHeight LastTransmissionBlockHeight `protobuf:"bytes,12,opt,name=last_transmission_block_height,json=lastTransmissionBlockHeight,proto3" json:"last_transmission_block_height"` + PreCCV bool `protobuf:"varint,13,opt,name=preCCV,proto3" json:"preCCV,omitempty"` + UnbondingPeriod *durationpb.Duration `protobuf:"bytes,14,opt,name=unbonding_period,json=unbondingPeriod,proto3" json:"unbonding_period,omitempty"` + ConnId string `protobuf:"bytes,15,opt,name=conn_id,json=connId,proto3" json:"conn_id,omitempty"` + CounterpartyClientId string `protobuf:"bytes,16,opt,name=counterparty_client_id,json=counterpartyClientId,proto3" json:"counterparty_client_id,omitempty"` + TransferChannelId string `protobuf:"bytes,17,opt,name=transfer_channel_id,json=transferChannelId,proto3" json:"transfer_channel_id,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -168,6 +173,41 @@ func (m *GenesisState) GetLastTransmissionBlockHeight() LastTransmissionBlockHei return LastTransmissionBlockHeight{} } +func (m *GenesisState) GetPreCCV() bool { + if m != nil { + return m.PreCCV + } + return false +} + +func (m *GenesisState) GetUnbondingPeriod() *durationpb.Duration { + if m != nil { + return m.UnbondingPeriod + } + return nil +} + +func (m *GenesisState) GetConnId() string { + if m != nil { + return m.ConnId + } + return "" +} + +func (m *GenesisState) GetCounterpartyClientId() string { + if m != nil { + return m.CounterpartyClientId + } + return "" +} + +func (m *GenesisState) GetTransferChannelId() string { + if m != nil { + return m.TransferChannelId + } + return "" +} + // MaturingVSCPacket defines the genesis information for the // unbonding VSC packet type MaturingVSCPacket struct { @@ -334,56 +374,63 @@ func init() { } var fileDescriptor_2db73a6057a27482 = []byte{ - // 784 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x6f, 0xc3, 0x34, - 0x14, 0x6e, 0x58, 0x57, 0x5a, 0x6f, 0x63, 0x9b, 0x37, 0xaa, 0xb0, 0x8a, 0x50, 0xba, 0x4b, 0x25, - 0x20, 0x51, 0x07, 0x42, 0x08, 0x24, 0x04, 0xeb, 0x24, 0xa8, 0x04, 0x63, 0x6a, 0xbb, 0x1e, 0x76, - 0x89, 0x5c, 0xc7, 0x24, 0xd6, 0x12, 0xbb, 0x8a, 0x9d, 0x8c, 0x1d, 0xb8, 0x70, 0xe5, 0xc2, 0x9f, - 0xb5, 0xe3, 0x8e, 0x9c, 0xd0, 0xb4, 0xfd, 0x23, 0x28, 0xb6, 0xd3, 0x1f, 0x5b, 0x11, 0xbd, 0xd9, - 0x7e, 0xef, 0xfb, 0xbe, 0xf7, 0xcb, 0x0f, 0xf4, 0x28, 0x93, 0x24, 0xc5, 0x11, 0xa2, 0xcc, 0x17, - 0x04, 0x67, 0x29, 0x95, 0xf7, 0x1e, 0xc6, 0xb9, 0x87, 0x39, 0x13, 0x59, 0x42, 0x52, 0x2f, 0xef, - 0x79, 0x21, 0x61, 0x44, 0x50, 0xe1, 0xce, 0x52, 0x2e, 0x39, 0x3c, 0x5d, 0x03, 0x71, 0x31, 0xce, - 0xdd, 0x12, 0xe2, 0xe6, 0xbd, 0x13, 0x27, 0xe4, 0x3c, 0x8c, 0x89, 0xa7, 0x20, 0xd3, 0xec, 0x57, - 0x2f, 0xc8, 0x52, 0x24, 0x29, 0x67, 0x9a, 0xe4, 0xc4, 0xa3, 0x53, 0xec, 0xc5, 0x34, 0x8c, 0x24, - 0x8e, 0x29, 0x61, 0x52, 0x78, 0x92, 0xb0, 0x80, 0xa4, 0x09, 0x65, 0xb2, 0x90, 0x5c, 0xdc, 0x0c, - 0xe0, 0xe3, 0x02, 0x80, 0x79, 0x4a, 0x3c, 0x1c, 0x21, 0xc6, 0x48, 0x5c, 0x78, 0x99, 0xa3, 0x71, - 0x39, 0x0e, 0x79, 0xc8, 0xd5, 0xd1, 0x2b, 0x4e, 0xe6, 0xf5, 0x6c, 0x93, 0x0c, 0xe7, 0xa1, 0x6b, - 0x4c, 0x6b, 0x29, 0x18, 0x34, 0xc5, 0xd4, 0x93, 0xf7, 0x33, 0x62, 0xf2, 0xef, 0x3c, 0xd5, 0xc1, - 0xee, 0x0f, 0xba, 0x22, 0x23, 0x89, 0x24, 0x81, 0x03, 0x50, 0x9b, 0xa1, 0x14, 0x25, 0xc2, 0xb6, - 0xda, 0x56, 0x77, 0xe7, 0xec, 0x13, 0x77, 0x83, 0x0a, 0xb9, 0x57, 0x0a, 0x72, 0x5e, 0x7d, 0xf8, - 0xe7, 0xa3, 0xca, 0xd0, 0x10, 0xc0, 0x4f, 0x01, 0x9c, 0xa5, 0x3c, 0xa7, 0x01, 0x49, 0x7d, 0x5d, - 0x18, 0x9f, 0x06, 0xf6, 0x3b, 0x6d, 0xab, 0xdb, 0x18, 0x1e, 0x94, 0x96, 0xbe, 0x32, 0x0c, 0x02, - 0xe8, 0x82, 0xa3, 0x85, 0xb7, 0x2e, 0x45, 0xe1, 0xbe, 0xa5, 0xdc, 0x0f, 0xe7, 0xee, 0xda, 0x32, - 0x08, 0x60, 0x0b, 0x34, 0x18, 0xb9, 0xf3, 0x55, 0x60, 0x76, 0xb5, 0x6d, 0x75, 0xeb, 0xc3, 0x3a, - 0x23, 0x77, 0xfd, 0xe2, 0x0e, 0x7d, 0xf0, 0xfe, 0x6b, 0x69, 0x51, 0xa4, 0x67, 0x6f, 0x97, 0x49, - 0x4d, 0xb1, 0xbb, 0xdc, 0x31, 0x77, 0xa9, 0x47, 0x79, 0xcf, 0xd5, 0x51, 0xa9, 0x8a, 0x0c, 0x8f, - 0x56, 0x43, 0xd5, 0x65, 0x8a, 0x80, 0xbd, 0x10, 0xe0, 0x4c, 0x10, 0x26, 0x32, 0x61, 0x34, 0x6a, - 0x4a, 0xc3, 0xfd, 0x5f, 0x8d, 0x12, 0xa6, 0x65, 0x9a, 0x73, 0x99, 0x95, 0x77, 0x18, 0x82, 0x83, - 0x04, 0xc9, 0x2c, 0xa5, 0x2c, 0xf4, 0x67, 0x08, 0xdf, 0x12, 0x29, 0xec, 0x77, 0xdb, 0x5b, 0xdd, - 0x9d, 0xb3, 0x2f, 0x37, 0x6a, 0xcd, 0xcf, 0x06, 0x3c, 0x19, 0xf5, 0xaf, 0x14, 0xdc, 0x74, 0x69, - 0xbf, 0x64, 0xd5, 0xaf, 0x02, 0x5e, 0x82, 0x7d, 0xca, 0xa8, 0xa4, 0x28, 0xf6, 0x73, 0x14, 0xfb, - 0x82, 0x48, 0xbb, 0xae, 0x74, 0xda, 0xcb, 0x81, 0x17, 0x13, 0xe4, 0x4e, 0x50, 0x4c, 0x03, 0x24, - 0x79, 0x7a, 0x3d, 0x0b, 0x90, 0x24, 0x86, 0x71, 0xcf, 0xc0, 0x27, 0x28, 0x1e, 0x11, 0x09, 0x7f, - 0x07, 0x27, 0x11, 0x29, 0xd2, 0xf7, 0x25, 0x2f, 0x18, 0x05, 0x91, 0x7e, 0xa6, 0xfc, 0x8b, 0xbe, - 0x36, 0x14, 0xf5, 0x37, 0x1b, 0xa5, 0xf0, 0xa3, 0xa2, 0x19, 0xf3, 0x89, 0x22, 0xd1, 0x9a, 0x83, - 0x0b, 0xa3, 0xda, 0x8c, 0xd6, 0x59, 0x03, 0xf8, 0x87, 0x05, 0x3e, 0xe4, 0x99, 0x14, 0x12, 0xb1, - 0xa0, 0xa8, 0x5d, 0xc0, 0xef, 0x98, 0xa4, 0x09, 0xf1, 0x45, 0x8c, 0x44, 0x44, 0x59, 0x68, 0x03, - 0x15, 0xc2, 0x57, 0x1b, 0x85, 0xf0, 0xcb, 0x82, 0xe9, 0xc2, 0x10, 0x19, 0xfd, 0x16, 0x7f, 0x6b, - 0x1a, 0x19, 0x09, 0x28, 0x81, 0x3d, 0x23, 0x5a, 0xbf, 0x64, 0x9b, 0x37, 0x71, 0x47, 0x8d, 0xc9, - 0x17, 0x1b, 0xc9, 0xf7, 0xcd, 0xd9, 0xf4, 0xaa, 0x4c, 0xdd, 0x70, 0xbf, 0xb2, 0xc2, 0x3f, 0x2d, - 0xe0, 0xc4, 0x48, 0x48, 0x5f, 0xa6, 0x88, 0x89, 0x84, 0x0a, 0x41, 0x39, 0xf3, 0xa7, 0x31, 0xc7, - 0xb7, 0xbe, 0xae, 0x96, 0xbd, 0xab, 0xc4, 0xbf, 0xdb, 0x48, 0xfc, 0x27, 0x24, 0xe4, 0x78, 0x89, - 0xe9, 0xbc, 0x20, 0xd2, 0x3d, 0x29, 0x6b, 0x10, 0xff, 0xb7, 0x4b, 0xe7, 0x12, 0x1c, 0xbe, 0x99, - 0x41, 0x78, 0x0c, 0xb6, 0x73, 0x81, 0x07, 0x81, 0xda, 0x32, 0xd5, 0xa1, 0xbe, 0xc0, 0x53, 0xb0, - 0xa7, 0xa7, 0x52, 0xde, 0xfb, 0x45, 0x1d, 0xd5, 0xb2, 0xa8, 0x0e, 0x77, 0xcb, 0xc7, 0x31, 0x4d, - 0x48, 0xe7, 0x06, 0x34, 0xd7, 0x0f, 0x04, 0x6c, 0x82, 0x9a, 0x49, 0x4f, 0xb3, 0x9a, 0x1b, 0xec, - 0x82, 0x83, 0x37, 0xf3, 0xa7, 0x99, 0xdf, 0xcb, 0x57, 0x86, 0xa6, 0x73, 0x0d, 0x8e, 0xd6, 0x74, - 0x1a, 0x7e, 0x0b, 0x5a, 0x79, 0x39, 0xf2, 0x4b, 0xdf, 0x1d, 0x05, 0x41, 0x4a, 0x84, 0xde, 0x94, - 0x8d, 0xe1, 0x07, 0x73, 0x97, 0xf9, 0x0f, 0xfe, 0x5e, 0x3b, 0x9c, 0x8f, 0x1f, 0x9e, 0x1d, 0xeb, - 0xf1, 0xd9, 0xb1, 0x9e, 0x9e, 0x1d, 0xeb, 0xaf, 0x17, 0xa7, 0xf2, 0xf8, 0xe2, 0x54, 0xfe, 0x7e, - 0x71, 0x2a, 0x37, 0x5f, 0x87, 0x54, 0x46, 0xd9, 0xd4, 0xc5, 0x3c, 0xf1, 0x30, 0x17, 0x09, 0x17, - 0xde, 0xa2, 0x25, 0x9f, 0xcd, 0x57, 0xfc, 0x6f, 0xab, 0x4b, 0x5e, 0x6d, 0xf0, 0x69, 0x4d, 0xad, - 0xf0, 0xcf, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x8a, 0xe8, 0x9f, 0xf7, 0x06, 0x00, 0x00, + // 888 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcf, 0x6f, 0xe4, 0x34, + 0x14, 0x6e, 0xd8, 0xee, 0x6c, 0xeb, 0xb6, 0xdb, 0xa9, 0x5b, 0x86, 0x6c, 0x2b, 0x86, 0xa1, 0x7b, + 0x19, 0x09, 0x48, 0xd4, 0xb2, 0x42, 0x08, 0x24, 0x04, 0x9d, 0x4a, 0x30, 0x12, 0x2c, 0xd5, 0xb4, + 0x3b, 0x87, 0xbd, 0x44, 0x1e, 0xc7, 0x9b, 0x58, 0x9b, 0xd8, 0x91, 0xed, 0xa4, 0xf4, 0xc0, 0x85, + 0x2b, 0x17, 0xfe, 0x21, 0xee, 0x7b, 0xdc, 0x23, 0x27, 0x84, 0xda, 0x7f, 0x04, 0xf9, 0x47, 0x32, + 0x99, 0xed, 0x20, 0xe6, 0x66, 0xfb, 0xbd, 0xf7, 0x7d, 0xef, 0x87, 0xfd, 0x19, 0x9c, 0x50, 0xa6, + 0x88, 0xc0, 0x29, 0xa2, 0x2c, 0x92, 0x04, 0x97, 0x82, 0xaa, 0x9b, 0x10, 0xe3, 0x2a, 0xc4, 0x9c, + 0xc9, 0x32, 0x27, 0x22, 0xac, 0x4e, 0xc2, 0x84, 0x30, 0x22, 0xa9, 0x0c, 0x0a, 0xc1, 0x15, 0x87, + 0x4f, 0x97, 0x84, 0x04, 0x18, 0x57, 0x41, 0x1d, 0x12, 0x54, 0x27, 0x87, 0xfd, 0x84, 0xf3, 0x24, + 0x23, 0xa1, 0x09, 0x99, 0x95, 0xaf, 0xc2, 0xb8, 0x14, 0x48, 0x51, 0xce, 0x2c, 0xc8, 0x61, 0x48, + 0x67, 0x38, 0xcc, 0x68, 0x92, 0x2a, 0x9c, 0x51, 0xc2, 0x94, 0x0c, 0x15, 0x61, 0x31, 0x11, 0x39, + 0x65, 0x4a, 0x53, 0xce, 0x77, 0x2e, 0xe0, 0x63, 0x1d, 0x80, 0xb9, 0x20, 0x21, 0x4e, 0x11, 0x63, + 0x24, 0xd3, 0x5e, 0x6e, 0xe9, 0x5c, 0x0e, 0x12, 0x9e, 0x70, 0xb3, 0x0c, 0xf5, 0xca, 0x9d, 0x9e, + 0xae, 0x52, 0x61, 0x93, 0xba, 0x8d, 0x39, 0x6a, 0x25, 0x83, 0x66, 0x98, 0x86, 0xea, 0xa6, 0x20, + 0xae, 0xfe, 0xe3, 0x3f, 0x01, 0xd8, 0xfe, 0xde, 0x76, 0xe4, 0x52, 0x21, 0x45, 0xe0, 0x18, 0x74, + 0x0a, 0x24, 0x50, 0x2e, 0x7d, 0x6f, 0xe0, 0x0d, 0xb7, 0x4e, 0x3f, 0x09, 0x56, 0xe8, 0x50, 0x70, + 0x61, 0x42, 0xce, 0xd6, 0xdf, 0xfc, 0xfd, 0xd1, 0xda, 0xc4, 0x01, 0xc0, 0x4f, 0x01, 0x2c, 0x04, + 0xaf, 0x68, 0x4c, 0x44, 0x64, 0x1b, 0x13, 0xd1, 0xd8, 0x7f, 0x6f, 0xe0, 0x0d, 0x37, 0x27, 0xdd, + 0xda, 0x32, 0x32, 0x86, 0x71, 0x0c, 0x03, 0xb0, 0x3f, 0xf7, 0xb6, 0xad, 0xd0, 0xee, 0x0f, 0x8c, + 0xfb, 0x5e, 0xe3, 0x6e, 0x2d, 0xe3, 0x18, 0x1e, 0x81, 0x4d, 0x46, 0xae, 0x23, 0x93, 0x98, 0xbf, + 0x3e, 0xf0, 0x86, 0x1b, 0x93, 0x0d, 0x46, 0xae, 0x47, 0x7a, 0x0f, 0x23, 0xf0, 0xfe, 0xbb, 0xd4, + 0x52, 0x97, 0xe7, 0x3f, 0xac, 0x8b, 0x9a, 0xe1, 0xa0, 0x3d, 0xb1, 0xa0, 0x35, 0xa3, 0xea, 0x24, + 0xb0, 0x59, 0x99, 0x8e, 0x4c, 0xf6, 0x17, 0x53, 0xb5, 0x6d, 0x4a, 0x81, 0x3f, 0x27, 0xe0, 0x4c, + 0x12, 0x26, 0x4b, 0xe9, 0x38, 0x3a, 0x86, 0x23, 0xf8, 0x5f, 0x8e, 0x3a, 0xcc, 0xd2, 0xf4, 0x1a, + 0x9a, 0x85, 0x73, 0x98, 0x80, 0x6e, 0x8e, 0x54, 0x29, 0x28, 0x4b, 0xa2, 0x02, 0xe1, 0xd7, 0x44, + 0x49, 0xff, 0xd1, 0xe0, 0xc1, 0x70, 0xeb, 0xf4, 0x8b, 0x95, 0x46, 0xf3, 0x93, 0x0b, 0x9e, 0x5e, + 0x8e, 0x2e, 0x4c, 0xb8, 0x9b, 0xd2, 0x6e, 0x8d, 0x6a, 0x4f, 0x25, 0x7c, 0x0e, 0x76, 0x29, 0xa3, + 0x8a, 0xa2, 0x2c, 0xaa, 0x50, 0x16, 0x49, 0xa2, 0xfc, 0x0d, 0xc3, 0x33, 0x68, 0x27, 0xae, 0x6f, + 0x50, 0x30, 0x45, 0x19, 0x8d, 0x91, 0xe2, 0xe2, 0x45, 0x11, 0x23, 0x45, 0x1c, 0xe2, 0x8e, 0x0b, + 0x9f, 0xa2, 0xec, 0x92, 0x28, 0xf8, 0x2b, 0x38, 0x4c, 0x89, 0x2e, 0x3f, 0x52, 0x5c, 0x23, 0x4a, + 0xa2, 0xa2, 0xd2, 0xf8, 0xeb, 0xb9, 0x6e, 0x1a, 0xe8, 0xaf, 0x57, 0x2a, 0xe1, 0x07, 0x03, 0x73, + 0xc5, 0xa7, 0x06, 0xc4, 0x72, 0x8e, 0xcf, 0x1d, 0x6b, 0x2f, 0x5d, 0x66, 0x8d, 0xe1, 0x6f, 0x1e, + 0xf8, 0x90, 0x97, 0x4a, 0x2a, 0xc4, 0x62, 0xdd, 0xbb, 0x98, 0x5f, 0x33, 0x45, 0x73, 0x12, 0xc9, + 0x0c, 0xc9, 0x94, 0xb2, 0xc4, 0x07, 0x26, 0x85, 0x2f, 0x57, 0x4a, 0xe1, 0xe7, 0x39, 0xd2, 0xb9, + 0x03, 0x72, 0xfc, 0x47, 0xfc, 0xbe, 0xe9, 0xd2, 0x51, 0x40, 0x05, 0xfc, 0x82, 0x58, 0xfe, 0x1a, + 0xad, 0x19, 0xe2, 0x96, 0xb9, 0x26, 0xcf, 0x56, 0xa2, 0x1f, 0xb9, 0xb5, 0x9b, 0x55, 0x5d, 0xba, + 0xc3, 0x7e, 0xc7, 0x0a, 0x7f, 0xf7, 0x40, 0x3f, 0x43, 0x52, 0x45, 0x4a, 0x20, 0x26, 0x73, 0x2a, + 0x25, 0xe5, 0x2c, 0x9a, 0x65, 0x1c, 0xbf, 0x8e, 0x6c, 0xb7, 0xfc, 0x6d, 0x43, 0xfe, 0xed, 0x4a, + 0xe4, 0x3f, 0x22, 0xa9, 0xae, 0x5a, 0x48, 0x67, 0x1a, 0xc8, 0xce, 0xa4, 0xee, 0x41, 0xf6, 0xdf, + 0x2e, 0xb0, 0x07, 0x3a, 0x85, 0x20, 0xa3, 0xd1, 0xd4, 0xdf, 0x31, 0xaf, 0xd4, 0xed, 0xe0, 0x39, + 0xe8, 0x96, 0x6c, 0xc6, 0x6d, 0x77, 0x0a, 0x22, 0x28, 0x8f, 0xfd, 0xc7, 0x26, 0xad, 0x27, 0x81, + 0x15, 0xdc, 0xa0, 0x16, 0xdc, 0xe0, 0xdc, 0x09, 0xee, 0x64, 0xb7, 0x09, 0xb9, 0x30, 0x11, 0xf0, + 0x03, 0xf0, 0x08, 0x73, 0xc6, 0xf4, 0x95, 0xda, 0x35, 0x52, 0xd1, 0xd1, 0xdb, 0x71, 0x0c, 0x9f, + 0x81, 0x1e, 0xe6, 0xa5, 0x2e, 0xaf, 0x40, 0x42, 0xdd, 0xb4, 0x14, 0xa8, 0x6b, 0xfc, 0x0e, 0xda, + 0xd6, 0xb6, 0x0a, 0x99, 0xa6, 0xbd, 0x5a, 0x54, 0xa1, 0x3d, 0xab, 0x42, 0xb5, 0xa9, 0x51, 0xa1, + 0xe3, 0xe7, 0x60, 0xef, 0xde, 0x03, 0x83, 0x07, 0xe0, 0x61, 0x25, 0xf1, 0x38, 0x36, 0x12, 0xba, + 0x3e, 0xb1, 0x1b, 0xf8, 0x14, 0xec, 0xd8, 0x27, 0xa7, 0x6e, 0x22, 0x7d, 0x49, 0x8c, 0x12, 0xae, + 0x4f, 0xb6, 0xeb, 0xc3, 0x2b, 0x9a, 0x93, 0xe3, 0x97, 0xa0, 0xb7, 0xfc, 0xb6, 0xeb, 0x36, 0xba, + 0xd9, 0x59, 0x54, 0xb7, 0x83, 0x43, 0xd0, 0xbd, 0xf7, 0xb8, 0x2c, 0xf2, 0xe3, 0x6a, 0xe1, 0x45, + 0x1c, 0xbf, 0x00, 0xfb, 0x4b, 0xae, 0x31, 0xfc, 0x06, 0x1c, 0x55, 0xf5, 0x7b, 0x6e, 0x69, 0x19, + 0x8a, 0x63, 0x41, 0xa4, 0xfd, 0x06, 0x36, 0x27, 0x4f, 0x1a, 0x97, 0x46, 0x9e, 0xbe, 0xb3, 0x0e, + 0x67, 0x57, 0x6f, 0x6e, 0xfb, 0xde, 0xdb, 0xdb, 0xbe, 0xf7, 0xcf, 0x6d, 0xdf, 0xfb, 0xe3, 0xae, + 0xbf, 0xf6, 0xf6, 0xae, 0xbf, 0xf6, 0xd7, 0x5d, 0x7f, 0xed, 0xe5, 0x57, 0x09, 0x55, 0x69, 0x39, + 0x0b, 0x30, 0xcf, 0x43, 0xcc, 0x65, 0xce, 0x65, 0x38, 0xbf, 0x6f, 0x9f, 0x35, 0xff, 0xd7, 0x2f, + 0x8b, 0x3f, 0x98, 0xf9, 0x9e, 0x66, 0x1d, 0x33, 0xfb, 0xcf, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, + 0x93, 0x2d, 0x0b, 0xa2, 0xd4, 0x07, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -406,6 +453,53 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TransferChannelId) > 0 { + i -= len(m.TransferChannelId) + copy(dAtA[i:], m.TransferChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.TransferChannelId))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + if len(m.CounterpartyClientId) > 0 { + i -= len(m.CounterpartyClientId) + copy(dAtA[i:], m.CounterpartyClientId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.CounterpartyClientId))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if len(m.ConnId) > 0 { + i -= len(m.ConnId) + copy(dAtA[i:], m.ConnId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConnId))) + i-- + dAtA[i] = 0x7a + } + if m.UnbondingPeriod != nil { + { + size, err := m.UnbondingPeriod.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 + } + if m.PreCCV { + i-- + if m.PreCCV { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x68 + } { size, err := m.LastTransmissionBlockHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -705,6 +799,25 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.LastTransmissionBlockHeight.Size() n += 1 + l + sovGenesis(uint64(l)) + if m.PreCCV { + n += 2 + } + if m.UnbondingPeriod != nil { + l = m.UnbondingPeriod.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ConnId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.CounterpartyClientId) + if l > 0 { + n += 2 + l + sovGenesis(uint64(l)) + } + l = len(m.TransferChannelId) + if l > 0 { + n += 2 + l + sovGenesis(uint64(l)) + } return n } @@ -1177,6 +1290,158 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PreCCV", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PreCCV = bool(v != 0) + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UnbondingPeriod == nil { + m.UnbondingPeriod = &durationpb.Duration{} + } + if err := m.UnbondingPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TransferChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/ccv/democracy/staking/expected_keepers.go b/x/ccv/democracy/staking/expected_keepers.go new file mode 100644 index 0000000000..9a7322e648 --- /dev/null +++ b/x/ccv/democracy/staking/expected_keepers.go @@ -0,0 +1,11 @@ +package staking + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" +) + +// ConsumerKeeper defines the contract needed to be fulfilled for staking module. +type ConsumerKeeper interface { + GetParams(ctx sdk.Context) consumertypes.Params +} diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index aa27177f0a..ae6adbcedf 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -29,20 +29,22 @@ type AppModule struct { // embed the Cosmos SDK's x/staking AppModule staking.AppModule - keeper keeper.Keeper - accKeeper types.AccountKeeper - bankKeeper types.BankKeeper + keeper keeper.Keeper + accKeeper types.AccountKeeper + bankKeeper types.BankKeeper + consumerKeeper ConsumerKeeper } // NewAppModule creates a new AppModule object using the native x/staking module // AppModule constructor. -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, ck ConsumerKeeper) AppModule { stakingAppMod := staking.NewAppModule(cdc, keeper, ak, bk) return AppModule{ - AppModule: stakingAppMod, - keeper: keeper, - accKeeper: ak, - bankKeeper: bk, + AppModule: stakingAppMod, + keeper: keeper, + accKeeper: ak, + bankKeeper: bk, + consumerKeeper: ck, } } @@ -54,7 +56,10 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - _ = staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState) + valUpdates := staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState) + if !am.consumerKeeper.GetParams(ctx).Enabled { + return valUpdates + } return []abci.ValidatorUpdate{} } @@ -64,6 +69,9 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // consumer chain's x/cvv/consumer module and so this module is not responsible // for returning the initial validator set. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - _ = am.keeper.BlockValidatorUpdates(ctx) + valUpdates := am.keeper.BlockValidatorUpdates(ctx) + if !am.consumerKeeper.GetParams(ctx).Enabled { + return valUpdates + } return []abci.ValidatorUpdate{} } diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 78eaa34c1a..ba8f8037b5 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -53,9 +53,9 @@ type ConsumerAdditionProposal struct { // spawn time is the time on the provider chain at which the consumer chain genesis is finalized and all validators // will be responsible for starting their consumer chain validator node. SpawnTime time.Time `protobuf:"bytes,7,opt,name=spawn_time,json=spawnTime,proto3,stdtime" json:"spawn_time"` - // BlocksPerDistributionTransmission is the number of blocks between ibc-token-transfers from the consumer chain to the provider chain. - // Note that at this transmission event a fraction of the accumulated tokens are divided and sent consumer redistribution address. - BlocksPerDistributionTransmission int64 `protobuf:"varint,8,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + UnbondingPeriod time.Duration `protobuf:"bytes,8,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` // Sent CCV related IBC packets will timeout after this duration CcvTimeoutPeriod time.Duration `protobuf:"bytes,9,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` // Sent transfer related IBC packets will timeout after this duration @@ -64,13 +64,15 @@ type ConsumerAdditionProposal struct { // during distribution events. The fraction is a string representing a // decimal number. For example "0.75" would represent 75%. ConsumerRedistributionFraction string `protobuf:"bytes,11,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` + // BlocksPerDistributionTransmission is the number of blocks between ibc-token-transfers from the consumer chain to the provider chain. + // On sending transmission event, `consumer_redistribution_fraction` of the accumulated tokens are sent to the consumer redistribution address. + BlocksPerDistributionTransmission int64 `protobuf:"varint,12,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` // The number of historical info entries to persist in store. // This param is a part of the cosmos sdk staking module. In the case of // a ccv enabled consumer chain, the ccv module acts as the staking module. - HistoricalEntries int64 `protobuf:"varint,12,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` - // Unbonding period for the consumer, - // which should be smaller than that of the provider in general. - UnbondingPeriod time.Duration `protobuf:"bytes,13,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` + HistoricalEntries int64 `protobuf:"varint,13,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` + ConnId string `protobuf:"bytes,15,opt,name=conn_id,json=connId,proto3" json:"conn_id,omitempty"` + TransferChannelId string `protobuf:"bytes,16,opt,name=transfer_channel_id,json=transferChannelId,proto3" json:"transfer_channel_id,omitempty"` } func (m *ConsumerAdditionProposal) Reset() { *m = ConsumerAdditionProposal{} } @@ -544,69 +546,72 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 992 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6f, 0xdb, 0xb6, - 0x1b, 0xb7, 0x9a, 0xc4, 0x2f, 0x74, 0xfa, 0x12, 0xb6, 0xff, 0x54, 0xce, 0xbf, 0xb0, 0x5d, 0x6f, - 0x07, 0x0f, 0x45, 0x25, 0x24, 0xbd, 0x6c, 0xc5, 0x76, 0x70, 0xdc, 0x75, 0x19, 0xb0, 0x6e, 0xae, - 0x62, 0x6c, 0xc0, 0x76, 0x10, 0x28, 0x8a, 0xb1, 0x88, 0x48, 0xa2, 0x40, 0xd2, 0x5a, 0xf2, 0x0d, - 0x76, 0x2c, 0xb0, 0x4b, 0x8f, 0xfd, 0x06, 0xfb, 0x1a, 0x3d, 0xf6, 0xb8, 0xd3, 0x36, 0x24, 0x9f, - 0x62, 0xb7, 0x81, 0xa4, 0xe4, 0xb7, 0xa6, 0x80, 0x83, 0x61, 0x37, 0xf1, 0x79, 0x7e, 0xcf, 0x8f, - 0x3f, 0x3e, 0x2f, 0xa4, 0xc0, 0x01, 0x4d, 0x25, 0xe1, 0x38, 0x42, 0x34, 0xf5, 0x05, 0xc1, 0x53, - 0x4e, 0xe5, 0xb9, 0x8b, 0x71, 0xee, 0x66, 0x9c, 0xe5, 0x34, 0x24, 0xdc, 0xcd, 0xf7, 0x67, 0xdf, - 0x4e, 0xc6, 0x99, 0x64, 0xf0, 0xa3, 0x2b, 0x62, 0x1c, 0x8c, 0x73, 0x67, 0x86, 0xcb, 0xf7, 0xf7, - 0xee, 0x4d, 0xd8, 0x84, 0x69, 0xbc, 0xab, 0xbe, 0x4c, 0xe8, 0x5e, 0x67, 0xc2, 0xd8, 0x24, 0x26, - 0xae, 0x5e, 0x05, 0xd3, 0x13, 0x57, 0xd2, 0x84, 0x08, 0x89, 0x92, 0xac, 0x00, 0xb4, 0x57, 0x01, - 0xe1, 0x94, 0x23, 0x49, 0x59, 0x5a, 0x12, 0xd0, 0x00, 0xbb, 0x98, 0x71, 0xe2, 0xe2, 0x98, 0x92, - 0x54, 0x2a, 0x79, 0xe6, 0xab, 0x00, 0xb8, 0x0a, 0x10, 0xd3, 0x49, 0x24, 0x8d, 0x59, 0xb8, 0x92, - 0xa4, 0x21, 0xe1, 0x09, 0x35, 0xe0, 0xf9, 0xca, 0x04, 0xf4, 0x7e, 0xad, 0x02, 0x7b, 0xc8, 0x52, - 0x31, 0x4d, 0x08, 0x1f, 0x84, 0x21, 0x55, 0x9b, 0x8d, 0x38, 0xcb, 0x98, 0x40, 0x31, 0xbc, 0x07, - 0xb6, 0x24, 0x95, 0x31, 0xb1, 0xad, 0xae, 0xd5, 0x6f, 0x78, 0x66, 0x01, 0xbb, 0xa0, 0x19, 0x12, - 0x81, 0x39, 0xcd, 0x14, 0xd8, 0xbe, 0xa1, 0x7d, 0x8b, 0x26, 0xd8, 0x02, 0x75, 0x93, 0x1f, 0x1a, - 0xda, 0x1b, 0xda, 0x5d, 0xd3, 0xeb, 0xaf, 0x43, 0xf8, 0x15, 0xb8, 0x45, 0x53, 0x2a, 0x29, 0x8a, - 0xfd, 0x88, 0x28, 0x9d, 0xf6, 0x66, 0xd7, 0xea, 0x37, 0x0f, 0xf6, 0x1c, 0x1a, 0x60, 0x47, 0x1d, - 0xcd, 0x29, 0x0e, 0x94, 0xef, 0x3b, 0x47, 0x1a, 0x71, 0xb8, 0xf9, 0xf6, 0x8f, 0x4e, 0xc5, 0xbb, - 0x59, 0xc4, 0x19, 0x23, 0x7c, 0x08, 0xb6, 0x27, 0x24, 0x25, 0x82, 0x0a, 0x3f, 0x42, 0x22, 0xb2, - 0xb7, 0xba, 0x56, 0x7f, 0xdb, 0x6b, 0x16, 0xb6, 0x23, 0x24, 0x22, 0xd8, 0x01, 0xcd, 0x80, 0xa6, - 0x88, 0x9f, 0x1b, 0x44, 0x55, 0x23, 0x80, 0x31, 0x69, 0xc0, 0x10, 0x00, 0x91, 0xa1, 0x9f, 0x53, - 0x5f, 0xd5, 0xc1, 0xae, 0x15, 0x42, 0x4c, 0x0d, 0x9c, 0xb2, 0x06, 0xce, 0xb8, 0x2c, 0xd2, 0x61, - 0x5d, 0x09, 0x79, 0xf5, 0x67, 0xc7, 0xf2, 0x1a, 0x3a, 0x4e, 0x79, 0xe0, 0x77, 0xe0, 0xe3, 0x20, - 0x66, 0xf8, 0x54, 0xf8, 0x19, 0xe1, 0x7e, 0x48, 0x85, 0xe4, 0x34, 0x98, 0xaa, 0x3c, 0xf8, 0x92, - 0xa3, 0x54, 0x24, 0x54, 0x08, 0x95, 0xa7, 0x7a, 0xd7, 0xea, 0x6f, 0x78, 0x0f, 0x0d, 0x76, 0x44, - 0xf8, 0xb3, 0x05, 0xe4, 0x78, 0x01, 0x08, 0x5f, 0x02, 0x88, 0x71, 0xae, 0x35, 0xb1, 0xa9, 0x54, - 0xac, 0x94, 0x85, 0x76, 0x43, 0xab, 0x6b, 0xbd, 0xa7, 0xee, 0x59, 0xd1, 0x21, 0x46, 0xdc, 0x6b, - 0x25, 0xee, 0x0e, 0xc6, 0xf9, 0xd8, 0x44, 0x8f, 0x74, 0x30, 0xfc, 0x09, 0xdc, 0xd7, 0x5a, 0x4e, - 0x08, 0x5f, 0xe5, 0x05, 0xeb, 0xf3, 0xfe, 0xaf, 0xe4, 0x58, 0x26, 0x3f, 0x02, 0x5d, 0x5c, 0x74, - 0x90, 0xcf, 0xc9, 0x52, 0x02, 0x4e, 0x38, 0xc2, 0xba, 0x49, 0x9a, 0xba, 0x0b, 0xda, 0x25, 0xce, - 0x5b, 0x82, 0x3d, 0x2f, 0x50, 0xf0, 0x31, 0x80, 0x11, 0x15, 0x92, 0x71, 0x8a, 0x51, 0xec, 0x93, - 0x54, 0x72, 0x4a, 0x84, 0xbd, 0xad, 0x13, 0xb7, 0x33, 0xf7, 0x7c, 0x69, 0x1c, 0xf0, 0x5b, 0x70, - 0x67, 0x9a, 0x06, 0x2c, 0x0d, 0x69, 0x3a, 0x29, 0x8f, 0x73, 0x73, 0xfd, 0xe3, 0xdc, 0x9e, 0x05, - 0x9b, 0x83, 0x3c, 0xad, 0xff, 0xf2, 0xa6, 0x53, 0x79, 0xfd, 0xa6, 0x53, 0xe9, 0xfd, 0x66, 0x81, - 0xfb, 0xc3, 0x99, 0xd6, 0x84, 0xe5, 0x28, 0xfe, 0x2f, 0x87, 0x62, 0x00, 0x1a, 0x42, 0xb2, 0xcc, - 0xb4, 0xe1, 0xe6, 0x35, 0xda, 0xb0, 0xae, 0xc2, 0x94, 0xa3, 0xf7, 0xf7, 0x26, 0xa8, 0x8e, 0x10, - 0x47, 0x89, 0x80, 0x63, 0x70, 0x5b, 0x92, 0x24, 0x8b, 0x91, 0x24, 0xbe, 0x99, 0x25, 0x2d, 0xb5, - 0x79, 0xf0, 0x48, 0xcf, 0xd8, 0xe2, 0xed, 0xe0, 0x2c, 0xdc, 0x07, 0xf9, 0xbe, 0x33, 0xd4, 0xd6, - 0x63, 0x89, 0x24, 0xf1, 0x6e, 0x95, 0x1c, 0xc6, 0x08, 0x3f, 0x05, 0xb6, 0xe4, 0x53, 0x21, 0xe7, - 0xb9, 0x9e, 0x57, 0xf7, 0x86, 0xae, 0xd0, 0x6e, 0xe9, 0x37, 0xe9, 0x9c, 0x55, 0xf5, 0xea, 0x7e, - 0xde, 0xf8, 0x37, 0xfd, 0x7c, 0x0c, 0xee, 0xaa, 0xdb, 0x60, 0x95, 0x73, 0x73, 0x7d, 0xce, 0x1d, - 0x15, 0xbf, 0x4c, 0xfa, 0x12, 0xc0, 0x5c, 0xe0, 0x55, 0xce, 0xad, 0x6b, 0xe8, 0xcc, 0x05, 0x5e, - 0xa6, 0x0c, 0xc1, 0x03, 0x11, 0x23, 0x11, 0xf9, 0x09, 0x91, 0x7a, 0x3a, 0xb2, 0x98, 0xa4, 0x54, - 0x44, 0x25, 0x79, 0x75, 0x7d, 0xf2, 0x96, 0x26, 0x7a, 0xa1, 0x78, 0xbc, 0x92, 0xa6, 0xd8, 0x65, - 0x08, 0xda, 0x57, 0xef, 0x32, 0x2b, 0x50, 0x4d, 0xf7, 0xdb, 0xff, 0xaf, 0xa0, 0x98, 0x55, 0xe9, - 0x33, 0xd0, 0x4a, 0xd0, 0x99, 0x9f, 0x11, 0x33, 0x4e, 0x86, 0x30, 0x43, 0xf8, 0x94, 0x48, 0x51, - 0xdc, 0x5d, 0xbb, 0x09, 0x3a, 0x1b, 0x19, 0xff, 0xb1, 0x72, 0x8f, 0x8c, 0xb7, 0x17, 0x80, 0x9d, - 0x23, 0x94, 0x86, 0x22, 0x42, 0xa7, 0xe4, 0x05, 0x91, 0x28, 0x44, 0x12, 0xc1, 0x27, 0x60, 0xb7, - 0x7c, 0x10, 0xfd, 0x13, 0x42, 0xfc, 0x8c, 0xb1, 0xd8, 0x47, 0x61, 0xc8, 0x8b, 0xb9, 0xb9, 0x5b, - 0x7a, 0x9f, 0x13, 0x32, 0x62, 0x2c, 0x1e, 0x84, 0x21, 0x87, 0x36, 0xa8, 0xe5, 0x84, 0x8b, 0xf9, - 0x04, 0x95, 0xcb, 0xde, 0x27, 0xa0, 0xa1, 0xf7, 0x1c, 0xe0, 0x53, 0x01, 0x1f, 0x80, 0x86, 0x62, - 0x22, 0x42, 0x10, 0x61, 0x5b, 0xdd, 0x8d, 0x7e, 0xc3, 0x9b, 0x1b, 0x7a, 0x12, 0xb4, 0x3e, 0xf4, - 0xa2, 0x09, 0xf8, 0x03, 0xa8, 0x15, 0x47, 0xd4, 0x81, 0xcd, 0x83, 0x2f, 0x9c, 0x35, 0xde, 0x73, - 0xe7, 0x43, 0x84, 0x5e, 0xc9, 0xd6, 0xe3, 0xf3, 0x77, 0x74, 0xe5, 0xc6, 0x10, 0xf0, 0xfb, 0xd5, - 0x4d, 0x3f, 0xbf, 0xd6, 0xa6, 0x2b, 0x7c, 0xf3, 0x3d, 0x1f, 0x81, 0xe6, 0xc0, 0x1c, 0xfb, 0x1b, - 0x2a, 0xe4, 0xfb, 0x69, 0xd9, 0x5e, 0x48, 0xcb, 0xe1, 0xf8, 0xed, 0x45, 0xdb, 0x7a, 0x77, 0xd1, - 0xb6, 0xfe, 0xba, 0x68, 0x5b, 0xaf, 0x2e, 0xdb, 0x95, 0x77, 0x97, 0xed, 0xca, 0xef, 0x97, 0xed, - 0xca, 0x8f, 0x4f, 0x27, 0x54, 0x46, 0xd3, 0xc0, 0xc1, 0x2c, 0x71, 0x31, 0x13, 0x09, 0x13, 0xee, - 0x5c, 0xde, 0xe3, 0xd9, 0x7f, 0xd1, 0xd9, 0xf2, 0x9f, 0x91, 0x3c, 0xcf, 0x88, 0x08, 0xaa, 0xba, - 0x67, 0x9f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0xbc, 0xa3, 0xcd, 0xef, 0x4a, 0x09, 0x00, 0x00, + // 1026 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0xcf, 0x6f, 0xdb, 0x36, + 0x14, 0xc7, 0xad, 0x26, 0xb1, 0x63, 0x3a, 0x6d, 0x12, 0xa6, 0x4b, 0x94, 0xac, 0xb0, 0x5d, 0x6f, + 0x87, 0x0c, 0x45, 0x25, 0x24, 0xbd, 0x6c, 0xc5, 0x76, 0x48, 0xdc, 0x75, 0x09, 0xb0, 0x6e, 0xae, + 0x12, 0x6c, 0xc0, 0x76, 0x10, 0x68, 0x8a, 0xb1, 0x88, 0x48, 0xa4, 0x40, 0xd2, 0x5a, 0xf2, 0x1f, + 0xec, 0xd8, 0x63, 0x8f, 0xfd, 0x0f, 0xf6, 0x6f, 0xf4, 0xd8, 0xe3, 0x0e, 0xc3, 0x36, 0x24, 0x7f, + 0xc5, 0x6e, 0x03, 0x49, 0xc9, 0xbf, 0x9a, 0x02, 0x0e, 0x86, 0xdd, 0x44, 0xbe, 0xef, 0xfb, 0xbc, + 0x47, 0xbd, 0xf7, 0x28, 0x81, 0x7d, 0xca, 0x14, 0x11, 0x38, 0x46, 0x94, 0x85, 0x92, 0xe0, 0xa1, + 0xa0, 0xea, 0xd2, 0xc7, 0x38, 0xf7, 0x33, 0xc1, 0x73, 0x1a, 0x11, 0xe1, 0xe7, 0x7b, 0xa3, 0x67, + 0x2f, 0x13, 0x5c, 0x71, 0xf8, 0xc9, 0x0d, 0x3e, 0x1e, 0xc6, 0xb9, 0x37, 0xd2, 0xe5, 0x7b, 0x3b, + 0xf7, 0x07, 0x7c, 0xc0, 0x8d, 0xde, 0xd7, 0x4f, 0xd6, 0x75, 0xa7, 0x35, 0xe0, 0x7c, 0x90, 0x10, + 0xdf, 0xac, 0xfa, 0xc3, 0x33, 0x5f, 0xd1, 0x94, 0x48, 0x85, 0xd2, 0xac, 0x10, 0x34, 0x67, 0x05, + 0xd1, 0x50, 0x20, 0x45, 0x39, 0x2b, 0x01, 0xb4, 0x8f, 0x7d, 0xcc, 0x05, 0xf1, 0x71, 0x42, 0x09, + 0x53, 0x3a, 0x3d, 0xfb, 0x54, 0x08, 0x7c, 0x2d, 0x48, 0xe8, 0x20, 0x56, 0x76, 0x5b, 0xfa, 0x8a, + 0xb0, 0x88, 0x88, 0x94, 0x5a, 0xf1, 0x78, 0x65, 0x1d, 0x3a, 0x7f, 0x54, 0x81, 0xdb, 0xe5, 0x4c, + 0x0e, 0x53, 0x22, 0x0e, 0xa2, 0x88, 0xea, 0x60, 0x3d, 0xc1, 0x33, 0x2e, 0x51, 0x02, 0xef, 0x83, + 0x25, 0x45, 0x55, 0x42, 0x5c, 0xa7, 0xed, 0xec, 0xd6, 0x03, 0xbb, 0x80, 0x6d, 0xd0, 0x88, 0x88, + 0xc4, 0x82, 0x66, 0x5a, 0xec, 0xde, 0x31, 0xb6, 0xc9, 0x2d, 0xb8, 0x0d, 0x96, 0xed, 0xfb, 0xa1, + 0x91, 0xbb, 0x60, 0xcc, 0x35, 0xb3, 0x3e, 0x8e, 0xe0, 0x37, 0xe0, 0x1e, 0x65, 0x54, 0x51, 0x94, + 0x84, 0x31, 0xd1, 0x79, 0xba, 0x8b, 0x6d, 0x67, 0xb7, 0xb1, 0xbf, 0xe3, 0xd1, 0x3e, 0xf6, 0xf4, + 0xd1, 0xbc, 0xe2, 0x40, 0xf9, 0x9e, 0x77, 0x64, 0x14, 0x87, 0x8b, 0x6f, 0xff, 0x6c, 0x55, 0x82, + 0xbb, 0x85, 0x9f, 0xdd, 0x84, 0x0f, 0xc1, 0xca, 0x80, 0x30, 0x22, 0xa9, 0x0c, 0x63, 0x24, 0x63, + 0x77, 0xa9, 0xed, 0xec, 0xae, 0x04, 0x8d, 0x62, 0xef, 0x08, 0xc9, 0x18, 0xb6, 0x40, 0xa3, 0x4f, + 0x19, 0x12, 0x97, 0x56, 0x51, 0x35, 0x0a, 0x60, 0xb7, 0x8c, 0xa0, 0x0b, 0x80, 0xcc, 0xd0, 0x2f, + 0x2c, 0xd4, 0x75, 0x70, 0x6b, 0x45, 0x22, 0xb6, 0x06, 0x5e, 0x59, 0x03, 0xef, 0xb4, 0x2c, 0xd2, + 0xe1, 0xb2, 0x4e, 0xe4, 0xd5, 0x5f, 0x2d, 0x27, 0xa8, 0x1b, 0x3f, 0x6d, 0x81, 0xdf, 0x81, 0xb5, + 0x21, 0xeb, 0x73, 0x16, 0x51, 0x36, 0x08, 0x33, 0x22, 0x28, 0x8f, 0xdc, 0x65, 0x83, 0xda, 0x7e, + 0x0f, 0xf5, 0xac, 0x28, 0xa7, 0x25, 0xbd, 0xd6, 0xa4, 0xd5, 0x91, 0x73, 0xcf, 0xf8, 0xc2, 0x97, + 0x00, 0x62, 0x9c, 0x9b, 0x94, 0xf8, 0x50, 0x95, 0xc4, 0xfa, 0xfc, 0xc4, 0x35, 0x8c, 0xf3, 0x53, + 0xeb, 0x5d, 0x20, 0x7f, 0x06, 0x5b, 0x4a, 0x20, 0x26, 0xcf, 0x88, 0x98, 0xe5, 0x82, 0xf9, 0xb9, + 0x1f, 0x95, 0x8c, 0x69, 0xf8, 0x11, 0x68, 0xe3, 0xa2, 0x81, 0x42, 0x41, 0x22, 0x2a, 0x95, 0xa0, + 0xfd, 0xa1, 0xf6, 0x0d, 0xcf, 0x04, 0xc2, 0xa6, 0x47, 0x1a, 0xa6, 0x09, 0x9a, 0xa5, 0x2e, 0x98, + 0x92, 0x3d, 0x2f, 0x54, 0xf0, 0x7b, 0xf0, 0x69, 0x3f, 0xe1, 0xf8, 0x5c, 0xea, 0xe4, 0xc2, 0x29, + 0x92, 0x09, 0x9d, 0x52, 0x29, 0x35, 0x6d, 0xa5, 0xed, 0xec, 0x2e, 0x04, 0x0f, 0xad, 0xb6, 0x47, + 0xc4, 0xb3, 0x09, 0xe5, 0xe9, 0x84, 0x10, 0x3e, 0x06, 0x30, 0xa6, 0x52, 0x71, 0x41, 0x31, 0x4a, + 0x42, 0xc2, 0x94, 0xa0, 0x44, 0xba, 0x77, 0x8d, 0xfb, 0xfa, 0xd8, 0xf2, 0xb5, 0x35, 0xc0, 0x2d, + 0x50, 0xc3, 0x9c, 0x99, 0xae, 0x5d, 0x35, 0x09, 0x57, 0xf5, 0xf2, 0x38, 0x82, 0x1e, 0xd8, 0x18, + 0xbd, 0x3f, 0x1c, 0x23, 0xc6, 0x48, 0xa2, 0x45, 0x6b, 0x46, 0xb4, 0x5e, 0x9a, 0xba, 0xd6, 0x72, + 0x1c, 0x3d, 0x5d, 0xfe, 0xf5, 0x4d, 0xab, 0xf2, 0xfa, 0x4d, 0xab, 0xd2, 0xf9, 0xcd, 0x01, 0x5b, + 0xdd, 0xd1, 0xa9, 0x53, 0x9e, 0xa3, 0xe4, 0xff, 0x9c, 0xae, 0x03, 0x50, 0x97, 0x8a, 0x67, 0xb6, + 0x9f, 0x17, 0x6f, 0xd1, 0xcf, 0xcb, 0xda, 0x4d, 0x1b, 0x3a, 0xff, 0x2c, 0x82, 0x6a, 0x0f, 0x09, + 0x94, 0x4a, 0x78, 0x0a, 0x56, 0x15, 0x49, 0xb3, 0x04, 0x29, 0x12, 0xda, 0xa1, 0x34, 0xa9, 0x36, + 0xf6, 0x1f, 0x99, 0x61, 0x9d, 0xbc, 0x66, 0xbc, 0x89, 0x8b, 0x25, 0xdf, 0xf3, 0xba, 0x66, 0xf7, + 0x44, 0x21, 0x45, 0x82, 0x7b, 0x25, 0xc3, 0x6e, 0xc2, 0xcf, 0x81, 0xab, 0xc4, 0x50, 0xaa, 0xf1, + 0xb8, 0x8c, 0xfb, 0xe4, 0x8e, 0x29, 0xcd, 0x66, 0x69, 0xb7, 0x1d, 0x36, 0xea, 0x8f, 0x9b, 0x27, + 0x63, 0xe1, 0xbf, 0x4c, 0xc6, 0x09, 0xd8, 0xd0, 0xd7, 0xca, 0x2c, 0x73, 0x71, 0x7e, 0xe6, 0xba, + 0xf6, 0x9f, 0x86, 0xbe, 0x04, 0x30, 0x97, 0x78, 0x96, 0xb9, 0x74, 0x8b, 0x3c, 0x73, 0x89, 0xa7, + 0x91, 0x11, 0x78, 0x20, 0x13, 0x24, 0xe3, 0x30, 0x25, 0xca, 0xcc, 0x59, 0x96, 0x10, 0x46, 0x65, + 0x5c, 0xc2, 0xab, 0xf3, 0xc3, 0xb7, 0x0d, 0xe8, 0x85, 0xe6, 0x04, 0x25, 0xa6, 0x88, 0xd2, 0x05, + 0xcd, 0x9b, 0xa3, 0x8c, 0x0a, 0x54, 0x33, 0xfd, 0xf6, 0xf1, 0x0d, 0x88, 0x51, 0x95, 0xbe, 0x00, + 0xdb, 0x29, 0xba, 0x08, 0x33, 0x62, 0x6f, 0x44, 0x0b, 0xcc, 0x10, 0x3e, 0x27, 0x4a, 0x9a, 0x8b, + 0x71, 0x21, 0xd8, 0x4c, 0xd1, 0x45, 0xcf, 0xda, 0x4f, 0xb4, 0xb9, 0x67, 0xad, 0x9d, 0x3e, 0x58, + 0x3f, 0x42, 0x2c, 0x92, 0x31, 0x3a, 0x27, 0x2f, 0x88, 0x42, 0x11, 0x52, 0x08, 0x3e, 0x01, 0x9b, + 0xe5, 0x97, 0x35, 0x3c, 0x23, 0x24, 0xcc, 0x38, 0x4f, 0x42, 0x14, 0x45, 0xa2, 0x98, 0x9b, 0x8d, + 0xd2, 0xfa, 0x9c, 0x90, 0x1e, 0xe7, 0xc9, 0x41, 0x14, 0x09, 0xe8, 0x82, 0x5a, 0x4e, 0x84, 0x1c, + 0x4f, 0x50, 0xb9, 0xec, 0x7c, 0x06, 0xea, 0x26, 0xe6, 0x01, 0x3e, 0x97, 0xf0, 0x01, 0xa8, 0x6b, + 0x12, 0x91, 0x92, 0x48, 0xd7, 0x69, 0x2f, 0xec, 0xd6, 0x83, 0xf1, 0x46, 0x47, 0x81, 0xed, 0x0f, + 0x7d, 0x1a, 0x25, 0xfc, 0x11, 0xd4, 0x8a, 0x23, 0x1a, 0xc7, 0xc6, 0xfe, 0x57, 0xde, 0x1c, 0x3f, + 0x06, 0xde, 0x87, 0x80, 0x41, 0x49, 0xeb, 0x88, 0xf1, 0x07, 0x79, 0xe6, 0xc6, 0x90, 0xf0, 0x87, + 0xd9, 0xa0, 0x5f, 0xde, 0x2a, 0xe8, 0x0c, 0x6f, 0x1c, 0xf3, 0x11, 0x68, 0x1c, 0xd8, 0x63, 0x7f, + 0x4b, 0xa5, 0x7a, 0xff, 0xb5, 0xac, 0x4c, 0xbc, 0x96, 0xc3, 0xd3, 0xb7, 0x57, 0x4d, 0xe7, 0xdd, + 0x55, 0xd3, 0xf9, 0xfb, 0xaa, 0xe9, 0xbc, 0xba, 0x6e, 0x56, 0xde, 0x5d, 0x37, 0x2b, 0xbf, 0x5f, + 0x37, 0x2b, 0x3f, 0x3d, 0x1d, 0x50, 0x15, 0x0f, 0xfb, 0x1e, 0xe6, 0xa9, 0x8f, 0xb9, 0x4c, 0xb9, + 0xf4, 0xc7, 0xe9, 0x3d, 0x1e, 0xfd, 0x60, 0x5d, 0x4c, 0xff, 0x62, 0xa9, 0xcb, 0x8c, 0xc8, 0x7e, + 0xd5, 0xf4, 0xec, 0x93, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xbe, 0x72, 0xa9, 0x93, 0x09, + 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -629,17 +634,30 @@ func (m *ConsumerAdditionProposal) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err1 != nil { - return 0, err1 + if len(m.TransferChannelId) > 0 { + i -= len(m.TransferChannelId) + copy(dAtA[i:], m.TransferChannelId) + i = encodeVarintProvider(dAtA, i, uint64(len(m.TransferChannelId))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if len(m.ConnId) > 0 { + i -= len(m.ConnId) + copy(dAtA[i:], m.ConnId) + i = encodeVarintProvider(dAtA, i, uint64(len(m.ConnId))) + i-- + dAtA[i] = 0x7a } - i -= n1 - i = encodeVarintProvider(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x6a if m.HistoricalEntries != 0 { i = encodeVarintProvider(dAtA, i, uint64(m.HistoricalEntries)) i-- + dAtA[i] = 0x68 + } + if m.BlocksPerDistributionTransmission != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) + i-- dAtA[i] = 0x60 } if len(m.ConsumerRedistributionFraction) > 0 { @@ -649,27 +667,30 @@ func (m *ConsumerAdditionProposal) MarshalToSizedBuffer(dAtA []byte) (int, error i-- dAtA[i] = 0x5a } - n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintProvider(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x52 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) if err2 != nil { return 0, err2 } i -= n2 i = encodeVarintProvider(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x52 - n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + dAtA[i] = 0x4a + n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) if err3 != nil { return 0, err3 } i -= n3 i = encodeVarintProvider(dAtA, i, uint64(n3)) i-- - dAtA[i] = 0x4a - if m.BlocksPerDistributionTransmission != 0 { - i = encodeVarintProvider(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) - i-- - dAtA[i] = 0x40 - } + dAtA[i] = 0x42 n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.SpawnTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.SpawnTime):]) if err4 != nil { return 0, err4 @@ -1078,9 +1099,8 @@ func (m *ConsumerAdditionProposal) Size() (n int) { } l = github_com_gogo_protobuf_types.SizeOfStdTime(m.SpawnTime) n += 1 + l + sovProvider(uint64(l)) - if m.BlocksPerDistributionTransmission != 0 { - n += 1 + sovProvider(uint64(m.BlocksPerDistributionTransmission)) - } + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod) + n += 1 + l + sovProvider(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.CcvTimeoutPeriod) n += 1 + l + sovProvider(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.TransferTimeoutPeriod) @@ -1089,11 +1109,20 @@ func (m *ConsumerAdditionProposal) Size() (n int) { if l > 0 { n += 1 + l + sovProvider(uint64(l)) } + if m.BlocksPerDistributionTransmission != 0 { + n += 1 + sovProvider(uint64(m.BlocksPerDistributionTransmission)) + } if m.HistoricalEntries != 0 { n += 1 + sovProvider(uint64(m.HistoricalEntries)) } - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod) - n += 1 + l + sovProvider(uint64(l)) + l = len(m.ConnId) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = len(m.TransferChannelId) + if l > 0 { + n += 2 + l + sovProvider(uint64(l)) + } return n } @@ -1494,10 +1523,10 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerDistributionTransmission", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) } - m.BlocksPerDistributionTransmission = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -1507,11 +1536,25 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) @@ -1611,6 +1654,25 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { m.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerDistributionTransmission", wireType) + } + m.BlocksPerDistributionTransmission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) } @@ -1629,11 +1691,11 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { break } } - case 13: + case 15: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConnId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -1643,24 +1705,55 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthProvider } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err + m.ConnId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.TransferChannelId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From aa566c92df42a4789e4ca7b2b0cd72bf91bb1286 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Tue, 20 Dec 2022 00:03:27 +0800 Subject: [PATCH 02/71] add preCCV store and use it on democracy staking --- x/ccv/consumer/keeper/genesis.go | 1 + x/ccv/consumer/keeper/keeper.go | 19 +++++++++++++++++++ x/ccv/consumer/types/keys.go | 7 +++++++ x/ccv/democracy/staking/expected_keepers.go | 1 + x/ccv/democracy/staking/module.go | 4 ++-- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 14b0c9c9d1..76c3e86296 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -20,6 +20,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) // PreCCV is true when consumer chain used to be running on non-consumer chain, and when it is in the progress of upgrading // to consumer chain, where consumer chain upgrade is done. if state.PreCCV { + k.SetPreCCV(ctx) return []abci.ValidatorUpdate{} } diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index e04b00a965..c94c11acb8 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -206,6 +206,25 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } +func (k Keeper) IsPreCCV(ctx sdk.Context) bool { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.PreCCVKey()) + if bz != nil { + return true + } + return false +} + +func (k Keeper) SetPreCCV(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PreCCVKey(), []byte{1}) +} + +func (k Keeper) DeletePreCCV(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.PreCCVKey()) +} + // IteratePacketMaturityTime iterates through the VSC packet maturity times set in the store func (k Keeper) IteratePacketMaturityTime(ctx sdk.Context, cb func(vscId, timeNs uint64) (stop bool)) { store := ctx.KVStore(k.storeKey) diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 46fb5e9b8a..185050974f 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -67,6 +67,9 @@ const ( // CrossChainValidatorPrefix is the byte prefix that will store cross-chain validators by consensus address CrossChainValidatorBytePrefix + + // PreCCVPrefix is the byte prefix to store the consumer is running on democracy staking module without consumer + PreCCVPrefix ) // PortKey returns the key to the port ID in the store @@ -99,6 +102,10 @@ func PendingChangesKey() []byte { return []byte{PendingChangesByteKey} } +func PreCCVKey() []byte { + return []byte{PreCCVPrefix} +} + // PacketMaturityTimeKey returns the key for storing maturity time for a given received VSC packet id func PacketMaturityTimeKey(id uint64) []byte { seqBytes := make([]byte, 8) diff --git a/x/ccv/democracy/staking/expected_keepers.go b/x/ccv/democracy/staking/expected_keepers.go index 9a7322e648..66cb093d37 100644 --- a/x/ccv/democracy/staking/expected_keepers.go +++ b/x/ccv/democracy/staking/expected_keepers.go @@ -8,4 +8,5 @@ import ( // ConsumerKeeper defines the contract needed to be fulfilled for staking module. type ConsumerKeeper interface { GetParams(ctx sdk.Context) consumertypes.Params + IsPreCCV(ctx sdk.Context) bool } diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index ae6adbcedf..9180652acf 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -57,7 +57,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. cdc.MustUnmarshalJSON(data, &genesisState) valUpdates := staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState) - if !am.consumerKeeper.GetParams(ctx).Enabled { + if am.consumerKeeper.IsPreCCV(ctx) { return valUpdates } @@ -70,7 +70,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // for returning the initial validator set. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { valUpdates := am.keeper.BlockValidatorUpdates(ctx) - if !am.consumerKeeper.GetParams(ctx).Enabled { + if am.consumerKeeper.IsPreCCV(ctx) { return valUpdates } return []abci.ValidatorUpdate{} From dc9768de8064b4c749d6318cab46098be2f70df8 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Tue, 20 Dec 2022 00:46:57 +0800 Subject: [PATCH 03/71] add TODOs and one more packet possibility --- proto/interchain_security/ccv/provider/v1/provider.proto | 2 ++ proto/interchain_security/ccv/v1/ccv.proto | 8 ++++++++ x/ccv/consumer/ibc_module.go | 1 + x/ccv/provider/keeper/relay.go | 1 + 4 files changed, 12 insertions(+) diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index cdb24198e4..afb19b755a 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -61,6 +61,8 @@ message ConsumerAdditionProposal { int64 historical_entries = 13; string conn_id = 15; // the ID of the connection end on the consumer chain on top of which the CCV channel will be established. string transfer_channel_id = 16; // the ID of a token transfer channel used for the Reward Distribution sub-protocol. + // TODO: preCCV field shouldn't be added here? to make sure if it's a new chain with consumer initial validator set + // or if initial validator set will be provided from provider chain via packet } // ConsumerRemovalProposal is a governance proposal on the provider chain to remove (and stop) a consumer chain. diff --git a/proto/interchain_security/ccv/v1/ccv.proto b/proto/interchain_security/ccv/v1/ccv.proto index f25b997356..dd59456861 100644 --- a/proto/interchain_security/ccv/v1/ccv.proto +++ b/proto/interchain_security/ccv/v1/ccv.proto @@ -9,6 +9,14 @@ import "cosmos/staking/v1beta1/staking.proto"; import "gogoproto/gogo.proto"; import "tendermint/abci/types.proto"; +// This packet is to send for preCCV chain, and once it's received consumer chain sends VSCMaturedPacketData +// and consumer chain becomes preCCV chain as false, and provider chain record preCCV field as false on provider chain +message ReplaceWholeValidatorSet { + repeated .tendermint.abci.ValidatorUpdate initial_val_set = 1 + [ (gogoproto.nullable) = false ]; + uint64 valset_update_id = 2; +} + // This packet is sent from provider chain to consumer chain if the validator // set for consumer chain changes (due to new bonding/unbonding messages or // slashing events) A VSCMatured packet from consumer chain will be sent diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 59e5382040..d18edddf90 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -213,6 +213,7 @@ func (am AppModule) OnRecvPacket( errAck := channeltypes.NewErrorAcknowledgement("cannot unmarshal CCV packet data") ack = &errAck } else { + // TODO: add possibility to receive ReplaceValidatorSet if it's the first time switching to consumer chain ack = am.keeper.OnRecvVSCPacket(ctx, packet, data) } diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 9b3cc39fc3..d8485dc6af 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -161,6 +161,7 @@ func (k Keeper) SendVSCPackets(ctx sdk.Context) { // SendVSCPacketsToChain sends all queued VSC packets to the specified chain func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string) { + // TODO: send init genesis packet if target chain is preCCV? pendingPackets := k.GetPendingVSCPackets(ctx, chainID) for _, data := range pendingPackets { // send packet over IBC From 473e467adcf1e0b90aa726028e433e7ac6023fa2 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Thu, 29 Dec 2022 01:35:07 +0800 Subject: [PATCH 04/71] status update --- app/consumer-democracy/app.go | 31 +- app/consumer/app.go | 2 +- app/sovereign/app.go | 808 ++++++++++++++++++ app/sovereign/encoding.go | 38 + app/sovereign/export.go | 201 +++++ app/sovereign/genesis.go | 20 + app/sovereign/upgrades.go | 31 + app/sovereign/upgrades/v3/upgrades.go | 26 + cmd/interchain-security-sd/main.go | 32 + consumer/README.md | 64 ++ consumer/build_binaries.sh | 6 + consumer/run.sh | 6 + consumer/start_consumer.sh | 315 +++++++ consumer/start_provider.sh | 134 +++ .../ccv/consumer/v1/genesis.proto | 9 +- .../ccv/provider/v1/provider.proto | 6 +- proto/interchain_security/ccv/v1/ccv.proto | 8 - x/ccv/consumer/keeper/genesis.go | 19 +- x/ccv/consumer/keeper/keeper.go | 21 +- x/ccv/consumer/keeper/relay.go | 1 - x/ccv/consumer/keeper/validators.go | 2 + x/ccv/consumer/module.go | 36 +- x/ccv/consumer/types/genesis.pb.go | 327 ++----- x/ccv/provider/keeper/relay.go | 1 - x/ccv/provider/types/provider.pb.go | 221 ++--- 25 files changed, 1906 insertions(+), 459 deletions(-) create mode 100644 app/sovereign/app.go create mode 100644 app/sovereign/encoding.go create mode 100644 app/sovereign/export.go create mode 100644 app/sovereign/genesis.go create mode 100644 app/sovereign/upgrades.go create mode 100644 app/sovereign/upgrades/v3/upgrades.go create mode 100644 cmd/interchain-security-sd/main.go create mode 100644 consumer/README.md create mode 100644 consumer/build_binaries.sh create mode 100644 consumer/run.sh create mode 100644 consumer/start_consumer.sh create mode 100644 consumer/start_provider.sh diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index fa4eb46a32..296bdf0e14 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -8,6 +8,8 @@ import ( "os" "path/filepath" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -436,7 +438,7 @@ func New( // register slashing module StakingHooks to the consumer keeper app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) - consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper) + consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper, app.StakingKeeper) app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, @@ -625,6 +627,8 @@ func New( app.UpgradeKeeper.SetUpgradeHandler( upgradeName, func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + fmt.Println("UPGRADING DATA!!!", upgradeName) + app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) fromVM := make(map[string]uint64) @@ -633,6 +637,26 @@ func New( fromVM[moduleName] = eachModule.ConsensusVersion() } + // TODO: should have a way to read from current node home + userHomeDir, err := os.UserHomeDir() + if err != nil { + stdlog.Println("Failed to get home dir %2", err) + } + nodeHome := userHomeDir + "/.sovereign/config/genesis.json" + fmt.Println("NodeHome:", nodeHome) + appState, _, err := genutiltypes.GenesisStateFromGenFile(nodeHome) + if err != nil { + return fromVM, fmt.Errorf("failed to unmarshal genesis state: %w", err) + } + + var consumerGenesis = ibcconsumertypes.GenesisState{} + appCodec.MustUnmarshalJSON(appState[ibcconsumertypes.ModuleName], &consumerGenesis) + + fmt.Println("appState[ibcconsumertypes.ModuleName]", string(appState[ibcconsumertypes.ModuleName])) + consumerGenesis.PreCCV = true + fmt.Println("consumerGenesis", consumerGenesis) + app.ConsumerKeeper.InitGenesis(ctx, &consumerGenesis) + ctx.Logger().Info("start to run module migrations...") return app.MM.RunMigrations(ctx, app.configurator, fromVM) @@ -645,7 +669,10 @@ func New( } if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := store.StoreUpgrades{} + fmt.Println("UPGRADING STORAGE!!!", upgradeName) + storeUpgrades := store.StoreUpgrades{ + Added: []string{ibcconsumertypes.ModuleName}, + } // configure store loader that checks if version == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) diff --git a/app/consumer/app.go b/app/consumer/app.go index 2da5e560eb..ce343a9f52 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -344,7 +344,7 @@ func New( // register slashing module Slashing hooks to the consumer keeper app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) - consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper) + consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper, nil) app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, diff --git a/app/sovereign/app.go b/app/sovereign/app.go new file mode 100644 index 0000000000..73ca49b716 --- /dev/null +++ b/app/sovereign/app.go @@ -0,0 +1,808 @@ +package app + +import ( + "io" + "os" + "path/filepath" + + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" + "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/server/api" + "github.com/cosmos/cosmos-sdk/server/config" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/capability" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/cosmos/cosmos-sdk/x/crisis" + crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/evidence" + evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/cosmos/cosmos-sdk/x/params" + paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/x/slashing" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" + upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" + upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/cosmos/ibc-go/v3/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v3/modules/core" + ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" + ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client" + ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + "github.com/spf13/cast" + "github.com/tendermint/spm/cosmoscmd" + abci "github.com/tendermint/tendermint/abci/types" + tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/tendermint/tendermint/libs/log" + tmos "github.com/tendermint/tendermint/libs/os" + dbm "github.com/tendermint/tm-db" + + // add mint + mint "github.com/cosmos/cosmos-sdk/x/mint" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" + icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" +) + +const ( + AccountAddressPrefix = "cosmos" + AppName = "interchain-security-sovereign" + Version = "3.0.0" +) + +// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals + +func getGovProposalHandlers() []govclient.ProposalHandler { + var govProposalHandlers []govclient.ProposalHandler + // this line is used by starport scaffolding # stargate/app/govProposalHandlers + + govProposalHandlers = append(govProposalHandlers, + paramsclient.ProposalHandler, + distrclient.ProposalHandler, + upgradeclient.ProposalHandler, + upgradeclient.CancelProposalHandler, + ibcclientclient.UpdateClientProposalHandler, + ibcclientclient.UpgradeProposalHandler, + // this line is used by starport scaffolding # stargate/app/govProposalHandler + ) + + return govProposalHandlers +} + +var ( + // DefaultNodeHome default home directories for the application daemon + DefaultNodeHome string + + // ModuleBasics defines the module BasicManager is in charge of setting up basic, + // non-dependant module elements, such as codec registration + // and genesis verification. + ModuleBasics = module.NewBasicManager( + auth.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + genutil.AppModuleBasic{}, + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic(getGovProposalHandlers()...), + params.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + ibc.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + transfer.AppModuleBasic{}, + vesting.AppModuleBasic{}, + ica.AppModuleBasic{}, + mint.AppModuleBasic{}, + ) + + // module account permissions + maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + // mint module needs burn access to remove excess validator tokens (it overallocates, then burns) + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + icatypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + // this line is used by starport scaffolding # stargate/app/maccPerms + } +) + +var ( + _ servertypes.Application = (*SovereignApp)(nil) +) + +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) +} + +// SovereignApp extends an ABCI application, but with most of its parameters exported. +// They are exported for convenience in creating helper functions, as object +// capabilities aren't needed for testing. +type SovereignApp struct { + *baseapp.BaseApp + + cdc *codec.LegacyAmino + appCodec codec.Codec + interfaceRegistry types.InterfaceRegistry + + invCheckPeriod uint + + // keys to access the substores + keys map[string]*sdk.KVStoreKey + tkeys map[string]*sdk.TransientStoreKey + memKeys map[string]*sdk.MemoryStoreKey + + // keepers + AccountKeeper authkeeper.AccountKeeper + AuthzKeeper authzkeeper.Keeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + // MonitoringKeeper monitoringpkeeper.Keeper + ICAControllerKeeper icacontrollerkeeper.Keeper + ICAHostKeeper icahostkeeper.Keeper + + // make scoped keepers public for test purposes + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + // ScopedMonitoringKeeper capabilitykeeper.ScopedKeeper + ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + + ScopedStakeibcKeeper capabilitykeeper.ScopedKeeper + + ScopedRecordsKeeper capabilitykeeper.ScopedKeeper + ScopedIcacallbacksKeeper capabilitykeeper.ScopedKeeper + // this line is used by starport scaffolding # stargate/app/keeperDeclaration + + mm *module.Manager + sm *module.SimulationManager + configurator module.Configurator +} + +// RUN GOSEC +// New returns a reference to an initialized blockchain app +func New( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + skipUpgradeHeights map[int64]bool, + homePath string, + invCheckPeriod uint, + encodingConfig cosmoscmd.EncodingConfig, + appOpts servertypes.AppOptions, + baseAppOptions ...func(*baseapp.BaseApp), +) cosmoscmd.App { + appCodec := encodingConfig.Marshaler + cdc := encodingConfig.Amino + interfaceRegistry := encodingConfig.InterfaceRegistry + + bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp.SetCommitMultiStoreTracer(traceStore) + bApp.SetVersion(Version) + bApp.SetInterfaceRegistry(interfaceRegistry) + + keys := sdk.NewKVStoreKeys( + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, // monitoringptypes.StoreKey, + icacontrollertypes.StoreKey, icahosttypes.StoreKey, + authzkeeper.StoreKey, + // this line is used by starport scaffolding # stargate/app/storeKey + ) + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + app := &SovereignApp{ + BaseApp: bApp, + cdc: cdc, + appCodec: appCodec, + interfaceRegistry: interfaceRegistry, + invCheckPeriod: invCheckPeriod, + keys: keys, + tkeys: tkeys, + memKeys: memKeys, + } + + app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + + // set the BaseApp's parameter store + bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) + + // add capability keeper and ScopeToModule for ibc module + app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + + // grant capabilities for the ibc and ibc-transfer modules + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) + scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + // this line is used by starport scaffolding # stargate/app/scopedKeeper + + // add keepers + app.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, + ) + + app.AuthzKeeper = authzkeeper.NewKeeper( + keys[authzkeeper.StoreKey], + appCodec, + app.BaseApp.MsgServiceRouter(), + ) + + app.BankKeeper = bankkeeper.NewBaseKeeper( + appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), + ) + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), + ) + + app.DistrKeeper = distrkeeper.NewKeeper( + appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, + &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + ) + + app.MintKeeper = mintkeeper.NewKeeper( + appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, + app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, + ) + + app.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), + ) + app.CrisisKeeper = crisiskeeper.NewKeeper( + app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, + ) + + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) + app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) + + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + app.StakingKeeper = *stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), + ) + + // ... other modules keepers + + // Create IBC Keeper + app.IBCKeeper = ibckeeper.NewKeeper( + appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + ) + + // Create Transfer Keepers + app.TransferKeeper = ibctransferkeeper.NewKeeper( + appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + ) + transferModule := transfer.NewAppModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) + + // Create evidence Keeper for to register the IBC light client misbehaviour evidence route + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper, + ) + // If evidence needs to be handled for the app, set routes in router here and seal + app.EvidenceKeeper = *evidenceKeeper + + // TODO(TEST-20): look for all lines that include 'monitoring' in this file! there are a few places this + // is commented out + // scopedMonitoringKeeper := app.CapabilityKeeper.ScopeToModule(monitoringptypes.ModuleName) + // app.MonitoringKeeper = *monitoringpkeeper.NewKeeper( + // appCodec, + // keys[monitoringptypes.StoreKey], + // keys[monitoringptypes.MemStoreKey], + // app.GetSubspace(monitoringptypes.ModuleName), + // app.StakingKeeper, + // app.IBCKeeper.ClientKeeper, + // app.IBCKeeper.ConnectionKeeper, + // app.IBCKeeper.ChannelKeeper, + // &app.IBCKeeper.PortKeeper, + // scopedMonitoringKeeper, + // ) + // monitoringModule := monitoringp.NewAppModule(appCodec, app.MonitoringKeeper) + + // Note: must be above app.StakeibcKeeper + app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + scopedICAControllerKeeper, app.MsgServiceRouter(), + ) + + // Register Gov (must be registerd after stakeibc) + govRouter := govtypes.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + + app.GovKeeper = govkeeper.NewKeeper( + appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, + &stakingKeeper, govRouter, + ) + + // this line is used by starport scaffolding # stargate/app/keeperDefinition + + // create IBC middleware stacks by combining middleware with base application + app.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), + ) + icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper) + + // Create the middleware stacks + + // Stack one contains + // - IBC + // - ICA + // - icacallbacks + // - stakeibc + // - base app + var icamiddlewareStack porttypes.IBCModule + icamiddlewareStack = icacontroller.NewIBCModule(app.ICAControllerKeeper, icamiddlewareStack) + icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) + + // Create static IBC router, add transfer route, then set and seal it + ibcRouter := ibcporttypes.NewRouter() + ibcRouter. + AddRoute(ibctransfertypes.ModuleName, transferIBCModule). + AddRoute(icacontrollertypes.SubModuleName, icamiddlewareStack). + AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) + // this line is used by starport scaffolding # ibc/app/router + app.IBCKeeper.SetRouter(ibcRouter) + + /**** Module Options ****/ + + // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment + // we prefer to be more strict in what arguments the modules expect. + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + + // NOTE: Any module instantiated in the module manager that is later modified + // must be passed by reference here. + + app.mm = module.NewManager( + genutil.NewAppModule( + app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + encodingConfig.TxConfig, + ), + auth.NewAppModule(appCodec, app.AccountKeeper, nil), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + ibc.NewAppModule(app.IBCKeeper), + params.NewAppModule(app.ParamsKeeper), + transferModule, + // monitoringModule, + icaModule, + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + // this line is used by starport scaffolding # stargate/app/appModule + ) + + // During begin block slashing happens after distr.BeginBlocker so that + // there is nothing left over in the validator fee pool, so as to keep the + // CanWithdrawInvariant invariant. + // NOTE: staking module is required if HistoricalEntries param > 0 + app.mm.SetOrderBeginBlockers( + upgradetypes.ModuleName, + capabilitytypes.ModuleName, + minttypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + vestingtypes.ModuleName, + ibchost.ModuleName, + ibctransfertypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + govtypes.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + // monitoringptypes.ModuleName, + icatypes.ModuleName, + authz.ModuleName, + // this line is used by starport scaffolding # stargate/app/beginBlockers + ) + + app.mm.SetOrderEndBlockers( + crisistypes.ModuleName, + govtypes.ModuleName, + stakingtypes.ModuleName, + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + minttypes.ModuleName, + vestingtypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + ibchost.ModuleName, + ibctransfertypes.ModuleName, + // monitoringptypes.ModuleName, + icatypes.ModuleName, + authz.ModuleName, + // this line is used by starport scaffolding # stargate/app/endBlockers + ) + + // NOTE: The genutils module must occur after staking so that pools are + // properly initialized with tokens from genesis accounts. + // NOTE: Capability module must occur first so that it can initialize any capabilities + // so that other modules that want to create or claim capabilities afterwards in InitChain + // can do so safely. + app.mm.SetOrderInitGenesis( + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + vestingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + crisistypes.ModuleName, + ibchost.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + ibctransfertypes.ModuleName, + feegrant.ModuleName, + // monitoringptypes.ModuleName, + icatypes.ModuleName, + authz.ModuleName, + // this line is used by starport scaffolding # stargate/app/initGenesis + ) + + app.mm.RegisterInvariants(&app.CrisisKeeper) + app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(app.configurator) + app.setupUpgradeHandlers() + + // create the simulation manager and define the order of the modules for deterministic simulations + // app.sm = module.NewSimulationManager( + // auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), + // bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + // capability.NewAppModule(appCodec, *app.CapabilityKeeper), + // feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + // gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + // mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + // staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + // distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + // slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + // params.NewAppModule(app.ParamsKeeper), + // evidence.NewAppModule(app.EvidenceKeeper), + // ibc.NewAppModule(app.IBCKeeper), + // transferModule, + // // monitoringModule, + // stakeibcModule, + // epochsModule, + // interchainQueryModule, + // recordsModule, + // icacallbacksModule, + // this line is used by starport scaffolding # stargate/app/appModule + // ) + // app.sm.RegisterStoreDecoders() + + // initialize stores + app.MountKVStores(keys) + app.MountTransientStores(tkeys) + app.MountMemoryStores(memKeys) + + // initialize BaseApp + app.SetInitChainer(app.InitChainer) + app.SetBeginBlocker(app.BeginBlocker) + + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + FeegrantKeeper: app.FeeGrantKeeper, + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + ) + if err != nil { + panic(err) + } + + app.SetAnteHandler(anteHandler) + app.SetEndBlocker(app.EndBlocker) + + if loadLatest { + if err := app.LoadLatestVersion(); err != nil { + tmos.Exit(err.Error()) + } + } + + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedTransferKeeper = scopedTransferKeeper + // app.ScopedMonitoringKeeper = scopedMonitoringKeeper + app.ScopedICAControllerKeeper = scopedICAControllerKeeper + app.ScopedICAHostKeeper = scopedICAHostKeeper + // this line is used by starport scaffolding # stargate/app/beforeInitReturn + + return app +} + +// Name returns the name of the App +func (app *SovereignApp) Name() string { return app.BaseApp.Name() } + +// GetBaseApp returns the base app of the application +func (app *SovereignApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } + +// GetStakingKeeper implements the TestingApp interface. +func (app *SovereignApp) GetStakingKeeper() stakingkeeper.Keeper { + return app.StakingKeeper +} + +// GetIBCKeeper implements the TestingApp interface. +func (app *SovereignApp) GetTransferKeeper() *ibctransferkeeper.Keeper { + return &app.TransferKeeper +} + +// GetIBCKeeper implements the TestingApp interface. +func (app *SovereignApp) GetIBCKeeper() *ibckeeper.Keeper { + return app.IBCKeeper +} + +// GetScopedIBCKeeper implements the TestingApp interface. +func (app *SovereignApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { + return app.ScopedIBCKeeper +} + +// GetTxConfig implements the TestingApp interface. +func (app *SovereignApp) GetTxConfig() client.TxConfig { + cfg := MakeEncodingConfig() + return cfg.TxConfig +} + +// BeginBlocker application updates every begin block +func (app *SovereignApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + return app.mm.BeginBlock(ctx, req) +} + +// EndBlocker application updates every end block +func (app *SovereignApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { + return app.mm.EndBlock(ctx, req) +} + +// InitChainer application update at chain initialization +func (app *SovereignApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { + var genesisState GenesisState + if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { + panic(err) + } + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + return app.mm.InitGenesis(ctx, app.appCodec, genesisState) +} + +// LoadHeight loads a particular height +func (app *SovereignApp) LoadHeight(height int64) error { + return app.LoadVersion(height) +} + +// ModuleAccountAddrs returns all the app's module account addresses. +func (app *SovereignApp) ModuleAccountAddrs() map[string]bool { + modAccAddrs := make(map[string]bool) + for acc := range maccPerms { + modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + + return modAccAddrs +} + +// LegacyAmino returns SimApp's amino codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *SovereignApp) LegacyAmino() *codec.LegacyAmino { + return app.cdc +} + +// AppCodec returns an app codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *SovereignApp) AppCodec() codec.Codec { + return app.appCodec +} + +// InterfaceRegistry returns an InterfaceRegistry +func (app *SovereignApp) InterfaceRegistry() types.InterfaceRegistry { + return app.interfaceRegistry +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (app *SovereignApp) GetKey(storeKey string) *sdk.KVStoreKey { + return app.keys[storeKey] +} + +// GetTKey returns the TransientStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (app *SovereignApp) GetTKey(storeKey string) *sdk.TransientStoreKey { + return app.tkeys[storeKey] +} + +// GetMemKey returns the MemStoreKey for the provided mem key. +// +// NOTE: This is solely used for testing purposes. +func (app *SovereignApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey { + return app.memKeys[storeKey] +} + +// GetSubspace returns a param subspace for a given module name. +// +// NOTE: This is solely to be used for testing purposes. +func (app *SovereignApp) GetSubspace(moduleName string) paramstypes.Subspace { + subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) + return subspace +} + +// RegisterAPIRoutes registers all application module routes with the provided +// API server. +func (app *SovereignApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { + clientCtx := apiSvr.ClientCtx + rpc.RegisterRoutes(clientCtx, apiSvr.Router) + // Register legacy tx routes. + authrest.RegisterTxRoutes(clientCtx, apiSvr.Router) + // Register new tx routes from grpc-gateway. + authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register new tendermint queries routes from grpc-gateway. + tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register legacy and grpc-gateway routes for all modules. + ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) + ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) +} + +// RegisterTxService implements the Application.RegisterTxService method. +func (app *SovereignApp) RegisterTxService(clientCtx client.Context) { + authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) +} + +// RegisterTendermintService implements the Application.RegisterTendermintService method. +func (app *SovereignApp) RegisterTendermintService(clientCtx client.Context) { + tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) +} + +// GetMaccPerms returns a copy of the module account permissions +func GetMaccPerms() map[string][]string { + dupMaccPerms := make(map[string][]string) + for k, v := range maccPerms { + dupMaccPerms[k] = v + } + return dupMaccPerms +} + +// initParamsKeeper init params keeper and its subspaces +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) + + paramsKeeper.Subspace(authtypes.ModuleName) + paramsKeeper.Subspace(banktypes.ModuleName) + paramsKeeper.Subspace(stakingtypes.ModuleName) + paramsKeeper.Subspace(distrtypes.ModuleName) + paramsKeeper.Subspace(slashingtypes.ModuleName) + paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) + paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(minttypes.ModuleName) + // paramsKeeper.Subspace(monitoringptypes.ModuleName) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) + // this line is used by starport scaffolding # stargate/app/paramSubspace + + return paramsKeeper +} + +// SimulationManager implements the SimulationApp interface +func (app *SovereignApp) SimulationManager() *module.SimulationManager { + return app.sm +} diff --git a/app/sovereign/encoding.go b/app/sovereign/encoding.go new file mode 100644 index 0000000000..60535a84cf --- /dev/null +++ b/app/sovereign/encoding.go @@ -0,0 +1,38 @@ +package app + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/x/auth/tx" +) + +// This data structure (EncodingConfig) is heavily inspired by Quicksilver. https://github.com/ingenuity-build/quicksilver/blob/main/app/encoding.go +type EncodingConfig struct { + InterfaceRegistry types.InterfaceRegistry + Marshaler codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} + +// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. +func MakeEncodingConfig() EncodingConfig { + amino := codec.NewLegacyAmino() + interfaceRegistry := types.NewInterfaceRegistry() + marshaler := codec.NewProtoCodec(interfaceRegistry) + txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) + + encodingConfig := EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: marshaler, + TxConfig: txCfg, + Amino: amino, + } + + std.RegisterLegacyAminoCodec(encodingConfig.Amino) + std.RegisterInterfaces(encodingConfig.InterfaceRegistry) + ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) + ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig +} diff --git a/app/sovereign/export.go b/app/sovereign/export.go new file mode 100644 index 0000000000..3c5a7e14d7 --- /dev/null +++ b/app/sovereign/export.go @@ -0,0 +1,201 @@ +package app + +import ( + "encoding/json" + "log" + + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + servertypes "github.com/cosmos/cosmos-sdk/server/types" + sdk "github.com/cosmos/cosmos-sdk/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// ExportAppStateAndValidators exports the state of the application for a genesis +// file. +func (app *SovereignApp) ExportAppStateAndValidators( + forZeroHeight bool, jailAllowedAddrs []string, +) (servertypes.ExportedApp, error) { + // as if they could withdraw from the start of the next block + ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + + // We export at last height + 1, because that's the height at which + // Tendermint will start InitChain. + height := app.LastBlockHeight() + 1 + if forZeroHeight { + height = 0 + app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) + } + + genState := app.mm.ExportGenesis(ctx, app.appCodec) + appState, err := json.MarshalIndent(genState, "", " ") + if err != nil { + return servertypes.ExportedApp{}, err + } + + validators, err := staking.WriteValidators(ctx, app.StakingKeeper) + if err != nil { + return servertypes.ExportedApp{}, err + } + return servertypes.ExportedApp{ + AppState: appState, + Validators: validators, + Height: height, + ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + }, nil +} + +// prepare for fresh start at zero height +// NOTE zero height genesis is a temporary feature which will be deprecated +// +// in favour of export at a block height +func (app *SovereignApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { + applyAllowedAddrs := false + + // check if there is a allowed address list + if len(jailAllowedAddrs) > 0 { + applyAllowedAddrs = true + } + + allowedAddrsMap := make(map[string]bool) + + for _, addr := range jailAllowedAddrs { + _, err := sdk.ValAddressFromBech32(addr) + if err != nil { + log.Fatal(err) + } + allowedAddrsMap[addr] = true + } + + /* Just to be safe, assert the invariants on current state. */ + app.CrisisKeeper.AssertInvariants(ctx) + + /* Handle fee distribution state. */ + + // withdraw all validator commission + app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + if err != nil { + panic(err) + } + + return false + }) + + // withdraw all delegator rewards + dels := app.StakingKeeper.GetAllDelegations(ctx) + for _, delegation := range dels { + valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) + if err != nil { + panic(err) + } + + delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) + if err != nil { + panic(err) + } + _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) + } + + // clear validator slash events + app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) + + // clear validator historical rewards + app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) + + // set context height to zero + height := ctx.BlockHeight() + ctx = ctx.WithBlockHeight(0) + + // reinitialize all validators + app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + // donate any unwithdrawn outstanding reward fraction tokens to the community pool + scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) + feePool := app.DistrKeeper.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) + app.DistrKeeper.SetFeePool(ctx, feePool) + + app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + return false + }) + + // reinitialize all delegations + for _, del := range dels { + valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) + if err != nil { + panic(err) + } + delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) + if err != nil { + panic(err) + } + app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) + app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) + } + + // reset context height + ctx = ctx.WithBlockHeight(height) + + /* Handle staking state. */ + + // iterate through redelegations, reset creation height + app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + for i := range red.Entries { + red.Entries[i].CreationHeight = 0 + } + app.StakingKeeper.SetRedelegation(ctx, red) + return false + }) + + // iterate through unbonding delegations, reset creation height + app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + for i := range ubd.Entries { + ubd.Entries[i].CreationHeight = 0 + } + app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + return false + }) + + // Iterate through validators by power descending, reset bond heights, and + // update bond intra-tx counters. + store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) + iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) + counter := int16(0) + + for ; iter.Valid(); iter.Next() { + addr := sdk.ValAddress(iter.Key()[1:]) + validator, found := app.StakingKeeper.GetValidator(ctx, addr) + if !found { + panic("expected validator, not found") + } + + validator.UnbondingHeight = 0 + if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { + validator.Jailed = true + } + + app.StakingKeeper.SetValidator(ctx, validator) + counter++ + } + + iter.Close() + + _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) + if err != nil { + log.Fatal(err) + } + + /* Handle slashing state. */ + + // reset start height on signing infos + app.SlashingKeeper.IterateValidatorSigningInfos( + ctx, + func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { + info.StartHeight = 0 + app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + return false + }, + ) +} diff --git a/app/sovereign/genesis.go b/app/sovereign/genesis.go new file mode 100644 index 0000000000..340cd801a8 --- /dev/null +++ b/app/sovereign/genesis.go @@ -0,0 +1,20 @@ +package app + +import ( + "encoding/json" +) + +// The genesis state of the blockchain is represented here as a map of raw json +// messages key'd by a identifier string. +// The identifier is used to determine which module genesis information belongs +// to so it may be appropriately routed during init chain. +// Within this application default genesis information is retrieved from +// the ModuleBasicManager which populates json from each BasicModule +// object provided to it during init. +type GenesisState map[string]json.RawMessage + +// NewDefaultGenesisState generates the default state for the application. +func NewDefaultGenesisState() GenesisState { + encCfg := MakeEncodingConfig() + return ModuleBasics.DefaultGenesis(encCfg.Marshaler) +} diff --git a/app/sovereign/upgrades.go b/app/sovereign/upgrades.go new file mode 100644 index 0000000000..734c2b3b2f --- /dev/null +++ b/app/sovereign/upgrades.go @@ -0,0 +1,31 @@ +package app + +import ( + "fmt" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func (app *SovereignApp) setupUpgradeHandlers() { + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err)) + } + + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + + var storeUpgrades *storetypes.StoreUpgrades + + switch upgradeInfo.Name { + // no store upgrades + case "v3": + storeUpgrades = &storetypes.StoreUpgrades{} + } + + if storeUpgrades != nil { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades)) + } +} diff --git a/app/sovereign/upgrades/v3/upgrades.go b/app/sovereign/upgrades/v3/upgrades.go new file mode 100644 index 0000000000..bb40c1713a --- /dev/null +++ b/app/sovereign/upgrades/v3/upgrades.go @@ -0,0 +1,26 @@ +package v3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Note: ensure these values are properly set before running upgrade +var ( + UpgradeName = "v3" +) + +// CreateUpgradeHandler creates an SDK upgrade handler for v3 +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + newVm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return newVm, err + } + return newVm, nil + } +} diff --git a/cmd/interchain-security-sd/main.go b/cmd/interchain-security-sd/main.go new file mode 100644 index 0000000000..4dc2748ad0 --- /dev/null +++ b/cmd/interchain-security-sd/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "os" + + "github.com/cosmos/cosmos-sdk/server" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" + app "github.com/cosmos/interchain-security/app/sovereign" + "github.com/tendermint/spm/cosmoscmd" +) + +func main() { + rootCmd, _ := cosmoscmd.NewRootCmd( + app.AppName, + app.AccountAddressPrefix, + app.DefaultNodeHome, + app.AppName, + app.ModuleBasics, + app.New, + // this line is used by starport scaffolding # root/arguments + ) + + if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil { + switch e := err.(type) { + case server.ErrorCode: + os.Exit(e.Code) + + default: + os.Exit(1) + } + } +} diff --git a/consumer/README.md b/consumer/README.md new file mode 100644 index 0000000000..5b95bf4b0c --- /dev/null +++ b/consumer/README.md @@ -0,0 +1,64 @@ +## How to run consumer chain + +### Pre-install + +Binaries: + +- interchain-security-pd - [Interchain security](https://github.com/cosmos/interchain-security) version: v0.2.1 +- consumerd +- hermes(version: v0.15.0) + +### Commands + +```sh +rm -rf /Users/admin/.provider1 +rm -rf /Users/admin/.provider +rm -rf /Users/admin/.consumer1 +rm -rf /Users/admin/.consumer +rm -rf /Users/admin/.sovereign +sh run.sh +``` + +### Genesis modification script for consumer chain + +```sh +# Add ccv section +if ! ./$PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$CONSUMER_HOME"/consumer_section.json; +then + echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." + exit 1 +fi + +jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$CONSUMER_HOME"/config/genesis.json "$CONSUMER_HOME"/consumer_section.json > "$CONSUMER_HOME"/genesis_consumer.json && \ + mv "$CONSUMER_HOME"/genesis_consumer.json "$CONSUMER_HOME"/config/genesis.json +``` + +### Initial validator set on consumer chain + +```json + "initial_val_set": [ + { + "pub_key": { + "ed25519": "6s4FU4uSsWNjnqhNc9vhyZBqrLjib+z/mfh1LhvkalE=" + }, + "power": "1" + }, + { + "pub_key": { + "ed25519": "JCFnTza2T2jlkTWxC0kY9lczh7F+jQ/bGyhHFFNr7/w=" + }, + "power": "100" + } + ], +``` + +### Process of execution of soft upgrade from sovereign chain to consumer chain + +1. Start provider chain with two validators and register consumer chain +2. Build normal sovereign chain daemon +3. Start single validator sovereign chain +4. Two provider chain validators with sovereign chain +5. Raise Upgrade proposal on sovereign chain and vote +6. Build consumer chain daemon with upgrade handler for ccv module and relevant modules +7. Once chain halt, restart 3 nodes +8. Ensure blocks are being produced without the first node used for sovereign chain diff --git a/consumer/build_binaries.sh b/consumer/build_binaries.sh new file mode 100644 index 0000000000..43ddcef129 --- /dev/null +++ b/consumer/build_binaries.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +go install ../cmd/interchain-security-sd +go install ../cmd/interchain-security-pd +go install ../cmd/interchain-security-cdd +go install ../cmd/interchain-security-cd diff --git a/consumer/run.sh b/consumer/run.sh new file mode 100644 index 0000000000..28f3feacaa --- /dev/null +++ b/consumer/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -eux + +bash build_binaries.sh +bash start_provider.sh +bash start_consumer.sh diff --git a/consumer/start_consumer.sh b/consumer/start_consumer.sh new file mode 100644 index 0000000000..cb987ed6c5 --- /dev/null +++ b/consumer/start_consumer.sh @@ -0,0 +1,315 @@ +#!/bin/bash +set -eux + +SOVEREIGN_HOME="$HOME/.sovereign" +CONSUMER_HOME="$HOME/.consumer" +CONSUMER_HOME1="$HOME/.consumer1" +PROVIDER_CHAIN_ID="provider" +CONSUMER_CHAIN_ID="consumer" +MONIKER="consumer" +VALIDATOR="validator" +VALIDATOR1="validator1" +KEYRING="--keyring-backend test" +TX_FLAGS="--gas-adjustment 100 --gas auto" +PROVIDER_BINARY="interchain-security-pd" +SOVEREIGN_BINARY="interchain-security-sd" +CONSUMER_BINARY="interchain-security-cdd" +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +SOVEREIGN_RPC_LADDR="$NODE_IP:26648" +SOVEREIGN_GRPC_ADDR="$NODE_IP:9081" +CONSUMER_RPC_LADDR="$NODE_IP:26638" +CONSUMER_GRPC_ADDR="$NODE_IP:9071" +CONSUMER_RPC_LADDR1="$NODE_IP:26628" +CONSUMER_GRPC_ADDR1="$NODE_IP:9061" +CONSUMER_USER="consumer" +SOVEREIGN_VALIDATOR="sovereign_validator" +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_NODE_ADDRESS="tcp://localhost:26658" + +# Clean start +killall $SOVEREIGN_BINARY &> /dev/null || true +killall $CONSUMER_BINARY &> /dev/null || true +rm -rf $CONSUMER_HOME +rm -rf $CONSUMER_HOME1 +rm -rf $SOVEREIGN_HOME + +################SOVEREIGN############################ +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME +sleep 1 + +# Create user account keypair +$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 +$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 + +# Add account in genesis (required by Hermes) +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME + +# generate genesis for sovereign chain +$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 10000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME +sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json + +################CONSUMER############################ + +# Build genesis file and node directory structure +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME +sleep 1 + +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json +cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json + +#######CHAIN2####### +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 +sleep 1 +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json +cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json + +##########SET CONFIG.TOML##################### +# Set default client port +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml +sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) +node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) +node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) + +# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml + +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml + +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml + +# Start the chain +$SOVEREIGN_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$SOVEREIGN_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $SOVEREIGN_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 10 + +###########################UPGRADE TO SOVEREIGN CHAIN########################## + +$SOVEREIGN_BINARY tx gov submit-proposal software-upgrade "v07-Theta" --upgrade-height=7 \ +--title="upgrade to consumer chain" --description="upgrade to consumer chain description" \ +--from=$SOVEREIGN_VALIDATOR $KEYRING --chain-id=$CONSUMER_CHAIN_ID \ +--home=$SOVEREIGN_HOME --yes -b block --deposit="100000000stake" + +# Vote yes to proposal +$SOVEREIGN_BINARY tx gov vote 1 yes --from $SOVEREIGN_VALIDATOR --chain-id $CONSUMER_CHAIN_ID --node tcp://$SOVEREIGN_RPC_LADDR \ +--home $SOVEREIGN_HOME -b block -y $KEYRING +sleep 30 + +###########################START BINARIES AGAIN AFTER UPGRADE########################## +$SOVEREIGN_BINARY query gov proposals --node tcp://$SOVEREIGN_RPC_LADDR +$SOVEREIGN_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR +# $SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR1 + +killall $SOVEREIGN_BINARY &> /dev/null || true + +# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler +if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; +then + echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." + exit 1 +fi + +jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ + mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json + +# Modify genesis params +jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ + $SOVEREIGN_HOME/config/genesis.json > \ + $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json +sleep 1 + + +$CONSUMER_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$CONSUMER_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $CONSUMER_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 30 + +######################################HERMES################################### + +# Setup Hermes in packet relayer mode +killall hermes 2> /dev/null || true + +tee ~/.hermes/config.toml< ~/.hermes/logs & + +############################################################ + +PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) +DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) +OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) + +$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 50000000stake \ + --from $VALIDATOR \ + $KEYRING \ + --home $PROVIDER_HOME \ + --node tcp://${PROVIDER_RPC_LADDR} \ + --chain-id $PROVIDER_CHAIN_ID -y -b block +sleep 1 + +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} + +$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR + +$CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR +$PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/consumer/start_provider.sh b/consumer/start_provider.sh new file mode 100644 index 0000000000..cba04726fd --- /dev/null +++ b/consumer/start_provider.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set -eux + +TOTAL_COINS=100000000000stake +STAKE_COINS=100000000stake +TOTAL_COINS1=120000000000stake +STAKE_COINS1=1000000stake +PROVIDER_BINARY=interchain-security-pd +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_CHAIN_ID=provider +PROVIDER_MONIKER=provider +VALIDATOR=validator +VALIDATOR1=validator1 +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +PROVIDER_DELEGATOR=delegator + +# Clean start +killall $PROVIDER_BINARY &> /dev/null || true + +#######VALIDATOR1####################### +rm -rf $PROVIDER_HOME + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID +jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ + $PROVIDER_HOME/config/genesis.json > \ + $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json +sleep 1 + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 +sleep 1 +$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 + +# Stake 1/1000 user's coins +$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR +sleep 1 + +###########VALIDATOR 2############################ +rm -rf $PROVIDER_HOME1 + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID +cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test +sleep 1 + +####################GENTX AND DISTRIBUTE GENESIS############################## +cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ + +# Stake 1/1000 user's coins +# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 +# sleep 1 + +$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ +sleep 1 + +cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json + +####################ADDING PEERS#################### +node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) +node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml + +#################### Start the chain node1 ################### +$PROVIDER_BINARY start \ + --home $PROVIDER_HOME \ + --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ + --grpc.address $PROVIDER_GRPC_ADDR \ + --address tcp://${NODE_IP}:26655 \ + --p2p.laddr tcp://${NODE_IP}:26656 \ + --grpc-web.enable=false \ + --trace \ + &> $PROVIDER_HOME/logs & + +#################### Start the chain node2 ################### +# $PROVIDER_BINARY start \ +# --home $PROVIDER_HOME1 \ +# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ +# --grpc.address $PROVIDER_GRPC_ADDR1 \ +# --address tcp://${NODE_IP}:26665 \ +# --p2p.laddr tcp://${NODE_IP}:26666 \ +# --grpc-web.enable=false \ +# --trace \ +# &> $PROVIDER_HOME1/logs & +sleep 10 + +# Build consumer chain proposal file +tee $PROVIDER_HOME/consumer-proposal.json< 0 { - i -= len(m.TransferChannelId) - copy(dAtA[i:], m.TransferChannelId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.TransferChannelId))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a - } - if len(m.CounterpartyClientId) > 0 { - i -= len(m.CounterpartyClientId) - copy(dAtA[i:], m.CounterpartyClientId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.CounterpartyClientId))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - } - if len(m.ConnId) > 0 { - i -= len(m.ConnId) - copy(dAtA[i:], m.ConnId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConnId))) - i-- - dAtA[i] = 0x7a - } - if m.UnbondingPeriod != nil { - { - size, err := m.UnbondingPeriod.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - } if m.PreCCV { i-- if m.PreCCV { @@ -802,22 +727,6 @@ func (m *GenesisState) Size() (n int) { if m.PreCCV { n += 2 } - if m.UnbondingPeriod != nil { - l = m.UnbondingPeriod.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.ConnId) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.CounterpartyClientId) - if l > 0 { - n += 2 + l + sovGenesis(uint64(l)) - } - l = len(m.TransferChannelId) - if l > 0 { - n += 2 + l + sovGenesis(uint64(l)) - } return n } @@ -1310,138 +1219,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } } m.PreCCV = bool(v != 0) - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.UnbondingPeriod == nil { - m.UnbondingPeriod = &durationpb.Duration{} - } - if err := m.UnbondingPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConnId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConnId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CounterpartyClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 17: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TransferChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index d8485dc6af..9b3cc39fc3 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -161,7 +161,6 @@ func (k Keeper) SendVSCPackets(ctx sdk.Context) { // SendVSCPacketsToChain sends all queued VSC packets to the specified chain func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string) { - // TODO: send init genesis packet if target chain is preCCV? pendingPackets := k.GetPendingVSCPackets(ctx, chainID) for _, data := range pendingPackets { // send packet over IBC diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index ba8f8037b5..9a6874456b 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -70,9 +70,7 @@ type ConsumerAdditionProposal struct { // The number of historical info entries to persist in store. // This param is a part of the cosmos sdk staking module. In the case of // a ccv enabled consumer chain, the ccv module acts as the staking module. - HistoricalEntries int64 `protobuf:"varint,13,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` - ConnId string `protobuf:"bytes,15,opt,name=conn_id,json=connId,proto3" json:"conn_id,omitempty"` - TransferChannelId string `protobuf:"bytes,16,opt,name=transfer_channel_id,json=transferChannelId,proto3" json:"transfer_channel_id,omitempty"` + HistoricalEntries int64 `protobuf:"varint,13,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` } func (m *ConsumerAdditionProposal) Reset() { *m = ConsumerAdditionProposal{} } @@ -546,72 +544,69 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 1026 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0xcf, 0x6f, 0xdb, 0x36, - 0x14, 0xc7, 0xad, 0x26, 0xb1, 0x63, 0x3a, 0x6d, 0x12, 0xa6, 0x4b, 0x94, 0xac, 0xb0, 0x5d, 0x6f, - 0x87, 0x0c, 0x45, 0x25, 0x24, 0xbd, 0x6c, 0xc5, 0x76, 0x48, 0xdc, 0x75, 0x09, 0xb0, 0x6e, 0xae, - 0x12, 0x6c, 0xc0, 0x76, 0x10, 0x68, 0x8a, 0xb1, 0x88, 0x48, 0xa4, 0x40, 0xd2, 0x5a, 0xf2, 0x1f, - 0xec, 0xd8, 0x63, 0x8f, 0xfd, 0x0f, 0xf6, 0x6f, 0xf4, 0xd8, 0xe3, 0x0e, 0xc3, 0x36, 0x24, 0x7f, - 0xc5, 0x6e, 0x03, 0x49, 0xc9, 0xbf, 0x9a, 0x02, 0x0e, 0x86, 0xdd, 0x44, 0xbe, 0xef, 0xfb, 0xbc, - 0x47, 0xbd, 0xf7, 0x28, 0x81, 0x7d, 0xca, 0x14, 0x11, 0x38, 0x46, 0x94, 0x85, 0x92, 0xe0, 0xa1, - 0xa0, 0xea, 0xd2, 0xc7, 0x38, 0xf7, 0x33, 0xc1, 0x73, 0x1a, 0x11, 0xe1, 0xe7, 0x7b, 0xa3, 0x67, - 0x2f, 0x13, 0x5c, 0x71, 0xf8, 0xc9, 0x0d, 0x3e, 0x1e, 0xc6, 0xb9, 0x37, 0xd2, 0xe5, 0x7b, 0x3b, - 0xf7, 0x07, 0x7c, 0xc0, 0x8d, 0xde, 0xd7, 0x4f, 0xd6, 0x75, 0xa7, 0x35, 0xe0, 0x7c, 0x90, 0x10, - 0xdf, 0xac, 0xfa, 0xc3, 0x33, 0x5f, 0xd1, 0x94, 0x48, 0x85, 0xd2, 0xac, 0x10, 0x34, 0x67, 0x05, - 0xd1, 0x50, 0x20, 0x45, 0x39, 0x2b, 0x01, 0xb4, 0x8f, 0x7d, 0xcc, 0x05, 0xf1, 0x71, 0x42, 0x09, - 0x53, 0x3a, 0x3d, 0xfb, 0x54, 0x08, 0x7c, 0x2d, 0x48, 0xe8, 0x20, 0x56, 0x76, 0x5b, 0xfa, 0x8a, - 0xb0, 0x88, 0x88, 0x94, 0x5a, 0xf1, 0x78, 0x65, 0x1d, 0x3a, 0x7f, 0x54, 0x81, 0xdb, 0xe5, 0x4c, - 0x0e, 0x53, 0x22, 0x0e, 0xa2, 0x88, 0xea, 0x60, 0x3d, 0xc1, 0x33, 0x2e, 0x51, 0x02, 0xef, 0x83, - 0x25, 0x45, 0x55, 0x42, 0x5c, 0xa7, 0xed, 0xec, 0xd6, 0x03, 0xbb, 0x80, 0x6d, 0xd0, 0x88, 0x88, - 0xc4, 0x82, 0x66, 0x5a, 0xec, 0xde, 0x31, 0xb6, 0xc9, 0x2d, 0xb8, 0x0d, 0x96, 0xed, 0xfb, 0xa1, - 0x91, 0xbb, 0x60, 0xcc, 0x35, 0xb3, 0x3e, 0x8e, 0xe0, 0x37, 0xe0, 0x1e, 0x65, 0x54, 0x51, 0x94, - 0x84, 0x31, 0xd1, 0x79, 0xba, 0x8b, 0x6d, 0x67, 0xb7, 0xb1, 0xbf, 0xe3, 0xd1, 0x3e, 0xf6, 0xf4, - 0xd1, 0xbc, 0xe2, 0x40, 0xf9, 0x9e, 0x77, 0x64, 0x14, 0x87, 0x8b, 0x6f, 0xff, 0x6c, 0x55, 0x82, - 0xbb, 0x85, 0x9f, 0xdd, 0x84, 0x0f, 0xc1, 0xca, 0x80, 0x30, 0x22, 0xa9, 0x0c, 0x63, 0x24, 0x63, - 0x77, 0xa9, 0xed, 0xec, 0xae, 0x04, 0x8d, 0x62, 0xef, 0x08, 0xc9, 0x18, 0xb6, 0x40, 0xa3, 0x4f, - 0x19, 0x12, 0x97, 0x56, 0x51, 0x35, 0x0a, 0x60, 0xb7, 0x8c, 0xa0, 0x0b, 0x80, 0xcc, 0xd0, 0x2f, - 0x2c, 0xd4, 0x75, 0x70, 0x6b, 0x45, 0x22, 0xb6, 0x06, 0x5e, 0x59, 0x03, 0xef, 0xb4, 0x2c, 0xd2, - 0xe1, 0xb2, 0x4e, 0xe4, 0xd5, 0x5f, 0x2d, 0x27, 0xa8, 0x1b, 0x3f, 0x6d, 0x81, 0xdf, 0x81, 0xb5, - 0x21, 0xeb, 0x73, 0x16, 0x51, 0x36, 0x08, 0x33, 0x22, 0x28, 0x8f, 0xdc, 0x65, 0x83, 0xda, 0x7e, - 0x0f, 0xf5, 0xac, 0x28, 0xa7, 0x25, 0xbd, 0xd6, 0xa4, 0xd5, 0x91, 0x73, 0xcf, 0xf8, 0xc2, 0x97, - 0x00, 0x62, 0x9c, 0x9b, 0x94, 0xf8, 0x50, 0x95, 0xc4, 0xfa, 0xfc, 0xc4, 0x35, 0x8c, 0xf3, 0x53, - 0xeb, 0x5d, 0x20, 0x7f, 0x06, 0x5b, 0x4a, 0x20, 0x26, 0xcf, 0x88, 0x98, 0xe5, 0x82, 0xf9, 0xb9, - 0x1f, 0x95, 0x8c, 0x69, 0xf8, 0x11, 0x68, 0xe3, 0xa2, 0x81, 0x42, 0x41, 0x22, 0x2a, 0x95, 0xa0, - 0xfd, 0xa1, 0xf6, 0x0d, 0xcf, 0x04, 0xc2, 0xa6, 0x47, 0x1a, 0xa6, 0x09, 0x9a, 0xa5, 0x2e, 0x98, - 0x92, 0x3d, 0x2f, 0x54, 0xf0, 0x7b, 0xf0, 0x69, 0x3f, 0xe1, 0xf8, 0x5c, 0xea, 0xe4, 0xc2, 0x29, - 0x92, 0x09, 0x9d, 0x52, 0x29, 0x35, 0x6d, 0xa5, 0xed, 0xec, 0x2e, 0x04, 0x0f, 0xad, 0xb6, 0x47, - 0xc4, 0xb3, 0x09, 0xe5, 0xe9, 0x84, 0x10, 0x3e, 0x06, 0x30, 0xa6, 0x52, 0x71, 0x41, 0x31, 0x4a, - 0x42, 0xc2, 0x94, 0xa0, 0x44, 0xba, 0x77, 0x8d, 0xfb, 0xfa, 0xd8, 0xf2, 0xb5, 0x35, 0xc0, 0x2d, - 0x50, 0xc3, 0x9c, 0x99, 0xae, 0x5d, 0x35, 0x09, 0x57, 0xf5, 0xf2, 0x38, 0x82, 0x1e, 0xd8, 0x18, - 0xbd, 0x3f, 0x1c, 0x23, 0xc6, 0x48, 0xa2, 0x45, 0x6b, 0x46, 0xb4, 0x5e, 0x9a, 0xba, 0xd6, 0x72, - 0x1c, 0x3d, 0x5d, 0xfe, 0xf5, 0x4d, 0xab, 0xf2, 0xfa, 0x4d, 0xab, 0xd2, 0xf9, 0xcd, 0x01, 0x5b, - 0xdd, 0xd1, 0xa9, 0x53, 0x9e, 0xa3, 0xe4, 0xff, 0x9c, 0xae, 0x03, 0x50, 0x97, 0x8a, 0x67, 0xb6, - 0x9f, 0x17, 0x6f, 0xd1, 0xcf, 0xcb, 0xda, 0x4d, 0x1b, 0x3a, 0xff, 0x2c, 0x82, 0x6a, 0x0f, 0x09, - 0x94, 0x4a, 0x78, 0x0a, 0x56, 0x15, 0x49, 0xb3, 0x04, 0x29, 0x12, 0xda, 0xa1, 0x34, 0xa9, 0x36, - 0xf6, 0x1f, 0x99, 0x61, 0x9d, 0xbc, 0x66, 0xbc, 0x89, 0x8b, 0x25, 0xdf, 0xf3, 0xba, 0x66, 0xf7, - 0x44, 0x21, 0x45, 0x82, 0x7b, 0x25, 0xc3, 0x6e, 0xc2, 0xcf, 0x81, 0xab, 0xc4, 0x50, 0xaa, 0xf1, - 0xb8, 0x8c, 0xfb, 0xe4, 0x8e, 0x29, 0xcd, 0x66, 0x69, 0xb7, 0x1d, 0x36, 0xea, 0x8f, 0x9b, 0x27, - 0x63, 0xe1, 0xbf, 0x4c, 0xc6, 0x09, 0xd8, 0xd0, 0xd7, 0xca, 0x2c, 0x73, 0x71, 0x7e, 0xe6, 0xba, - 0xf6, 0x9f, 0x86, 0xbe, 0x04, 0x30, 0x97, 0x78, 0x96, 0xb9, 0x74, 0x8b, 0x3c, 0x73, 0x89, 0xa7, - 0x91, 0x11, 0x78, 0x20, 0x13, 0x24, 0xe3, 0x30, 0x25, 0xca, 0xcc, 0x59, 0x96, 0x10, 0x46, 0x65, - 0x5c, 0xc2, 0xab, 0xf3, 0xc3, 0xb7, 0x0d, 0xe8, 0x85, 0xe6, 0x04, 0x25, 0xa6, 0x88, 0xd2, 0x05, - 0xcd, 0x9b, 0xa3, 0x8c, 0x0a, 0x54, 0x33, 0xfd, 0xf6, 0xf1, 0x0d, 0x88, 0x51, 0x95, 0xbe, 0x00, - 0xdb, 0x29, 0xba, 0x08, 0x33, 0x62, 0x6f, 0x44, 0x0b, 0xcc, 0x10, 0x3e, 0x27, 0x4a, 0x9a, 0x8b, - 0x71, 0x21, 0xd8, 0x4c, 0xd1, 0x45, 0xcf, 0xda, 0x4f, 0xb4, 0xb9, 0x67, 0xad, 0x9d, 0x3e, 0x58, - 0x3f, 0x42, 0x2c, 0x92, 0x31, 0x3a, 0x27, 0x2f, 0x88, 0x42, 0x11, 0x52, 0x08, 0x3e, 0x01, 0x9b, - 0xe5, 0x97, 0x35, 0x3c, 0x23, 0x24, 0xcc, 0x38, 0x4f, 0x42, 0x14, 0x45, 0xa2, 0x98, 0x9b, 0x8d, - 0xd2, 0xfa, 0x9c, 0x90, 0x1e, 0xe7, 0xc9, 0x41, 0x14, 0x09, 0xe8, 0x82, 0x5a, 0x4e, 0x84, 0x1c, - 0x4f, 0x50, 0xb9, 0xec, 0x7c, 0x06, 0xea, 0x26, 0xe6, 0x01, 0x3e, 0x97, 0xf0, 0x01, 0xa8, 0x6b, - 0x12, 0x91, 0x92, 0x48, 0xd7, 0x69, 0x2f, 0xec, 0xd6, 0x83, 0xf1, 0x46, 0x47, 0x81, 0xed, 0x0f, - 0x7d, 0x1a, 0x25, 0xfc, 0x11, 0xd4, 0x8a, 0x23, 0x1a, 0xc7, 0xc6, 0xfe, 0x57, 0xde, 0x1c, 0x3f, - 0x06, 0xde, 0x87, 0x80, 0x41, 0x49, 0xeb, 0x88, 0xf1, 0x07, 0x79, 0xe6, 0xc6, 0x90, 0xf0, 0x87, - 0xd9, 0xa0, 0x5f, 0xde, 0x2a, 0xe8, 0x0c, 0x6f, 0x1c, 0xf3, 0x11, 0x68, 0x1c, 0xd8, 0x63, 0x7f, - 0x4b, 0xa5, 0x7a, 0xff, 0xb5, 0xac, 0x4c, 0xbc, 0x96, 0xc3, 0xd3, 0xb7, 0x57, 0x4d, 0xe7, 0xdd, - 0x55, 0xd3, 0xf9, 0xfb, 0xaa, 0xe9, 0xbc, 0xba, 0x6e, 0x56, 0xde, 0x5d, 0x37, 0x2b, 0xbf, 0x5f, - 0x37, 0x2b, 0x3f, 0x3d, 0x1d, 0x50, 0x15, 0x0f, 0xfb, 0x1e, 0xe6, 0xa9, 0x8f, 0xb9, 0x4c, 0xb9, - 0xf4, 0xc7, 0xe9, 0x3d, 0x1e, 0xfd, 0x60, 0x5d, 0x4c, 0xff, 0x62, 0xa9, 0xcb, 0x8c, 0xc8, 0x7e, - 0xd5, 0xf4, 0xec, 0x93, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xbe, 0x72, 0xa9, 0x93, 0x09, - 0x00, 0x00, + // 991 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4d, 0x6f, 0xdb, 0x46, + 0x13, 0xc7, 0xc5, 0xd8, 0xd6, 0xcb, 0xca, 0x79, 0xf1, 0x26, 0x8f, 0x43, 0xf9, 0x09, 0x24, 0x45, + 0xed, 0x41, 0x45, 0x10, 0x12, 0x76, 0x2e, 0x6d, 0xd0, 0x1e, 0x64, 0xa5, 0xa9, 0x0b, 0x34, 0xad, + 0x42, 0x0b, 0x2d, 0xd0, 0x1e, 0x88, 0xe5, 0x72, 0x2d, 0x2e, 0x4c, 0x72, 0x89, 0xdd, 0x15, 0x6b, + 0x7f, 0x83, 0x1e, 0x03, 0xf4, 0x92, 0x63, 0xbe, 0x41, 0xbf, 0x46, 0x8e, 0x39, 0xf6, 0xd4, 0x16, + 0xf6, 0xa7, 0xe8, 0xad, 0xd8, 0x5d, 0x52, 0x6f, 0x71, 0x00, 0x19, 0x45, 0x6f, 0xdc, 0x99, 0xff, + 0xfc, 0x66, 0xc8, 0x99, 0xdd, 0x25, 0x38, 0xa0, 0xa9, 0x24, 0x1c, 0x47, 0x88, 0xa6, 0xbe, 0x20, + 0x78, 0xca, 0xa9, 0x3c, 0x77, 0x31, 0xce, 0xdd, 0x8c, 0xb3, 0x9c, 0x86, 0x84, 0xbb, 0xf9, 0xfe, + 0xec, 0xd9, 0xc9, 0x38, 0x93, 0x0c, 0x7e, 0x74, 0x45, 0x8c, 0x83, 0x71, 0xee, 0xcc, 0x74, 0xf9, + 0xfe, 0xde, 0xbd, 0x09, 0x9b, 0x30, 0xad, 0x77, 0xd5, 0x93, 0x09, 0xdd, 0xeb, 0x4c, 0x18, 0x9b, + 0xc4, 0xc4, 0xd5, 0xab, 0x60, 0x7a, 0xe2, 0x4a, 0x9a, 0x10, 0x21, 0x51, 0x92, 0x15, 0x82, 0xf6, + 0xaa, 0x20, 0x9c, 0x72, 0x24, 0x29, 0x4b, 0x4b, 0x00, 0x0d, 0xb0, 0x8b, 0x19, 0x27, 0x2e, 0x8e, + 0x29, 0x49, 0xa5, 0x2a, 0xcf, 0x3c, 0x15, 0x02, 0x57, 0x09, 0x62, 0x3a, 0x89, 0xa4, 0x31, 0x0b, + 0x57, 0x92, 0x34, 0x24, 0x3c, 0xa1, 0x46, 0x3c, 0x5f, 0x99, 0x80, 0xde, 0xaf, 0x55, 0x60, 0x0f, + 0x59, 0x2a, 0xa6, 0x09, 0xe1, 0x83, 0x30, 0xa4, 0x2a, 0xd9, 0x88, 0xb3, 0x8c, 0x09, 0x14, 0xc3, + 0x7b, 0x60, 0x4b, 0x52, 0x19, 0x13, 0xdb, 0xea, 0x5a, 0xfd, 0x86, 0x67, 0x16, 0xb0, 0x0b, 0x9a, + 0x21, 0x11, 0x98, 0xd3, 0x4c, 0x89, 0xed, 0x1b, 0xda, 0xb7, 0x68, 0x82, 0x2d, 0x50, 0x37, 0xdf, + 0x87, 0x86, 0xf6, 0x86, 0x76, 0xd7, 0xf4, 0xfa, 0xeb, 0x10, 0x7e, 0x05, 0x6e, 0xd1, 0x94, 0x4a, + 0x8a, 0x62, 0x3f, 0x22, 0xaa, 0x4e, 0x7b, 0xb3, 0x6b, 0xf5, 0x9b, 0x07, 0x7b, 0x0e, 0x0d, 0xb0, + 0xa3, 0x5e, 0xcd, 0x29, 0x5e, 0x28, 0xdf, 0x77, 0x8e, 0xb4, 0xe2, 0x70, 0xf3, 0xed, 0x1f, 0x9d, + 0x8a, 0x77, 0xb3, 0x88, 0x33, 0x46, 0xf8, 0x10, 0x6c, 0x4f, 0x48, 0x4a, 0x04, 0x15, 0x7e, 0x84, + 0x44, 0x64, 0x6f, 0x75, 0xad, 0xfe, 0xb6, 0xd7, 0x2c, 0x6c, 0x47, 0x48, 0x44, 0xb0, 0x03, 0x9a, + 0x01, 0x4d, 0x11, 0x3f, 0x37, 0x8a, 0xaa, 0x56, 0x00, 0x63, 0xd2, 0x82, 0x21, 0x00, 0x22, 0x43, + 0x3f, 0xa7, 0xbe, 0xea, 0x83, 0x5d, 0x2b, 0x0a, 0x31, 0x3d, 0x70, 0xca, 0x1e, 0x38, 0xe3, 0xb2, + 0x49, 0x87, 0x75, 0x55, 0xc8, 0xab, 0x3f, 0x3b, 0x96, 0xd7, 0xd0, 0x71, 0xca, 0x03, 0xbf, 0x05, + 0x77, 0xa6, 0x69, 0xc0, 0xd2, 0x90, 0xa6, 0x13, 0x3f, 0x23, 0x9c, 0xb2, 0xd0, 0xae, 0x6b, 0x54, + 0xeb, 0x3d, 0xd4, 0xb3, 0xa2, 0x9d, 0x86, 0xf4, 0x5a, 0x91, 0x6e, 0xcf, 0x82, 0x47, 0x3a, 0x16, + 0xbe, 0x04, 0x10, 0xe3, 0x5c, 0x97, 0xc4, 0xa6, 0xb2, 0x24, 0x36, 0xd6, 0x27, 0xde, 0xc1, 0x38, + 0x1f, 0x9b, 0xe8, 0x02, 0xf9, 0x13, 0xb8, 0x2f, 0x39, 0x4a, 0xc5, 0x09, 0xe1, 0xab, 0x5c, 0xb0, + 0x3e, 0xf7, 0x7f, 0x25, 0x63, 0x19, 0x7e, 0x04, 0xba, 0xb8, 0x18, 0x20, 0x9f, 0x93, 0x90, 0x0a, + 0xc9, 0x69, 0x30, 0x55, 0xb1, 0xfe, 0x09, 0x47, 0x58, 0xcf, 0x48, 0x53, 0x0f, 0x41, 0xbb, 0xd4, + 0x79, 0x4b, 0xb2, 0xe7, 0x85, 0x0a, 0x7e, 0x07, 0x3e, 0x0e, 0x62, 0x86, 0x4f, 0x85, 0x2a, 0xce, + 0x5f, 0x22, 0xe9, 0xd4, 0x09, 0x15, 0x42, 0xd1, 0xb6, 0xbb, 0x56, 0x7f, 0xc3, 0x7b, 0x68, 0xb4, + 0x23, 0xc2, 0x9f, 0x2d, 0x28, 0xc7, 0x0b, 0x42, 0xf8, 0x18, 0xc0, 0x88, 0x0a, 0xc9, 0x38, 0xc5, + 0x28, 0xf6, 0x49, 0x2a, 0x39, 0x25, 0xc2, 0xbe, 0xa9, 0xc3, 0x77, 0xe6, 0x9e, 0x2f, 0x8d, 0xe3, + 0x69, 0xfd, 0x97, 0x37, 0x9d, 0xca, 0xeb, 0x37, 0x9d, 0x4a, 0xef, 0x37, 0x0b, 0xdc, 0x1f, 0xce, + 0x8a, 0x4d, 0x58, 0x8e, 0xe2, 0xff, 0x72, 0x53, 0x0c, 0x40, 0x43, 0x48, 0x96, 0x99, 0x31, 0xdc, + 0xbc, 0xc6, 0x18, 0xd6, 0x55, 0x98, 0x72, 0xf4, 0xfe, 0xde, 0x04, 0xd5, 0x11, 0xe2, 0x28, 0x11, + 0x70, 0x0c, 0x6e, 0x4b, 0x92, 0x64, 0x31, 0x92, 0xc4, 0x37, 0x7b, 0x49, 0x97, 0xda, 0x3c, 0x78, + 0xa4, 0xf7, 0xd8, 0xe2, 0xe9, 0xe0, 0x2c, 0x9c, 0x07, 0xf9, 0xbe, 0x33, 0xd4, 0xd6, 0x63, 0x89, + 0x24, 0xf1, 0x6e, 0x95, 0x0c, 0x63, 0x84, 0x9f, 0x02, 0x5b, 0xf2, 0xa9, 0x90, 0xf3, 0x29, 0x9f, + 0xb7, 0xf7, 0x86, 0xfe, 0xa2, 0xbb, 0xa5, 0xdf, 0x0c, 0xc6, 0xac, 0xad, 0x57, 0x0f, 0xf4, 0xc6, + 0xbf, 0x19, 0xe8, 0x63, 0x70, 0x57, 0x9d, 0x06, 0xab, 0xcc, 0xcd, 0xf5, 0x99, 0x3b, 0x2a, 0x7e, + 0x19, 0xfa, 0x12, 0xc0, 0x5c, 0xe0, 0x55, 0xe6, 0xd6, 0x35, 0xea, 0xcc, 0x05, 0x5e, 0x46, 0x86, + 0xe0, 0x81, 0x88, 0x91, 0x88, 0xfc, 0x84, 0x48, 0xbd, 0x3d, 0xb2, 0x98, 0xa4, 0x54, 0x44, 0x25, + 0xbc, 0xba, 0x3e, 0xbc, 0xa5, 0x41, 0x2f, 0x14, 0xc7, 0x2b, 0x31, 0x45, 0x96, 0x21, 0x68, 0x5f, + 0x9d, 0x65, 0xd6, 0xa0, 0x9a, 0x9e, 0xb7, 0xff, 0x5f, 0x81, 0x98, 0x75, 0xe9, 0x33, 0xd0, 0x4a, + 0xd0, 0x99, 0x9f, 0x11, 0x73, 0x90, 0x19, 0x60, 0x86, 0xf0, 0x29, 0x91, 0x42, 0x9f, 0x67, 0x1b, + 0xde, 0x6e, 0x82, 0xce, 0x46, 0xc6, 0x7f, 0xac, 0xdc, 0x23, 0xe3, 0xed, 0x05, 0x60, 0xe7, 0x08, + 0xa5, 0xa1, 0x88, 0xd0, 0x29, 0x79, 0x41, 0x24, 0x0a, 0x91, 0x44, 0xf0, 0x09, 0xd8, 0x2d, 0x2f, + 0x44, 0xff, 0x84, 0x10, 0x3f, 0x63, 0x2c, 0xf6, 0x51, 0x18, 0xf2, 0x62, 0xdf, 0xdc, 0x2d, 0xbd, + 0xcf, 0x09, 0x19, 0x31, 0x16, 0x0f, 0xc2, 0x90, 0x43, 0x1b, 0xd4, 0x72, 0xc2, 0xc5, 0x7c, 0x07, + 0x95, 0xcb, 0xde, 0x27, 0xa0, 0xa1, 0x73, 0x0e, 0xf0, 0xa9, 0x80, 0x0f, 0x40, 0x43, 0x91, 0x88, + 0x10, 0x44, 0xd8, 0x56, 0x77, 0xa3, 0xdf, 0xf0, 0xe6, 0x86, 0x9e, 0x04, 0xad, 0x0f, 0xdd, 0x68, + 0x02, 0xfe, 0x00, 0x6a, 0xc5, 0x2b, 0xea, 0xc0, 0xe6, 0xc1, 0x17, 0xce, 0x1a, 0xf7, 0xb9, 0xf3, + 0x21, 0xa0, 0x57, 0xd2, 0x7a, 0x7c, 0x7e, 0x8f, 0xae, 0x9c, 0x18, 0x02, 0x7e, 0xbf, 0x9a, 0xf4, + 0xf3, 0x6b, 0x25, 0x5d, 0xe1, 0xcd, 0x73, 0x3e, 0x02, 0xcd, 0x81, 0x79, 0xed, 0x6f, 0xa8, 0x90, + 0xef, 0x7f, 0x96, 0xed, 0x85, 0xcf, 0x72, 0x38, 0x7e, 0x7b, 0xd1, 0xb6, 0xde, 0x5d, 0xb4, 0xad, + 0xbf, 0x2e, 0xda, 0xd6, 0xab, 0xcb, 0x76, 0xe5, 0xdd, 0x65, 0xbb, 0xf2, 0xfb, 0x65, 0xbb, 0xf2, + 0xe3, 0xd3, 0x09, 0x95, 0xd1, 0x34, 0x70, 0x30, 0x4b, 0x5c, 0xcc, 0x44, 0xc2, 0x84, 0x3b, 0x2f, + 0xef, 0xf1, 0xec, 0xbf, 0xe8, 0x6c, 0xf9, 0xcf, 0x48, 0x9e, 0x67, 0x44, 0x04, 0x55, 0x3d, 0xb3, + 0x4f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x8e, 0x50, 0x86, 0x4a, 0x09, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -634,22 +629,6 @@ func (m *ConsumerAdditionProposal) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - if len(m.TransferChannelId) > 0 { - i -= len(m.TransferChannelId) - copy(dAtA[i:], m.TransferChannelId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.TransferChannelId))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - } - if len(m.ConnId) > 0 { - i -= len(m.ConnId) - copy(dAtA[i:], m.ConnId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ConnId))) - i-- - dAtA[i] = 0x7a - } if m.HistoricalEntries != 0 { i = encodeVarintProvider(dAtA, i, uint64(m.HistoricalEntries)) i-- @@ -1115,14 +1094,6 @@ func (m *ConsumerAdditionProposal) Size() (n int) { if m.HistoricalEntries != 0 { n += 1 + sovProvider(uint64(m.HistoricalEntries)) } - l = len(m.ConnId) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) - } - l = len(m.TransferChannelId) - if l > 0 { - n += 2 + l + sovProvider(uint64(l)) - } return n } @@ -1691,70 +1662,6 @@ func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { break } } - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConnId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProvider - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConnId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProvider - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TransferChannelId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipProvider(dAtA[iNdEx:]) From c6803f110ab4739af6d56c057c6f8139c935249b Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Thu, 5 Jan 2023 17:42:13 +0800 Subject: [PATCH 05/71] Resolve hermes start issue for trusted validator set by changing revision height --- consumer/start_consumer.sh | 4 ++-- consumer/start_provider.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/consumer/start_consumer.sh b/consumer/start_consumer.sh index cb987ed6c5..b9e82b98e9 100644 --- a/consumer/start_consumer.sh +++ b/consumer/start_consumer.sh @@ -297,7 +297,7 @@ PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) -$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 50000000stake \ +$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ --from $VALIDATOR \ $KEYRING \ --home $PROVIDER_HOME \ @@ -306,7 +306,7 @@ $PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 50000000stake \ sleep 1 $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} +# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} $CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR $CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR diff --git a/consumer/start_provider.sh b/consumer/start_provider.sh index cba04726fd..e2bd305657 100644 --- a/consumer/start_provider.sh +++ b/consumer/start_provider.sh @@ -110,7 +110,7 @@ tee $PROVIDER_HOME/consumer-proposal.json< Date: Fri, 6 Jan 2023 17:53:35 +0800 Subject: [PATCH 06/71] remove intermediary logs --- app/consumer-democracy/app.go | 5 ----- x/ccv/consumer/keeper/genesis.go | 12 ------------ x/ccv/consumer/keeper/validators.go | 2 -- x/ccv/consumer/module.go | 5 ----- 4 files changed, 24 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 296bdf0e14..0832daffb0 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -627,7 +627,6 @@ func New( app.UpgradeKeeper.SetUpgradeHandler( upgradeName, func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { - fmt.Println("UPGRADING DATA!!!", upgradeName) app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) @@ -643,7 +642,6 @@ func New( stdlog.Println("Failed to get home dir %2", err) } nodeHome := userHomeDir + "/.sovereign/config/genesis.json" - fmt.Println("NodeHome:", nodeHome) appState, _, err := genutiltypes.GenesisStateFromGenFile(nodeHome) if err != nil { return fromVM, fmt.Errorf("failed to unmarshal genesis state: %w", err) @@ -652,9 +650,7 @@ func New( var consumerGenesis = ibcconsumertypes.GenesisState{} appCodec.MustUnmarshalJSON(appState[ibcconsumertypes.ModuleName], &consumerGenesis) - fmt.Println("appState[ibcconsumertypes.ModuleName]", string(appState[ibcconsumertypes.ModuleName])) consumerGenesis.PreCCV = true - fmt.Println("consumerGenesis", consumerGenesis) app.ConsumerKeeper.InitGenesis(ctx, &consumerGenesis) ctx.Logger().Info("start to run module migrations...") @@ -669,7 +665,6 @@ func New( } if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - fmt.Println("UPGRADING STORAGE!!!", upgradeName) storeUpgrades := store.StoreUpgrades{ Added: []string{ibcconsumertypes.ModuleName}, } diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 8acced3dd1..98fc9ed847 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -17,13 +17,11 @@ import ( // 2. A consumer chain restarts after a client to the provider was created, but the CCV channel handshake is still in progress // 3. A consumer chain restarts after the CCV channel handshake was completed. func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) []abci.ValidatorUpdate { - fmt.Println("consumer.InitGenesis") // PreCCV is true when consumer chain used to be running on non-consumer chain, and when it is in the progress of upgrading // to consumer chain, where consumer chain upgrade is done. if state.PreCCV { k.SetPreCCV(ctx, state) } - fmt.Println("consumer.InitGenesis1") k.SetParams(ctx, state.Params) // TODO: Remove enabled flag and find a better way to setup e2e tests @@ -32,7 +30,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) return nil } - fmt.Println("consumer.InitGenesis2") k.SetPort(ctx, ccv.ConsumerPortID) // Only try to bind to port if it is not already bound, since we may already own @@ -46,11 +43,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) } } - fmt.Println("consumer.InitGenesis3") // initialValSet is checked in NewChain case by ValidateGenesis // start a new chain if state.NewChain { - fmt.Println("consumer.InitGenesis4") // create the provider client in InitGenesis for new consumer chain. CCV Handshake must be established with this client id. clientID, err := k.clientKeeper.CreateClient(ctx, state.ProviderClientState, state.ProviderConsensusState) if err != nil { @@ -64,7 +59,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) k.SetHeightValsetUpdateID(ctx, uint64(ctx.BlockHeight()), uint64(0)) } else { - fmt.Println("consumer.InitGenesis5") // chain restarts with the CCV channel established if state.ProviderChannelId != "" { // set provider channel ID @@ -87,27 +81,21 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) if err != nil { panic(fmt.Sprintf("could not set last transmission block height: %v", err)) } - } - fmt.Println("consumer.InitGenesis6") // set pending consumer pending packets // note that the list includes pending mature VSC packet only if the handshake is completed k.AppendPendingPacket(ctx, state.PendingConsumerPackets.List...) - fmt.Println("consumer.InitGenesis7") // set height to valset update id mapping for _, h2v := range state.HeightToValsetUpdateId { k.SetHeightValsetUpdateID(ctx, h2v.Height, h2v.ValsetUpdateId) } - fmt.Println("consumer.InitGenesis8") // set provider client id k.SetProviderClientID(ctx, state.ProviderClientId) - } - fmt.Println("consumer.InitGenesis9", state.InitialValSet) if state.PreCCV { return []abci.ValidatorUpdate{} } diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index dcc41f176b..73f015ca96 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -1,7 +1,6 @@ package keeper import ( - "fmt" "time" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -151,7 +150,6 @@ func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { // TrackHistoricalInfo saves the latest historical-info and deletes the oldest // heights that are below pruning height func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { - fmt.Println("Consumer.BeginBlock.TrackHistoricalInfo") numHistoricalEntries := k.GetHistoricalEntries(ctx) diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 6d6b0b0efa..55bc29a70f 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -160,7 +160,6 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // Set the VSC ID for the subsequent block to the same value as the current block // Panic if the provider's channel was established and then closed func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - fmt.Println("Consumer.BeginBlock", am.keeper.IsPreCCV(ctx)) channelID, found := am.keeper.GetProviderChannel(ctx) if found && am.keeper.IsChannelClosed(ctx, channelID) { @@ -175,7 +174,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { blockHeight := uint64(ctx.BlockHeight()) vID := am.keeper.GetHeightValsetUpdateID(ctx, blockHeight) am.keeper.SetHeightValsetUpdateID(ctx, blockHeight+1, vID) - fmt.Println("Consumer.BeginBlock.TrackHistoricalInfo", am.keeper.IsPreCCV(ctx)) am.keeper.TrackHistoricalInfo(ctx) } @@ -183,13 +181,11 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // EndBlock implements the AppModule interface // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { - fmt.Println("Consumer.EndBlock", am.keeper.IsPreCCV(ctx)) if am.keeper.IsPreCCV(ctx) { initialValSet := am.keeper.GetInitialValSet(ctx) // Note: validator set update is only done on consumer chain from first endblocker // on soft fork from existing chain am.keeper.DeletePreCCV(ctx) - fmt.Println("Consumer.EndBlock1.initialValSet", initialValSet) // populate cross chain validators states with initial valset am.keeper.ApplyCCValidatorChanges(ctx, initialValSet) @@ -203,7 +199,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V initialValSet = append(initialValSet, update) } } - fmt.Println("Consumer.EndBlock2.initialValSet", initialValSet) return initialValSet } From 2806d6f41880b40927dd66aaf97eab05f6ffec95 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Fri, 6 Jan 2023 18:01:28 +0800 Subject: [PATCH 07/71] remove further unused codebase --- proto/interchain_security/ccv/consumer/v1/genesis.proto | 4 ---- proto/interchain_security/ccv/provider/v1/provider.proto | 2 -- x/ccv/consumer/ibc_module.go | 1 - x/ccv/consumer/keeper/genesis.go | 2 -- 4 files changed, 9 deletions(-) diff --git a/proto/interchain_security/ccv/consumer/v1/genesis.proto b/proto/interchain_security/ccv/consumer/v1/genesis.proto index b3ba6ddfc3..d5efc7e6bf 100644 --- a/proto/interchain_security/ccv/consumer/v1/genesis.proto +++ b/proto/interchain_security/ccv/consumer/v1/genesis.proto @@ -40,10 +40,6 @@ message GenesisState { interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight last_transmission_block_height = 12 [ (gogoproto.nullable) = false ]; bool preCCV = 13; // flag indicating whether the consumer CCV module starts in pre-CCV state - // google.protobuf.Duration unbonding_period = 14; // the unbonding period on the consumer chain. - // string conn_id = 15; // the ID of the connection end on the consumer chain on top of which the CCV channel will be established. - // string counterparty_client_id = 16; // the ID of the client of the consumer chain on the provider chain. - // string transfer_channel_id = 17; // the ID of a token transfer channel used for the Reward Distribution sub-protocol. } // MaturingVSCPacket defines the genesis information for the diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 81466126dd..87a0058b4c 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -59,8 +59,6 @@ message ConsumerAdditionProposal { // This param is a part of the cosmos sdk staking module. In the case of // a ccv enabled consumer chain, the ccv module acts as the staking module. int64 historical_entries = 13; - // string conn_id = 15; // the ID of the connection end on the consumer chain on top of which the CCV channel will be established. - // string transfer_channel_id = 16; // the ID of a token transfer channel used for the Reward Distribution sub-protocol. } // ConsumerRemovalProposal is a governance proposal on the provider chain to remove (and stop) a consumer chain. diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index d18edddf90..59e5382040 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -213,7 +213,6 @@ func (am AppModule) OnRecvPacket( errAck := channeltypes.NewErrorAcknowledgement("cannot unmarshal CCV packet data") ack = &errAck } else { - // TODO: add possibility to receive ReplaceValidatorSet if it's the first time switching to consumer chain ack = am.keeper.OnRecvVSCPacket(ctx, packet, data) } diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 98fc9ed847..7347ff38e0 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -100,10 +100,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) return []abci.ValidatorUpdate{} } - fmt.Println("consumer.InitGenesis10", state.InitialValSet) // populate cross chain validators states with initial valset k.ApplyCCValidatorChanges(ctx, state.InitialValSet) - fmt.Println("consumer.InitGenesis11") return state.InitialValSet } From c3ae9a4313826c3b2b56793d9faef3cc669ce36e Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Wed, 18 Jan 2023 21:08:10 +0800 Subject: [PATCH 08/71] updates for endblocker test, existing test fixes, get last validators --- app/consumer-democracy/app.go | 4 +- x/ccv/consumer/ibc_module_test.go | 12 +-- x/ccv/consumer/module.go | 4 +- x/ccv/consumer/module_test.go | 119 +++++++++++++++++++++++++++ x/ccv/consumer/types/genesis_test.go | 7 ++ 5 files changed, 136 insertions(+), 10 deletions(-) create mode 100644 x/ccv/consumer/module_test.go diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 0832daffb0..e2a436db72 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -508,7 +508,7 @@ func New( ccvdistrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, - ibcconsumertypes.ModuleName, // Note: consumer initiation before staking module + ibcconsumertypes.ModuleName, // Note: consumer beginblocker before staking module ccvstakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -524,7 +524,7 @@ func New( app.MM.SetOrderEndBlockers( crisistypes.ModuleName, ccvgovtypes.ModuleName, - ibcconsumertypes.ModuleName, // Note: consumer initiation before staking module + ibcconsumertypes.ModuleName, // Note: consumer endblocker before staking module ccvstakingtypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, diff --git a/x/ccv/consumer/ibc_module_test.go b/x/ccv/consumer/ibc_module_test.go index 67eed2568c..32e02105ec 100644 --- a/x/ccv/consumer/ibc_module_test.go +++ b/x/ccv/consumer/ibc_module_test.go @@ -105,7 +105,7 @@ func TestOnChanOpenInit(t *testing.T) { // Common setup consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx( t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) consumerKeeper.SetPort(ctx, ccv.ConsumerPortID) consumerKeeper.SetProviderClientID(ctx, "clientIDToProvider") @@ -154,7 +154,7 @@ func TestOnChanOpenTry(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) // No external keeper methods should be called defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) // OnOpenTry must error even with correct arguments _, err := consumerModule.OnChanOpenTry( @@ -248,7 +248,7 @@ func TestOnChanOpenAck(t *testing.T) { // Common setup consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx( t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) // Instantiate valid params as default. Individual test cases mutate these as needed. params := params{ @@ -298,7 +298,7 @@ func TestOnChanOpenAck(t *testing.T) { func TestOnChanOpenConfirm(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) err := consumerModule.OnChanOpenConfirm(ctx, ccv.ConsumerPortID, "channel-1") require.Error(t, err, "OnChanOpenConfirm callback must error on consumer chain") @@ -338,7 +338,7 @@ func TestOnChanCloseInit(t *testing.T) { for _, tc := range testCases { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) if tc.establishedProviderExists { consumerKeeper.SetProviderChannel(ctx, "provider") @@ -366,7 +366,7 @@ func TestOnChanCloseConfirm(t *testing.T) { // No external keeper methods should be called defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper) + consumerModule := consumer.NewAppModule(consumerKeeper, nil) // Nothing happens, no error returned err := consumerModule.OnChanCloseConfirm(ctx, "portID", "channelID") diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 55bc29a70f..696ca4e12f 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -94,7 +94,7 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { } type StakingKeeper interface { - GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) + GetLastValidators(ctx sdk.Context) (validators []stakingtypes.Validator) } // AppModule represents the AppModule for this module @@ -193,7 +193,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V for _, val := range initialValSet { initialSetFlag[val.PubKey.String()] = true } - for _, val := range am.sk.GetAllValidators(ctx) { + for _, val := range am.sk.GetLastValidators(ctx) { update := val.ABCIValidatorUpdateZero() if !initialSetFlag[update.PubKey.String()] { initialValSet = append(initialValSet, update) diff --git a/x/ccv/consumer/module_test.go b/x/ccv/consumer/module_test.go new file mode 100644 index 0000000000..0851aa3188 --- /dev/null +++ b/x/ccv/consumer/module_test.go @@ -0,0 +1,119 @@ +package consumer_test + +import ( + "encoding/json" + "testing" + + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/teststaking" + ccvstakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + democracyapp "github.com/cosmos/interchain-security/app/consumer-democracy" + "github.com/cosmos/interchain-security/x/ccv/consumer" + "github.com/cosmos/interchain-security/x/ccv/consumer/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/spm/cosmoscmd" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmtypes "github.com/tendermint/tendermint/types" + dbm "github.com/tendermint/tm-db" +) + +func TestEndBlock(t *testing.T) { + PKs := simapp.CreateTestPubKeys(500) + validator1 := teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0]) + validator2 := teststaking.NewValidator(t, sdk.ValAddress(PKs[1].Address().Bytes()), PKs[1]) + _ = validator2 + + tmPK1, err := cryptocodec.ToTmPubKeyInterface(PKs[0]) + require.NoError(t, err) + tmValidator1 := tmtypes.NewValidator(tmPK1, 1) + _ = tmValidator1 + + tmPK2, err := cryptocodec.ToTmPubKeyInterface(PKs[1]) + require.NoError(t, err) + tmValidator2 := tmtypes.NewValidator(tmPK2, 1) + _ = tmValidator2 + + tmPK3, err := cryptocodec.ToTmPubKeyInterface(PKs[2]) + require.NoError(t, err) + tmValidator3 := tmtypes.NewValidator(tmPK3, 1) + _ = tmValidator3 + + testCases := []struct { + name string + preCCV bool + sovereignValidators []ccvstakingtypes.Validator + providerValidators []abci.ValidatorUpdate + expValUpdateLen int + }{ + { + name: "case not preCCV", + preCCV: false, + sovereignValidators: []ccvstakingtypes.Validator{validator1}, + providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator1)}, + expValUpdateLen: 1, + }, + { + name: "case preCCV - no duplication with sovereign validators", + preCCV: true, + sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, + providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, + expValUpdateLen: 3, + }, + { + name: "case preCCV - duplication with sovereign validators", + preCCV: true, + sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, + providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator2), tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, + expValUpdateLen: 3, + }, + } + + for _, tc := range testCases { + db := dbm.NewMemDB() + encodingConfig := cosmoscmd.MakeEncodingConfig(democracyapp.ModuleBasics) + appCodec := encodingConfig.Marshaler + app := democracyapp.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, "", 5, encodingConfig, simapp.EmptyAppOptions{}) + dApp := app.(*democracyapp.App) + ctx := dApp.BaseApp.NewContext(true, tmproto.Header{}) + + genesisState := democracyapp.NewDefaultGenesisState(appCodec) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + panic(err) + } + + app.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: simapp.DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + + dApp.StakingKeeper.SetParams(ctx, ccvstakingtypes.DefaultParams()) + for _, val := range tc.sovereignValidators { + dApp.StakingKeeper.SetValidator(ctx, val) + dApp.StakingKeeper.SetLastValidatorPower(ctx, val.GetOperator(), 1) + } + + dApp.ConsumerKeeper.SetPreCCV(ctx, &types.GenesisState{ + InitialValSet: tc.providerValidators, + PreCCV: tc.preCCV, + }) + consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper, dApp.StakingKeeper) + + valUpdate := consumerModule.EndBlock( + ctx, + abci.RequestEndBlock{}, + ) + + // check returned initial validators are expected values + require.Len(t, valUpdate, tc.expValUpdateLen) + // check preCCV deleted after the execution + require.False(t, dApp.ConsumerKeeper.IsPreCCV(ctx)) + } +} diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index c074cba70e..022729baa2 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -100,6 +100,7 @@ func TestValidateInitialGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{}, + false, }, true, }, @@ -118,6 +119,7 @@ func TestValidateInitialGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{}, + false, }, true, }, @@ -136,6 +138,7 @@ func TestValidateInitialGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{}, + false, }, true, }, @@ -154,6 +157,7 @@ func TestValidateInitialGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{Height: 1}, + false, }, true, }, @@ -172,6 +176,7 @@ func TestValidateInitialGenesisState(t *testing.T) { nil, types.ConsumerPackets{List: []types.ConsumerPacket{{}}}, types.LastTransmissionBlockHeight{}, + false, }, true, }, @@ -331,6 +336,7 @@ func TestValidateRestartGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{}, + false, }, true, }, @@ -349,6 +355,7 @@ func TestValidateRestartGenesisState(t *testing.T) { nil, types.ConsumerPackets{}, types.LastTransmissionBlockHeight{}, + false, }, true, }, From 67aa39b7fa795abb1519a5afb9731fdfa34d0c71 Mon Sep 17 00:00:00 2001 From: jstr1121 Date: Thu, 19 Jan 2023 23:27:13 +0800 Subject: [PATCH 09/71] update for slashing sovereign validators for the fault made before consumer chain upgrade height --- app/consumer-democracy/app.go | 1 + app/consumer/app.go | 1 + consumer/start_consumer2.sh | 313 ++++++++++++++++++++++++++++ consumer/start_provider2.sh | 133 ++++++++++++ x/ccv/consumer/keeper/keeper.go | 19 ++ x/ccv/consumer/keeper/validators.go | 92 +++++++- x/ccv/consumer/module.go | 2 + x/ccv/consumer/types/keys.go | 15 +- x/ccv/types/expected_keepers.go | 7 + 9 files changed, 572 insertions(+), 11 deletions(-) create mode 100644 consumer/start_consumer2.sh create mode 100644 consumer/start_provider2.sh diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index e2a436db72..860be9ef07 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -419,6 +419,7 @@ func New( &app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, + app.StakingKeeper, app.SlashingKeeper, app.BankKeeper, app.AccountKeeper, diff --git a/app/consumer/app.go b/app/consumer/app.go index ce343a9f52..c44f266d9b 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -334,6 +334,7 @@ func New( &app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, + nil, app.SlashingKeeper, app.BankKeeper, app.AccountKeeper, diff --git a/consumer/start_consumer2.sh b/consumer/start_consumer2.sh new file mode 100644 index 0000000000..38238c569c --- /dev/null +++ b/consumer/start_consumer2.sh @@ -0,0 +1,313 @@ +#!/bin/bash +set -eux + +SOVEREIGN_HOME="$HOME/.sovereign" +CONSUMER_HOME="$HOME/.consumer" +CONSUMER_HOME1="$HOME/.consumer1" +PROVIDER_CHAIN_ID="provider" +CONSUMER_CHAIN_ID="consumer" +MONIKER="consumer" +VALIDATOR="validator" +VALIDATOR1="validator1" +KEYRING="--keyring-backend test" +TX_FLAGS="--gas-adjustment 100 --gas auto" +PROVIDER_BINARY="interchain-security-pd" +SOVEREIGN_BINARY="interchain-security-sd" +CONSUMER_BINARY="interchain-security-cdd" +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +SOVEREIGN_RPC_LADDR="$NODE_IP:26648" +SOVEREIGN_GRPC_ADDR="$NODE_IP:9081" +CONSUMER_RPC_LADDR="$NODE_IP:26638" +CONSUMER_GRPC_ADDR="$NODE_IP:9071" +CONSUMER_RPC_LADDR1="$NODE_IP:26628" +CONSUMER_GRPC_ADDR1="$NODE_IP:9061" +CONSUMER_USER="consumer" +SOVEREIGN_VALIDATOR="sovereign_validator" +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_NODE_ADDRESS="tcp://localhost:26658" + +# Clean start +killall $SOVEREIGN_BINARY &> /dev/null || true +killall $CONSUMER_BINARY &> /dev/null || true +rm -rf $CONSUMER_HOME +rm -rf $CONSUMER_HOME1 +rm -rf $SOVEREIGN_HOME + +################SOVEREIGN############################ +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME +sleep 1 + +# Create user account keypair +$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 +$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 + +# Add account in genesis (required by Hermes) +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME + +# generate genesis for sovereign chain +$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 10000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME +sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json + +################CONSUMER############################ + +# Build genesis file and node directory structure +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME +sleep 1 + +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json +cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json + +#######CHAIN2####### +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 +sleep 1 +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json +cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json + +##########SET CONFIG.TOML##################### +# Set default client port +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml +sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) +node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) +node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) + +# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml + +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml + +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml + +# Start the chain +$SOVEREIGN_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$SOVEREIGN_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $SOVEREIGN_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 10 + +###########################UPGRADE TO SOVEREIGN CHAIN########################## + +$SOVEREIGN_BINARY tx gov submit-proposal software-upgrade "v07-Theta" --upgrade-height=7 \ +--title="upgrade to consumer chain" --description="upgrade to consumer chain description" \ +--from=$SOVEREIGN_VALIDATOR $KEYRING --chain-id=$CONSUMER_CHAIN_ID \ +--home=$SOVEREIGN_HOME --yes -b block --deposit="100000000stake" + +# Vote yes to proposal +$SOVEREIGN_BINARY tx gov vote 1 yes --from $SOVEREIGN_VALIDATOR --chain-id $CONSUMER_CHAIN_ID --node tcp://$SOVEREIGN_RPC_LADDR \ +--home $SOVEREIGN_HOME -b block -y $KEYRING +sleep 30 + +###########################START BINARIES AGAIN AFTER UPGRADE########################## +$SOVEREIGN_BINARY query gov proposals --node tcp://$SOVEREIGN_RPC_LADDR +$SOVEREIGN_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR +# $SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR1 + +killall $SOVEREIGN_BINARY &> /dev/null || true + +# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler +if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; +then + echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." + exit 1 +fi + +jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ + mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json + +# Modify genesis params +jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ + $SOVEREIGN_HOME/config/genesis.json > \ + $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json +sleep 1 + + +$CONSUMER_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$CONSUMER_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $CONSUMER_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 30 + +######################################HERMES################################### + +# Setup Hermes in packet relayer mode +killall hermes 2> /dev/null || true + +tee ~/.hermes/config.toml< ~/.hermes/logs & + +############################################################ + +PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) +DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) +OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) + +$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 50000000stake \ + --from $VALIDATOR \ + $KEYRING \ + --home $PROVIDER_HOME \ + --node tcp://${PROVIDER_RPC_LADDR} \ + --chain-id $PROVIDER_CHAIN_ID -y -b block +sleep 1 + +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} + +$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR + +$CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR +$PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/consumer/start_provider2.sh b/consumer/start_provider2.sh new file mode 100644 index 0000000000..613f7ae597 --- /dev/null +++ b/consumer/start_provider2.sh @@ -0,0 +1,133 @@ +#!/bin/bash +set -eux + +TOTAL_COINS=100000000000stake +STAKE_COINS=100000000stake +TOTAL_COINS1=120000000000stake +STAKE_COINS1=1000000stake +PROVIDER_BINARY=interchain-security-pd +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_CHAIN_ID=provider +PROVIDER_MONIKER=provider +VALIDATOR=validator +VALIDATOR1=validator1 +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +PROVIDER_DELEGATOR=delegator + +# Clean start +killall $PROVIDER_BINARY &> /dev/null || true + +#######VALIDATOR1####################### +rm -rf $PROVIDER_HOME + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID +jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"11600s\" | .app_state.provider.params.template_client.trusting_period = \"11300s\"" \ $PROVIDER_HOME/config/genesis.json > \ + $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json +sleep 1 + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 +sleep 1 +$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 + +# Stake 1/1000 user's coins +$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR +sleep 1 + +###########VALIDATOR 2############################ +rm -rf $PROVIDER_HOME1 + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID +cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test +sleep 1 + +####################GENTX AND DISTRIBUTE GENESIS############################## +cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ + +# Stake 1/1000 user's coins +# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 +# sleep 1 + +$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ +sleep 1 + +cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json + +####################ADDING PEERS#################### +node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) +node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml + +#################### Start the chain node1 ################### +$PROVIDER_BINARY start \ + --home $PROVIDER_HOME \ + --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ + --grpc.address $PROVIDER_GRPC_ADDR \ + --address tcp://${NODE_IP}:26655 \ + --p2p.laddr tcp://${NODE_IP}:26656 \ + --grpc-web.enable=false \ + --trace \ + &> $PROVIDER_HOME/logs & + +#################### Start the chain node2 ################### +# $PROVIDER_BINARY start \ +# --home $PROVIDER_HOME1 \ +# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ +# --grpc.address $PROVIDER_GRPC_ADDR1 \ +# --address tcp://${NODE_IP}:26665 \ +# --p2p.laddr tcp://${NODE_IP}:26666 \ +# --grpc-web.enable=false \ +# --trace \ +# &> $PROVIDER_HOME1/logs & +sleep 10 + +# Build consumer chain proposal file +tee $PROVIDER_HOME/consumer-proposal.json< Date: Tue, 31 Jan 2023 22:25:47 +0800 Subject: [PATCH 10/71] resolve comments on github and slack communication --- consumer/build_binaries.sh | 6 - .../README.md | 28 +- .../build_binaries.sh | 6 + .../start_consumer.sh | 359 ++++++++++++++++++ .../start_provider.sh | 134 +++++++ .../hermes-0.15.0}/start_consumer.sh | 13 +- .../hermes-0.15.0}/start_provider.sh | 0 .../hermes-1.2.0/start_consumer.sh | 0 .../hermes-1.2.0/start_provider.sh | 0 .../sovereign_consumer_upgrade_local}/run.sh | 0 .../start_consumer.sh | 359 ++++++++++++++++++ .../start_provider.sh | 134 +++++++ x/ccv/consumer/keeper/validators.go | 48 +-- x/ccv/consumer/module.go | 10 +- x/ccv/types/expected_keepers.go | 5 + 15 files changed, 1025 insertions(+), 77 deletions(-) delete mode 100644 consumer/build_binaries.sh rename {consumer => tests/sovereign_consumer_upgrade_local}/README.md (72%) create mode 100644 tests/sovereign_consumer_upgrade_local/build_binaries.sh create mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh create mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh rename {consumer => tests/sovereign_consumer_upgrade_local/hermes-0.15.0}/start_consumer.sh (99%) rename {consumer => tests/sovereign_consumer_upgrade_local/hermes-0.15.0}/start_provider.sh (100%) rename consumer/start_consumer2.sh => tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_consumer.sh (100%) rename consumer/start_provider2.sh => tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_provider.sh (100%) rename {consumer => tests/sovereign_consumer_upgrade_local}/run.sh (100%) create mode 100644 tests/sovereign_consumer_upgrade_local/start_consumer.sh create mode 100644 tests/sovereign_consumer_upgrade_local/start_provider.sh diff --git a/consumer/build_binaries.sh b/consumer/build_binaries.sh deleted file mode 100644 index 43ddcef129..0000000000 --- a/consumer/build_binaries.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -go install ../cmd/interchain-security-sd -go install ../cmd/interchain-security-pd -go install ../cmd/interchain-security-cdd -go install ../cmd/interchain-security-cd diff --git a/consumer/README.md b/tests/sovereign_consumer_upgrade_local/README.md similarity index 72% rename from consumer/README.md rename to tests/sovereign_consumer_upgrade_local/README.md index 5b95bf4b0c..05a841f80b 100644 --- a/consumer/README.md +++ b/tests/sovereign_consumer_upgrade_local/README.md @@ -10,6 +10,8 @@ Binaries: ### Commands +Copy `start_consumer.sh`, `start_provider.sh` from one of the directories and execute following commands. + ```sh rm -rf /Users/admin/.provider1 rm -rf /Users/admin/.provider @@ -33,32 +35,14 @@ jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$CONSUMER_HOME"/config/genesis mv "$CONSUMER_HOME"/genesis_consumer.json "$CONSUMER_HOME"/config/genesis.json ``` -### Initial validator set on consumer chain - -```json - "initial_val_set": [ - { - "pub_key": { - "ed25519": "6s4FU4uSsWNjnqhNc9vhyZBqrLjib+z/mfh1LhvkalE=" - }, - "power": "1" - }, - { - "pub_key": { - "ed25519": "JCFnTza2T2jlkTWxC0kY9lczh7F+jQ/bGyhHFFNr7/w=" - }, - "power": "100" - } - ], -``` - ### Process of execution of soft upgrade from sovereign chain to consumer chain -1. Start provider chain with two validators and register consumer chain +1. Start provider chain and register consumer chain 2. Build normal sovereign chain daemon 3. Start single validator sovereign chain -4. Two provider chain validators with sovereign chain +4. Provider chain validator with sovereign chain 5. Raise Upgrade proposal on sovereign chain and vote 6. Build consumer chain daemon with upgrade handler for ccv module and relevant modules -7. Once chain halt, restart 3 nodes +7. Once chain halt, restart 2 nodes to move from sovereign chain to consumer chain 8. Ensure blocks are being produced without the first node used for sovereign chain +9. Execute delegation on provider chain and ensure consumer chain validators' voting power changes diff --git a/tests/sovereign_consumer_upgrade_local/build_binaries.sh b/tests/sovereign_consumer_upgrade_local/build_binaries.sh new file mode 100644 index 0000000000..f20cc28b4a --- /dev/null +++ b/tests/sovereign_consumer_upgrade_local/build_binaries.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +go install ../../cmd/interchain-security-sd +go install ../../cmd/interchain-security-pd +go install ../../cmd/interchain-security-cdd +go install ../../cmd/interchain-security-cd diff --git a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh new file mode 100644 index 0000000000..3ca098f3d3 --- /dev/null +++ b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh @@ -0,0 +1,359 @@ +#!/bin/bash +set -eux + +SOVEREIGN_HOME="$HOME/.sovereign" +CONSUMER_HOME="$HOME/.consumer" +CONSUMER_HOME1="$HOME/.consumer1" +PROVIDER_CHAIN_ID="provider" +CONSUMER_CHAIN_ID="consumer" +MONIKER="consumer" +VALIDATOR="validator" +VALIDATOR1="validator1" +KEYRING="--keyring-backend test" +TX_FLAGS="--gas-adjustment 100 --gas auto" +PROVIDER_BINARY="interchain-security-pd" +SOVEREIGN_BINARY="interchain-security-sd" +CONSUMER_BINARY="interchain-security-cdd" +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +SOVEREIGN_RPC_LADDR="$NODE_IP:26648" +SOVEREIGN_GRPC_ADDR="$NODE_IP:9081" +CONSUMER_RPC_LADDR="$NODE_IP:26638" +CONSUMER_GRPC_ADDR="$NODE_IP:9071" +CONSUMER_RPC_LADDR1="$NODE_IP:26628" +CONSUMER_GRPC_ADDR1="$NODE_IP:9061" +CONSUMER_USER="consumer" +SOVEREIGN_VALIDATOR="sovereign_validator" +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_NODE_ADDRESS="tcp://localhost:26658" + +# Clean start +killall $SOVEREIGN_BINARY &> /dev/null || true +killall $CONSUMER_BINARY &> /dev/null || true +rm -rf $CONSUMER_HOME +rm -rf $CONSUMER_HOME1 +rm -rf $SOVEREIGN_HOME + +################SOVEREIGN############################ +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME +sleep 1 + +# Create user account keypair +$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 +$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 + +# Add account in genesis (required by Hermes) +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME + +# generate genesis for sovereign chain +$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 11000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME +sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json + +################CONSUMER############################ + +# Build genesis file and node directory structure +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME +sleep 1 + +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json +cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json + +#######CHAIN2####### +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 +sleep 1 +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json +cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json + +##########SET CONFIG.TOML##################### +# Set default client port +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml +sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) +node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) +node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) + +# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml + +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml + +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml + +# Start the chain +$SOVEREIGN_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$SOVEREIGN_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $SOVEREIGN_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 10 + +######################################HERMES################################### + +# Setup Hermes in packet relayer mode +killall hermes 2> /dev/null || true + +tee ~/.hermes/config.toml< ~/.hermes/logs & + +# Build consumer chain proposal file +tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true + +# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler +if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; +then + echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." + exit 1 +fi + +jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ + mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json + +# Modify genesis params +jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ + $SOVEREIGN_HOME/config/genesis.json > \ + $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json +sleep 1 + + +$CONSUMER_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$CONSUMER_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $CONSUMER_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 30 + +# # create channel between consumer and provider between provider port and consumer port +# hermes query clients consumer +# hermes query clients provider +# hermes query client consensus consumer 07-tendermint-1 +# hermes query client consensus provider 07-tendermint-1 +hermes create connection $CONSUMER_CHAIN_ID --client-a 07-tendermint-1 --client-b 07-tendermint-1 +hermes create channel $CONSUMER_CHAIN_ID --port-a consumer --port-b provider -o ordered --channel-version 1 connection-1 + +# ############################################################ + +PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) +DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) +OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) + +$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ + --from $VALIDATOR \ + $KEYRING \ + --home $PROVIDER_HOME \ + --node tcp://${PROVIDER_RPC_LADDR} \ + --chain-id $PROVIDER_CHAIN_ID -y -b block +sleep 1 + +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} +# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} + +$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR + +# $CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR +# $PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh new file mode 100644 index 0000000000..149cf32f80 --- /dev/null +++ b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set -eux + +TOTAL_COINS=100000000000stake +STAKE_COINS=100000000stake +TOTAL_COINS1=120000000000stake +STAKE_COINS1=1000000stake +PROVIDER_BINARY=interchain-security-pd +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_CHAIN_ID=provider +PROVIDER_MONIKER=provider +VALIDATOR=validator +VALIDATOR1=validator1 +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +PROVIDER_DELEGATOR=delegator + +# Clean start +killall $PROVIDER_BINARY &> /dev/null || true + +#######VALIDATOR1####################### +rm -rf $PROVIDER_HOME + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID +jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ + $PROVIDER_HOME/config/genesis.json > \ + $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json +sleep 1 + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 +sleep 1 +$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 + +# Stake 1/1000 user's coins +$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR +sleep 1 + +###########VALIDATOR 2############################ +rm -rf $PROVIDER_HOME1 + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID +cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test +sleep 1 + +####################GENTX AND DISTRIBUTE GENESIS############################## +cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ + +# Stake 1/1000 user's coins +# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 +# sleep 1 + +$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ +sleep 1 + +cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json + +####################ADDING PEERS#################### +node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) +node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml + +#################### Start the chain node1 ################### +$PROVIDER_BINARY start \ + --home $PROVIDER_HOME \ + --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ + --grpc.address $PROVIDER_GRPC_ADDR \ + --address tcp://${NODE_IP}:26655 \ + --p2p.laddr tcp://${NODE_IP}:26656 \ + --grpc-web.enable=false \ + --trace \ + &> $PROVIDER_HOME/logs & + +#################### Start the chain node2 ################### +# $PROVIDER_BINARY start \ +# --home $PROVIDER_HOME1 \ +# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ +# --grpc.address $PROVIDER_GRPC_ADDR1 \ +# --address tcp://${NODE_IP}:26665 \ +# --p2p.laddr tcp://${NODE_IP}:26666 \ +# --grpc-web.enable=false \ +# --trace \ +# &> $PROVIDER_HOME1/logs & +sleep 10 + +# # Build consumer chain proposal file +# tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true tee ~/.hermes/config.toml< /dev/null || true +killall $CONSUMER_BINARY &> /dev/null || true +rm -rf $CONSUMER_HOME +rm -rf $CONSUMER_HOME1 +rm -rf $SOVEREIGN_HOME + +################SOVEREIGN############################ +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME +sleep 1 + +# Create user account keypair +$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 +$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 + +# Add account in genesis (required by Hermes) +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME + +# generate genesis for sovereign chain +$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 11000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME +$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME +sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json + +################CONSUMER############################ + +# Build genesis file and node directory structure +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME +sleep 1 + +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json +cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json + +#######CHAIN2####### +$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 +sleep 1 +#copy genesis +cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json + +# Copy validator key files +cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json +cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json + +##########SET CONFIG.TOML##################### +# Set default client port +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml +sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml +sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) +node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) +node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) + +# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml +# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml + +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml + +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml +sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml + +# Start the chain +$SOVEREIGN_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$SOVEREIGN_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $SOVEREIGN_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 10 + +######################################HERMES################################### + +# Setup Hermes in packet relayer mode +killall hermes 2> /dev/null || true + +tee ~/.hermes/config.toml< ~/.hermes/logs & + +# Build consumer chain proposal file +tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true + +# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler +if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; +then + echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." + exit 1 +fi + +jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ + mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json + +# Modify genesis params +jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ + $SOVEREIGN_HOME/config/genesis.json > \ + $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json +sleep 1 + + +$CONSUMER_BINARY start \ + --home $SOVEREIGN_HOME \ + --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ + --grpc.address ${SOVEREIGN_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26645 \ + --p2p.laddr tcp://${NODE_IP}:26646 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $SOVEREIGN_HOME/logs & + +$CONSUMER_BINARY start \ + --home $CONSUMER_HOME \ + --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ + --grpc.address ${CONSUMER_GRPC_ADDR} \ + --address tcp://${NODE_IP}:26635 \ + --p2p.laddr tcp://${NODE_IP}:26636 \ + --grpc-web.enable=false \ + --log_level trace \ + --trace \ + &> $CONSUMER_HOME/logs & + +# $CONSUMER_BINARY start \ +# --home $CONSUMER_HOME1 \ +# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ +# --grpc.address ${CONSUMER_GRPC_ADDR1} \ +# --address tcp://${NODE_IP}:26625 \ +# --p2p.laddr tcp://${NODE_IP}:26626 \ +# --grpc-web.enable=false \ +# --log_level trace \ +# --trace \ +# &> $CONSUMER_HOME1/logs & +sleep 30 + +# # create channel between consumer and provider between provider port and consumer port +# hermes query clients consumer +# hermes query clients provider +# hermes query client consensus consumer 07-tendermint-1 +# hermes query client consensus provider 07-tendermint-1 +hermes create connection $CONSUMER_CHAIN_ID --client-a 07-tendermint-1 --client-b 07-tendermint-1 +hermes create channel $CONSUMER_CHAIN_ID --port-a consumer --port-b provider -o ordered --channel-version 1 connection-1 + +# ############################################################ + +PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) +DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) +OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) + +$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ + --from $VALIDATOR \ + $KEYRING \ + --home $PROVIDER_HOME \ + --node tcp://${PROVIDER_RPC_LADDR} \ + --chain-id $PROVIDER_CHAIN_ID -y -b block +sleep 1 + +$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} +# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} + +$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR +$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR + +# $CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR +# $PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/tests/sovereign_consumer_upgrade_local/start_provider.sh b/tests/sovereign_consumer_upgrade_local/start_provider.sh new file mode 100644 index 0000000000..149cf32f80 --- /dev/null +++ b/tests/sovereign_consumer_upgrade_local/start_provider.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set -eux + +TOTAL_COINS=100000000000stake +STAKE_COINS=100000000stake +TOTAL_COINS1=120000000000stake +STAKE_COINS1=1000000stake +PROVIDER_BINARY=interchain-security-pd +PROVIDER_HOME="$HOME/.provider" +PROVIDER_HOME1="$HOME/.provider1" +PROVIDER_CHAIN_ID=provider +PROVIDER_MONIKER=provider +VALIDATOR=validator +VALIDATOR1=validator1 +NODE_IP="localhost" +PROVIDER_RPC_LADDR="$NODE_IP:26658" +PROVIDER_GRPC_ADDR="$NODE_IP:9091" +PROVIDER_RPC_LADDR1="$NODE_IP:26668" +PROVIDER_GRPC_ADDR1="$NODE_IP:9101" +PROVIDER_DELEGATOR=delegator + +# Clean start +killall $PROVIDER_BINARY &> /dev/null || true + +#######VALIDATOR1####################### +rm -rf $PROVIDER_HOME + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID +jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ + $PROVIDER_HOME/config/genesis.json > \ + $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json +sleep 1 + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 +sleep 1 +$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test +sleep 1 + +# Stake 1/1000 user's coins +$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR +sleep 1 + +###########VALIDATOR 2############################ +rm -rf $PROVIDER_HOME1 + +$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID +cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json + +# Create account keypair +$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 +sleep 1 + +# Add stake to user +$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test +sleep 1 + +####################GENTX AND DISTRIBUTE GENESIS############################## +cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ + +# Stake 1/1000 user's coins +# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 +# sleep 1 + +$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ +sleep 1 + +cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json + +####################ADDING PEERS#################### +node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) +node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) +sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml +sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml + +#################### Start the chain node1 ################### +$PROVIDER_BINARY start \ + --home $PROVIDER_HOME \ + --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ + --grpc.address $PROVIDER_GRPC_ADDR \ + --address tcp://${NODE_IP}:26655 \ + --p2p.laddr tcp://${NODE_IP}:26656 \ + --grpc-web.enable=false \ + --trace \ + &> $PROVIDER_HOME/logs & + +#################### Start the chain node2 ################### +# $PROVIDER_BINARY start \ +# --home $PROVIDER_HOME1 \ +# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ +# --grpc.address $PROVIDER_GRPC_ADDR1 \ +# --address tcp://${NODE_IP}:26665 \ +# --p2p.laddr tcp://${NODE_IP}:26666 \ +# --grpc-web.enable=false \ +# --trace \ +# &> $PROVIDER_HOME1/logs & +sleep 10 + +# # Build consumer chain proposal file +# tee $PROVIDER_HOME/consumer-proposal.json< Date: Tue, 21 Feb 2023 23:20:07 +0800 Subject: [PATCH 11/71] update sovereign app to use v4 ibc from v3 & resolve consumer module merge conflict fix issue --- app/sovereign/app.go | 40 +++--- x/ccv/consumer/module.go | 5 - x/ccv/consumer/types/genesis.pb.go | 211 +++++++---------------------- 3 files changed, 70 insertions(+), 186 deletions(-) diff --git a/app/sovereign/app.go b/app/sovereign/app.go index 73ca49b716..66e8503009 100644 --- a/app/sovereign/app.go +++ b/app/sovereign/app.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -70,16 +70,16 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v3/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v3/modules/core" - ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" + ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcporttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" "github.com/spf13/cast" "github.com/tendermint/spm/cosmoscmd" abci "github.com/tendermint/tendermint/abci/types" @@ -93,14 +93,14 @@ import ( mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" - icacontroller "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller" - icacontrollerkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/keeper" - icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" - icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" + icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" ) const ( @@ -426,7 +426,7 @@ func New( // - stakeibc // - base app var icamiddlewareStack porttypes.IBCModule - icamiddlewareStack = icacontroller.NewIBCModule(app.ICAControllerKeeper, icamiddlewareStack) + icamiddlewareStack = icacontroller.NewIBCMiddleware(icamiddlewareStack, app.ICAControllerKeeper) icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) // Create static IBC router, add transfer route, then set and seal it diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 2caed6a77f..988d74ed19 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -199,11 +199,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V return initialValSet } - // distribution transmission - err := am.keeper.DistributeToProviderValidatorSet(ctx) - if err != nil { - panic(err) - } // Execute EndBlock logic for the Reward Distribution sub-protocol am.keeper.EndBlockRD(ctx) diff --git a/x/ccv/consumer/types/genesis.pb.go b/x/ccv/consumer/types/genesis.pb.go index 56005a0434..47253f25a1 100644 --- a/x/ccv/consumer/types/genesis.pb.go +++ b/x/ccv/consumer/types/genesis.pb.go @@ -170,7 +170,6 @@ func (m *GenesisState) GetLastTransmissionBlockHeight() LastTransmissionBlockHei return LastTransmissionBlockHeight{} } -<<<<<<< HEAD func (m *GenesisState) GetPreCCV() bool { if m != nil { return m.PreCCV @@ -178,62 +177,6 @@ func (m *GenesisState) GetPreCCV() bool { return false } -// MaturingVSCPacket defines the genesis information for the -// unbonding VSC packet -type MaturingVSCPacket struct { - VscId uint64 `protobuf:"varint,1,opt,name=vscId,proto3" json:"vscId,omitempty"` - MaturityTime uint64 `protobuf:"varint,2,opt,name=maturity_time,json=maturityTime,proto3" json:"maturity_time,omitempty"` -} - -func (m *MaturingVSCPacket) Reset() { *m = MaturingVSCPacket{} } -func (m *MaturingVSCPacket) String() string { return proto.CompactTextString(m) } -func (*MaturingVSCPacket) ProtoMessage() {} -func (*MaturingVSCPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_2db73a6057a27482, []int{1} -} -func (m *MaturingVSCPacket) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MaturingVSCPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MaturingVSCPacket.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MaturingVSCPacket) XXX_Merge(src proto.Message) { - xxx_messageInfo_MaturingVSCPacket.Merge(m, src) -} -func (m *MaturingVSCPacket) XXX_Size() int { - return m.Size() -} -func (m *MaturingVSCPacket) XXX_DiscardUnknown() { - xxx_messageInfo_MaturingVSCPacket.DiscardUnknown(m) -} - -var xxx_messageInfo_MaturingVSCPacket proto.InternalMessageInfo - -func (m *MaturingVSCPacket) GetVscId() uint64 { - if m != nil { - return m.VscId - } - return 0 -} - -func (m *MaturingVSCPacket) GetMaturityTime() uint64 { - if m != nil { - return m.MaturityTime - } - return 0 -} - -======= ->>>>>>> 558516f90cf7f111ebf8bfa1fadafaa99c50e502 // HeightValsetUpdateID defines the genesis information for the mapping // of each block height to a valset update id type HeightToValsetUpdateID struct { @@ -345,110 +288,56 @@ func init() { } var fileDescriptor_2db73a6057a27482 = []byte{ -<<<<<<< HEAD - // 800 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x6f, 0xf3, 0x34, - 0x18, 0x6e, 0xf8, 0xfa, 0x95, 0xd6, 0xdb, 0xf8, 0x36, 0x6f, 0x54, 0x61, 0x15, 0xa1, 0x74, 0x97, - 0x4a, 0x40, 0xa2, 0x0e, 0x84, 0x10, 0x48, 0x08, 0xd6, 0x49, 0x50, 0x09, 0xc6, 0xd4, 0x76, 0x3d, - 0xec, 0x12, 0xb9, 0x8e, 0x49, 0xac, 0x25, 0x76, 0x14, 0x3b, 0x19, 0x3b, 0x70, 0xe1, 0xca, 0x85, - 0x3f, 0x6b, 0xc7, 0x1d, 0x39, 0x21, 0xb4, 0xfd, 0x13, 0x1c, 0x51, 0x6c, 0xa7, 0x3f, 0xb6, 0x22, - 0x7a, 0xb3, 0xfd, 0xbe, 0xcf, 0xf3, 0xbc, 0xbf, 0xfc, 0x82, 0x01, 0x65, 0x92, 0x64, 0x38, 0x42, - 0x94, 0xf9, 0x82, 0xe0, 0x3c, 0xa3, 0xf2, 0xce, 0xc3, 0xb8, 0xf0, 0x30, 0x67, 0x22, 0x4f, 0x48, - 0xe6, 0x15, 0x03, 0x2f, 0x24, 0x8c, 0x08, 0x2a, 0xdc, 0x34, 0xe3, 0x92, 0xc3, 0x93, 0x0d, 0x10, - 0x17, 0xe3, 0xc2, 0xad, 0x20, 0x6e, 0x31, 0x38, 0x76, 0x42, 0xce, 0xc3, 0x98, 0x78, 0x0a, 0x32, - 0xcf, 0x7f, 0xf6, 0x82, 0x3c, 0x43, 0x92, 0x72, 0xa6, 0x49, 0x8e, 0x3d, 0x3a, 0xc7, 0x5e, 0x4c, - 0xc3, 0x48, 0xe2, 0x98, 0x12, 0x26, 0x85, 0x27, 0x09, 0x0b, 0x48, 0x96, 0x50, 0x26, 0x4b, 0xc9, - 0xe5, 0xcd, 0x00, 0x3e, 0x2c, 0x01, 0x98, 0x67, 0xc4, 0xc3, 0x11, 0x62, 0x8c, 0xc4, 0xa5, 0x97, - 0x39, 0x1a, 0x97, 0xa3, 0x90, 0x87, 0x5c, 0x1d, 0xbd, 0xf2, 0x64, 0x5e, 0x4f, 0xb7, 0xc9, 0x70, - 0x11, 0xba, 0xc6, 0x74, 0x56, 0x82, 0x41, 0x73, 0x4c, 0x3d, 0x79, 0x97, 0x12, 0x93, 0x7f, 0xef, - 0x9f, 0x26, 0xd8, 0xfd, 0x4e, 0x57, 0x64, 0x22, 0x91, 0x24, 0x70, 0x04, 0x1a, 0x29, 0xca, 0x50, - 0x22, 0x6c, 0xab, 0x6b, 0xf5, 0x77, 0x4e, 0x3f, 0x72, 0xb7, 0xa8, 0x90, 0x7b, 0xa9, 0x20, 0x67, - 0xf5, 0xfb, 0xbf, 0x3e, 0xa8, 0x8d, 0x0d, 0x01, 0xfc, 0x18, 0xc0, 0x34, 0xe3, 0x05, 0x0d, 0x48, - 0xe6, 0xeb, 0xc2, 0xf8, 0x34, 0xb0, 0xdf, 0xea, 0x5a, 0xfd, 0xd6, 0x78, 0xbf, 0xb2, 0x0c, 0x95, - 0x61, 0x14, 0x40, 0x17, 0x1c, 0x2e, 0xbd, 0x75, 0x29, 0x4a, 0xf7, 0x57, 0xca, 0xfd, 0x60, 0xe1, - 0xae, 0x2d, 0xa3, 0x00, 0x76, 0x40, 0x8b, 0x91, 0x5b, 0x5f, 0x05, 0x66, 0xd7, 0xbb, 0x56, 0xbf, - 0x39, 0x6e, 0x32, 0x72, 0x3b, 0x2c, 0xef, 0xd0, 0x07, 0xef, 0x3e, 0x97, 0x16, 0x65, 0x7a, 0xf6, - 0xeb, 0x2a, 0xa9, 0x39, 0x76, 0x57, 0x3b, 0xe6, 0xae, 0xf4, 0xa8, 0x18, 0xb8, 0x3a, 0x2a, 0x55, - 0x91, 0xf1, 0xe1, 0x7a, 0xa8, 0xba, 0x4c, 0x11, 0xb0, 0x97, 0x02, 0x9c, 0x09, 0xc2, 0x44, 0x2e, - 0x8c, 0x46, 0x43, 0x69, 0xb8, 0xff, 0xab, 0x51, 0xc1, 0xb4, 0x4c, 0x7b, 0x21, 0xb3, 0xf6, 0x0e, - 0x43, 0xb0, 0x9f, 0x20, 0x99, 0x67, 0x94, 0x85, 0x7e, 0x8a, 0xf0, 0x0d, 0x91, 0xc2, 0x7e, 0xbb, - 0xfb, 0xaa, 0xbf, 0x73, 0xfa, 0xf9, 0x56, 0xad, 0xf9, 0xd1, 0x80, 0x67, 0x93, 0xe1, 0xa5, 0x82, - 0x9b, 0x2e, 0xbd, 0xa9, 0x58, 0xf5, 0xab, 0x80, 0x17, 0xe0, 0x0d, 0x65, 0x54, 0x52, 0x14, 0xfb, - 0x05, 0x8a, 0x7d, 0x41, 0xa4, 0xdd, 0x54, 0x3a, 0xdd, 0xd5, 0xc0, 0xcb, 0x09, 0x72, 0x67, 0x28, - 0xa6, 0x01, 0x92, 0x3c, 0xbb, 0x4a, 0x03, 0x24, 0x89, 0x61, 0xdc, 0x33, 0xf0, 0x19, 0x8a, 0x27, - 0x44, 0xc2, 0x5f, 0xc1, 0x71, 0x44, 0xca, 0xf4, 0x7d, 0xc9, 0x4b, 0x46, 0x41, 0xa4, 0x9f, 0x2b, - 0xff, 0xb2, 0xaf, 0x2d, 0x45, 0xfd, 0xd5, 0x56, 0x29, 0x7c, 0xaf, 0x68, 0xa6, 0x7c, 0xa6, 0x48, - 0xb4, 0xe6, 0xe8, 0xdc, 0xa8, 0xb6, 0xa3, 0x4d, 0xd6, 0x00, 0xfe, 0x66, 0x81, 0xf7, 0x79, 0x2e, - 0x85, 0x44, 0x2c, 0x28, 0x6b, 0x17, 0xf0, 0x5b, 0x26, 0x69, 0x42, 0x7c, 0x11, 0x23, 0x11, 0x51, - 0x16, 0xda, 0x40, 0x85, 0xf0, 0xc5, 0x56, 0x21, 0xfc, 0xb4, 0x64, 0x3a, 0x37, 0x44, 0x46, 0xbf, - 0xc3, 0x5f, 0x9a, 0x26, 0x46, 0x02, 0x4a, 0x60, 0xa7, 0x44, 0xeb, 0x57, 0x6c, 0x8b, 0x26, 0xee, - 0xa8, 0x31, 0xf9, 0x6c, 0x2b, 0xf9, 0xa1, 0x39, 0x9b, 0x5e, 0x55, 0xa9, 0x1b, 0xee, 0x67, 0x56, - 0xf8, 0xbb, 0x05, 0x9c, 0x18, 0x09, 0xe9, 0xcb, 0x0c, 0x31, 0x91, 0x50, 0x21, 0x28, 0x67, 0xfe, - 0x3c, 0xe6, 0xf8, 0xc6, 0xd7, 0xd5, 0xb2, 0x77, 0x95, 0xf8, 0x37, 0x5b, 0x89, 0xff, 0x80, 0x84, - 0x9c, 0xae, 0x30, 0x9d, 0x95, 0x44, 0xba, 0x27, 0x55, 0x0d, 0xe2, 0xff, 0x76, 0x81, 0x6d, 0xd0, - 0x48, 0x33, 0x32, 0x1c, 0xce, 0xec, 0x3d, 0xf5, 0x4b, 0xcd, 0xad, 0x77, 0x01, 0x0e, 0x5e, 0xcc, - 0x26, 0x3c, 0x02, 0xaf, 0x0b, 0x81, 0x47, 0x81, 0xda, 0x3e, 0xf5, 0xb1, 0xbe, 0xc0, 0x13, 0xb0, - 0xa7, 0xa7, 0x55, 0xde, 0xf9, 0x65, 0x7d, 0xd5, 0x12, 0xa9, 0x8f, 0x77, 0xab, 0xc7, 0x29, 0x4d, - 0x48, 0xef, 0x1a, 0xb4, 0x37, 0x0f, 0x4a, 0x19, 0x81, 0x49, 0x5b, 0xb3, 0x9a, 0x1b, 0xec, 0x83, - 0xfd, 0x17, 0x73, 0xa9, 0x99, 0xdf, 0x29, 0xd6, 0x86, 0xa9, 0x77, 0x05, 0x0e, 0x37, 0x4c, 0x00, - 0xfc, 0x1a, 0x74, 0x8a, 0xea, 0x2b, 0xac, 0xac, 0x01, 0x14, 0x04, 0x19, 0x11, 0x7a, 0x83, 0xb6, - 0xc6, 0xef, 0x2d, 0x5c, 0x16, 0x3f, 0xfb, 0x5b, 0xed, 0x70, 0x36, 0xbd, 0x7f, 0x74, 0xac, 0x87, - 0x47, 0xc7, 0xfa, 0xfb, 0xd1, 0xb1, 0xfe, 0x78, 0x72, 0x6a, 0x0f, 0x4f, 0x4e, 0xed, 0xcf, 0x27, - 0xa7, 0x76, 0xfd, 0x65, 0x48, 0x65, 0x94, 0xcf, 0x5d, 0xcc, 0x13, 0x0f, 0x73, 0x91, 0x70, 0xe1, - 0x2d, 0x5b, 0xf5, 0xc9, 0x62, 0xf5, 0xff, 0xb2, 0xbe, 0xfc, 0xd5, 0x66, 0x9f, 0x37, 0xd4, 0x6a, - 0xff, 0xf4, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x7c, 0x6e, 0x21, 0x0f, 0x07, 0x00, 0x00, -======= - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcf, 0x6f, 0xdb, 0x36, - 0x14, 0xb6, 0x92, 0xcc, 0xb3, 0x99, 0x6c, 0xc9, 0x98, 0xcd, 0xd0, 0x6c, 0x4c, 0xf3, 0xb2, 0x1d, - 0x0c, 0x6c, 0x93, 0x60, 0x0f, 0x18, 0x86, 0x15, 0x28, 0xda, 0x24, 0x40, 0x6b, 0x20, 0x6d, 0x03, - 0x3b, 0xf1, 0x21, 0x17, 0x81, 0xa6, 0x58, 0x89, 0x88, 0x44, 0x1a, 0x22, 0xa5, 0x34, 0x87, 0x5e, - 0x7a, 0xed, 0xa5, 0x7f, 0x56, 0x8e, 0x39, 0xf6, 0x14, 0x14, 0xc9, 0x3f, 0x52, 0x88, 0xa4, 0xfc, - 0xa3, 0x71, 0x50, 0x9f, 0x4c, 0xf2, 0x7d, 0xef, 0xfb, 0xde, 0x7b, 0x1f, 0x4d, 0x81, 0x2e, 0x65, - 0x92, 0xa4, 0x38, 0x42, 0x94, 0xf9, 0x82, 0xe0, 0x2c, 0xa5, 0xf2, 0xd2, 0xc3, 0x38, 0xf7, 0x30, - 0x67, 0x22, 0x4b, 0x48, 0xea, 0xe5, 0x5d, 0x2f, 0x24, 0x8c, 0x08, 0x2a, 0xdc, 0x49, 0xca, 0x25, - 0x87, 0xbf, 0x2f, 0x49, 0x71, 0x31, 0xce, 0xdd, 0x32, 0xc5, 0xcd, 0xbb, 0xcd, 0x3f, 0x1e, 0xe2, - 0xcd, 0xbb, 0xc5, 0x8f, 0xa6, 0x6a, 0xf6, 0x56, 0x51, 0x9f, 0xd2, 0xea, 0x9c, 0x96, 0x24, 0x2c, - 0x20, 0x69, 0x42, 0x99, 0xf4, 0xd0, 0x18, 0x53, 0x4f, 0x5e, 0x4e, 0x88, 0xa9, 0xad, 0xe9, 0xd1, - 0x31, 0xf6, 0x62, 0x1a, 0x46, 0x12, 0xc7, 0x94, 0x30, 0x29, 0xbc, 0x39, 0x74, 0xde, 0x9d, 0xdb, - 0x99, 0x84, 0xdf, 0x8a, 0x04, 0xcc, 0x53, 0xe2, 0xe1, 0x08, 0x31, 0x46, 0x62, 0xa5, 0xa8, 0x97, - 0x06, 0xe2, 0x84, 0x9c, 0x87, 0x31, 0xf1, 0xd4, 0x6e, 0x9c, 0xbd, 0xf6, 0x82, 0x2c, 0x45, 0x92, - 0x72, 0x66, 0xe2, 0x3f, 0x86, 0x3c, 0xe4, 0x6a, 0xe9, 0x15, 0x2b, 0x7d, 0xba, 0x77, 0x53, 0x03, - 0x5b, 0xcf, 0xf4, 0xdc, 0x86, 0x12, 0x49, 0x02, 0xfb, 0xa0, 0x3a, 0x41, 0x29, 0x4a, 0x84, 0x6d, - 0xb5, 0xad, 0xce, 0x66, 0xef, 0x4f, 0x77, 0x85, 0x39, 0xba, 0xc7, 0x2a, 0x65, 0x7f, 0xe3, 0xea, - 0xe6, 0xd7, 0xca, 0xc0, 0x10, 0xc0, 0xbf, 0x00, 0x9c, 0xa4, 0x3c, 0xa7, 0x01, 0x49, 0x7d, 0xdd, - 0xa7, 0x4f, 0x03, 0x7b, 0xad, 0x6d, 0x75, 0xea, 0x83, 0x9d, 0x32, 0x72, 0xa0, 0x02, 0xfd, 0x00, - 0xba, 0x60, 0x77, 0x86, 0xd6, 0x9d, 0x15, 0xf0, 0x75, 0x05, 0xff, 0x61, 0x0a, 0xd7, 0x91, 0x7e, - 0x00, 0x5b, 0xa0, 0xce, 0xc8, 0x85, 0xaf, 0x0a, 0xb3, 0x37, 0xda, 0x56, 0xa7, 0x36, 0xa8, 0x31, - 0x72, 0x71, 0x50, 0xec, 0xa1, 0x0f, 0x7e, 0xfa, 0x52, 0x5a, 0x14, 0xed, 0xd9, 0xdf, 0x94, 0x4d, - 0x8d, 0xb1, 0x3b, 0x6f, 0x80, 0x3b, 0x37, 0xf2, 0xbc, 0xeb, 0xea, 0xaa, 0xd4, 0x44, 0x06, 0xbb, - 0x8b, 0xa5, 0xea, 0x31, 0x45, 0xc0, 0x9e, 0x09, 0x70, 0x26, 0x08, 0x13, 0x99, 0x30, 0x1a, 0x55, - 0xa5, 0xe1, 0x7e, 0x55, 0xa3, 0x4c, 0xd3, 0x32, 0x8d, 0xa9, 0xcc, 0xc2, 0x39, 0x0c, 0xc1, 0x4e, - 0x82, 0x64, 0x96, 0x52, 0x16, 0xfa, 0x13, 0x84, 0xcf, 0x89, 0x14, 0xf6, 0xb7, 0xed, 0xf5, 0xce, - 0x66, 0xef, 0xdf, 0x95, 0xac, 0x79, 0x61, 0x92, 0x47, 0xc3, 0x83, 0x63, 0x95, 0x6e, 0x5c, 0xda, - 0x2e, 0x59, 0xf5, 0xa9, 0x80, 0x2f, 0xc1, 0x36, 0x65, 0x54, 0x52, 0x14, 0xfb, 0x39, 0x8a, 0x7d, - 0x41, 0xa4, 0x5d, 0x53, 0x3a, 0xed, 0xf9, 0xc2, 0x8b, 0xbb, 0xec, 0x8e, 0x50, 0x4c, 0x03, 0x24, - 0x79, 0x7a, 0x3a, 0x09, 0x90, 0x24, 0x86, 0xf1, 0x3b, 0x93, 0x3e, 0x42, 0xf1, 0x90, 0x48, 0xf8, - 0x16, 0x34, 0x23, 0x52, 0xb4, 0xef, 0x4b, 0x5e, 0x30, 0x0a, 0x22, 0xfd, 0x4c, 0xe1, 0x0b, 0x5f, - 0xeb, 0x8a, 0xfa, 0xd1, 0x4a, 0x2d, 0x3c, 0x57, 0x34, 0x27, 0x7c, 0xa4, 0x48, 0xb4, 0x66, 0xff, - 0xd0, 0xa8, 0x36, 0xa2, 0x65, 0xd1, 0x00, 0xbe, 0xb3, 0xc0, 0x2f, 0x3c, 0x93, 0x42, 0x22, 0x16, - 0x14, 0xb3, 0x0b, 0xf8, 0x05, 0x93, 0x34, 0x21, 0xbe, 0x88, 0x91, 0x88, 0x28, 0x0b, 0x6d, 0xa0, - 0x4a, 0xf8, 0x6f, 0xa5, 0x12, 0x5e, 0xcd, 0x98, 0x0e, 0x0d, 0x91, 0xd1, 0x6f, 0xf1, 0xfb, 0xa1, - 0xa1, 0x91, 0x80, 0x29, 0xb0, 0x27, 0x44, 0xeb, 0x97, 0x6c, 0x53, 0x13, 0x37, 0xd5, 0x35, 0xe9, - 0x3d, 0x28, 0x6f, 0xae, 0x48, 0x91, 0xa3, 0x2d, 0x3a, 0x44, 0x12, 0x1d, 0x51, 0x51, 0x1a, 0xd8, - 0x30, 0xcc, 0x8b, 0x20, 0x01, 0xdf, 0x5b, 0xc0, 0x89, 0x91, 0x90, 0xbe, 0x4c, 0x11, 0x13, 0x09, - 0x15, 0x82, 0x72, 0xe6, 0x8f, 0x63, 0x8e, 0xcf, 0x7d, 0x3d, 0x2b, 0x7b, 0x4b, 0x49, 0x3f, 0x59, - 0xa9, 0xf3, 0x23, 0x24, 0xe4, 0xc9, 0x1c, 0xd3, 0x7e, 0x41, 0xa4, 0x1d, 0x29, 0x27, 0x10, 0x3f, - 0x0c, 0xd9, 0x3b, 0x03, 0x8d, 0xe5, 0xf6, 0xc1, 0x06, 0xa8, 0x9a, 0x72, 0x8a, 0x97, 0x66, 0x63, - 0x60, 0x76, 0xb0, 0x03, 0x76, 0xee, 0xdd, 0x96, 0x35, 0x85, 0xf8, 0x3e, 0x5f, 0xb0, 0x78, 0xef, - 0x14, 0xec, 0x2e, 0xf1, 0x05, 0x3e, 0x06, 0xad, 0xbc, 0xbc, 0xa0, 0x73, 0x7f, 0x4e, 0x14, 0x04, - 0x29, 0x11, 0xfa, 0x5d, 0xab, 0x0f, 0x7e, 0x9e, 0x42, 0xa6, 0xff, 0xb7, 0xa7, 0x1a, 0xb0, 0x7f, - 0x72, 0x75, 0xeb, 0x58, 0xd7, 0xb7, 0x8e, 0xf5, 0xe9, 0xd6, 0xb1, 0x3e, 0xdc, 0x39, 0x95, 0xeb, - 0x3b, 0xa7, 0xf2, 0xf1, 0xce, 0xa9, 0x9c, 0xfd, 0x1f, 0x52, 0x19, 0x65, 0x63, 0x17, 0xf3, 0xc4, - 0xc3, 0x5c, 0x24, 0x5c, 0x78, 0xb3, 0x11, 0xfe, 0x3d, 0xfd, 0x34, 0xbc, 0x59, 0xfc, 0x38, 0xa8, - 0x97, 0x7f, 0x5c, 0x55, 0x0f, 0xee, 0x3f, 0x9f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x5a, 0x50, - 0x50, 0xcb, 0x06, 0x00, 0x00, ->>>>>>> 558516f90cf7f111ebf8bfa1fadafaa99c50e502 + // 782 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcf, 0x6f, 0xeb, 0x34, + 0x1c, 0x6f, 0xde, 0x1b, 0xa5, 0xf5, 0xde, 0xe3, 0x0d, 0x0f, 0xaa, 0xd0, 0x8a, 0x50, 0x06, 0x87, + 0x4a, 0x40, 0xa2, 0x16, 0x09, 0x21, 0x90, 0x10, 0xac, 0x93, 0xa0, 0xd2, 0x80, 0xa9, 0xdd, 0x7a, + 0xd8, 0x25, 0x72, 0x1d, 0x93, 0x58, 0x4b, 0xec, 0xc8, 0x76, 0x32, 0x76, 0xe0, 0xc2, 0x95, 0x0b, + 0x7f, 0xd6, 0x8e, 0x3b, 0x72, 0x42, 0x68, 0xfb, 0x1f, 0x38, 0xa3, 0xd8, 0x4e, 0x7f, 0xb0, 0x4e, + 0xaf, 0xa7, 0xc4, 0xf9, 0x7e, 0x7e, 0x7c, 0x7f, 0x38, 0x36, 0x18, 0x52, 0xa6, 0x88, 0xc0, 0x09, + 0xa2, 0x2c, 0x94, 0x04, 0x17, 0x82, 0xaa, 0x9b, 0x00, 0xe3, 0x32, 0xc0, 0x9c, 0xc9, 0x22, 0x23, + 0x22, 0x28, 0x87, 0x41, 0x4c, 0x18, 0x91, 0x54, 0xfa, 0xb9, 0xe0, 0x8a, 0xc3, 0x8f, 0xb6, 0x50, + 0x7c, 0x8c, 0x4b, 0xbf, 0xa6, 0xf8, 0xe5, 0xb0, 0xfb, 0xf1, 0x53, 0xba, 0xe5, 0xb0, 0x7a, 0x18, + 0xa9, 0xee, 0x68, 0x17, 0xf7, 0xa5, 0xac, 0xe1, 0xf4, 0x14, 0x61, 0x11, 0x11, 0x19, 0x65, 0x2a, + 0x40, 0x0b, 0x4c, 0x03, 0x75, 0x93, 0x13, 0x9b, 0x5b, 0x37, 0xa0, 0x0b, 0x1c, 0xa4, 0x34, 0x4e, + 0x14, 0x4e, 0x29, 0x61, 0x4a, 0x06, 0x6b, 0xe8, 0x72, 0xb8, 0xb6, 0xb2, 0x84, 0x0f, 0x2b, 0x02, + 0xe6, 0x82, 0x04, 0x38, 0x41, 0x8c, 0x91, 0x54, 0x3b, 0x9a, 0x57, 0x0b, 0xf1, 0x62, 0xce, 0xe3, + 0x94, 0x04, 0x7a, 0xb5, 0x28, 0x7e, 0x09, 0xa2, 0x42, 0x20, 0x45, 0x39, 0xb3, 0xf1, 0x77, 0x62, + 0x1e, 0x73, 0xfd, 0x1a, 0x54, 0x6f, 0xe6, 0xeb, 0xd1, 0xbf, 0x2d, 0xf0, 0xe2, 0x7b, 0xd3, 0xb7, + 0x99, 0x42, 0x8a, 0xc0, 0x09, 0x68, 0xe6, 0x48, 0xa0, 0x4c, 0xba, 0x4e, 0xdf, 0x19, 0xec, 0x8f, + 0x3e, 0xf1, 0x77, 0xe8, 0xa3, 0x7f, 0xa6, 0x29, 0xc7, 0x7b, 0xb7, 0x7f, 0x7f, 0xd0, 0x98, 0x5a, + 0x01, 0xf8, 0x29, 0x80, 0xb9, 0xe0, 0x25, 0x8d, 0x88, 0x08, 0x4d, 0x9d, 0x21, 0x8d, 0xdc, 0x67, + 0x7d, 0x67, 0xd0, 0x9e, 0x1e, 0xd4, 0x91, 0xb1, 0x0e, 0x4c, 0x22, 0xe8, 0x83, 0xc3, 0x15, 0xda, + 0x54, 0x56, 0xc1, 0x9f, 0x6b, 0xf8, 0xdb, 0x4b, 0xb8, 0x89, 0x4c, 0x22, 0xd8, 0x03, 0x6d, 0x46, + 0xae, 0x43, 0x9d, 0x98, 0xbb, 0xd7, 0x77, 0x06, 0xad, 0x69, 0x8b, 0x91, 0xeb, 0x71, 0xb5, 0x86, + 0x21, 0x78, 0xf7, 0xff, 0xd6, 0xb2, 0x2a, 0xcf, 0x7d, 0xa3, 0x2e, 0x6a, 0x81, 0xfd, 0xf5, 0x01, + 0xf8, 0x6b, 0x2d, 0x2f, 0x87, 0xbe, 0xc9, 0x4a, 0x77, 0x64, 0x7a, 0xb8, 0x99, 0xaa, 0x69, 0x53, + 0x02, 0xdc, 0x95, 0x01, 0x67, 0x92, 0x30, 0x59, 0x48, 0xeb, 0xd1, 0xd4, 0x1e, 0xfe, 0x6b, 0x3d, + 0x6a, 0x9a, 0xb1, 0xe9, 0x2c, 0x6d, 0x36, 0xbe, 0xc3, 0x18, 0x1c, 0x64, 0x48, 0x15, 0x82, 0xb2, + 0x38, 0xcc, 0x11, 0xbe, 0x22, 0x4a, 0xba, 0x6f, 0xf6, 0x9f, 0x0f, 0xf6, 0x47, 0x5f, 0xec, 0x34, + 0x9a, 0x1f, 0x2d, 0x79, 0x3e, 0x1b, 0x9f, 0x69, 0xba, 0x9d, 0xd2, 0xab, 0x5a, 0xd5, 0x7c, 0x95, + 0xf0, 0x27, 0xf0, 0x8a, 0x32, 0xaa, 0x28, 0x4a, 0xc3, 0x12, 0xa5, 0xa1, 0x24, 0xca, 0x6d, 0x69, + 0x9f, 0xfe, 0x7a, 0xe2, 0xd5, 0x5e, 0xf6, 0xe7, 0x28, 0xa5, 0x11, 0x52, 0x5c, 0x5c, 0xe4, 0x11, + 0x52, 0xc4, 0x2a, 0xbe, 0xb4, 0xf4, 0x39, 0x4a, 0x67, 0x44, 0xc1, 0xdf, 0x40, 0x37, 0x21, 0x55, + 0xf9, 0xa1, 0xe2, 0x95, 0xa2, 0x24, 0x2a, 0x2c, 0x34, 0xbe, 0x9a, 0x6b, 0x5b, 0x4b, 0x7f, 0xbd, + 0x53, 0x09, 0x3f, 0x68, 0x99, 0x73, 0x3e, 0xd7, 0x22, 0xc6, 0x73, 0x72, 0x62, 0x5d, 0x3b, 0xc9, + 0xb6, 0x68, 0x04, 0x7f, 0x77, 0xc0, 0xfb, 0xbc, 0x50, 0x52, 0x21, 0x16, 0x55, 0xbd, 0x8b, 0xf8, + 0x35, 0x53, 0x34, 0x23, 0xa1, 0x4c, 0x91, 0x4c, 0x28, 0x8b, 0x5d, 0xa0, 0x53, 0xf8, 0x72, 0xa7, + 0x14, 0x7e, 0x5e, 0x29, 0x9d, 0x58, 0x21, 0xeb, 0xdf, 0xe3, 0x8f, 0x43, 0x33, 0x6b, 0x01, 0x05, + 0x70, 0x73, 0x62, 0xfc, 0x6b, 0xb5, 0xe5, 0x10, 0xf7, 0xf5, 0x36, 0x19, 0x3d, 0x69, 0x6f, 0xb7, + 0x48, 0xc5, 0x31, 0x23, 0x3a, 0x41, 0x0a, 0x9d, 0x52, 0x59, 0x0f, 0xb0, 0x63, 0x95, 0x37, 0x41, + 0x12, 0xfe, 0xe1, 0x00, 0x2f, 0x45, 0x52, 0x85, 0x4a, 0x20, 0x26, 0x33, 0x2a, 0x25, 0xe5, 0x2c, + 0x5c, 0xa4, 0x1c, 0x5f, 0x85, 0xa6, 0x57, 0xee, 0x0b, 0x6d, 0xfd, 0xed, 0x4e, 0x95, 0x9f, 0x22, + 0xa9, 0xce, 0xd7, 0x94, 0x8e, 0x2b, 0x21, 0x33, 0x91, 0xba, 0x03, 0xe9, 0xd3, 0x10, 0xd8, 0x01, + 0xcd, 0x5c, 0x90, 0xf1, 0x78, 0xee, 0xbe, 0xd4, 0xff, 0xa8, 0x5d, 0x1d, 0x5d, 0x82, 0xce, 0xf6, + 0xb1, 0x56, 0x0c, 0x9b, 0x66, 0x75, 0x02, 0xed, 0x4d, 0xed, 0x0a, 0x0e, 0xc0, 0xc1, 0xa3, 0x5d, + 0xf4, 0x4c, 0x23, 0xde, 0x2a, 0x37, 0x46, 0x7f, 0x74, 0x01, 0x0e, 0xb7, 0xcc, 0x0b, 0x7e, 0x03, + 0x7a, 0x65, 0xbd, 0x71, 0xd7, 0x7e, 0x5a, 0x14, 0x45, 0x82, 0x48, 0x73, 0xde, 0xb5, 0xa7, 0xef, + 0x2d, 0x21, 0xcb, 0xff, 0xf0, 0x3b, 0x03, 0x38, 0x3e, 0xbf, 0xbd, 0xf7, 0x9c, 0xbb, 0x7b, 0xcf, + 0xf9, 0xe7, 0xde, 0x73, 0xfe, 0x7c, 0xf0, 0x1a, 0x77, 0x0f, 0x5e, 0xe3, 0xaf, 0x07, 0xaf, 0x71, + 0xf9, 0x55, 0x4c, 0x55, 0x52, 0x2c, 0x7c, 0xcc, 0xb3, 0x00, 0x73, 0x99, 0x71, 0x19, 0xac, 0x5a, + 0xfb, 0xd9, 0xf2, 0xca, 0xf8, 0x75, 0xf3, 0xd2, 0xd0, 0x37, 0xc2, 0xa2, 0xa9, 0x0f, 0xe2, 0xcf, + 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xab, 0x08, 0x12, 0x9c, 0xe3, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { From 62da0d29ab83fdf60e75b4990dff1a10ae3f9d81 Mon Sep 17 00:00:00 2001 From: jstr1121 <118450565+jstr1121@users.noreply.github.com> Date: Tue, 21 Feb 2023 23:21:53 +0800 Subject: [PATCH 12/71] Update app/sovereign/upgrades/v3/upgrades.go Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com> --- app/sovereign/upgrades/v3/upgrades.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/sovereign/upgrades/v3/upgrades.go b/app/sovereign/upgrades/v3/upgrades.go index bb40c1713a..39cfa318f1 100644 --- a/app/sovereign/upgrades/v3/upgrades.go +++ b/app/sovereign/upgrades/v3/upgrades.go @@ -18,9 +18,6 @@ func CreateUpgradeHandler( ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { newVm, err := mm.RunMigrations(ctx, configurator, vm) - if err != nil { - return newVm, err - } - return newVm, nil + return newVm, err } } From d46d6ef29ea82ebd75061976678b962b415e65c2 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:50:48 -0800 Subject: [PATCH 13/71] rm sovereign chain and tests. Will be replaced by simapp and integration tests --- app/sovereign/app.go | 808 ------------------ app/sovereign/encoding.go | 38 - app/sovereign/export.go | 201 ----- app/sovereign/genesis.go | 20 - app/sovereign/upgrades.go | 31 - app/sovereign/upgrades/v3/upgrades.go | 23 - cmd/interchain-security-sd/main.go | 32 - .../README.md | 48 -- .../build_binaries.sh | 6 - .../start_consumer.sh | 359 -------- .../start_provider.sh | 134 --- .../hermes-0.15.0/start_consumer.sh | 304 ------- .../hermes-0.15.0/start_provider.sh | 134 --- .../hermes-1.2.0/start_consumer.sh | 313 ------- .../hermes-1.2.0/start_provider.sh | 133 --- tests/sovereign_consumer_upgrade_local/run.sh | 6 - .../start_consumer.sh | 359 -------- .../start_provider.sh | 134 --- 18 files changed, 3083 deletions(-) delete mode 100644 app/sovereign/app.go delete mode 100644 app/sovereign/encoding.go delete mode 100644 app/sovereign/export.go delete mode 100644 app/sovereign/genesis.go delete mode 100644 app/sovereign/upgrades.go delete mode 100644 app/sovereign/upgrades/v3/upgrades.go delete mode 100644 cmd/interchain-security-sd/main.go delete mode 100644 tests/sovereign_consumer_upgrade_local/README.md delete mode 100644 tests/sovereign_consumer_upgrade_local/build_binaries.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0/start_consumer.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-0.15.0/start_provider.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_consumer.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_provider.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/run.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/start_consumer.sh delete mode 100644 tests/sovereign_consumer_upgrade_local/start_provider.sh diff --git a/app/sovereign/app.go b/app/sovereign/app.go deleted file mode 100644 index 66e8503009..0000000000 --- a/app/sovereign/app.go +++ /dev/null @@ -1,808 +0,0 @@ -package app - -import ( - "io" - "os" - "path/filepath" - - porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/cosmos/cosmos-sdk/client/rpc" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/server/api" - "github.com/cosmos/cosmos-sdk/server/config" - servertypes "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/auth/ante" - authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/x/authz" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - "github.com/cosmos/cosmos-sdk/x/bank" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/cosmos-sdk/x/crisis" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distr "github.com/cosmos/cosmos-sdk/x/distribution" - distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/cosmos-sdk/x/gov" - govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/cosmos/cosmos-sdk/x/params" - paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/cosmos/cosmos-sdk/x/slashing" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v4/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v4/modules/core" - ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - ibcporttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" - "github.com/spf13/cast" - "github.com/tendermint/spm/cosmoscmd" - abci "github.com/tendermint/tendermint/abci/types" - tmjson "github.com/tendermint/tendermint/libs/json" - "github.com/tendermint/tendermint/libs/log" - tmos "github.com/tendermint/tendermint/libs/os" - dbm "github.com/tendermint/tm-db" - - // add mint - mint "github.com/cosmos/cosmos-sdk/x/mint" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - - ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" - icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller" - icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper" - icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" - icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" -) - -const ( - AccountAddressPrefix = "cosmos" - AppName = "interchain-security-sovereign" - Version = "3.0.0" -) - -// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals - -func getGovProposalHandlers() []govclient.ProposalHandler { - var govProposalHandlers []govclient.ProposalHandler - // this line is used by starport scaffolding # stargate/app/govProposalHandlers - - govProposalHandlers = append(govProposalHandlers, - paramsclient.ProposalHandler, - distrclient.ProposalHandler, - upgradeclient.ProposalHandler, - upgradeclient.CancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, - // this line is used by starport scaffolding # stargate/app/govProposalHandler - ) - - return govProposalHandlers -} - -var ( - // DefaultNodeHome default home directories for the application daemon - DefaultNodeHome string - - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - genutil.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic(getGovProposalHandlers()...), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - ibc.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - ica.AppModuleBasic{}, - mint.AppModuleBasic{}, - ) - - // module account permissions - maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - // mint module needs burn access to remove excess validator tokens (it overallocates, then burns) - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - icatypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - // this line is used by starport scaffolding # stargate/app/maccPerms - } -) - -var ( - _ servertypes.Application = (*SovereignApp)(nil) -) - -func init() { - userHomeDir, err := os.UserHomeDir() - if err != nil { - panic(err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) -} - -// SovereignApp extends an ABCI application, but with most of its parameters exported. -// They are exported for convenience in creating helper functions, as object -// capabilities aren't needed for testing. -type SovereignApp struct { - *baseapp.BaseApp - - cdc *codec.LegacyAmino - appCodec codec.Codec - interfaceRegistry types.InterfaceRegistry - - invCheckPeriod uint - - // keys to access the substores - keys map[string]*sdk.KVStoreKey - tkeys map[string]*sdk.TransientStoreKey - memKeys map[string]*sdk.MemoryStoreKey - - // keepers - AccountKeeper authkeeper.AccountKeeper - AuthzKeeper authzkeeper.Keeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - // MonitoringKeeper monitoringpkeeper.Keeper - ICAControllerKeeper icacontrollerkeeper.Keeper - ICAHostKeeper icahostkeeper.Keeper - - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - // ScopedMonitoringKeeper capabilitykeeper.ScopedKeeper - ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper - - ScopedStakeibcKeeper capabilitykeeper.ScopedKeeper - - ScopedRecordsKeeper capabilitykeeper.ScopedKeeper - ScopedIcacallbacksKeeper capabilitykeeper.ScopedKeeper - // this line is used by starport scaffolding # stargate/app/keeperDeclaration - - mm *module.Manager - sm *module.SimulationManager - configurator module.Configurator -} - -// RUN GOSEC -// New returns a reference to an initialized blockchain app -func New( - logger log.Logger, - db dbm.DB, - traceStore io.Writer, - loadLatest bool, - skipUpgradeHeights map[int64]bool, - homePath string, - invCheckPeriod uint, - encodingConfig cosmoscmd.EncodingConfig, - appOpts servertypes.AppOptions, - baseAppOptions ...func(*baseapp.BaseApp), -) cosmoscmd.App { - appCodec := encodingConfig.Marshaler - cdc := encodingConfig.Amino - interfaceRegistry := encodingConfig.InterfaceRegistry - - bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) - bApp.SetCommitMultiStoreTracer(traceStore) - bApp.SetVersion(Version) - bApp.SetInterfaceRegistry(interfaceRegistry) - - keys := sdk.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, - minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, // monitoringptypes.StoreKey, - icacontrollertypes.StoreKey, icahosttypes.StoreKey, - authzkeeper.StoreKey, - // this line is used by starport scaffolding # stargate/app/storeKey - ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - - app := &SovereignApp{ - BaseApp: bApp, - cdc: cdc, - appCodec: appCodec, - interfaceRegistry: interfaceRegistry, - invCheckPeriod: invCheckPeriod, - keys: keys, - tkeys: tkeys, - memKeys: memKeys, - } - - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) - - // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) - - // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) - - // grant capabilities for the ibc and ibc-transfer modules - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) - scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - // this line is used by starport scaffolding # stargate/app/scopedKeeper - - // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, - ) - - app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], - appCodec, - app.BaseApp.MsgServiceRouter(), - ) - - app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), - ) - stakingKeeper := stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), - ) - - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), - ) - - app.MintKeeper = mintkeeper.NewKeeper( - appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, - app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, - ) - - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), - ) - app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - ) - - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) - - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper = *stakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), - ) - - // ... other modules keepers - - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, - ) - - // Create Transfer Keepers - app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, - ) - transferModule := transfer.NewAppModule(app.TransferKeeper) - transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - - // Create evidence Keeper for to register the IBC light client misbehaviour evidence route - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper, - ) - // If evidence needs to be handled for the app, set routes in router here and seal - app.EvidenceKeeper = *evidenceKeeper - - // TODO(TEST-20): look for all lines that include 'monitoring' in this file! there are a few places this - // is commented out - // scopedMonitoringKeeper := app.CapabilityKeeper.ScopeToModule(monitoringptypes.ModuleName) - // app.MonitoringKeeper = *monitoringpkeeper.NewKeeper( - // appCodec, - // keys[monitoringptypes.StoreKey], - // keys[monitoringptypes.MemStoreKey], - // app.GetSubspace(monitoringptypes.ModuleName), - // app.StakingKeeper, - // app.IBCKeeper.ClientKeeper, - // app.IBCKeeper.ConnectionKeeper, - // app.IBCKeeper.ChannelKeeper, - // &app.IBCKeeper.PortKeeper, - // scopedMonitoringKeeper, - // ) - // monitoringModule := monitoringp.NewAppModule(appCodec, app.MonitoringKeeper) - - // Note: must be above app.StakeibcKeeper - app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( - appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName), - app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - scopedICAControllerKeeper, app.MsgServiceRouter(), - ) - - // Register Gov (must be registerd after stakeibc) - govRouter := govtypes.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) - - app.GovKeeper = govkeeper.NewKeeper( - appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, govRouter, - ) - - // this line is used by starport scaffolding # stargate/app/keeperDefinition - - // create IBC middleware stacks by combining middleware with base application - app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), - ) - icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper) - - // Create the middleware stacks - - // Stack one contains - // - IBC - // - ICA - // - icacallbacks - // - stakeibc - // - base app - var icamiddlewareStack porttypes.IBCModule - icamiddlewareStack = icacontroller.NewIBCMiddleware(icamiddlewareStack, app.ICAControllerKeeper) - icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) - - // Create static IBC router, add transfer route, then set and seal it - ibcRouter := ibcporttypes.NewRouter() - ibcRouter. - AddRoute(ibctransfertypes.ModuleName, transferIBCModule). - AddRoute(icacontrollertypes.SubModuleName, icamiddlewareStack). - AddRoute(icahosttypes.SubModuleName, icaHostIBCModule) - // this line is used by starport scaffolding # ibc/app/router - app.IBCKeeper.SetRouter(ibcRouter) - - /**** Module Options ****/ - - // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment - // we prefer to be more strict in what arguments the modules expect. - skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) - - // NOTE: Any module instantiated in the module manager that is later modified - // must be passed by reference here. - - app.mm = module.NewManager( - genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, - encodingConfig.TxConfig, - ), - auth.NewAppModule(appCodec, app.AccountKeeper, nil), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - params.NewAppModule(app.ParamsKeeper), - transferModule, - // monitoringModule, - icaModule, - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - // this line is used by starport scaffolding # stargate/app/appModule - ) - - // During begin block slashing happens after distr.BeginBlocker so that - // there is nothing left over in the validator fee pool, so as to keep the - // CanWithdrawInvariant invariant. - // NOTE: staking module is required if HistoricalEntries param > 0 - app.mm.SetOrderBeginBlockers( - upgradetypes.ModuleName, - capabilitytypes.ModuleName, - minttypes.ModuleName, - distrtypes.ModuleName, - slashingtypes.ModuleName, - evidencetypes.ModuleName, - stakingtypes.ModuleName, - vestingtypes.ModuleName, - ibchost.ModuleName, - ibctransfertypes.ModuleName, - authtypes.ModuleName, - banktypes.ModuleName, - govtypes.ModuleName, - crisistypes.ModuleName, - genutiltypes.ModuleName, - feegrant.ModuleName, - paramstypes.ModuleName, - // monitoringptypes.ModuleName, - icatypes.ModuleName, - authz.ModuleName, - // this line is used by starport scaffolding # stargate/app/beginBlockers - ) - - app.mm.SetOrderEndBlockers( - crisistypes.ModuleName, - govtypes.ModuleName, - stakingtypes.ModuleName, - capabilitytypes.ModuleName, - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - slashingtypes.ModuleName, - minttypes.ModuleName, - vestingtypes.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - feegrant.ModuleName, - paramstypes.ModuleName, - upgradetypes.ModuleName, - ibchost.ModuleName, - ibctransfertypes.ModuleName, - // monitoringptypes.ModuleName, - icatypes.ModuleName, - authz.ModuleName, - // this line is used by starport scaffolding # stargate/app/endBlockers - ) - - // NOTE: The genutils module must occur after staking so that pools are - // properly initialized with tokens from genesis accounts. - // NOTE: Capability module must occur first so that it can initialize any capabilities - // so that other modules that want to create or claim capabilities afterwards in InitChain - // can do so safely. - app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - vestingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - minttypes.ModuleName, - crisistypes.ModuleName, - ibchost.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - paramstypes.ModuleName, - upgradetypes.ModuleName, - ibctransfertypes.ModuleName, - feegrant.ModuleName, - // monitoringptypes.ModuleName, - icatypes.ModuleName, - authz.ModuleName, - // this line is used by starport scaffolding # stargate/app/initGenesis - ) - - app.mm.RegisterInvariants(&app.CrisisKeeper) - app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.mm.RegisterServices(app.configurator) - app.setupUpgradeHandlers() - - // create the simulation manager and define the order of the modules for deterministic simulations - // app.sm = module.NewSimulationManager( - // auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), - // bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - // capability.NewAppModule(appCodec, *app.CapabilityKeeper), - // feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - // gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - // mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - // staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - // distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - // slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - // params.NewAppModule(app.ParamsKeeper), - // evidence.NewAppModule(app.EvidenceKeeper), - // ibc.NewAppModule(app.IBCKeeper), - // transferModule, - // // monitoringModule, - // stakeibcModule, - // epochsModule, - // interchainQueryModule, - // recordsModule, - // icacallbacksModule, - // this line is used by starport scaffolding # stargate/app/appModule - // ) - // app.sm.RegisterStoreDecoders() - - // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) - - // initialize BaseApp - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - - anteHandler, err := ante.NewAnteHandler( - ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, - ) - if err != nil { - panic(err) - } - - app.SetAnteHandler(anteHandler) - app.SetEndBlocker(app.EndBlocker) - - if loadLatest { - if err := app.LoadLatestVersion(); err != nil { - tmos.Exit(err.Error()) - } - } - - app.ScopedIBCKeeper = scopedIBCKeeper - app.ScopedTransferKeeper = scopedTransferKeeper - // app.ScopedMonitoringKeeper = scopedMonitoringKeeper - app.ScopedICAControllerKeeper = scopedICAControllerKeeper - app.ScopedICAHostKeeper = scopedICAHostKeeper - // this line is used by starport scaffolding # stargate/app/beforeInitReturn - - return app -} - -// Name returns the name of the App -func (app *SovereignApp) Name() string { return app.BaseApp.Name() } - -// GetBaseApp returns the base app of the application -func (app *SovereignApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } - -// GetStakingKeeper implements the TestingApp interface. -func (app *SovereignApp) GetStakingKeeper() stakingkeeper.Keeper { - return app.StakingKeeper -} - -// GetIBCKeeper implements the TestingApp interface. -func (app *SovereignApp) GetTransferKeeper() *ibctransferkeeper.Keeper { - return &app.TransferKeeper -} - -// GetIBCKeeper implements the TestingApp interface. -func (app *SovereignApp) GetIBCKeeper() *ibckeeper.Keeper { - return app.IBCKeeper -} - -// GetScopedIBCKeeper implements the TestingApp interface. -func (app *SovereignApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { - return app.ScopedIBCKeeper -} - -// GetTxConfig implements the TestingApp interface. -func (app *SovereignApp) GetTxConfig() client.TxConfig { - cfg := MakeEncodingConfig() - return cfg.TxConfig -} - -// BeginBlocker application updates every begin block -func (app *SovereignApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.mm.BeginBlock(ctx, req) -} - -// EndBlocker application updates every end block -func (app *SovereignApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.mm.EndBlock(ctx, req) -} - -// InitChainer application update at chain initialization -func (app *SovereignApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { - var genesisState GenesisState - if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { - panic(err) - } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) - return app.mm.InitGenesis(ctx, app.appCodec, genesisState) -} - -// LoadHeight loads a particular height -func (app *SovereignApp) LoadHeight(height int64) error { - return app.LoadVersion(height) -} - -// ModuleAccountAddrs returns all the app's module account addresses. -func (app *SovereignApp) ModuleAccountAddrs() map[string]bool { - modAccAddrs := make(map[string]bool) - for acc := range maccPerms { - modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true - } - - return modAccAddrs -} - -// LegacyAmino returns SimApp's amino codec. -// -// NOTE: This is solely to be used for testing purposes as it may be desirable -// for modules to register their own custom testing types. -func (app *SovereignApp) LegacyAmino() *codec.LegacyAmino { - return app.cdc -} - -// AppCodec returns an app codec. -// -// NOTE: This is solely to be used for testing purposes as it may be desirable -// for modules to register their own custom testing types. -func (app *SovereignApp) AppCodec() codec.Codec { - return app.appCodec -} - -// InterfaceRegistry returns an InterfaceRegistry -func (app *SovereignApp) InterfaceRegistry() types.InterfaceRegistry { - return app.interfaceRegistry -} - -// GetKey returns the KVStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *SovereignApp) GetKey(storeKey string) *sdk.KVStoreKey { - return app.keys[storeKey] -} - -// GetTKey returns the TransientStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *SovereignApp) GetTKey(storeKey string) *sdk.TransientStoreKey { - return app.tkeys[storeKey] -} - -// GetMemKey returns the MemStoreKey for the provided mem key. -// -// NOTE: This is solely used for testing purposes. -func (app *SovereignApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey { - return app.memKeys[storeKey] -} - -// GetSubspace returns a param subspace for a given module name. -// -// NOTE: This is solely to be used for testing purposes. -func (app *SovereignApp) GetSubspace(moduleName string) paramstypes.Subspace { - subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) - return subspace -} - -// RegisterAPIRoutes registers all application module routes with the provided -// API server. -func (app *SovereignApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { - clientCtx := apiSvr.ClientCtx - rpc.RegisterRoutes(clientCtx, apiSvr.Router) - // Register legacy tx routes. - authrest.RegisterTxRoutes(clientCtx, apiSvr.Router) - // Register new tx routes from grpc-gateway. - authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - - // Register legacy and grpc-gateway routes for all modules. - ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) -} - -// RegisterTxService implements the Application.RegisterTxService method. -func (app *SovereignApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) -} - -// RegisterTendermintService implements the Application.RegisterTendermintService method. -func (app *SovereignApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) -} - -// GetMaccPerms returns a copy of the module account permissions -func GetMaccPerms() map[string][]string { - dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } - return dupMaccPerms -} - -// initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - paramsKeeper.Subspace(authtypes.ModuleName) - paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) - paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibchost.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - // paramsKeeper.Subspace(monitoringptypes.ModuleName) - paramsKeeper.Subspace(icacontrollertypes.SubModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) - // this line is used by starport scaffolding # stargate/app/paramSubspace - - return paramsKeeper -} - -// SimulationManager implements the SimulationApp interface -func (app *SovereignApp) SimulationManager() *module.SimulationManager { - return app.sm -} diff --git a/app/sovereign/encoding.go b/app/sovereign/encoding.go deleted file mode 100644 index 60535a84cf..0000000000 --- a/app/sovereign/encoding.go +++ /dev/null @@ -1,38 +0,0 @@ -package app - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/x/auth/tx" -) - -// This data structure (EncodingConfig) is heavily inspired by Quicksilver. https://github.com/ingenuity-build/quicksilver/blob/main/app/encoding.go -type EncodingConfig struct { - InterfaceRegistry types.InterfaceRegistry - Marshaler codec.Codec - TxConfig client.TxConfig - Amino *codec.LegacyAmino -} - -// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -func MakeEncodingConfig() EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) - - encodingConfig := EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, - } - - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig -} diff --git a/app/sovereign/export.go b/app/sovereign/export.go deleted file mode 100644 index 3c5a7e14d7..0000000000 --- a/app/sovereign/export.go +++ /dev/null @@ -1,201 +0,0 @@ -package app - -import ( - "encoding/json" - "log" - - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - servertypes "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -// ExportAppStateAndValidators exports the state of the application for a genesis -// file. -func (app *SovereignApp) ExportAppStateAndValidators( - forZeroHeight bool, jailAllowedAddrs []string, -) (servertypes.ExportedApp, error) { - // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) - - // We export at last height + 1, because that's the height at which - // Tendermint will start InitChain. - height := app.LastBlockHeight() + 1 - if forZeroHeight { - height = 0 - app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) - } - - genState := app.mm.ExportGenesis(ctx, app.appCodec) - appState, err := json.MarshalIndent(genState, "", " ") - if err != nil { - return servertypes.ExportedApp{}, err - } - - validators, err := staking.WriteValidators(ctx, app.StakingKeeper) - if err != nil { - return servertypes.ExportedApp{}, err - } - return servertypes.ExportedApp{ - AppState: appState, - Validators: validators, - Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), - }, nil -} - -// prepare for fresh start at zero height -// NOTE zero height genesis is a temporary feature which will be deprecated -// -// in favour of export at a block height -func (app *SovereignApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false - - // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } - - allowedAddrsMap := make(map[string]bool) - - for _, addr := range jailAllowedAddrs { - _, err := sdk.ValAddressFromBech32(addr) - if err != nil { - log.Fatal(err) - } - allowedAddrsMap[addr] = true - } - - /* Just to be safe, assert the invariants on current state. */ - app.CrisisKeeper.AssertInvariants(ctx) - - /* Handle fee distribution state. */ - - // withdraw all validator commission - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) - if err != nil { - panic(err) - } - - return false - }) - - // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) - for _, delegation := range dels { - valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) - if err != nil { - panic(err) - } - - delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) - if err != nil { - panic(err) - } - _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) - } - - // clear validator slash events - app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) - - // clear validator historical rewards - app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) - - // set context height to zero - height := ctx.BlockHeight() - ctx = ctx.WithBlockHeight(0) - - // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) - - app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) - return false - }) - - // reinitialize all delegations - for _, del := range dels { - valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) - if err != nil { - panic(err) - } - delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) - if err != nil { - panic(err) - } - app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) - } - - // reset context height - ctx = ctx.WithBlockHeight(height) - - /* Handle staking state. */ - - // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { - for i := range red.Entries { - red.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetRedelegation(ctx, red) - return false - }) - - // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { - for i := range ubd.Entries { - ubd.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) - return false - }) - - // Iterate through validators by power descending, reset bond heights, and - // update bond intra-tx counters. - store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) - counter := int16(0) - - for ; iter.Valid(); iter.Next() { - addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { - panic("expected validator, not found") - } - - validator.UnbondingHeight = 0 - if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { - validator.Jailed = true - } - - app.StakingKeeper.SetValidator(ctx, validator) - counter++ - } - - iter.Close() - - _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) - if err != nil { - log.Fatal(err) - } - - /* Handle slashing state. */ - - // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( - ctx, - func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { - info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) - return false - }, - ) -} diff --git a/app/sovereign/genesis.go b/app/sovereign/genesis.go deleted file mode 100644 index 340cd801a8..0000000000 --- a/app/sovereign/genesis.go +++ /dev/null @@ -1,20 +0,0 @@ -package app - -import ( - "encoding/json" -) - -// The genesis state of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. -// The identifier is used to determine which module genesis information belongs -// to so it may be appropriately routed during init chain. -// Within this application default genesis information is retrieved from -// the ModuleBasicManager which populates json from each BasicModule -// object provided to it during init. -type GenesisState map[string]json.RawMessage - -// NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState() GenesisState { - encCfg := MakeEncodingConfig() - return ModuleBasics.DefaultGenesis(encCfg.Marshaler) -} diff --git a/app/sovereign/upgrades.go b/app/sovereign/upgrades.go deleted file mode 100644 index 734c2b3b2f..0000000000 --- a/app/sovereign/upgrades.go +++ /dev/null @@ -1,31 +0,0 @@ -package app - -import ( - "fmt" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" -) - -func (app *SovereignApp) setupUpgradeHandlers() { - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err)) - } - - if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - return - } - - var storeUpgrades *storetypes.StoreUpgrades - - switch upgradeInfo.Name { - // no store upgrades - case "v3": - storeUpgrades = &storetypes.StoreUpgrades{} - } - - if storeUpgrades != nil { - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades)) - } -} diff --git a/app/sovereign/upgrades/v3/upgrades.go b/app/sovereign/upgrades/v3/upgrades.go deleted file mode 100644 index 39cfa318f1..0000000000 --- a/app/sovereign/upgrades/v3/upgrades.go +++ /dev/null @@ -1,23 +0,0 @@ -package v3 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" -) - -// Note: ensure these values are properly set before running upgrade -var ( - UpgradeName = "v3" -) - -// CreateUpgradeHandler creates an SDK upgrade handler for v3 -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - newVm, err := mm.RunMigrations(ctx, configurator, vm) - return newVm, err - } -} diff --git a/cmd/interchain-security-sd/main.go b/cmd/interchain-security-sd/main.go deleted file mode 100644 index 4dc2748ad0..0000000000 --- a/cmd/interchain-security-sd/main.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "os" - - "github.com/cosmos/cosmos-sdk/server" - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - app "github.com/cosmos/interchain-security/app/sovereign" - "github.com/tendermint/spm/cosmoscmd" -) - -func main() { - rootCmd, _ := cosmoscmd.NewRootCmd( - app.AppName, - app.AccountAddressPrefix, - app.DefaultNodeHome, - app.AppName, - app.ModuleBasics, - app.New, - // this line is used by starport scaffolding # root/arguments - ) - - if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - - default: - os.Exit(1) - } - } -} diff --git a/tests/sovereign_consumer_upgrade_local/README.md b/tests/sovereign_consumer_upgrade_local/README.md deleted file mode 100644 index 05a841f80b..0000000000 --- a/tests/sovereign_consumer_upgrade_local/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## How to run consumer chain - -### Pre-install - -Binaries: - -- interchain-security-pd - [Interchain security](https://github.com/cosmos/interchain-security) version: v0.2.1 -- consumerd -- hermes(version: v0.15.0) - -### Commands - -Copy `start_consumer.sh`, `start_provider.sh` from one of the directories and execute following commands. - -```sh -rm -rf /Users/admin/.provider1 -rm -rf /Users/admin/.provider -rm -rf /Users/admin/.consumer1 -rm -rf /Users/admin/.consumer -rm -rf /Users/admin/.sovereign -sh run.sh -``` - -### Genesis modification script for consumer chain - -```sh -# Add ccv section -if ! ./$PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$CONSUMER_HOME"/consumer_section.json; -then - echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." - exit 1 -fi - -jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$CONSUMER_HOME"/config/genesis.json "$CONSUMER_HOME"/consumer_section.json > "$CONSUMER_HOME"/genesis_consumer.json && \ - mv "$CONSUMER_HOME"/genesis_consumer.json "$CONSUMER_HOME"/config/genesis.json -``` - -### Process of execution of soft upgrade from sovereign chain to consumer chain - -1. Start provider chain and register consumer chain -2. Build normal sovereign chain daemon -3. Start single validator sovereign chain -4. Provider chain validator with sovereign chain -5. Raise Upgrade proposal on sovereign chain and vote -6. Build consumer chain daemon with upgrade handler for ccv module and relevant modules -7. Once chain halt, restart 2 nodes to move from sovereign chain to consumer chain -8. Ensure blocks are being produced without the first node used for sovereign chain -9. Execute delegation on provider chain and ensure consumer chain validators' voting power changes diff --git a/tests/sovereign_consumer_upgrade_local/build_binaries.sh b/tests/sovereign_consumer_upgrade_local/build_binaries.sh deleted file mode 100644 index f20cc28b4a..0000000000 --- a/tests/sovereign_consumer_upgrade_local/build_binaries.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -go install ../../cmd/interchain-security-sd -go install ../../cmd/interchain-security-pd -go install ../../cmd/interchain-security-cdd -go install ../../cmd/interchain-security-cd diff --git a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh deleted file mode 100644 index 3ca098f3d3..0000000000 --- a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_consumer.sh +++ /dev/null @@ -1,359 +0,0 @@ -#!/bin/bash -set -eux - -SOVEREIGN_HOME="$HOME/.sovereign" -CONSUMER_HOME="$HOME/.consumer" -CONSUMER_HOME1="$HOME/.consumer1" -PROVIDER_CHAIN_ID="provider" -CONSUMER_CHAIN_ID="consumer" -MONIKER="consumer" -VALIDATOR="validator" -VALIDATOR1="validator1" -KEYRING="--keyring-backend test" -TX_FLAGS="--gas-adjustment 100 --gas auto" -PROVIDER_BINARY="interchain-security-pd" -SOVEREIGN_BINARY="interchain-security-sd" -CONSUMER_BINARY="interchain-security-cdd" -NODE_IP="localhost" -PROVIDER_RPC_LADDR="$NODE_IP:26658" -PROVIDER_GRPC_ADDR="$NODE_IP:9091" -PROVIDER_RPC_LADDR1="$NODE_IP:26668" -PROVIDER_GRPC_ADDR1="$NODE_IP:9101" -SOVEREIGN_RPC_LADDR="$NODE_IP:26648" -SOVEREIGN_GRPC_ADDR="$NODE_IP:9081" -CONSUMER_RPC_LADDR="$NODE_IP:26638" -CONSUMER_GRPC_ADDR="$NODE_IP:9071" -CONSUMER_RPC_LADDR1="$NODE_IP:26628" -CONSUMER_GRPC_ADDR1="$NODE_IP:9061" -CONSUMER_USER="consumer" -SOVEREIGN_VALIDATOR="sovereign_validator" -PROVIDER_HOME="$HOME/.provider" -PROVIDER_HOME1="$HOME/.provider1" -PROVIDER_NODE_ADDRESS="tcp://localhost:26658" - -# Clean start -killall $SOVEREIGN_BINARY &> /dev/null || true -killall $CONSUMER_BINARY &> /dev/null || true -rm -rf $CONSUMER_HOME -rm -rf $CONSUMER_HOME1 -rm -rf $SOVEREIGN_HOME - -################SOVEREIGN############################ -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME -sleep 1 - -# Create user account keypair -$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 -$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 - -# Add account in genesis (required by Hermes) -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME - -# generate genesis for sovereign chain -$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 11000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME -sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json - -################CONSUMER############################ - -# Build genesis file and node directory structure -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME -sleep 1 - -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json -cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json - -#######CHAIN2####### -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 -sleep 1 -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json -cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json - -##########SET CONFIG.TOML##################### -# Set default client port -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml -sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) -node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) -node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) - -# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml - -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml - -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml - -# Start the chain -$SOVEREIGN_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$SOVEREIGN_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $SOVEREIGN_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 10 - -######################################HERMES################################### - -# Setup Hermes in packet relayer mode -killall hermes 2> /dev/null || true - -tee ~/.hermes/config.toml< ~/.hermes/logs & - -# Build consumer chain proposal file -tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true - -# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler -if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; -then - echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." - exit 1 -fi - -jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ - mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json - -# Modify genesis params -jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ - $SOVEREIGN_HOME/config/genesis.json > \ - $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json -sleep 1 - - -$CONSUMER_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$CONSUMER_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $CONSUMER_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 30 - -# # create channel between consumer and provider between provider port and consumer port -# hermes query clients consumer -# hermes query clients provider -# hermes query client consensus consumer 07-tendermint-1 -# hermes query client consensus provider 07-tendermint-1 -hermes create connection $CONSUMER_CHAIN_ID --client-a 07-tendermint-1 --client-b 07-tendermint-1 -hermes create channel $CONSUMER_CHAIN_ID --port-a consumer --port-b provider -o ordered --channel-version 1 connection-1 - -# ############################################################ - -PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) -DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) -OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) - -$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ - --from $VALIDATOR \ - $KEYRING \ - --home $PROVIDER_HOME \ - --node tcp://${PROVIDER_RPC_LADDR} \ - --chain-id $PROVIDER_CHAIN_ID -y -b block -sleep 1 - -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} -# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} - -$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR - -# $CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR -# $PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh deleted file mode 100644 index 149cf32f80..0000000000 --- a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0-old-connection/start_provider.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -set -eux - -TOTAL_COINS=100000000000stake -STAKE_COINS=100000000stake -TOTAL_COINS1=120000000000stake -STAKE_COINS1=1000000stake -PROVIDER_BINARY=interchain-security-pd -PROVIDER_HOME="$HOME/.provider" -PROVIDER_HOME1="$HOME/.provider1" -PROVIDER_CHAIN_ID=provider -PROVIDER_MONIKER=provider -VALIDATOR=validator -VALIDATOR1=validator1 -NODE_IP="localhost" -PROVIDER_RPC_LADDR="$NODE_IP:26658" -PROVIDER_GRPC_ADDR="$NODE_IP:9091" -PROVIDER_RPC_LADDR1="$NODE_IP:26668" -PROVIDER_GRPC_ADDR1="$NODE_IP:9101" -PROVIDER_DELEGATOR=delegator - -# Clean start -killall $PROVIDER_BINARY &> /dev/null || true - -#######VALIDATOR1####################### -rm -rf $PROVIDER_HOME - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID -jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ - $PROVIDER_HOME/config/genesis.json > \ - $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json -sleep 1 - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 -sleep 1 -$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 - -# Stake 1/1000 user's coins -$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR -sleep 1 - -###########VALIDATOR 2############################ -rm -rf $PROVIDER_HOME1 - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID -cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test -sleep 1 - -####################GENTX AND DISTRIBUTE GENESIS############################## -cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ - -# Stake 1/1000 user's coins -# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 -# sleep 1 - -$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ -sleep 1 - -cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json - -####################ADDING PEERS#################### -node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) -node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml - -#################### Start the chain node1 ################### -$PROVIDER_BINARY start \ - --home $PROVIDER_HOME \ - --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ - --grpc.address $PROVIDER_GRPC_ADDR \ - --address tcp://${NODE_IP}:26655 \ - --p2p.laddr tcp://${NODE_IP}:26656 \ - --grpc-web.enable=false \ - --trace \ - &> $PROVIDER_HOME/logs & - -#################### Start the chain node2 ################### -# $PROVIDER_BINARY start \ -# --home $PROVIDER_HOME1 \ -# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ -# --grpc.address $PROVIDER_GRPC_ADDR1 \ -# --address tcp://${NODE_IP}:26665 \ -# --p2p.laddr tcp://${NODE_IP}:26666 \ -# --grpc-web.enable=false \ -# --trace \ -# &> $PROVIDER_HOME1/logs & -sleep 10 - -# # Build consumer chain proposal file -# tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true -killall $CONSUMER_BINARY &> /dev/null || true -rm -rf $CONSUMER_HOME -rm -rf $CONSUMER_HOME1 -rm -rf $SOVEREIGN_HOME - -################SOVEREIGN############################ -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME -sleep 1 - -# Create user account keypair -$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 -$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 - -# Add account in genesis (required by Hermes) -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME - -# generate genesis for sovereign chain -$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 10000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME -sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json - -################CONSUMER############################ - -# Build genesis file and node directory structure -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME -sleep 1 - -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json -cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json - -#######CHAIN2####### -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 -sleep 1 -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json -cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json - -##########SET CONFIG.TOML##################### -# Set default client port -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml -sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) -node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) -node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) - -# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml - -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml - -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml - -# Start the chain -$SOVEREIGN_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$SOVEREIGN_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $SOVEREIGN_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 10 - -###########################UPGRADE TO SOVEREIGN CHAIN########################## - -$SOVEREIGN_BINARY tx gov submit-proposal software-upgrade "v07-Theta" --upgrade-height=7 \ ---title="upgrade to consumer chain" --description="upgrade to consumer chain description" \ ---from=$SOVEREIGN_VALIDATOR $KEYRING --chain-id=$CONSUMER_CHAIN_ID \ ---home=$SOVEREIGN_HOME --yes -b block --deposit="100000000stake" - -# Vote yes to proposal -$SOVEREIGN_BINARY tx gov vote 1 yes --from $SOVEREIGN_VALIDATOR --chain-id $CONSUMER_CHAIN_ID --node tcp://$SOVEREIGN_RPC_LADDR \ ---home $SOVEREIGN_HOME -b block -y $KEYRING -sleep 30 - -###########################START BINARIES AGAIN AFTER UPGRADE########################## -$SOVEREIGN_BINARY query gov proposals --node tcp://$SOVEREIGN_RPC_LADDR -$SOVEREIGN_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR -# $SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR1 - -killall $SOVEREIGN_BINARY &> /dev/null || true - -# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler -if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; -then - echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." - exit 1 -fi - -jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ - mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json - -# Modify genesis params -jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ - $SOVEREIGN_HOME/config/genesis.json > \ - $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json -sleep 1 - - -$CONSUMER_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$CONSUMER_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $CONSUMER_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 30 - -######################################HERMES################################### - -# Setup Hermes in packet relayer mode -killall hermes 2> /dev/null || true - -tee ~/.hermes/config.toml< ~/.hermes/logs & - -############################################################ - -PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) -DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) -OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) - -$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ - --from $VALIDATOR \ - $KEYRING \ - --home $PROVIDER_HOME \ - --node tcp://${PROVIDER_RPC_LADDR} \ - --chain-id $PROVIDER_CHAIN_ID -y -b block -sleep 1 - -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} -# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} - -$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR - -$CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR -$PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} \ No newline at end of file diff --git a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0/start_provider.sh b/tests/sovereign_consumer_upgrade_local/hermes-0.15.0/start_provider.sh deleted file mode 100644 index e2bd305657..0000000000 --- a/tests/sovereign_consumer_upgrade_local/hermes-0.15.0/start_provider.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -set -eux - -TOTAL_COINS=100000000000stake -STAKE_COINS=100000000stake -TOTAL_COINS1=120000000000stake -STAKE_COINS1=1000000stake -PROVIDER_BINARY=interchain-security-pd -PROVIDER_HOME="$HOME/.provider" -PROVIDER_HOME1="$HOME/.provider1" -PROVIDER_CHAIN_ID=provider -PROVIDER_MONIKER=provider -VALIDATOR=validator -VALIDATOR1=validator1 -NODE_IP="localhost" -PROVIDER_RPC_LADDR="$NODE_IP:26658" -PROVIDER_GRPC_ADDR="$NODE_IP:9091" -PROVIDER_RPC_LADDR1="$NODE_IP:26668" -PROVIDER_GRPC_ADDR1="$NODE_IP:9101" -PROVIDER_DELEGATOR=delegator - -# Clean start -killall $PROVIDER_BINARY &> /dev/null || true - -#######VALIDATOR1####################### -rm -rf $PROVIDER_HOME - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID -jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ - $PROVIDER_HOME/config/genesis.json > \ - $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json -sleep 1 - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 -sleep 1 -$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 - -# Stake 1/1000 user's coins -$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR -sleep 1 - -###########VALIDATOR 2############################ -rm -rf $PROVIDER_HOME1 - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID -cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test -sleep 1 - -####################GENTX AND DISTRIBUTE GENESIS############################## -cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ - -# Stake 1/1000 user's coins -# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 -# sleep 1 - -$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ -sleep 1 - -cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json - -####################ADDING PEERS#################### -node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) -node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml - -#################### Start the chain node1 ################### -$PROVIDER_BINARY start \ - --home $PROVIDER_HOME \ - --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ - --grpc.address $PROVIDER_GRPC_ADDR \ - --address tcp://${NODE_IP}:26655 \ - --p2p.laddr tcp://${NODE_IP}:26656 \ - --grpc-web.enable=false \ - --trace \ - &> $PROVIDER_HOME/logs & - -#################### Start the chain node2 ################### -# $PROVIDER_BINARY start \ -# --home $PROVIDER_HOME1 \ -# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ -# --grpc.address $PROVIDER_GRPC_ADDR1 \ -# --address tcp://${NODE_IP}:26665 \ -# --p2p.laddr tcp://${NODE_IP}:26666 \ -# --grpc-web.enable=false \ -# --trace \ -# &> $PROVIDER_HOME1/logs & -sleep 10 - -# Build consumer chain proposal file -tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true -killall $CONSUMER_BINARY &> /dev/null || true -rm -rf $CONSUMER_HOME -rm -rf $CONSUMER_HOME1 -rm -rf $SOVEREIGN_HOME - -################SOVEREIGN############################ -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME -sleep 1 - -# Create user account keypair -$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 -$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 - -# Add account in genesis (required by Hermes) -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME - -# generate genesis for sovereign chain -$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 10000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME -sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json - -################CONSUMER############################ - -# Build genesis file and node directory structure -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME -sleep 1 - -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json -cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json - -#######CHAIN2####### -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 -sleep 1 -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json -cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json - -##########SET CONFIG.TOML##################### -# Set default client port -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml -sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) -node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) -node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) - -# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml - -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml - -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml - -# Start the chain -$SOVEREIGN_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$SOVEREIGN_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $SOVEREIGN_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 10 - -###########################UPGRADE TO SOVEREIGN CHAIN########################## - -$SOVEREIGN_BINARY tx gov submit-proposal software-upgrade "v07-Theta" --upgrade-height=7 \ ---title="upgrade to consumer chain" --description="upgrade to consumer chain description" \ ---from=$SOVEREIGN_VALIDATOR $KEYRING --chain-id=$CONSUMER_CHAIN_ID \ ---home=$SOVEREIGN_HOME --yes -b block --deposit="100000000stake" - -# Vote yes to proposal -$SOVEREIGN_BINARY tx gov vote 1 yes --from $SOVEREIGN_VALIDATOR --chain-id $CONSUMER_CHAIN_ID --node tcp://$SOVEREIGN_RPC_LADDR \ ---home $SOVEREIGN_HOME -b block -y $KEYRING -sleep 30 - -###########################START BINARIES AGAIN AFTER UPGRADE########################## -$SOVEREIGN_BINARY query gov proposals --node tcp://$SOVEREIGN_RPC_LADDR -$SOVEREIGN_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR -# $SOVEREIGN_BINARY status --node tcp://$CONSUMER_RPC_LADDR1 - -killall $SOVEREIGN_BINARY &> /dev/null || true - -# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler -if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; -then - echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." - exit 1 -fi - -jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ - mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json - -# Modify genesis params -jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ - $SOVEREIGN_HOME/config/genesis.json > \ - $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json -sleep 1 - - -$CONSUMER_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$CONSUMER_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $CONSUMER_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 30 - -######################################HERMES################################### - -# Setup Hermes in packet relayer mode -killall hermes 2> /dev/null || true - -tee ~/.hermes/config.toml< ~/.hermes/logs & - -############################################################ - -PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) -DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) -OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) - -$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 50000000stake \ - --from $VALIDATOR \ - $KEYRING \ - --home $PROVIDER_HOME \ - --node tcp://${PROVIDER_RPC_LADDR} \ - --chain-id $PROVIDER_CHAIN_ID -y -b block -sleep 1 - -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} - -$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR - -$CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR -$PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_provider.sh b/tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_provider.sh deleted file mode 100644 index 613f7ae597..0000000000 --- a/tests/sovereign_consumer_upgrade_local/hermes-1.2.0/start_provider.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash -set -eux - -TOTAL_COINS=100000000000stake -STAKE_COINS=100000000stake -TOTAL_COINS1=120000000000stake -STAKE_COINS1=1000000stake -PROVIDER_BINARY=interchain-security-pd -PROVIDER_HOME="$HOME/.provider" -PROVIDER_HOME1="$HOME/.provider1" -PROVIDER_CHAIN_ID=provider -PROVIDER_MONIKER=provider -VALIDATOR=validator -VALIDATOR1=validator1 -NODE_IP="localhost" -PROVIDER_RPC_LADDR="$NODE_IP:26658" -PROVIDER_GRPC_ADDR="$NODE_IP:9091" -PROVIDER_RPC_LADDR1="$NODE_IP:26668" -PROVIDER_GRPC_ADDR1="$NODE_IP:9101" -PROVIDER_DELEGATOR=delegator - -# Clean start -killall $PROVIDER_BINARY &> /dev/null || true - -#######VALIDATOR1####################### -rm -rf $PROVIDER_HOME - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID -jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"11600s\" | .app_state.provider.params.template_client.trusting_period = \"11300s\"" \ $PROVIDER_HOME/config/genesis.json > \ - $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json -sleep 1 - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 -sleep 1 -$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 - -# Stake 1/1000 user's coins -$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR -sleep 1 - -###########VALIDATOR 2############################ -rm -rf $PROVIDER_HOME1 - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID -cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test -sleep 1 - -####################GENTX AND DISTRIBUTE GENESIS############################## -cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ - -# Stake 1/1000 user's coins -# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 -# sleep 1 - -$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ -sleep 1 - -cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json - -####################ADDING PEERS#################### -node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) -node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml - -#################### Start the chain node1 ################### -$PROVIDER_BINARY start \ - --home $PROVIDER_HOME \ - --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ - --grpc.address $PROVIDER_GRPC_ADDR \ - --address tcp://${NODE_IP}:26655 \ - --p2p.laddr tcp://${NODE_IP}:26656 \ - --grpc-web.enable=false \ - --trace \ - &> $PROVIDER_HOME/logs & - -#################### Start the chain node2 ################### -# $PROVIDER_BINARY start \ -# --home $PROVIDER_HOME1 \ -# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ -# --grpc.address $PROVIDER_GRPC_ADDR1 \ -# --address tcp://${NODE_IP}:26665 \ -# --p2p.laddr tcp://${NODE_IP}:26666 \ -# --grpc-web.enable=false \ -# --trace \ -# &> $PROVIDER_HOME1/logs & -sleep 10 - -# Build consumer chain proposal file -tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true -killall $CONSUMER_BINARY &> /dev/null || true -rm -rf $CONSUMER_HOME -rm -rf $CONSUMER_HOME1 -rm -rf $SOVEREIGN_HOME - -################SOVEREIGN############################ -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $SOVEREIGN_HOME -sleep 1 - -# Create user account keypair -$SOVEREIGN_BINARY keys add $CONSUMER_USER $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/consumer_keypair.json 2>&1 -$SOVEREIGN_BINARY keys add $SOVEREIGN_VALIDATOR $KEYRING --home $SOVEREIGN_HOME --output json > $SOVEREIGN_HOME/sovereign_validator_keypair.json 2>&1 - -# Add account in genesis (required by Hermes) -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/consumer_keypair.json) 1000000000stake --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY add-genesis-account $(jq -r .address $SOVEREIGN_HOME/sovereign_validator_keypair.json) 1000000000000stake --home $SOVEREIGN_HOME - -# generate genesis for sovereign chain -$SOVEREIGN_BINARY gentx $SOVEREIGN_VALIDATOR 11000000000stake $KEYRING --chain-id=$CONSUMER_CHAIN_ID --home $SOVEREIGN_HOME -$SOVEREIGN_BINARY collect-gentxs --home $SOVEREIGN_HOME -sed -i '' 's/"voting_period": "172800s"/"voting_period": "20s"/g' $SOVEREIGN_HOME/config/genesis.json - -################CONSUMER############################ - -# Build genesis file and node directory structure -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME -sleep 1 - -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME/config/priv_validator_key.json $CONSUMER_HOME/config/priv_validator_key.json -cp $PROVIDER_HOME/config/node_key.json $CONSUMER_HOME/config/node_key.json - -#######CHAIN2####### -$SOVEREIGN_BINARY init --chain-id $CONSUMER_CHAIN_ID $MONIKER --home $CONSUMER_HOME1 -sleep 1 -#copy genesis -cp $SOVEREIGN_HOME/config/genesis.json $CONSUMER_HOME1/config/genesis.json - -# Copy validator key files -cp $PROVIDER_HOME1/config/priv_validator_key.json $CONSUMER_HOME1/config/priv_validator_key.json -cp $PROVIDER_HOME1/config/node_key.json $CONSUMER_HOME1/config/node_key.json - -##########SET CONFIG.TOML##################### -# Set default client port -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${SOVEREIGN_RPC_LADDR}\"/" $SOVEREIGN_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR}\"/" $CONSUMER_HOME/config/client.toml -sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${CONSUMER_RPC_LADDR1}\"/" $CONSUMER_HOME1/config/client.toml -sovereign=$($SOVEREIGN_BINARY tendermint show-node-id --home $SOVEREIGN_HOME) -node=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME) -node1=$($SOVEREIGN_BINARY tendermint show-node-id --home $CONSUMER_HOME1) - -# sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636,$node1@localhost:26626\"/" "$SOVEREIGN_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node1@localhost:26626\"/" "$CONSUMER_HOME"/config/config.toml -# sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646,$node@localhost:26636\"/" "$CONSUMER_HOME1"/config/config.toml - -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26636\"/" "$SOVEREIGN_HOME"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$sovereign@localhost:26646\"/" "$CONSUMER_HOME"/config/config.toml - -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1318\"/" "$CONSUMER_HOME"/config/app.toml -sed -i -r "118s/.*/address = \"tcp:\/\/0.0.0.0:1319\"/" "$CONSUMER_HOME1"/config/app.toml - -# Start the chain -$SOVEREIGN_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$SOVEREIGN_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $SOVEREIGN_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 10 - -######################################HERMES################################### - -# Setup Hermes in packet relayer mode -killall hermes 2> /dev/null || true - -tee ~/.hermes/config.toml< ~/.hermes/logs & - -# Build consumer chain proposal file -tee $PROVIDER_HOME/consumer-proposal.json< /dev/null || true - -# Add ccv section to SOVEREIGN_HOME genesis to be used on upgrade handler -if ! $PROVIDER_BINARY q provider consumer-genesis "$CONSUMER_CHAIN_ID" --node "$PROVIDER_NODE_ADDRESS" --output json > "$SOVEREIGN_HOME"/consumer_section.json; -then - echo "Failed to get consumer genesis for the chain-id '$CONSUMER_CHAIN_ID'! Finalize genesis failed. For more details please check the log file in output directory." - exit 1 -fi - -jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' "$SOVEREIGN_HOME"/config/genesis.json "$SOVEREIGN_HOME"/consumer_section.json > "$SOVEREIGN_HOME"/genesis_consumer.json && \ - mv "$SOVEREIGN_HOME"/genesis_consumer.json "$SOVEREIGN_HOME"/config/genesis.json - -# Modify genesis params -jq ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"70\" | .app_state.tokenfactory.paused = { \"paused\": false }" \ - $SOVEREIGN_HOME/config/genesis.json > \ - $SOVEREIGN_HOME/edited_genesis.json && mv $SOVEREIGN_HOME/edited_genesis.json $SOVEREIGN_HOME/config/genesis.json -sleep 1 - - -$CONSUMER_BINARY start \ - --home $SOVEREIGN_HOME \ - --rpc.laddr tcp://${SOVEREIGN_RPC_LADDR} \ - --grpc.address ${SOVEREIGN_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26645 \ - --p2p.laddr tcp://${NODE_IP}:26646 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $SOVEREIGN_HOME/logs & - -$CONSUMER_BINARY start \ - --home $CONSUMER_HOME \ - --rpc.laddr tcp://${CONSUMER_RPC_LADDR} \ - --grpc.address ${CONSUMER_GRPC_ADDR} \ - --address tcp://${NODE_IP}:26635 \ - --p2p.laddr tcp://${NODE_IP}:26636 \ - --grpc-web.enable=false \ - --log_level trace \ - --trace \ - &> $CONSUMER_HOME/logs & - -# $CONSUMER_BINARY start \ -# --home $CONSUMER_HOME1 \ -# --rpc.laddr tcp://${CONSUMER_RPC_LADDR1} \ -# --grpc.address ${CONSUMER_GRPC_ADDR1} \ -# --address tcp://${NODE_IP}:26625 \ -# --p2p.laddr tcp://${NODE_IP}:26626 \ -# --grpc-web.enable=false \ -# --log_level trace \ -# --trace \ -# &> $CONSUMER_HOME1/logs & -sleep 30 - -# # create channel between consumer and provider between provider port and consumer port -# hermes query clients consumer -# hermes query clients provider -# hermes query client consensus consumer 07-tendermint-1 -# hermes query client consensus provider 07-tendermint-1 -hermes create connection $CONSUMER_CHAIN_ID --client-a 07-tendermint-1 --client-b 07-tendermint-1 -hermes create channel $CONSUMER_CHAIN_ID --port-a consumer --port-b provider -o ordered --channel-version 1 connection-1 - -# ############################################################ - -PROVIDER_VALIDATOR_ADDRESS=$(jq -r .address $PROVIDER_HOME/keypair.json) -DELEGATIONS=$($PROVIDER_BINARY q staking delegations $PROVIDER_VALIDATOR_ADDRESS --home $PROVIDER_HOME --node tcp://${PROVIDER_RPC_LADDR} -o json) -OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r .delegation_responses[0].delegation.validator_address) - -$PROVIDER_BINARY tx staking delegate $OPERATOR_ADDR 32000000stake \ - --from $VALIDATOR \ - $KEYRING \ - --home $PROVIDER_HOME \ - --node tcp://${PROVIDER_RPC_LADDR} \ - --chain-id $PROVIDER_CHAIN_ID -y -b block -sleep 1 - -$PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR} -# $PROVIDER_BINARY status --node=tcp://${PROVIDER_RPC_LADDR1} - -$CONSUMER_BINARY status --node tcp://$SOVEREIGN_RPC_LADDR -$CONSUMER_BINARY status --node tcp://$CONSUMER_RPC_LADDR - -# $CONSUMER_BINARY query staking params --node=tcp://$CONSUMER_RPC_LADDR -# $PROVIDER_BINARY query staking params --node=tcp://${PROVIDER_RPC_LADDR} diff --git a/tests/sovereign_consumer_upgrade_local/start_provider.sh b/tests/sovereign_consumer_upgrade_local/start_provider.sh deleted file mode 100644 index 149cf32f80..0000000000 --- a/tests/sovereign_consumer_upgrade_local/start_provider.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -set -eux - -TOTAL_COINS=100000000000stake -STAKE_COINS=100000000stake -TOTAL_COINS1=120000000000stake -STAKE_COINS1=1000000stake -PROVIDER_BINARY=interchain-security-pd -PROVIDER_HOME="$HOME/.provider" -PROVIDER_HOME1="$HOME/.provider1" -PROVIDER_CHAIN_ID=provider -PROVIDER_MONIKER=provider -VALIDATOR=validator -VALIDATOR1=validator1 -NODE_IP="localhost" -PROVIDER_RPC_LADDR="$NODE_IP:26658" -PROVIDER_GRPC_ADDR="$NODE_IP:9091" -PROVIDER_RPC_LADDR1="$NODE_IP:26668" -PROVIDER_GRPC_ADDR1="$NODE_IP:9101" -PROVIDER_DELEGATOR=delegator - -# Clean start -killall $PROVIDER_BINARY &> /dev/null || true - -#######VALIDATOR1####################### -rm -rf $PROVIDER_HOME - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID -jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"600s\" | .app_state.provider.params.template_client.trusting_period = \"300s\"" \ - $PROVIDER_HOME/config/genesis.json > \ - $PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json -sleep 1 - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 -sleep 1 -$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test -sleep 1 - -# Stake 1/1000 user's coins -$PROVIDER_BINARY gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR -sleep 1 - -###########VALIDATOR 2############################ -rm -rf $PROVIDER_HOME1 - -$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME1 --chain-id $PROVIDER_CHAIN_ID -cp $PROVIDER_HOME/config/genesis.json $PROVIDER_HOME1/config/genesis.json - -# Create account keypair -$PROVIDER_BINARY keys add $VALIDATOR1 --home $PROVIDER_HOME1 --keyring-backend test --output json > $PROVIDER_HOME1/keypair.json 2>&1 -sleep 1 - -# Add stake to user -$PROVIDER_BINARY add-genesis-account $(jq -r .address $PROVIDER_HOME1/keypair.json) $TOTAL_COINS1 --home $PROVIDER_HOME1 --keyring-backend test -sleep 1 - -####################GENTX AND DISTRIBUTE GENESIS############################## -cp -r $PROVIDER_HOME/config/gentx $PROVIDER_HOME1/config/ - -# Stake 1/1000 user's coins -# $PROVIDER_BINARY gentx $VALIDATOR1 $STAKE_COINS1 --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME1 --keyring-backend test --moniker $VALIDATOR1 -# sleep 1 - -$PROVIDER_BINARY collect-gentxs --home $PROVIDER_HOME1 --gentx-dir $PROVIDER_HOME1/config/gentx/ -sleep 1 - -cp $PROVIDER_HOME1/config/genesis.json $PROVIDER_HOME/config/genesis.json - -####################ADDING PEERS#################### -node=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME) -node1=$($PROVIDER_BINARY tendermint show-node-id --home $PROVIDER_HOME1) -sed -i -r "/persistent_peers =/ s/= .*/= \"$node@localhost:26656\"/" "$PROVIDER_HOME1"/config/config.toml -sed -i -r "/persistent_peers =/ s/= .*/= \"$node1@localhost:26666\"/" "$PROVIDER_HOME"/config/config.toml - -#################### Start the chain node1 ################### -$PROVIDER_BINARY start \ - --home $PROVIDER_HOME \ - --rpc.laddr tcp://$PROVIDER_RPC_LADDR \ - --grpc.address $PROVIDER_GRPC_ADDR \ - --address tcp://${NODE_IP}:26655 \ - --p2p.laddr tcp://${NODE_IP}:26656 \ - --grpc-web.enable=false \ - --trace \ - &> $PROVIDER_HOME/logs & - -#################### Start the chain node2 ################### -# $PROVIDER_BINARY start \ -# --home $PROVIDER_HOME1 \ -# --rpc.laddr tcp://$PROVIDER_RPC_LADDR1 \ -# --grpc.address $PROVIDER_GRPC_ADDR1 \ -# --address tcp://${NODE_IP}:26665 \ -# --p2p.laddr tcp://${NODE_IP}:26666 \ -# --grpc-web.enable=false \ -# --trace \ -# &> $PROVIDER_HOME1/logs & -sleep 10 - -# # Build consumer chain proposal file -# tee $PROVIDER_HOME/consumer-proposal.json< Date: Thu, 9 Mar 2023 15:59:29 -0800 Subject: [PATCH 14/71] duplicate module name --- app/consumer-democracy/app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index ae437e1ac1..d0b40813f0 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -511,7 +511,6 @@ func New( evidencetypes.ModuleName, consumertypes.ModuleName, // Note: consumer beginblocker before staking module stakingtypes.ModuleName, - stakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, From 85b7be56b93da9527a08bc378043a8047ad21de2 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 9 Mar 2023 16:06:54 -0800 Subject: [PATCH 15/71] add comment --- x/ccv/consumer/module.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 988d74ed19..b149353d89 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -186,6 +186,8 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V // populate cross chain validators states with initial valset am.keeper.ApplyCCValidatorChanges(ctx, initialValSet) + // Add validator updates to initialValSet, such that the "old" validators returned from GetLastValidators + // are given zero power, and the "new" validators are given their full power. initialSetFlag := make(map[string]bool) for _, val := range initialValSet { initialSetFlag[val.PubKey.String()] = true From a651abcde1c53b71418557d7013918a9c4d98e8f Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 10 Mar 2023 15:16:22 -0800 Subject: [PATCH 16/71] small rename --- app/consumer-democracy/app.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index d0b40813f0..611a5cb47f 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -332,7 +332,7 @@ func New( app.AccountKeeper, ) - ccvstakingKeeper := stakingkeeper.NewKeeper( + stakingKeeper := stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, @@ -341,7 +341,7 @@ func New( ) app.MintKeeper = mintkeeper.NewKeeper( - appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &ccvstakingKeeper, + appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, ) @@ -357,7 +357,7 @@ func New( app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &ccvstakingKeeper, + &stakingKeeper, consumertypes.ConsumerRedistributeName, app.ModuleAccountAddrs(), ) @@ -378,7 +378,7 @@ func New( // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks // NOTE: slashing hook was removed since it's only relevant for consumerKeeper - app.StakingKeeper = *ccvstakingKeeper.SetHooks( + app.StakingKeeper = *stakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks()), ) @@ -391,7 +391,7 @@ func New( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)) govKeeper := govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &ccvstakingKeeper, ccvgovRouter, + &stakingKeeper, ccvgovRouter, ) app.GovKeeper = *govKeeper.SetHooks( From 1269163b9c75885ac4df83914b5e166a79de6a62 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 10 Mar 2023 15:35:14 -0800 Subject: [PATCH 17/71] remove democracy staking changes --- app/consumer-democracy/app.go | 4 +-- x/ccv/democracy/staking/expected_keepers.go | 12 ------- x/ccv/democracy/staking/module.go | 37 +++++++++++---------- 3 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 x/ccv/democracy/staking/expected_keepers.go diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 611a5cb47f..e4484e24b7 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -486,7 +486,7 @@ func New( mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName), - ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), + ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), @@ -587,7 +587,7 @@ func New( feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), ccvgov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, IsProposalWhitelisted), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper), + ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), params.NewAppModule(app.ParamsKeeper), diff --git a/x/ccv/democracy/staking/expected_keepers.go b/x/ccv/democracy/staking/expected_keepers.go deleted file mode 100644 index 66cb093d37..0000000000 --- a/x/ccv/democracy/staking/expected_keepers.go +++ /dev/null @@ -1,12 +0,0 @@ -package staking - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" -) - -// ConsumerKeeper defines the contract needed to be fulfilled for staking module. -type ConsumerKeeper interface { - GetParams(ctx sdk.Context) consumertypes.Params - IsPreCCV(ctx sdk.Context) bool -} diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index 9180652acf..45f2a32842 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -29,22 +29,20 @@ type AppModule struct { // embed the Cosmos SDK's x/staking AppModule staking.AppModule - keeper keeper.Keeper - accKeeper types.AccountKeeper - bankKeeper types.BankKeeper - consumerKeeper ConsumerKeeper + keeper keeper.Keeper + accKeeper types.AccountKeeper + bankKeeper types.BankKeeper } // NewAppModule creates a new AppModule object using the native x/staking module // AppModule constructor. -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, ck ConsumerKeeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule { stakingAppMod := staking.NewAppModule(cdc, keeper, ak, bk) return AppModule{ - AppModule: stakingAppMod, - keeper: keeper, - accKeeper: ak, - bankKeeper: bk, - consumerKeeper: ck, + AppModule: stakingAppMod, + keeper: keeper, + accKeeper: ak, + bankKeeper: bk, } } @@ -52,14 +50,14 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, // however, it returns no validator updates as validators are tracked via the // consumer chain's x/cvv/consumer module and so this module is not responsible // for returning the initial validator set. +// +// Note: InitGenesis is not called during the soft upgrade of a module (as a part of a migration from sovereign -> consumer chain), +// so there is no special handling needed in this method for a consumer being in the pre-CCV state. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - valUpdates := staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState) - if am.consumerKeeper.IsPreCCV(ctx) { - return valUpdates - } + _ = staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState) return []abci.ValidatorUpdate{} } @@ -68,10 +66,13 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // however, it returns no validator updates as validators are tracked via the // consumer chain's x/cvv/consumer module and so this module is not responsible // for returning the initial validator set. +// +// Note: This method does not require any special handling for PreCCV being true +// (as a part of the migration from sovereign -> consumer chain). +// The ccv consumer Endblocker is ordered to run before the staking Endblocker, +// so if PreCCV is true during one block, the ccv consumer Enblocker will return the proper validator updates, +// the PreCCV flag will be toggled to false, and no validator updates should be returned by this method. func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - valUpdates := am.keeper.BlockValidatorUpdates(ctx) - if am.consumerKeeper.IsPreCCV(ctx) { - return valUpdates - } + _ = am.keeper.BlockValidatorUpdates(ctx) return []abci.ValidatorUpdate{} } From 68515d9a221891428320f963774bab562c972b74 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 10 Mar 2023 16:41:10 -0800 Subject: [PATCH 18/71] consumer ccv beginblock, endblock, and initgenesis order shouldn't matter --- app/consumer-democracy/app.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index e4484e24b7..05f68085af 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -509,7 +509,6 @@ func New( distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, - consumertypes.ModuleName, // Note: consumer beginblocker before staking module stakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -521,11 +520,11 @@ func New( vestingtypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, + consumertypes.ModuleName, ) app.MM.SetOrderEndBlockers( crisistypes.ModuleName, govtypes.ModuleName, - consumertypes.ModuleName, // Note: consumer endblocker before staking module stakingtypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, @@ -541,6 +540,7 @@ func New( vestingtypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, + consumertypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -553,7 +553,6 @@ func New( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - consumertypes.ModuleName, // Note: consumer initiation before staking module distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, @@ -568,6 +567,7 @@ func New( vestingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, + consumertypes.ModuleName, ) app.MM.RegisterInvariants(&app.CrisisKeeper) From 48d64f4f10aa34703df4c601d994aba716134ed2 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 13 Mar 2023 10:26:03 -0700 Subject: [PATCH 19/71] add mock calls to compile --- testutil/keeper/mocks.go | 88 ++++++++++++++++++++++++++++ testutil/keeper/unit_test_helpers.go | 1 + 2 files changed, 89 insertions(+) diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index 66fc77dbce..d2ae917c4e 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -21,6 +21,7 @@ import ( exported "github.com/cosmos/ibc-go/v4/modules/core/exported" gomock "github.com/golang/mock/gomock" types8 "github.com/tendermint/tendermint/abci/types" +stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // MockStakingKeeper is a mock of StakingKeeper interface. @@ -210,6 +211,93 @@ func (mr *MockStakingKeeperMockRecorder) UnbondingTime(ctx interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnbondingTime", reflect.TypeOf((*MockStakingKeeper)(nil).UnbondingTime), ctx) } +// Unjail mocks base method. +func (m *MockStakingKeeper) Unjail(ctx types.Context, addr types.ConsAddress) { + m.ctrl.T.Helper() + _ = m.ctrl.Call(m, "Unjail", ctx, addr) +} + +// Unjail indicates an expected call of Unjail. +func (mr *MockStakingKeeperMockRecorder) Unjail(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unjail", reflect.TypeOf((*MockStakingKeeper)(nil).Unjail), ctx, addr) +} + +func (m *MockStakingKeeper) IterateValidators(ctx types.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { + m.ctrl.T.Helper() + _ = m.ctrl.Call(m, "IterateValidators", ctx, f) +} + +func (mr *MockStakingKeeperMockRecorder) IterateValidators(ctx, f interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateValidators", reflect.TypeOf((*MockStakingKeeper)(nil).IterateValidators), ctx, f) +} + +func (m *MockStakingKeeper) Validator(ctx types.Context, valAddr types.ValAddress) stakingtypes.ValidatorI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Validator", ctx, valAddr) + ret0, _ := ret[0].(stakingtypes.ValidatorI) + return ret0 +} + +func (mr *MockStakingKeeperMockRecorder) Validator(ctx, valAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validator", reflect.TypeOf((*MockStakingKeeper)(nil).Validator), ctx, valAddr) +} + +// IsValidatorJailed mocks base method. +func (m *MockStakingKeeper) IsValidatorJailed(ctx types.Context, addr types.ConsAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsValidatorJailed", ctx, addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsValidatorJailed indicates an expected call of IsValidatorJailed. +func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsValidatorJailed", reflect.TypeOf((*MockStakingKeeper)(nil).IsValidatorJailed), ctx, addr) +} + + +func (m *MockStakingKeeper) ValidatorByConsAddr(ctx types.Context, consAddr types.ConsAddress) stakingtypes.ValidatorI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ValidatorByConsAddr", ctx, consAddr) + ret0, _ := ret[0].(stakingtypes.ValidatorI) + return ret0 +} + +func (mr *MockStakingKeeperMockRecorder) ValidatorByConsAddr(ctx, consAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorByConsAddr", reflect.TypeOf((*MockStakingKeeper)(nil).ValidatorByConsAddr), ctx, consAddr) +} + +// Delegation mocks base method. +func (m *MockStakingKeeper) Delegation(ctx types.Context, addr types.AccAddress, valAddr types.ValAddress) stakingtypes.DelegationI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delegation", ctx, addr, valAddr) + ret0, _ := ret[0].(stakingtypes.DelegationI) + return ret0 +} + +// Delegation indicates an expected call of Delegation. +func (mr *MockStakingKeeperMockRecorder) Delegation(ctx, addr, valAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delegation", reflect.TypeOf((*MockStakingKeeper)(nil).Delegation), ctx, addr, valAddr) +} + +func (m *MockStakingKeeper) MaxValidators(ctx types.Context) uint32 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MaxValidators", ctx) + ret0, _ := ret[0].(uint32) + return ret0 +} + +func (mr *MockStakingKeeperMockRecorder) MaxValidators(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaxValidators", reflect.TypeOf((*MockStakingKeeper)(nil).MaxValidators), ctx) +} + // MockEvidenceKeeper is a mock of EvidenceKeeper interface. type MockEvidenceKeeper struct { ctrl *gomock.Controller diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index ab0eeef2ea..87e6db331b 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -138,6 +138,7 @@ func NewInMemConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consu mocks.MockPortKeeper, mocks.MockConnectionKeeper, mocks.MockClientKeeper, + mocks.MockStakingKeeper, mocks.MockSlashingKeeper, mocks.MockBankKeeper, mocks.MockAccountKeeper, From 95d11e7dbe3776621f8410adc9416b31d4034b3d Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 13 Mar 2023 10:26:18 -0700 Subject: [PATCH 20/71] adjust tests for new keeper field --- x/ccv/consumer/keeper/keeper.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 1f318cc6c7..562b5b6601 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -89,11 +89,11 @@ func NewKeeper( func (k Keeper) mustValidateFields() { // Ensures no fields are missed in this validation - if reflect.ValueOf(k).NumField() != 15 { - panic("number of fields in provider keeper is not 15") + if reflect.ValueOf(k).NumField() != 16 { + panic("number of fields in consumer keeper is not 16") } - // Note 14 fields will be validated, hooks are explicitly set after the constructor + // Note 15 fields will be validated, hooks are explicitly set after the constructor if reflect.ValueOf(k.storeKey).IsZero() { // 1 panic("storeKey is zero-valued or nil") @@ -119,22 +119,25 @@ func (k Keeper) mustValidateFields() { if reflect.ValueOf(k.clientKeeper).IsZero() { // 8 panic("clientKeeper is zero-valued or nil") } - if reflect.ValueOf(k.slashingKeeper).IsZero() { // 9 + if reflect.ValueOf(k.stakingKeeper).IsZero() { // 9 + panic("stakingKeeper is zero-valued or nil") + } + if reflect.ValueOf(k.slashingKeeper).IsZero() { // 10 panic("slashingKeeper is zero-valued or nil") } - if reflect.ValueOf(k.bankKeeper).IsZero() { // 10 + if reflect.ValueOf(k.bankKeeper).IsZero() { // 11 panic("bankKeeper is zero-valued or nil") } - if reflect.ValueOf(k.authKeeper).IsZero() { // 11 + if reflect.ValueOf(k.authKeeper).IsZero() { // 12 panic("authKeeper is zero-valued or nil") } - if reflect.ValueOf(k.ibcTransferKeeper).IsZero() { // 12 + if reflect.ValueOf(k.ibcTransferKeeper).IsZero() { // 13 panic("ibcTransferKeeper is zero-valued or nil") } - if reflect.ValueOf(k.ibcCoreKeeper).IsZero() { // 13 + if reflect.ValueOf(k.ibcCoreKeeper).IsZero() { // 14 panic("ibcCoreKeeper is zero-valued or nil") } - if reflect.ValueOf(k.feeCollectorName).IsZero() { // 14 + if reflect.ValueOf(k.feeCollectorName).IsZero() { // 15 panic("feeCollectorName is zero-valued or nil") } } From be3fda87b215edac12ac90f4967d0621264b3af4 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 13 Mar 2023 16:06:56 -0700 Subject: [PATCH 21/71] add registerDemocConsumer method --- app/consumer-democracy/app.go | 3 ++- app/consumer/app.go | 1 - testutil/keeper/unit_test_helpers.go | 35 +++++++++++++++++++++++++++- x/ccv/consumer/keeper/keeper.go | 35 +++++++++++++++++----------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 05f68085af..df0869fd87 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -419,7 +419,6 @@ func New( &app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, - app.StakingKeeper, app.SlashingKeeper, app.BankKeeper, app.AccountKeeper, @@ -428,6 +427,8 @@ func New( authtypes.FeeCollectorName, ) + app.ConsumerKeeper.RegisterAsDemocConsumer(app.StakingKeeper) + // consumer keeper satisfies the staking keeper interface // of the slashing module app.SlashingKeeper = slashingkeeper.NewKeeper( diff --git a/app/consumer/app.go b/app/consumer/app.go index 1f00fa0c11..0e5781ddf6 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -334,7 +334,6 @@ func New( &app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, - nil, app.SlashingKeeper, app.BankKeeper, app.AccountKeeper, diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 87e6db331b..b2e4f9e851 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -138,7 +138,6 @@ func NewInMemConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consu mocks.MockPortKeeper, mocks.MockConnectionKeeper, mocks.MockClientKeeper, - mocks.MockStakingKeeper, mocks.MockSlashingKeeper, mocks.MockBankKeeper, mocks.MockAccountKeeper, @@ -148,6 +147,28 @@ func NewInMemConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consu ) } +// NewInMemDemocConsumerKeeper instantiates an in-mem democracy consumer keeper from params and mocked keepers +func NewInMemDemocConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consumerkeeper.Keeper { + k := consumerkeeper.NewKeeper( + params.Cdc, + params.StoreKey, + *params.ParamsSubspace, + mocks.MockScopedKeeper, + mocks.MockChannelKeeper, + mocks.MockPortKeeper, + mocks.MockConnectionKeeper, + mocks.MockClientKeeper, + mocks.MockSlashingKeeper, + mocks.MockBankKeeper, + mocks.MockAccountKeeper, + mocks.MockIBCTransferKeeper, + mocks.MockIBCCoreKeeper, + authtypes.FeeCollectorName, + ) + k.RegisterAsDemocConsumer(mocks.MockStakingKeeper) + return k +} + // Returns an in-memory provider keeper, context, controller, and mocks, given a test instance and parameters. // // Note: Calling ctrl.Finish() at the end of a test function ensures that @@ -172,6 +193,18 @@ func GetConsumerKeeperAndCtx(t *testing.T, params InMemKeeperParams) ( return NewInMemConsumerKeeper(params, mocks), params.Ctx, ctrl, mocks } +// Return an in-memory democracy consumer keeper, context, controller, and mocks, given a test instance and parameters. +// +// Note: Calling ctrl.Finish() at the end of a test function ensures that +// no unexpected calls to external keepers are made. +func GetDemocConsumerKeeperAndCtx(t *testing.T, params InMemKeeperParams) ( + consumerkeeper.Keeper, sdk.Context, *gomock.Controller, MockedKeepers, +) { + ctrl := gomock.NewController(t) + mocks := NewMockedKeepers(ctrl) + return NewInMemDemocConsumerKeeper(params, mocks), params.Ctx, ctrl, mocks +} + // Registers proto interfaces for params.Cdc // // For now, we explicitly force certain unit tests to register sdk crypto interfaces. diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 562b5b6601..5a57168c4a 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -42,6 +42,7 @@ type Keeper struct { ibcTransferKeeper ccv.IBCTransferKeeper ibcCoreKeeper ccv.IBCCoreKeeper feeCollectorName string + isDemocConsumer bool } // NewKeeper creates a new Consumer Keeper instance @@ -52,7 +53,6 @@ func NewKeeper( scopedKeeper ccv.ScopedKeeper, channelKeeper ccv.ChannelKeeper, portKeeper ccv.PortKeeper, connectionKeeper ccv.ConnectionKeeper, clientKeeper ccv.ClientKeeper, - stakingKeeper ccv.StakingKeeper, slashingKeeper ccv.SlashingKeeper, bankKeeper ccv.BankKeeper, accountKeeper ccv.AccountKeeper, ibcTransferKeeper ccv.IBCTransferKeeper, ibcCoreKeeper ccv.IBCCoreKeeper, feeCollectorName string, @@ -71,29 +71,39 @@ func NewKeeper( portKeeper: portKeeper, connectionKeeper: connectionKeeper, clientKeeper: clientKeeper, - stakingKeeper: stakingKeeper, slashingKeeper: slashingKeeper, bankKeeper: bankKeeper, authKeeper: accountKeeper, ibcTransferKeeper: ibcTransferKeeper, ibcCoreKeeper: ibcCoreKeeper, feeCollectorName: feeCollectorName, + // Unless specified in registerAsDemocConsumer, keeper is for MVP consumer + stakingKeeper: nil, + isDemocConsumer: false, } k.mustValidateFields() return k } +func (k *Keeper) RegisterAsDemocConsumer(stakingKeeper ccv.StakingKeeper) { + k.stakingKeeper = stakingKeeper + k.isDemocConsumer = true +} + // Validates that the consumer keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { // Ensures no fields are missed in this validation - if reflect.ValueOf(k).NumField() != 16 { - panic("number of fields in consumer keeper is not 16") + if reflect.ValueOf(k).NumField() != 17 { + panic("number of fields in consumer keeper is not 17") } - // Note 15 fields will be validated, hooks are explicitly set after the constructor + // Note 14 / 17 fields will be validated, + // hooks are explicitly set after the constructor, + // stakingKeeper is optionally set after the constructor, + // isDemocConsumer is optionally set after the constructor if reflect.ValueOf(k.storeKey).IsZero() { // 1 panic("storeKey is zero-valued or nil") @@ -119,25 +129,22 @@ func (k Keeper) mustValidateFields() { if reflect.ValueOf(k.clientKeeper).IsZero() { // 8 panic("clientKeeper is zero-valued or nil") } - if reflect.ValueOf(k.stakingKeeper).IsZero() { // 9 - panic("stakingKeeper is zero-valued or nil") - } - if reflect.ValueOf(k.slashingKeeper).IsZero() { // 10 + if reflect.ValueOf(k.slashingKeeper).IsZero() { // 9 panic("slashingKeeper is zero-valued or nil") } - if reflect.ValueOf(k.bankKeeper).IsZero() { // 11 + if reflect.ValueOf(k.bankKeeper).IsZero() { // 10 panic("bankKeeper is zero-valued or nil") } - if reflect.ValueOf(k.authKeeper).IsZero() { // 12 + if reflect.ValueOf(k.authKeeper).IsZero() { // 11 panic("authKeeper is zero-valued or nil") } - if reflect.ValueOf(k.ibcTransferKeeper).IsZero() { // 13 + if reflect.ValueOf(k.ibcTransferKeeper).IsZero() { // 12 panic("ibcTransferKeeper is zero-valued or nil") } - if reflect.ValueOf(k.ibcCoreKeeper).IsZero() { // 14 + if reflect.ValueOf(k.ibcCoreKeeper).IsZero() { // 13 panic("ibcCoreKeeper is zero-valued or nil") } - if reflect.ValueOf(k.feeCollectorName).IsZero() { // 15 + if reflect.ValueOf(k.feeCollectorName).IsZero() { // 14 panic("feeCollectorName is zero-valued or nil") } } From 331f206425fcbb57b23d724206bc6eed9adbfd31 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:13:58 -0700 Subject: [PATCH 22/71] split out preCCV flag and initial valset --- x/ccv/consumer/keeper/genesis.go | 3 ++- x/ccv/consumer/keeper/keeper.go | 24 +++++++++++++----------- x/ccv/consumer/module_test.go | 8 +++----- x/ccv/consumer/types/keys.go | 6 ++++++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 7ceeef7e26..4552e280fd 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -20,7 +20,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) // PreCCV is true when consumer chain used to be running on non-consumer chain, and when it is in the progress of upgrading // to consumer chain, where consumer chain upgrade is done. if state.PreCCV { - k.SetPreCCV(ctx, state) + k.SetPreCCVTrue(ctx) + k.SetInitialValSet(ctx, state.InitialValSet) } k.SetParams(ctx, state.Params) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index d0854dc582..cf88984934 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -276,18 +276,12 @@ func (k Keeper) SetLastSovereignHeight(ctx sdk.Context, height int64) { func (k Keeper) IsPreCCV(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) bz := store.Get(types.PreCCVKey()) - if bz != nil { - return true - } - return false + return bz != nil } -func (k Keeper) SetPreCCV(ctx sdk.Context, state *types.GenesisState) { - initialValSet := types.GenesisState{ - InitialValSet: state.InitialValSet, - } - bz := k.cdc.MustMarshal(&initialValSet) +func (k Keeper) SetPreCCVTrue(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) + bz := sdk.Uint64ToBigEndian(uint64(1)) store.Set(types.PreCCVKey(), bz) } @@ -296,15 +290,23 @@ func (k Keeper) DeletePreCCV(ctx sdk.Context) { store.Delete(types.PreCCVKey()) } +func (k Keeper) SetInitialValSet(ctx sdk.Context, initialValSet []tmtypes.ValidatorUpdate) { + store := ctx.KVStore(k.storeKey) + initialValSetState := types.GenesisState{ + InitialValSet: initialValSet, + } + bz := k.cdc.MustMarshal(&initialValSetState) + store.Set(types.InitialValSetKey(), bz) +} + func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { store := ctx.KVStore(k.storeKey) initialValSet := types.GenesisState{} - bz := store.Get(types.PreCCVKey()) + bz := store.Get(types.InitialValSetKey()) if bz != nil { k.cdc.MustUnmarshal(bz, &initialValSet) return initialValSet.InitialValSet } - return []tmtypes.ValidatorUpdate{} } diff --git a/x/ccv/consumer/module_test.go b/x/ccv/consumer/module_test.go index 0851aa3188..cd15673360 100644 --- a/x/ccv/consumer/module_test.go +++ b/x/ccv/consumer/module_test.go @@ -11,7 +11,6 @@ import ( ccvstakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" democracyapp "github.com/cosmos/interchain-security/app/consumer-democracy" "github.com/cosmos/interchain-security/x/ccv/consumer" - "github.com/cosmos/interchain-security/x/ccv/consumer/types" "github.com/stretchr/testify/require" "github.com/tendermint/spm/cosmoscmd" abci "github.com/tendermint/tendermint/abci/types" @@ -21,6 +20,7 @@ import ( dbm "github.com/tendermint/tm-db" ) +// TODO: Determine if refactors are necessary for this test func TestEndBlock(t *testing.T) { PKs := simapp.CreateTestPubKeys(500) validator1 := teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0]) @@ -100,10 +100,8 @@ func TestEndBlock(t *testing.T) { dApp.StakingKeeper.SetLastValidatorPower(ctx, val.GetOperator(), 1) } - dApp.ConsumerKeeper.SetPreCCV(ctx, &types.GenesisState{ - InitialValSet: tc.providerValidators, - PreCCV: tc.preCCV, - }) + dApp.ConsumerKeeper.SetPreCCVTrue(ctx) + dApp.ConsumerKeeper.SetInitialValSet(ctx, tc.providerValidators) consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper, dApp.StakingKeeper) valUpdate := consumerModule.EndBlock( diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index f54fbd8d1f..ec9ca98e38 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -74,6 +74,8 @@ const ( // PreCCVByteKey is the byte to store the consumer is running on democracy staking module without consumer PreCCVByteKey + InitialValSetByteKey + // LastSovereignHeightByteKey is the byte that will store last sovereign height LastSovereignHeightByteKey ) @@ -112,6 +114,10 @@ func PreCCVKey() []byte { return []byte{PreCCVByteKey} } +func InitialValSetKey() []byte { + return []byte{InitialValSetByteKey} +} + func LastSovereignHeightKey() []byte { return []byte{LastSovereignHeightByteKey} } From 08bb06b8b038f4c1570c3c49b03ac02adbd0abfd Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:31:06 -0700 Subject: [PATCH 23/71] cleanup consumer module --- app/consumer/app.go | 2 +- x/ccv/consumer/keeper/keeper.go | 11 ++++++++++- x/ccv/consumer/module.go | 27 ++++++++++++--------------- x/ccv/types/expected_keepers.go | 6 +----- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/consumer/app.go b/app/consumer/app.go index 0e5781ddf6..00cfe5b27d 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -344,7 +344,7 @@ func New( // register slashing module Slashing hooks to the consumer keeper app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) - consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper, nil) + consumerModule := ibcconsumer.NewAppModule(app.ConsumerKeeper) app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index cf88984934..63ce58a009 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -10,6 +10,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types" @@ -273,6 +274,7 @@ func (k Keeper) SetLastSovereignHeight(ctx sdk.Context, height int64) { store.Set(types.LastSovereignHeightKey(), bz) } +// TODO: unit tests on these new CRUD methods func (k Keeper) IsPreCCV(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) bz := store.Get(types.PreCCVKey()) @@ -299,7 +301,7 @@ func (k Keeper) SetInitialValSet(ctx sdk.Context, initialValSet []tmtypes.Valida store.Set(types.InitialValSetKey(), bz) } -func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { +func (k Keeper) GetInitialValUpdates(ctx sdk.Context) []tmtypes.ValidatorUpdate { store := ctx.KVStore(k.storeKey) initialValSet := types.GenesisState{} bz := store.Get(types.InitialValSetKey()) @@ -310,6 +312,13 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { return []tmtypes.ValidatorUpdate{} } +func (k Keeper) GetLastSovereignValidators(ctx sdk.Context) []stakingtypes.Validator { + if !k.IsPreCCV(ctx) || k.stakingKeeper == nil { + panic("cannot get last sovereign validators if not in pre-ccv state") + } + return k.stakingKeeper.GetLastValidators(ctx) +} + // GetElapsedPacketMaturityTimes returns a slice of already elapsed PacketMaturityTimes, sorted by maturity times, // i.e., the slice contains the IDs of the matured VSCPackets. func (k Keeper) GetElapsedPacketMaturityTimes(ctx sdk.Context) (maturingVSCPackets []consumertypes.MaturingVSCPacket) { diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index b149353d89..13ef30a4a7 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -23,7 +23,6 @@ import ( "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/x/ccv/types" ) var ( @@ -93,14 +92,12 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic keeper keeper.Keeper - sk ccvtypes.DemocracyStakingKeeper } // NewAppModule creates a new consumer module -func NewAppModule(k keeper.Keeper, sk ccvtypes.DemocracyStakingKeeper) AppModule { +func NewAppModule(k keeper.Keeper) AppModule { return AppModule{ keeper: k, - sk: sk, } } @@ -177,29 +174,29 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { if am.keeper.IsPreCCV(ctx) { - initialValSet := am.keeper.GetInitialValSet(ctx) + initialValUpdates := am.keeper.GetInitialValUpdates(ctx) // Note: validator set update is only done on consumer chain from first endblocker // on soft fork from existing chain am.keeper.DeletePreCCV(ctx) // set last sovereign height am.keeper.SetLastSovereignHeight(ctx, ctx.BlockHeight()) // populate cross chain validators states with initial valset - am.keeper.ApplyCCValidatorChanges(ctx, initialValSet) + am.keeper.ApplyCCValidatorChanges(ctx, initialValUpdates) - // Add validator updates to initialValSet, such that the "old" validators returned from GetLastValidators + // Add validator updates to initialValUpdates, such that the "old" validators returned from sovereign staking module // are given zero power, and the "new" validators are given their full power. - initialSetFlag := make(map[string]bool) - for _, val := range initialValSet { - initialSetFlag[val.PubKey.String()] = true + initialUpdatesFlag := make(map[string]bool) + for _, val := range initialValUpdates { + initialUpdatesFlag[val.PubKey.String()] = true } - for _, val := range am.sk.GetLastValidators(ctx) { - update := val.ABCIValidatorUpdateZero() - if !initialSetFlag[update.PubKey.String()] { - initialValSet = append(initialValSet, update) + for _, val := range am.keeper.GetLastSovereignValidators(ctx) { + zeroPowerUpdate := val.ABCIValidatorUpdateZero() + if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { + initialValUpdates = append(initialValUpdates, zeroPowerUpdate) } } - return initialValSet + return initialValUpdates } // Execute EndBlock logic for the Reward Distribution sub-protocol diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index cd62bf62f4..56025820e6 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -18,11 +18,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// DemocracyStakingKeeper defines the interface expected by consumer module -type DemocracyStakingKeeper interface { - GetLastValidators(ctx sdk.Context) (validators []stakingtypes.Validator) -} - // StakingKeeper defines the contract expected by provider-chain ccv module from a Staking Module that will keep track // of the provider validator set. This version of the interchain-security protocol will mirror the provider chain's changes // so we do not need a registry module between the staking module and CCV. @@ -47,6 +42,7 @@ type StakingKeeper interface { Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) stakingtypes.DelegationI MaxValidators(ctx sdk.Context) uint32 GetLastTotalPower(ctx sdk.Context) sdk.Int + GetLastValidators(ctx sdk.Context) (validators []stakingtypes.Validator) } type EvidenceKeeper interface { From 91d7beeeffc1d8f8340833ac7af0980b02eacfea Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:36:27 -0700 Subject: [PATCH 24/71] cleanup --- app/consumer-democracy/app.go | 2 +- testutil/keeper/mocks.go | 14 ++++++++++++++ x/ccv/consumer/ibc_module_test.go | 12 ++++++------ x/ccv/consumer/module_test.go | 2 +- x/ccv/types/expected_keepers.go | 2 ++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index df0869fd87..b4e7173aa1 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -440,7 +440,7 @@ func New( // register slashing module StakingHooks to the consumer keeper app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) - consumerModule := consumer.NewAppModule(app.ConsumerKeeper, app.StakingKeeper) + consumerModule := consumer.NewAppModule(app.ConsumerKeeper) app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index d2ae917c4e..2c06e7b750 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -61,6 +61,20 @@ func (mr *MockStakingKeeperMockRecorder) GetLastTotalPower(ctx interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastTotalPower", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastTotalPower), ctx) } +// GetLastValidators mocks base method. +func (m *MockStakingKeeper) GetLastValidators(ctx types.Context) []stakingtypes.Validator { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLastValidators", ctx) + ret0, _ := ret[0].([]stakingtypes.Validator) + return ret0 +} + +// GetLastValidators indicates an expected call of GetLastValidators. +func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidators), ctx) +} + // GetLastValidatorPower mocks base method. func (m *MockStakingKeeper) GetLastValidatorPower(ctx types.Context, operator types.ValAddress) int64 { m.ctrl.T.Helper() diff --git a/x/ccv/consumer/ibc_module_test.go b/x/ccv/consumer/ibc_module_test.go index 4f86638783..ac71b7cfaf 100644 --- a/x/ccv/consumer/ibc_module_test.go +++ b/x/ccv/consumer/ibc_module_test.go @@ -124,7 +124,7 @@ func TestOnChanOpenInit(t *testing.T) { // Common setup consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx( t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) consumerKeeper.SetPort(ctx, ccv.ConsumerPortID) consumerKeeper.SetProviderClientID(ctx, "clientIDToProvider") @@ -177,7 +177,7 @@ func TestOnChanOpenTry(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) // No external keeper methods should be called defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) // OnOpenTry must error even with correct arguments _, err := consumerModule.OnChanOpenTry( @@ -271,7 +271,7 @@ func TestOnChanOpenAck(t *testing.T) { // Common setup consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx( t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) // Instantiate valid params as default. Individual test cases mutate these as needed. params := params{ @@ -321,7 +321,7 @@ func TestOnChanOpenAck(t *testing.T) { func TestOnChanOpenConfirm(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) err := consumerModule.OnChanOpenConfirm(ctx, ccv.ConsumerPortID, "channel-1") require.Error(t, err, "OnChanOpenConfirm callback must error on consumer chain") @@ -361,7 +361,7 @@ func TestOnChanCloseInit(t *testing.T) { for _, tc := range testCases { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) if tc.establishedProviderExists { consumerKeeper.SetProviderChannel(ctx, "provider") @@ -389,7 +389,7 @@ func TestOnChanCloseConfirm(t *testing.T) { // No external keeper methods should be called defer ctrl.Finish() - consumerModule := consumer.NewAppModule(consumerKeeper, nil) + consumerModule := consumer.NewAppModule(consumerKeeper) // Nothing happens, no error returned err := consumerModule.OnChanCloseConfirm(ctx, "portID", "channelID") diff --git a/x/ccv/consumer/module_test.go b/x/ccv/consumer/module_test.go index cd15673360..af9a2bf20e 100644 --- a/x/ccv/consumer/module_test.go +++ b/x/ccv/consumer/module_test.go @@ -102,7 +102,7 @@ func TestEndBlock(t *testing.T) { dApp.ConsumerKeeper.SetPreCCVTrue(ctx) dApp.ConsumerKeeper.SetInitialValSet(ctx, tc.providerValidators) - consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper, dApp.StakingKeeper) + consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper) valUpdate := consumerModule.EndBlock( ctx, diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index 56025820e6..edb4fa161e 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -21,6 +21,8 @@ import ( // StakingKeeper defines the contract expected by provider-chain ccv module from a Staking Module that will keep track // of the provider validator set. This version of the interchain-security protocol will mirror the provider chain's changes // so we do not need a registry module between the staking module and CCV. +// +// TODO: Do we want to split this into multiple interfaces for the contract needed by the a consumer vs democ consumer? type StakingKeeper interface { GetValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate UnbondingCanComplete(ctx sdk.Context, id uint64) error From 110d7106283d5f5c2185a4e058fcaac740799027 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:00:55 -0700 Subject: [PATCH 25/71] more cleanup --- app/consumer-democracy/app.go | 3 ++- testutil/keeper/unit_test_helpers.go | 34 ---------------------------- x/ccv/consumer/keeper/keeper.go | 32 ++++++++++++-------------- 3 files changed, 16 insertions(+), 53 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index b4e7173aa1..fc165134ea 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -427,7 +427,8 @@ func New( authtypes.FeeCollectorName, ) - app.ConsumerKeeper.RegisterAsDemocConsumer(app.StakingKeeper) + // Setting the staking keeper is only needed for sovereign to consumer migrated chains + app.ConsumerKeeper.SetStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface // of the slashing module diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index b2e4f9e851..ab0eeef2ea 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -147,28 +147,6 @@ func NewInMemConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consu ) } -// NewInMemDemocConsumerKeeper instantiates an in-mem democracy consumer keeper from params and mocked keepers -func NewInMemDemocConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consumerkeeper.Keeper { - k := consumerkeeper.NewKeeper( - params.Cdc, - params.StoreKey, - *params.ParamsSubspace, - mocks.MockScopedKeeper, - mocks.MockChannelKeeper, - mocks.MockPortKeeper, - mocks.MockConnectionKeeper, - mocks.MockClientKeeper, - mocks.MockSlashingKeeper, - mocks.MockBankKeeper, - mocks.MockAccountKeeper, - mocks.MockIBCTransferKeeper, - mocks.MockIBCCoreKeeper, - authtypes.FeeCollectorName, - ) - k.RegisterAsDemocConsumer(mocks.MockStakingKeeper) - return k -} - // Returns an in-memory provider keeper, context, controller, and mocks, given a test instance and parameters. // // Note: Calling ctrl.Finish() at the end of a test function ensures that @@ -193,18 +171,6 @@ func GetConsumerKeeperAndCtx(t *testing.T, params InMemKeeperParams) ( return NewInMemConsumerKeeper(params, mocks), params.Ctx, ctrl, mocks } -// Return an in-memory democracy consumer keeper, context, controller, and mocks, given a test instance and parameters. -// -// Note: Calling ctrl.Finish() at the end of a test function ensures that -// no unexpected calls to external keepers are made. -func GetDemocConsumerKeeperAndCtx(t *testing.T, params InMemKeeperParams) ( - consumerkeeper.Keeper, sdk.Context, *gomock.Controller, MockedKeepers, -) { - ctrl := gomock.NewController(t) - mocks := NewMockedKeepers(ctrl) - return NewInMemDemocConsumerKeeper(params, mocks), params.Ctx, ctrl, mocks -} - // Registers proto interfaces for params.Cdc // // For now, we explicitly force certain unit tests to register sdk crypto interfaces. diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 63ce58a009..6d63c685d7 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -28,14 +28,15 @@ import ( // Keeper defines the Cross-Chain Validation Consumer Keeper type Keeper struct { - storeKey sdk.StoreKey - cdc codec.BinaryCodec - paramStore paramtypes.Subspace - scopedKeeper ccv.ScopedKeeper - channelKeeper ccv.ChannelKeeper - portKeeper ccv.PortKeeper - connectionKeeper ccv.ConnectionKeeper - clientKeeper ccv.ClientKeeper + storeKey sdk.StoreKey + cdc codec.BinaryCodec + paramStore paramtypes.Subspace + scopedKeeper ccv.ScopedKeeper + channelKeeper ccv.ChannelKeeper + portKeeper ccv.PortKeeper + connectionKeeper ccv.ConnectionKeeper + clientKeeper ccv.ClientKeeper + // stakingKeeper is only needed for sovereign to consumer migration, and therefore is set after constructor stakingKeeper ccv.StakingKeeper slashingKeeper ccv.SlashingKeeper hooks ccv.ConsumerHooks @@ -44,7 +45,6 @@ type Keeper struct { ibcTransferKeeper ccv.IBCTransferKeeper ibcCoreKeeper ccv.IBCCoreKeeper feeCollectorName string - isDemocConsumer bool } // NewKeeper creates a new Consumer Keeper instance @@ -79,18 +79,15 @@ func NewKeeper( ibcTransferKeeper: ibcTransferKeeper, ibcCoreKeeper: ibcCoreKeeper, feeCollectorName: feeCollectorName, - // Unless specified in registerAsDemocConsumer, keeper is for MVP consumer - stakingKeeper: nil, - isDemocConsumer: false, + stakingKeeper: nil, } k.mustValidateFields() return k } -func (k *Keeper) RegisterAsDemocConsumer(stakingKeeper ccv.StakingKeeper) { +func (k *Keeper) SetStakingKeeper(stakingKeeper ccv.StakingKeeper) { k.stakingKeeper = stakingKeeper - k.isDemocConsumer = true } // Validates that the consumer keeper is initialized with non-zero and @@ -98,14 +95,13 @@ func (k *Keeper) RegisterAsDemocConsumer(stakingKeeper ccv.StakingKeeper) { func (k Keeper) mustValidateFields() { // Ensures no fields are missed in this validation - if reflect.ValueOf(k).NumField() != 17 { - panic("number of fields in consumer keeper is not 17") + if reflect.ValueOf(k).NumField() != 16 { + panic("number of fields in consumer keeper is not 16") } - // Note 14 / 17 fields will be validated, + // Note 14 / 16 fields will be validated, // hooks are explicitly set after the constructor, // stakingKeeper is optionally set after the constructor, - // isDemocConsumer is optionally set after the constructor utils.PanicIfZeroOrNil(k.storeKey, "storeKey") // 1 utils.PanicIfZeroOrNil(k.cdc, "cdc") // 2 From 35845370e86362ab6bea5f10b3f7de9a2fe85333 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:03:47 -0700 Subject: [PATCH 26/71] temp changes to validators.go --- x/ccv/consumer/keeper/validators.go | 53 ++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 0d963da511..85d9c70bd5 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -11,6 +11,10 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// +// TODO: make unit tests for BOTH MVP consumer democ consumer, and pre-ccv consumer for previously unimplemented methods +// + // ApplyCCValidatorChanges applies the given changes to the cross-chain validators states // and returns updates to forward to tendermint. func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.ValidatorUpdate) []abci.ValidatorUpdate { @@ -63,6 +67,13 @@ func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.Validato // IterateValidators iterate democracy staking validators when the block height is before the last sovereign height func (k Keeper) IterateValidators(ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return + } + + // TODO: figure out proper logic if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") @@ -74,6 +85,13 @@ func (k Keeper) IterateValidators(ctx sdk.Context, f func(index int64, validator // Validator returns democracy staking validator when the block height is before the last sovereign height func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return nil + } + + // TODO: figure out proper logic if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") @@ -86,11 +104,12 @@ func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.Val // IsJailed returns the outstanding slashing flag for the given validator adddress func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + + // TODO: figure out proper logic + if k.IsPreCCV(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") } - return k.stakingKeeper.IsValidatorJailed(ctx, addr) } return k.OutstandingDowntime(ctx, addr) @@ -108,7 +127,8 @@ func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) s Also, the slashing module will cal lthis function when it observes downtime. In that case the only requirement on the returned value is that it isn't null. */ - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + // TODO: figure out proper logic + if k.IsPreCCV(ctx) { if k.stakingKeeper == nil { return stakingtypes.Validator{} } @@ -125,7 +145,8 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p return } - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + // TODO: figure out proper logic + if k.IsPreCCV(ctx) { if k.stakingKeeper == nil { return } @@ -154,6 +175,12 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p // Jail performs jail operation on democracy staking validator if block height after last sovereign height func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return + } + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { return @@ -166,6 +193,12 @@ func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) { // Unjail performs unjail operation on democracy staking validator if block height after last sovereign height func (k Keeper) Unjail(ctx sdk.Context, addr sdk.ConsAddress) { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return + } + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { return @@ -177,6 +210,12 @@ func (k Keeper) Unjail(ctx sdk.Context, addr sdk.ConsAddress) { // Delegation returns delegation from an address to a democracy staking validator if block height after last sovereign height func (k Keeper) Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) stakingtypes.DelegationI { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return nil + } + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") @@ -189,6 +228,12 @@ func (k Keeper) Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.Val // MaxValidators returns max number of validators on democracy staking if block height after last sovereign height func (k Keeper) MaxValidators(ctx sdk.Context) uint32 { + + // MVP consumer performs a no-op + if !k.IsPreCCV(ctx) { + return 0 + } + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") From 11072807f44612408e2d0a24a6a3da9d0788fc23 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:13:44 -0700 Subject: [PATCH 27/71] comment out test --- x/ccv/consumer/module_test.go | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/x/ccv/consumer/module_test.go b/x/ccv/consumer/module_test.go index af9a2bf20e..393bf6c205 100644 --- a/x/ccv/consumer/module_test.go +++ b/x/ccv/consumer/module_test.go @@ -20,10 +20,10 @@ import ( dbm "github.com/tendermint/tm-db" ) -// TODO: Determine if refactors are necessary for this test +// TODO: Refactors are needed for this test. It doesn't follow our patterns func TestEndBlock(t *testing.T) { PKs := simapp.CreateTestPubKeys(500) - validator1 := teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0]) + // validator1 := teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0]) validator2 := teststaking.NewValidator(t, sdk.ValAddress(PKs[1].Address().Bytes()), PKs[1]) _ = validator2 @@ -49,27 +49,27 @@ func TestEndBlock(t *testing.T) { providerValidators []abci.ValidatorUpdate expValUpdateLen int }{ - { - name: "case not preCCV", - preCCV: false, - sovereignValidators: []ccvstakingtypes.Validator{validator1}, - providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator1)}, - expValUpdateLen: 1, - }, - { - name: "case preCCV - no duplication with sovereign validators", - preCCV: true, - sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, - providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, - expValUpdateLen: 3, - }, - { - name: "case preCCV - duplication with sovereign validators", - preCCV: true, - sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, - providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator2), tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, - expValUpdateLen: 3, - }, + // { + // name: "case not preCCV", + // preCCV: false, + // sovereignValidators: []ccvstakingtypes.Validator{validator1}, + // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator1)}, + // expValUpdateLen: 1, + // }, + // { + // name: "case preCCV - no duplication with sovereign validators", + // preCCV: true, + // sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, + // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, + // expValUpdateLen: 3, + // }, + // { + // name: "case preCCV - duplication with sovereign validators", + // preCCV: true, + // sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, + // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator2), tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, + // expValUpdateLen: 3, + // }, } for _, tc := range testCases { @@ -100,8 +100,11 @@ func TestEndBlock(t *testing.T) { dApp.StakingKeeper.SetLastValidatorPower(ctx, val.GetOperator(), 1) } - dApp.ConsumerKeeper.SetPreCCVTrue(ctx) - dApp.ConsumerKeeper.SetInitialValSet(ctx, tc.providerValidators) + // The following setters would be made in InitGenesis if preCCV is true in genesis state + if tc.preCCV { + dApp.ConsumerKeeper.SetPreCCVTrue(ctx) + dApp.ConsumerKeeper.SetInitialValSet(ctx, tc.providerValidators) + } consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper) valUpdate := consumerModule.EndBlock( From fa5a6eb02a145ef062edefcd2754c3d30a253a14 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:17:35 -0700 Subject: [PATCH 28/71] rm bad code from merge --- x/ccv/consumer/types/keys.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index ec9ca98e38..2d13671cf0 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -135,12 +135,6 @@ func PacketMaturityTimeKey(vscID uint64, maturityTime time.Time) []byte { ) } -// IdFromPacketMaturityTimeKey returns the packet id corresponding to a maturity time full key (including prefix) -func IdFromPacketMaturityTimeKey(key []byte) uint64 { - // Bytes after single byte prefix are converted to uin64 - return binary.BigEndian.Uint64(key[1:]) -} - // HeightValsetUpdateIDKey returns the key to a valset update ID for a given block height func HeightValsetUpdateIDKey(height uint64) []byte { hBytes := make([]byte, 8) From 4b5fd84513501b3d4e1d7223ad0b4ac57b548728 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 15 Mar 2023 11:20:59 -0700 Subject: [PATCH 29/71] comment --- app/consumer-democracy/app.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index fc165134ea..612e3727f5 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -668,6 +668,8 @@ func New( } if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + // CCV consumer module store is not available for sovereign chain, + // therefore it needs to be marked as an added KV store storeUpgrades := store.StoreUpgrades{ Added: []string{consumertypes.ModuleName}, } From 00a78efd1efed5568ae9af6b2afcbe8a3a04c5ed Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 15 Mar 2023 11:33:15 -0700 Subject: [PATCH 30/71] Update app.go --- app/consumer-democracy/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 612e3727f5..fc02f2c954 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -669,7 +669,7 @@ func New( if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { // CCV consumer module store is not available for sovereign chain, - // therefore it needs to be marked as an added KV store + // therefore it needs to be marked as an added KV store for the sovereign -> consumer changeover storeUpgrades := store.StoreUpgrades{ Added: []string{consumertypes.ModuleName}, } From e09066d5a0088ebc89cb565c150359a5276a1dc4 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 15 Mar 2023 15:31:49 -0700 Subject: [PATCH 31/71] UTs for CRUD --- x/ccv/consumer/keeper/keeper.go | 5 +- x/ccv/consumer/keeper/keeper_test.go | 113 +++++++++++++++++++++++++++ x/ccv/consumer/keeper/validators.go | 12 +-- x/ccv/consumer/module.go | 2 +- 4 files changed, 122 insertions(+), 10 deletions(-) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 6d63c685d7..f3bdb621fe 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -254,7 +254,7 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } -func (k Keeper) LastSovereignHeight(ctx sdk.Context) int64 { +func (k Keeper) GetLastSovereignHeight(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) bz := store.Get(types.LastSovereignHeightKey()) if bz == nil { @@ -270,7 +270,6 @@ func (k Keeper) SetLastSovereignHeight(ctx sdk.Context, height int64) { store.Set(types.LastSovereignHeightKey(), bz) } -// TODO: unit tests on these new CRUD methods func (k Keeper) IsPreCCV(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) bz := store.Get(types.PreCCVKey()) @@ -297,7 +296,7 @@ func (k Keeper) SetInitialValSet(ctx sdk.Context, initialValSet []tmtypes.Valida store.Set(types.InitialValSetKey(), bz) } -func (k Keeper) GetInitialValUpdates(ctx sdk.Context) []tmtypes.ValidatorUpdate { +func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { store := ctx.KVStore(k.storeKey) initialValSet := types.GenesisState{} bz := store.Get(types.InitialValSetKey()) diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index b544b3b3ed..799ff1ae0a 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types" + "github.com/cosmos/interchain-security/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/testutil/keeper" "github.com/cosmos/interchain-security/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" @@ -83,6 +84,118 @@ func TestPendingChanges(t *testing.T) { require.Nil(t, gotPd, "got non-nil pending changes after Delete") } +// TestLastSovereignHeight tests the getter and setter for the last sovereign height +func TestLastSovereignHeight(t *testing.T) { + consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Default value should be 0 without any setter + require.Equal(t, int64(0), consumerKeeper.GetLastSovereignHeight(ctx)) + + // Set/get the last sovereign height being 10 + consumerKeeper.SetLastSovereignHeight(ctx, 10) + require.Equal(t, int64(10), consumerKeeper.GetLastSovereignHeight(ctx)) + + // Set/get the last sovereign height being 43234426 + consumerKeeper.SetLastSovereignHeight(ctx, 43234426) + require.Equal(t, int64(43234426), consumerKeeper.GetLastSovereignHeight(ctx)) +} + +// TestPreCCV tests the getter, setter and deletion methods for the pre-CCV state flag +func TestPreCCV(t *testing.T) { + consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Default value is false without any setter + require.False(t, consumerKeeper.IsPreCCV(ctx)) + + // Set/get the pre-CCV state to true + consumerKeeper.SetPreCCVTrue(ctx) + require.True(t, consumerKeeper.IsPreCCV(ctx)) + + // Delete the pre-CCV state, setting it to false + consumerKeeper.DeletePreCCV(ctx) + require.False(t, consumerKeeper.IsPreCCV(ctx)) +} + +// TestInitialValSet tests the getter and setter methods for storing the initial validator set for a consumer +func TestInitialValSet(t *testing.T) { + consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Default value is empty val update list + require.Empty(t, consumerKeeper.GetInitialValSet(ctx)) + + // Set/get the initial validator set + cId1 := crypto.NewCryptoIdentityFromIntSeed(7896) + cId2 := crypto.NewCryptoIdentityFromIntSeed(7897) + cId3 := crypto.NewCryptoIdentityFromIntSeed(7898) + valUpdates := []abci.ValidatorUpdate{ + { + PubKey: cId1.TMProtoCryptoPublicKey(), + Power: 1097, + }, + { + PubKey: cId2.TMProtoCryptoPublicKey(), + Power: 19068, + }, + { + PubKey: cId3.TMProtoCryptoPublicKey(), + Power: 10978554, + }, + } + + consumerKeeper.SetInitialValSet(ctx, valUpdates) + require.Equal(t, []abci.ValidatorUpdate{ + { + PubKey: cId1.TMProtoCryptoPublicKey(), + Power: 1097, + }, + { + PubKey: cId2.TMProtoCryptoPublicKey(), + Power: 19068, + }, + { + PubKey: cId3.TMProtoCryptoPublicKey(), + Power: 10978554, + }, + }, consumerKeeper.GetInitialValSet(ctx)) + +} + +// TestGetLastSovereignValidators tests the getter method for getting the last valset +// from the sovereign staking keeper +func TestGetLastSovereignValidators(t *testing.T) { + ck, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Should panic if pre-CCV is true but staking keeper is not set + ck.SetPreCCVTrue(ctx) + require.Panics(t, func() { ck.GetLastSovereignValidators(ctx) }) + + // Should panic if staking keeper is set but pre-CCV is false + ck.SetStakingKeeper(mocks.MockStakingKeeper) + ck.DeletePreCCV(ctx) + require.False(t, ck.IsPreCCV(ctx)) + require.Panics(t, func() { ck.GetLastSovereignValidators(ctx) }) + + // Set the pre-CCV state to true and get the last sovereign validators from mock + ck.SetPreCCVTrue(ctx) + require.True(t, ck.IsPreCCV(ctx)) + cId1 := crypto.NewCryptoIdentityFromIntSeed(11) + val := cId1.SDKStakingValidator() + val.Description.Moniker = "sanity check this is the correctly serialized val" + gomock.InOrder( + mocks.MockStakingKeeper.EXPECT().GetLastValidators(ctx).Return([]stakingtypes.Validator{ + val, + }), + ) + lastSovVals := ck.GetLastSovereignValidators(ctx) + require.Equal(t, []stakingtypes.Validator{val}, lastSovVals) + require.Equal(t, "sanity check this is the correctly serialized val", + lastSovVals[0].Description.Moniker) +} + // TestPacketMaturityTime tests getter, setter, and iterator functionality for the packet maturity time of a received VSC packet func TestPacketMaturityTime(t *testing.T) { ck, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 85d9c70bd5..e70bea8b99 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -74,7 +74,7 @@ func (k Keeper) IterateValidators(ctx sdk.Context, f func(index int64, validator } // TODO: figure out proper logic - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") } @@ -92,7 +92,7 @@ func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.Val } // TODO: figure out proper logic - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") } @@ -181,7 +181,7 @@ func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) { return } - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { return } @@ -199,7 +199,7 @@ func (k Keeper) Unjail(ctx sdk.Context, addr sdk.ConsAddress) { return } - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { return } @@ -216,7 +216,7 @@ func (k Keeper) Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.Val return nil } - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") } @@ -234,7 +234,7 @@ func (k Keeper) MaxValidators(ctx sdk.Context) uint32 { return 0 } - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.LastSovereignHeight(ctx) { + if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { if k.stakingKeeper == nil { panic("empty staking keeper") } diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 13ef30a4a7..c51145aa7d 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -174,7 +174,7 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { if am.keeper.IsPreCCV(ctx) { - initialValUpdates := am.keeper.GetInitialValUpdates(ctx) + initialValUpdates := am.keeper.GetInitialValSet(ctx) // Note: validator set update is only done on consumer chain from first endblocker // on soft fork from existing chain am.keeper.DeletePreCCV(ctx) From 772c09cd92a79c7324226ec5b8babf8b2bdbcc00 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 15 Mar 2023 15:35:07 -0700 Subject: [PATCH 32/71] UTs for keys --- x/ccv/consumer/types/keys.go | 1 + x/ccv/consumer/types/keys_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 2d13671cf0..3543f83d58 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -74,6 +74,7 @@ const ( // PreCCVByteKey is the byte to store the consumer is running on democracy staking module without consumer PreCCVByteKey + // InitialValSetByteKey is the byte to store the initial validator set for a consumer InitialValSetByteKey // LastSovereignHeightByteKey is the byte that will store last sovereign height diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index 7df0e45607..9c7b91e2be 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -41,6 +41,9 @@ func getSingleByteKeys() [][]byte { keys[i], i = ProviderClientIDKey(), i+1 keys[i], i = ProviderChannelKey(), i+1 keys[i], i = PendingChangesKey(), i+1 + keys[i], i = PreCCVKey(), i+1 + keys[i], i = InitialValSetKey(), i+1 + keys[i], i = LastSovereignHeightKey(), i+1 keys[i], i = []byte{HistoricalInfoBytePrefix}, i+1 keys[i], i = []byte{PacketMaturityTimeBytePrefix}, i+1 keys[i], i = []byte{HeightValsetUpdateIDBytePrefix}, i+1 From c0847e1641584c27eba8d753b2c606cea4950ad3 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 10:57:01 -0700 Subject: [PATCH 33/71] use make for mocks --- testutil/keeper/mocks.go | 156 ++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 75 deletions(-) diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index 2c06e7b750..a3f1c48f6d 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -21,7 +21,6 @@ import ( exported "github.com/cosmos/ibc-go/v4/modules/core/exported" gomock "github.com/golang/mock/gomock" types8 "github.com/tendermint/tendermint/abci/types" -stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // MockStakingKeeper is a mock of StakingKeeper interface. @@ -47,32 +46,32 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { return m.recorder } -// GetLastTotalPower mocks base method. -func (m *MockStakingKeeper) GetLastTotalPower(ctx types.Context) types.Int { +// Delegation mocks base method. +func (m *MockStakingKeeper) Delegation(ctx types.Context, addr types.AccAddress, valAddr types.ValAddress) types4.DelegationI { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLastTotalPower", ctx) - ret0, _ := ret[0].(types.Int) + ret := m.ctrl.Call(m, "Delegation", ctx, addr, valAddr) + ret0, _ := ret[0].(types4.DelegationI) return ret0 } -// GetLastTotalPower indicates an expected call of GetLastTotalPower. -func (mr *MockStakingKeeperMockRecorder) GetLastTotalPower(ctx interface{}) *gomock.Call { +// Delegation indicates an expected call of Delegation. +func (mr *MockStakingKeeperMockRecorder) Delegation(ctx, addr, valAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastTotalPower", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastTotalPower), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delegation", reflect.TypeOf((*MockStakingKeeper)(nil).Delegation), ctx, addr, valAddr) } -// GetLastValidators mocks base method. -func (m *MockStakingKeeper) GetLastValidators(ctx types.Context) []stakingtypes.Validator { +// GetLastTotalPower mocks base method. +func (m *MockStakingKeeper) GetLastTotalPower(ctx types.Context) types.Int { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLastValidators", ctx) - ret0, _ := ret[0].([]stakingtypes.Validator) + ret := m.ctrl.Call(m, "GetLastTotalPower", ctx) + ret0, _ := ret[0].(types.Int) return ret0 } -// GetLastValidators indicates an expected call of GetLastValidators. -func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { +// GetLastTotalPower indicates an expected call of GetLastTotalPower. +func (mr *MockStakingKeeperMockRecorder) GetLastTotalPower(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidators), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastTotalPower", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastTotalPower), ctx) } // GetLastValidatorPower mocks base method. @@ -89,6 +88,20 @@ func (mr *MockStakingKeeperMockRecorder) GetLastValidatorPower(ctx, operator int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidatorPower", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidatorPower), ctx, operator) } +// GetLastValidators mocks base method. +func (m *MockStakingKeeper) GetLastValidators(ctx types.Context) []types4.Validator { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLastValidators", ctx) + ret0, _ := ret[0].([]types4.Validator) + return ret0 +} + +// GetLastValidators indicates an expected call of GetLastValidators. +func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidators), ctx) +} + // GetValidator mocks base method. func (m *MockStakingKeeper) GetValidator(ctx types.Context, addr types.ValAddress) (types4.Validator, bool) { m.ctrl.T.Helper() @@ -133,6 +146,20 @@ func (mr *MockStakingKeeperMockRecorder) GetValidatorUpdates(ctx interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorUpdates", reflect.TypeOf((*MockStakingKeeper)(nil).GetValidatorUpdates), ctx) } +// IsValidatorJailed mocks base method. +func (m *MockStakingKeeper) IsValidatorJailed(ctx types.Context, addr types.ConsAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsValidatorJailed", ctx, addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsValidatorJailed indicates an expected call of IsValidatorJailed. +func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsValidatorJailed", reflect.TypeOf((*MockStakingKeeper)(nil).IsValidatorJailed), ctx, addr) +} + // IterateLastValidatorPowers mocks base method. func (m *MockStakingKeeper) IterateLastValidatorPowers(ctx types.Context, cb func(types.ValAddress, int64) bool) { m.ctrl.T.Helper() @@ -145,6 +172,18 @@ func (mr *MockStakingKeeperMockRecorder) IterateLastValidatorPowers(ctx, cb inte return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateLastValidatorPowers", reflect.TypeOf((*MockStakingKeeper)(nil).IterateLastValidatorPowers), ctx, cb) } +// IterateValidators mocks base method. +func (m *MockStakingKeeper) IterateValidators(ctx types.Context, f func(int64, types4.ValidatorI) bool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IterateValidators", ctx, f) +} + +// IterateValidators indicates an expected call of IterateValidators. +func (mr *MockStakingKeeperMockRecorder) IterateValidators(ctx, f interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateValidators", reflect.TypeOf((*MockStakingKeeper)(nil).IterateValidators), ctx, f) +} + // Jail mocks base method. func (m *MockStakingKeeper) Jail(arg0 types.Context, arg1 types.ConsAddress) { m.ctrl.T.Helper() @@ -157,6 +196,20 @@ func (mr *MockStakingKeeperMockRecorder) Jail(arg0, arg1 interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Jail", reflect.TypeOf((*MockStakingKeeper)(nil).Jail), arg0, arg1) } +// MaxValidators mocks base method. +func (m *MockStakingKeeper) MaxValidators(ctx types.Context) uint32 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MaxValidators", ctx) + ret0, _ := ret[0].(uint32) + return ret0 +} + +// MaxValidators indicates an expected call of MaxValidators. +func (mr *MockStakingKeeperMockRecorder) MaxValidators(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaxValidators", reflect.TypeOf((*MockStakingKeeper)(nil).MaxValidators), ctx) +} + // PowerReduction mocks base method. func (m *MockStakingKeeper) PowerReduction(ctx types.Context) types.Int { m.ctrl.T.Helper() @@ -228,90 +281,43 @@ func (mr *MockStakingKeeperMockRecorder) UnbondingTime(ctx interface{}) *gomock. // Unjail mocks base method. func (m *MockStakingKeeper) Unjail(ctx types.Context, addr types.ConsAddress) { m.ctrl.T.Helper() - _ = m.ctrl.Call(m, "Unjail", ctx, addr) + m.ctrl.Call(m, "Unjail", ctx, addr) } - + // Unjail indicates an expected call of Unjail. func (mr *MockStakingKeeperMockRecorder) Unjail(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unjail", reflect.TypeOf((*MockStakingKeeper)(nil).Unjail), ctx, addr) } -func (m *MockStakingKeeper) IterateValidators(ctx types.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { - m.ctrl.T.Helper() - _ = m.ctrl.Call(m, "IterateValidators", ctx, f) -} - -func (mr *MockStakingKeeperMockRecorder) IterateValidators(ctx, f interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateValidators", reflect.TypeOf((*MockStakingKeeper)(nil).IterateValidators), ctx, f) -} - -func (m *MockStakingKeeper) Validator(ctx types.Context, valAddr types.ValAddress) stakingtypes.ValidatorI { +// Validator mocks base method. +func (m *MockStakingKeeper) Validator(ctx types.Context, addr types.ValAddress) types4.ValidatorI { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Validator", ctx, valAddr) - ret0, _ := ret[0].(stakingtypes.ValidatorI) + ret := m.ctrl.Call(m, "Validator", ctx, addr) + ret0, _ := ret[0].(types4.ValidatorI) return ret0 } -func (mr *MockStakingKeeperMockRecorder) Validator(ctx, valAddr interface{}) *gomock.Call { +// Validator indicates an expected call of Validator. +func (mr *MockStakingKeeperMockRecorder) Validator(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validator", reflect.TypeOf((*MockStakingKeeper)(nil).Validator), ctx, valAddr) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validator", reflect.TypeOf((*MockStakingKeeper)(nil).Validator), ctx, addr) } -// IsValidatorJailed mocks base method. -func (m *MockStakingKeeper) IsValidatorJailed(ctx types.Context, addr types.ConsAddress) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsValidatorJailed", ctx, addr) - ret0, _ := ret[0].(bool) - return ret0 -} - -// IsValidatorJailed indicates an expected call of IsValidatorJailed. -func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsValidatorJailed", reflect.TypeOf((*MockStakingKeeper)(nil).IsValidatorJailed), ctx, addr) -} - - -func (m *MockStakingKeeper) ValidatorByConsAddr(ctx types.Context, consAddr types.ConsAddress) stakingtypes.ValidatorI { +// ValidatorByConsAddr mocks base method. +func (m *MockStakingKeeper) ValidatorByConsAddr(ctx types.Context, consAddr types.ConsAddress) types4.ValidatorI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", ctx, consAddr) - ret0, _ := ret[0].(stakingtypes.ValidatorI) + ret0, _ := ret[0].(types4.ValidatorI) return ret0 } +// ValidatorByConsAddr indicates an expected call of ValidatorByConsAddr. func (mr *MockStakingKeeperMockRecorder) ValidatorByConsAddr(ctx, consAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorByConsAddr", reflect.TypeOf((*MockStakingKeeper)(nil).ValidatorByConsAddr), ctx, consAddr) } -// Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(ctx types.Context, addr types.AccAddress, valAddr types.ValAddress) stakingtypes.DelegationI { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delegation", ctx, addr, valAddr) - ret0, _ := ret[0].(stakingtypes.DelegationI) - return ret0 -} - -// Delegation indicates an expected call of Delegation. -func (mr *MockStakingKeeperMockRecorder) Delegation(ctx, addr, valAddr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delegation", reflect.TypeOf((*MockStakingKeeper)(nil).Delegation), ctx, addr, valAddr) -} - -func (m *MockStakingKeeper) MaxValidators(ctx types.Context) uint32 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MaxValidators", ctx) - ret0, _ := ret[0].(uint32) - return ret0 -} - -func (mr *MockStakingKeeperMockRecorder) MaxValidators(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaxValidators", reflect.TypeOf((*MockStakingKeeper)(nil).MaxValidators), ctx) -} - // MockEvidenceKeeper is a mock of EvidenceKeeper interface. type MockEvidenceKeeper struct { ctrl *gomock.Controller From e0e5699357f982bd91fd7afbac1c2a9160649b4d Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 13:52:15 -0700 Subject: [PATCH 34/71] todo --- app/consumer-democracy/app.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index fc02f2c954..5ceb480062 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -654,6 +654,8 @@ func New( appCodec.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis) consumerGenesis.PreCCV = true + // TODO: confirm InitiGenesis is not automatically called when a module is added during upgrade. + // We should only call InitGenesis once. app.ConsumerKeeper.InitGenesis(ctx, &consumerGenesis) ctx.Logger().Info("start to run module migrations...") From a7982dea7f4d97090d04f015cb04e72bdcb18cae Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:07:37 -0700 Subject: [PATCH 35/71] changeover method and test --- x/ccv/consumer/keeper/changeover.go | 34 +++++ x/ccv/consumer/keeper/changeover_test.go | 162 +++++++++++++++++++++++ x/ccv/consumer/keeper/keeper.go | 2 +- x/ccv/consumer/module.go | 28 +--- x/ccv/consumer/module_test.go | 120 ----------------- 5 files changed, 203 insertions(+), 143 deletions(-) create mode 100644 x/ccv/consumer/keeper/changeover.go create mode 100644 x/ccv/consumer/keeper/changeover_test.go delete mode 100644 x/ccv/consumer/module_test.go diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go new file mode 100644 index 0000000000..12f72773bc --- /dev/null +++ b/x/ccv/consumer/keeper/changeover.go @@ -0,0 +1,34 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci.ValidatorUpdate) { + + initialValUpdates = k.GetInitialValSet(ctx) + // set last sovereign height + k.SetLastSovereignHeight(ctx, ctx.BlockHeight()) + // populate cross chain validators states with initial valset + k.ApplyCCValidatorChanges(ctx, initialValUpdates) + + // Add validator updates to initialValUpdates, such that the "old" validators returned from sovereign staking module + // are given zero power, and the "new" validators are given their full power. + initialUpdatesFlag := make(map[string]bool) + for _, val := range initialValUpdates { + initialUpdatesFlag[val.PubKey.String()] = true + } + for _, val := range k.GetLastSovereignValidators(ctx) { + zeroPowerUpdate := val.ABCIValidatorUpdateZero() + if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { + initialValUpdates = append(initialValUpdates, zeroPowerUpdate) + } + } + + // Note: validator set update is only done on consumer chain from first endblocker + // on soft fork from existing chain + k.DeletePreCCV(ctx) + + return initialValUpdates +} diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go new file mode 100644 index 0000000000..d044923025 --- /dev/null +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -0,0 +1,162 @@ +package keeper_test + +import ( + "testing" + + sdkcryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/interchain-security/testutil/crypto" + uthelpers "github.com/cosmos/interchain-security/testutil/keeper" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" +) + +func TestChangeoverToConsumer(t *testing.T) { + + cIds := []crypto.CryptoIdentity{} + for i := 0; i < 10; i++ { + cIds = append(cIds, *crypto.NewCryptoIdentityFromIntSeed(i + 42834729)) + } + + // Instantiate 5 sov validators for use in test + sovVals := []stakingtypes.Validator{ + cIds[0].SDKStakingValidator(), + cIds[1].SDKStakingValidator(), + cIds[2].SDKStakingValidator(), + cIds[3].SDKStakingValidator(), + cIds[4].SDKStakingValidator(), + } + + // Instantiate 5 ics val updates for use in test + initialValUpdates := []abci.ValidatorUpdate{ + {Power: 55, PubKey: cIds[5].TMProtoCryptoPublicKey()}, + {Power: 87324, PubKey: cIds[6].TMProtoCryptoPublicKey()}, + {Power: 2, PubKey: cIds[7].TMProtoCryptoPublicKey()}, + {Power: 42389479, PubKey: cIds[8].TMProtoCryptoPublicKey()}, + {Power: 9089080, PubKey: cIds[9].TMProtoCryptoPublicKey()}, + } + + testCases := []struct { + name string + // Last sovereign validators that will be mock returned from stakingKeeper.GetLastValidators() + lastSovVals []stakingtypes.Validator + // Val updates corresponding to initial valset set for ccv set initGenesis + initialValUpdates []abci.ValidatorUpdate + // Expected length of val updates returned from ChangeoverToConsumer() + expectedReturnValUpdatesLen int + }{ + { + name: "no sov vals, no initial val updates", + lastSovVals: []stakingtypes.Validator{}, + initialValUpdates: []abci.ValidatorUpdate{}, + expectedReturnValUpdatesLen: 0, + }, + { + name: "one sov val, no initial val updates", + lastSovVals: []stakingtypes.Validator{sovVals[0]}, + initialValUpdates: []abci.ValidatorUpdate{}, + expectedReturnValUpdatesLen: 1, + }, + { + name: "no sov vals, one initial val update", + lastSovVals: []stakingtypes.Validator{}, + initialValUpdates: []abci.ValidatorUpdate{initialValUpdates[0]}, + expectedReturnValUpdatesLen: 1, + }, + { + name: "one sov val, one initial val update", + lastSovVals: []stakingtypes.Validator{sovVals[0]}, + initialValUpdates: []abci.ValidatorUpdate{initialValUpdates[0]}, + expectedReturnValUpdatesLen: 2, + }, + { + name: "five sov vals, five initial val updates", + lastSovVals: sovVals, + initialValUpdates: initialValUpdates, + expectedReturnValUpdatesLen: 10, + }, + } + + for _, tc := range testCases { + + keeperParams := uthelpers.NewInMemKeeperParams(t) + keeperParams.RegisterSdkCryptoCodecInterfaces() + consumerKeeper, ctx, ctrl, mocks := uthelpers.GetConsumerKeeperAndCtx(t, keeperParams) + defer ctrl.Finish() + + // Set PRECCV to true, as would be done in InitGenesis + consumerKeeper.SetPreCCVTrue(ctx) + + // Set initial valset, as would be done in InitGenesis + consumerKeeper.SetInitialValSet(ctx, tc.initialValUpdates) + + // Setup mocked return value for stakingKeeper.GetLastValidators() + gomock.InOrder( + mocks.MockStakingKeeper.EXPECT().GetLastValidators(ctx).Return(tc.lastSovVals), + ) + + // Add ref to staking keeper + consumerKeeper.SetStakingKeeper(mocks.MockStakingKeeper) + + returnedInitialValUpdates := consumerKeeper.ChangeoverToConsumer(ctx) + + // PreCCV should now be toggled false + require.False(t, consumerKeeper.IsPreCCV(ctx)) + + // Last sovereign height should be set to current block height + require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastSovereignHeight(ctx)) + + // Cross chain validator states should be populated with initial valset + ccVals := consumerKeeper.GetAllCCValidator(ctx) + require.Len(t, ccVals, len(tc.initialValUpdates)) + + // For each initial val update, assert that a corresponding ccVal entry exists + // with the same power and pubkey + for _, valUpdate := range tc.initialValUpdates { + found := false + for _, ccVal := range ccVals { + ccvValPubKey, err := ccVal.ConsPubKey() + require.NoError(t, err) + tmProtoPubKey, err := sdkcryptocodec.ToTmProtoPublicKey(ccvValPubKey) + require.NoError(t, err) + if tmProtoPubKey.Equal(valUpdate.PubKey) { + found = true + require.Equal(t, valUpdate.Power, ccVal.Power) + } + } + require.True(t, found) + } + + // Assert that initial val updates returned from ChangeoverToConsumer are formulated s.t. + // the "old" validators returned from sovereign staking module + // are given zero power, and the "new" validators are given their full power. + for _, returnedValUpdate := range returnedInitialValUpdates { + found := false + // Check all initial val updates for a pubkey match + for _, valUpdate := range tc.initialValUpdates { + if returnedValUpdate.PubKey.Equal(valUpdate.PubKey) { + require.Equal(t, valUpdate.Power, returnedValUpdate.Power) + found = true + } + } + // Check all sovereign validators for a pubkey match + for _, val := range tc.lastSovVals { + ccvValPubKey, err := val.ConsPubKey() + require.NoError(t, err) + tmProtoPubKey, err := sdkcryptocodec.ToTmProtoPublicKey(ccvValPubKey) + require.NoError(t, err) + if returnedValUpdate.PubKey.Equal(tmProtoPubKey) { + // Assert power of the val update is zero + require.Equal(t, int64(0), returnedValUpdate.Power) + found = true + } + } + // Assert that a match was found + require.True(t, found) + } + + // Assert no extraneous entries + require.Len(t, returnedInitialValUpdates, tc.expectedReturnValUpdatesLen) + } +} diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index f3bdb621fe..da2c1c031d 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -309,7 +309,7 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { func (k Keeper) GetLastSovereignValidators(ctx sdk.Context) []stakingtypes.Validator { if !k.IsPreCCV(ctx) || k.stakingKeeper == nil { - panic("cannot get last sovereign validators if not in pre-ccv state") + panic("cannot get last sovereign validators if not in pre-ccv state, or if staking keeper is nil") } return k.stakingKeeper.GetLastValidators(ctx) } diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index c51145aa7d..b3e1d5456a 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -172,30 +172,14 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // EndBlock implements the AppModule interface // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. +// +// TODO: e2e tests confirming behavior with and without sovereign -> consumer changeover func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { - if am.keeper.IsPreCCV(ctx) { - initialValUpdates := am.keeper.GetInitialValSet(ctx) - // Note: validator set update is only done on consumer chain from first endblocker - // on soft fork from existing chain - am.keeper.DeletePreCCV(ctx) - // set last sovereign height - am.keeper.SetLastSovereignHeight(ctx, ctx.BlockHeight()) - // populate cross chain validators states with initial valset - am.keeper.ApplyCCValidatorChanges(ctx, initialValUpdates) - - // Add validator updates to initialValUpdates, such that the "old" validators returned from sovereign staking module - // are given zero power, and the "new" validators are given their full power. - initialUpdatesFlag := make(map[string]bool) - for _, val := range initialValUpdates { - initialUpdatesFlag[val.PubKey.String()] = true - } - for _, val := range am.keeper.GetLastSovereignValidators(ctx) { - zeroPowerUpdate := val.ABCIValidatorUpdateZero() - if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { - initialValUpdates = append(initialValUpdates, zeroPowerUpdate) - } - } + // If PreCCV state is active, consumer is a previously sovereign chain + // that was just upgraded, execute changeover logic. + if am.keeper.IsPreCCV(ctx) { + initialValUpdates := am.keeper.ChangeoverToConsumer(ctx) return initialValUpdates } diff --git a/x/ccv/consumer/module_test.go b/x/ccv/consumer/module_test.go deleted file mode 100644 index 393bf6c205..0000000000 --- a/x/ccv/consumer/module_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package consumer_test - -import ( - "encoding/json" - "testing" - - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/teststaking" - ccvstakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - democracyapp "github.com/cosmos/interchain-security/app/consumer-democracy" - "github.com/cosmos/interchain-security/x/ccv/consumer" - "github.com/stretchr/testify/require" - "github.com/tendermint/spm/cosmoscmd" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtypes "github.com/tendermint/tendermint/types" - dbm "github.com/tendermint/tm-db" -) - -// TODO: Refactors are needed for this test. It doesn't follow our patterns -func TestEndBlock(t *testing.T) { - PKs := simapp.CreateTestPubKeys(500) - // validator1 := teststaking.NewValidator(t, sdk.ValAddress(PKs[0].Address().Bytes()), PKs[0]) - validator2 := teststaking.NewValidator(t, sdk.ValAddress(PKs[1].Address().Bytes()), PKs[1]) - _ = validator2 - - tmPK1, err := cryptocodec.ToTmPubKeyInterface(PKs[0]) - require.NoError(t, err) - tmValidator1 := tmtypes.NewValidator(tmPK1, 1) - _ = tmValidator1 - - tmPK2, err := cryptocodec.ToTmPubKeyInterface(PKs[1]) - require.NoError(t, err) - tmValidator2 := tmtypes.NewValidator(tmPK2, 1) - _ = tmValidator2 - - tmPK3, err := cryptocodec.ToTmPubKeyInterface(PKs[2]) - require.NoError(t, err) - tmValidator3 := tmtypes.NewValidator(tmPK3, 1) - _ = tmValidator3 - - testCases := []struct { - name string - preCCV bool - sovereignValidators []ccvstakingtypes.Validator - providerValidators []abci.ValidatorUpdate - expValUpdateLen int - }{ - // { - // name: "case not preCCV", - // preCCV: false, - // sovereignValidators: []ccvstakingtypes.Validator{validator1}, - // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator1)}, - // expValUpdateLen: 1, - // }, - // { - // name: "case preCCV - no duplication with sovereign validators", - // preCCV: true, - // sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, - // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, - // expValUpdateLen: 3, - // }, - // { - // name: "case preCCV - duplication with sovereign validators", - // preCCV: true, - // sovereignValidators: []ccvstakingtypes.Validator{validator1, validator2}, - // providerValidators: []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(tmValidator2), tmtypes.TM2PB.ValidatorUpdate(tmValidator3)}, - // expValUpdateLen: 3, - // }, - } - - for _, tc := range testCases { - db := dbm.NewMemDB() - encodingConfig := cosmoscmd.MakeEncodingConfig(democracyapp.ModuleBasics) - appCodec := encodingConfig.Marshaler - app := democracyapp.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, "", 5, encodingConfig, simapp.EmptyAppOptions{}) - dApp := app.(*democracyapp.App) - ctx := dApp.BaseApp.NewContext(true, tmproto.Header{}) - - genesisState := democracyapp.NewDefaultGenesisState(appCodec) - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - panic(err) - } - - app.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - - dApp.StakingKeeper.SetParams(ctx, ccvstakingtypes.DefaultParams()) - for _, val := range tc.sovereignValidators { - dApp.StakingKeeper.SetValidator(ctx, val) - dApp.StakingKeeper.SetLastValidatorPower(ctx, val.GetOperator(), 1) - } - - // The following setters would be made in InitGenesis if preCCV is true in genesis state - if tc.preCCV { - dApp.ConsumerKeeper.SetPreCCVTrue(ctx) - dApp.ConsumerKeeper.SetInitialValSet(ctx, tc.providerValidators) - } - consumerModule := consumer.NewAppModule(dApp.ConsumerKeeper) - - valUpdate := consumerModule.EndBlock( - ctx, - abci.RequestEndBlock{}, - ) - - // check returned initial validators are expected values - require.Len(t, valUpdate, tc.expValUpdateLen) - // check preCCV deleted after the execution - require.False(t, dApp.ConsumerKeeper.IsPreCCV(ctx)) - } -} From aa6da31262e04163c0883c2066a0052bd5379d0d Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 21:32:39 -0700 Subject: [PATCH 36/71] resolve #783 --- app/consumer-democracy/app.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 5ceb480062..fc6096198f 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -115,7 +115,7 @@ import ( const ( AppName = "interchain-security-cd" - upgradeName = "v07-Theta" + upgradeName = "v07-Theta" // arbitrary name, define your own appropriately named upgrade AccountAddressPrefix = "cosmos" ) @@ -639,6 +639,10 @@ func New( fromVM[moduleName] = eachModule.ConsensusVersion() } + // For a new consumer chain, this code (together with the entire SetUpgradeHandler) is not needed at all, + // upgrade handler code is application specific. However, as an example, sovereign to consumer + // changeover chains should utilize customized upgrade handler code similar to below. + // TODO: should have a way to read from current node home userHomeDir, err := os.UserHomeDir() if err != nil { @@ -670,8 +674,9 @@ func New( } if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - // CCV consumer module store is not available for sovereign chain, - // therefore it needs to be marked as an added KV store for the sovereign -> consumer changeover + // Chains may need to add a KV store to their application. The following code + // is needed for sovereign chains that're changing over to a consumer chain, with a consumer ccv module. + // When a chain starts from height 0 (like for testing purposes in this repo), the following code is not needed. storeUpgrades := store.StoreUpgrades{ Added: []string{consumertypes.ModuleName}, } From 53dd6eaaf5c1579d5c3358bb6ac8e7d7cafb5f4e Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 21:38:04 -0700 Subject: [PATCH 37/71] comment --- x/ccv/democracy/staking/module.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index 45f2a32842..8fdb2fbd99 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -12,6 +12,9 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// Note: for a democracy consumer, this "democracy staking" keeper is only for governance capabilities, +// where the ccv consumer module is responsible for proof of stake capabilities, validator set updates, etc. + var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} From 3651164344c61392ff5d9edb8689c78034a549d9 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 21:47:23 -0700 Subject: [PATCH 38/71] comments --- app/consumer-democracy/app.go | 2 +- x/ccv/consumer/keeper/genesis.go | 8 ++++++-- x/ccv/consumer/keeper/keeper.go | 2 +- x/ccv/consumer/module.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index fc6096198f..2b502c999e 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -427,7 +427,7 @@ func New( authtypes.FeeCollectorName, ) - // Setting the staking keeper is only needed for sovereign to consumer migrated chains + // Setting the staking keeper is only needed for sovereign to consumer changeover chains app.ConsumerKeeper.SetStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 4552e280fd..842231c6e8 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -17,8 +17,12 @@ import ( // 2. A consumer chain restarts after a client to the provider was created, but the CCV channel handshake is still in progress // 3. A consumer chain restarts after the CCV channel handshake was completed. func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) []abci.ValidatorUpdate { - // PreCCV is true when consumer chain used to be running on non-consumer chain, and when it is in the progress of upgrading - // to consumer chain, where consumer chain upgrade is done. + + // PreCCV is true during the process of a sovereign to consumer changeover. + // At the PreCCV point in the process, the sovereign chain has just been upgraded to include + // the consumer ccv module, but the sovereign staking keeper is still managing the validator set. + // In two blocks, the consumer ccv module will take over proof of stake capabilities, + // but the sovereign staking keeper will stick around for slashing/jailing purposes. if state.PreCCV { k.SetPreCCVTrue(ctx) k.SetInitialValSet(ctx, state.InitialValSet) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index da2c1c031d..14a3a4c121 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -36,7 +36,7 @@ type Keeper struct { portKeeper ccv.PortKeeper connectionKeeper ccv.ConnectionKeeper clientKeeper ccv.ClientKeeper - // stakingKeeper is only needed for sovereign to consumer migration, and therefore is set after constructor + // stakingKeeper is only needed for sovereign to consumer changeovers, and therefore is set after constructor stakingKeeper ccv.StakingKeeper slashingKeeper ccv.SlashingKeeper hooks ccv.ConsumerHooks diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index b3e1d5456a..e5321f06a1 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -177,7 +177,7 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { // If PreCCV state is active, consumer is a previously sovereign chain - // that was just upgraded, execute changeover logic. + // that was just upgraded to include the consumer ccv module, execute changeover logic. if am.keeper.IsPreCCV(ctx) { initialValUpdates := am.keeper.ChangeoverToConsumer(ctx) return initialValUpdates From 45453b815a51463c2f34e043328d8307fd6c8907 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 22:09:04 -0700 Subject: [PATCH 39/71] add appropriate TODOs, restore changes to main --- x/ccv/consumer/keeper/validators.go | 150 +++++----------------------- 1 file changed, 24 insertions(+), 126 deletions(-) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index e70bea8b99..70dc3b7315 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -12,7 +12,12 @@ import ( ) // -// TODO: make unit tests for BOTH MVP consumer democ consumer, and pre-ccv consumer for previously unimplemented methods +// TODO: Address https://github.com/cosmos/interchain-security/issues/781 in this file. +// Particularly, we need to better define which keepers are responsible for slashing capabilities +// during/after a sovereign to consumer changeover. +// +// TODO: make unit tests for all of: MVP consumer, democ consumer, and pre-ccv consumer +// for previously unimplemented methods, if they're implemented to solve the above issue. // // ApplyCCValidatorChanges applies the given changes to the cross-chain validators states @@ -65,58 +70,24 @@ func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.Validato return ret } -// IterateValidators iterate democracy staking validators when the block height is before the last sovereign height -func (k Keeper) IterateValidators(ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { - - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return - } - - // TODO: figure out proper logic - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - panic("empty staking keeper") - } - - k.stakingKeeper.IterateValidators(ctx, f) - } +// IterateValidators - unimplemented on CCV keeper but perform a no-op in order to pass the slashing module InitGenesis. +// It is allowed since the condition verifying validator public keys in HandleValidatorSignature (x/slashing/keeper/infractions.go) is removed +// therefore it isn't required to store any validator public keys to the slashing states during genesis. +func (k Keeper) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { } -// Validator returns democracy staking validator when the block height is before the last sovereign height +// Validator - unimplemented on CCV keeper func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI { - - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return nil - } - - // TODO: figure out proper logic - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - panic("empty staking keeper") - } - - return k.stakingKeeper.Validator(ctx, addr) - } - panic("unused after preCCV") + panic("unimplemented on CCV keeper") } // IsJailed returns the outstanding slashing flag for the given validator adddress func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { - - // TODO: figure out proper logic - if k.IsPreCCV(ctx) { - if k.stakingKeeper == nil { - panic("empty staking keeper") - } - return k.stakingKeeper.IsValidatorJailed(ctx, addr) - } return k.OutstandingDowntime(ctx, addr) } // ValidatorByConsAddr returns an empty validator -func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) stakingtypes.ValidatorI { +func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI { /* NOTE: @@ -127,34 +98,16 @@ func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) s Also, the slashing module will cal lthis function when it observes downtime. In that case the only requirement on the returned value is that it isn't null. */ - // TODO: figure out proper logic - if k.IsPreCCV(ctx) { - if k.stakingKeeper == nil { - return stakingtypes.Validator{} - } - - return k.stakingKeeper.ValidatorByConsAddr(ctx, consAddr) - } return stakingtypes.Validator{} } // Slash queues a slashing request for the the provider chain // All queued slashing requests will be cleared in EndBlock -func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infraction stakingtypes.InfractionType) { +func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, _ sdk.Dec, infraction stakingtypes.InfractionType) { if infraction == stakingtypes.InfractionEmpty { return } - // TODO: figure out proper logic - if k.IsPreCCV(ctx) { - if k.stakingKeeper == nil { - return - } - - k.stakingKeeper.Slash(ctx, addr, infractionHeight, power, slashFactor, infraction) - return - } - // get VSC ID for infraction height vscID := k.GetHeightValsetUpdateID(ctx, uint64(infractionHeight)) @@ -173,75 +126,20 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p ) } -// Jail performs jail operation on democracy staking validator if block height after last sovereign height -func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) { - - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return - } - - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - return - } - - k.stakingKeeper.Jail(ctx, addr) - return - } -} - -// Unjail performs unjail operation on democracy staking validator if block height after last sovereign height -func (k Keeper) Unjail(ctx sdk.Context, addr sdk.ConsAddress) { +// Jail - unimplemented on CCV keeper +func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) {} - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return - } +// Unjail - unimplemented on CCV keeper +func (k Keeper) Unjail(sdk.Context, sdk.ConsAddress) {} - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - return - } - - k.stakingKeeper.Unjail(ctx, addr) - } +// Delegation - unimplemented on CCV keeper +func (k Keeper) Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI { + panic("unimplemented on CCV keeper") } -// Delegation returns delegation from an address to a democracy staking validator if block height after last sovereign height -func (k Keeper) Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) stakingtypes.DelegationI { - - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return nil - } - - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - panic("empty staking keeper") - } - - return k.stakingKeeper.Delegation(ctx, addr, valAddr) - } - panic("unused after preCCV") -} - -// MaxValidators returns max number of validators on democracy staking if block height after last sovereign height -func (k Keeper) MaxValidators(ctx sdk.Context) uint32 { - - // MVP consumer performs a no-op - if !k.IsPreCCV(ctx) { - return 0 - } - - if k.IsPreCCV(ctx) || ctx.BlockHeight() <= k.GetLastSovereignHeight(ctx) { - if k.stakingKeeper == nil { - panic("empty staking keeper") - } - - return k.stakingKeeper.MaxValidators(ctx) - } - panic("unused after preCCV") +// MaxValidators - unimplemented on CCV keeper +func (k Keeper) MaxValidators(sdk.Context) uint32 { + panic("unimplemented on CCV keeper") } // UnbondingTime returns consumer unbonding period, satisfying the staking keeper interface From 7fa624bc7a8fba01b6020209a821f687ced558ed Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 16 Mar 2023 22:20:32 -0700 Subject: [PATCH 40/71] final nits before non-draft --- x/ccv/democracy/staking/module.go | 5 +++-- x/ccv/types/expected_keepers.go | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index 8fdb2fbd99..f8d93a4a1f 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -54,7 +54,8 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, // consumer chain's x/cvv/consumer module and so this module is not responsible // for returning the initial validator set. // -// Note: InitGenesis is not called during the soft upgrade of a module (as a part of a migration from sovereign -> consumer chain), +// Note: InitGenesis is not called during the soft upgrade of a module +// (as a part of a changeover from sovereign -> consumer chain), // so there is no special handling needed in this method for a consumer being in the pre-CCV state. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState @@ -71,7 +72,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // for returning the initial validator set. // // Note: This method does not require any special handling for PreCCV being true -// (as a part of the migration from sovereign -> consumer chain). +// (as a part of the changeover from sovereign -> consumer chain). // The ccv consumer Endblocker is ordered to run before the staking Endblocker, // so if PreCCV is true during one block, the ccv consumer Enblocker will return the proper validator updates, // the PreCCV flag will be toggled to false, and no validator updates should be returned by this method. diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index edb4fa161e..56025820e6 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -21,8 +21,6 @@ import ( // StakingKeeper defines the contract expected by provider-chain ccv module from a Staking Module that will keep track // of the provider validator set. This version of the interchain-security protocol will mirror the provider chain's changes // so we do not need a registry module between the staking module and CCV. -// -// TODO: Do we want to split this into multiple interfaces for the contract needed by the a consumer vs democ consumer? type StakingKeeper interface { GetValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate UnbondingCanComplete(ctx sdk.Context, id uint64) error From a07e84bac7ac8bcdfec8503911cae8fea0b50285 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 17 Mar 2023 09:55:19 -0700 Subject: [PATCH 41/71] comment on ChangeoverToConsumer --- x/ccv/consumer/keeper/changeover.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 12f72773bc..f5242f6630 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -5,6 +5,12 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// ChangeoverToConsumer includes the logic that needs to execute during the process of a +// sovereign to consumer changeover, where the previously sovereign chain has +// just been upgraded to include the consumer ccv module, but the provider valset is not +// yet responsible for POS/block production. This method constructs validator updates +// that will be given to tendermint, which allows the consumer chain to +// start using the provider valset, while the sovereign valset is given zero voting power where appropriate. func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci.ValidatorUpdate) { initialValUpdates = k.GetInitialValSet(ctx) From 0ce68ce8e4d89596c8c8b4e5a2aa654ea2b0eba8 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 17 Mar 2023 09:58:20 -0700 Subject: [PATCH 42/71] more clear comment --- x/ccv/consumer/keeper/changeover.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index f5242f6630..27f1d00ce9 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -32,8 +32,8 @@ func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci. } } - // Note: validator set update is only done on consumer chain from first endblocker - // on soft fork from existing chain + // Note: this method should only be executed once as a part of the changeover process. + // Therefore we set the PreCCV state to false so the endblocker caller doesn't call this method again. k.DeletePreCCV(ctx) return initialValUpdates From 3652b2a428d14f7de1e451b74d61606bdb7b748b Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:05:03 -0700 Subject: [PATCH 43/71] small comment change --- x/ccv/consumer/keeper/changeover.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 27f1d00ce9..156f57877b 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -20,7 +20,7 @@ func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci. k.ApplyCCValidatorChanges(ctx, initialValUpdates) // Add validator updates to initialValUpdates, such that the "old" validators returned from sovereign staking module - // are given zero power, and the "new" validators are given their full power. + // are given zero power, and the provider validators are given their full power. initialUpdatesFlag := make(map[string]bool) for _, val := range initialValUpdates { initialUpdatesFlag[val.PubKey.String()] = true From 4f2e77e15089a20bf4967ae0710a465a6656eb9e Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:07:34 -0700 Subject: [PATCH 44/71] update InitGenesis comment --- x/ccv/consumer/keeper/genesis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 842231c6e8..4626a17481 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -21,8 +21,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) // PreCCV is true during the process of a sovereign to consumer changeover. // At the PreCCV point in the process, the sovereign chain has just been upgraded to include // the consumer ccv module, but the sovereign staking keeper is still managing the validator set. - // In two blocks, the consumer ccv module will take over proof of stake capabilities, - // but the sovereign staking keeper will stick around for slashing/jailing purposes. + // Once the provider validator set starts validating blocks, the consumer CCV module + // will take over proof of stake capabilities, but the sovereign staking keeper will + // stick around for slashing/jailing purposes. if state.PreCCV { k.SetPreCCVTrue(ctx) k.SetInitialValSet(ctx, state.InitialValSet) From 6b63b7e76afa14a06e8bc748b05419e2f6570a2c Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 08:23:34 -0700 Subject: [PATCH 45/71] sovereign -> standalone --- app/consumer-democracy/app.go | 6 +++--- x/ccv/consumer/keeper/changeover_test.go | 10 +++++----- x/ccv/consumer/keeper/genesis.go | 8 ++++---- x/ccv/consumer/keeper/keeper.go | 14 +++++++------- x/ccv/consumer/keeper/keeper_test.go | 20 ++++++++++---------- x/ccv/consumer/keeper/validators.go | 2 +- x/ccv/consumer/module.go | 4 ++-- x/ccv/consumer/types/keys.go | 8 ++++---- x/ccv/democracy/staking/module.go | 4 ++-- x/ccv/provider/keeper/genesis.go | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 2b502c999e..059869cb70 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -427,7 +427,7 @@ func New( authtypes.FeeCollectorName, ) - // Setting the staking keeper is only needed for sovereign to consumer changeover chains + // Setting the staking keeper is only needed for standalone to consumer changeover chains app.ConsumerKeeper.SetStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface @@ -640,7 +640,7 @@ func New( } // For a new consumer chain, this code (together with the entire SetUpgradeHandler) is not needed at all, - // upgrade handler code is application specific. However, as an example, sovereign to consumer + // upgrade handler code is application specific. However, as an example, standalone to consumer // changeover chains should utilize customized upgrade handler code similar to below. // TODO: should have a way to read from current node home @@ -675,7 +675,7 @@ func New( if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { // Chains may need to add a KV store to their application. The following code - // is needed for sovereign chains that're changing over to a consumer chain, with a consumer ccv module. + // is needed for standalone chains that're changing over to a consumer chain, with a consumer ccv module. // When a chain starts from height 0 (like for testing purposes in this repo), the following code is not needed. storeUpgrades := store.StoreUpgrades{ Added: []string{consumertypes.ModuleName}, diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index d044923025..730c8ed5cb 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -39,7 +39,7 @@ func TestChangeoverToConsumer(t *testing.T) { testCases := []struct { name string - // Last sovereign validators that will be mock returned from stakingKeeper.GetLastValidators() + // Last standalone validators that will be mock returned from stakingKeeper.GetLastValidators() lastSovVals []stakingtypes.Validator // Val updates corresponding to initial valset set for ccv set initGenesis initialValUpdates []abci.ValidatorUpdate @@ -104,8 +104,8 @@ func TestChangeoverToConsumer(t *testing.T) { // PreCCV should now be toggled false require.False(t, consumerKeeper.IsPreCCV(ctx)) - // Last sovereign height should be set to current block height - require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastSovereignHeight(ctx)) + // Last standalone height should be set to current block height + require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastStandaloneHeight(ctx)) // Cross chain validator states should be populated with initial valset ccVals := consumerKeeper.GetAllCCValidator(ctx) @@ -129,7 +129,7 @@ func TestChangeoverToConsumer(t *testing.T) { } // Assert that initial val updates returned from ChangeoverToConsumer are formulated s.t. - // the "old" validators returned from sovereign staking module + // the "old" validators returned from standalone chain's staking module // are given zero power, and the "new" validators are given their full power. for _, returnedValUpdate := range returnedInitialValUpdates { found := false @@ -140,7 +140,7 @@ func TestChangeoverToConsumer(t *testing.T) { found = true } } - // Check all sovereign validators for a pubkey match + // Check all standalone validators for a pubkey match for _, val := range tc.lastSovVals { ccvValPubKey, err := val.ConsPubKey() require.NoError(t, err) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 4626a17481..22d25fec7d 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -18,11 +18,11 @@ import ( // 3. A consumer chain restarts after the CCV channel handshake was completed. func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) []abci.ValidatorUpdate { - // PreCCV is true during the process of a sovereign to consumer changeover. - // At the PreCCV point in the process, the sovereign chain has just been upgraded to include - // the consumer ccv module, but the sovereign staking keeper is still managing the validator set. + // PreCCV is true during the process of a standalone to consumer changeover. + // At the PreCCV point in the process, the standalone chain has just been upgraded to include + // the consumer ccv module, but the standalone staking keeper is still managing the validator set. // Once the provider validator set starts validating blocks, the consumer CCV module - // will take over proof of stake capabilities, but the sovereign staking keeper will + // will take over proof of stake capabilities, but the standalone staking keeper will // stick around for slashing/jailing purposes. if state.PreCCV { k.SetPreCCVTrue(ctx) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 14a3a4c121..781b34d05f 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -36,7 +36,7 @@ type Keeper struct { portKeeper ccv.PortKeeper connectionKeeper ccv.ConnectionKeeper clientKeeper ccv.ClientKeeper - // stakingKeeper is only needed for sovereign to consumer changeovers, and therefore is set after constructor + // stakingKeeper is only needed for standalone to consumer changeovers, and therefore is set after constructor stakingKeeper ccv.StakingKeeper slashingKeeper ccv.SlashingKeeper hooks ccv.ConsumerHooks @@ -254,9 +254,9 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } -func (k Keeper) GetLastSovereignHeight(ctx sdk.Context) int64 { +func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.LastSovereignHeightKey()) + bz := store.Get(types.LastStandaloneHeightKey()) if bz == nil { return 0 } @@ -264,10 +264,10 @@ func (k Keeper) GetLastSovereignHeight(ctx sdk.Context) int64 { return int64(height) } -func (k Keeper) SetLastSovereignHeight(ctx sdk.Context, height int64) { +func (k Keeper) SetLastStandaloneHeight(ctx sdk.Context, height int64) { bz := sdk.Uint64ToBigEndian(uint64(height)) store := ctx.KVStore(k.storeKey) - store.Set(types.LastSovereignHeightKey(), bz) + store.Set(types.LastStandaloneHeightKey(), bz) } func (k Keeper) IsPreCCV(ctx sdk.Context) bool { @@ -307,9 +307,9 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { return []tmtypes.ValidatorUpdate{} } -func (k Keeper) GetLastSovereignValidators(ctx sdk.Context) []stakingtypes.Validator { +func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) []stakingtypes.Validator { if !k.IsPreCCV(ctx) || k.stakingKeeper == nil { - panic("cannot get last sovereign validators if not in pre-ccv state, or if staking keeper is nil") + panic("cannot get last standalone validators if not in pre-ccv state, or if staking keeper is nil") } return k.stakingKeeper.GetLastValidators(ctx) } diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 799ff1ae0a..82b83dbc0c 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -84,21 +84,21 @@ func TestPendingChanges(t *testing.T) { require.Nil(t, gotPd, "got non-nil pending changes after Delete") } -// TestLastSovereignHeight tests the getter and setter for the last sovereign height +// TestLastSovereignHeight tests the getter and setter for the last standalone height func TestLastSovereignHeight(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() // Default value should be 0 without any setter - require.Equal(t, int64(0), consumerKeeper.GetLastSovereignHeight(ctx)) + require.Equal(t, int64(0), consumerKeeper.GetLastStandaloneHeight(ctx)) - // Set/get the last sovereign height being 10 - consumerKeeper.SetLastSovereignHeight(ctx, 10) - require.Equal(t, int64(10), consumerKeeper.GetLastSovereignHeight(ctx)) + // Set/get the last standalone height being 10 + consumerKeeper.SetLastStandaloneHeight(ctx, 10) + require.Equal(t, int64(10), consumerKeeper.GetLastStandaloneHeight(ctx)) - // Set/get the last sovereign height being 43234426 - consumerKeeper.SetLastSovereignHeight(ctx, 43234426) - require.Equal(t, int64(43234426), consumerKeeper.GetLastSovereignHeight(ctx)) + // Set/get the last standalone height being 43234426 + consumerKeeper.SetLastStandaloneHeight(ctx, 43234426) + require.Equal(t, int64(43234426), consumerKeeper.GetLastStandaloneHeight(ctx)) } // TestPreCCV tests the getter, setter and deletion methods for the pre-CCV state flag @@ -164,7 +164,7 @@ func TestInitialValSet(t *testing.T) { } // TestGetLastSovereignValidators tests the getter method for getting the last valset -// from the sovereign staking keeper +// from the standalone staking keeper func TestGetLastSovereignValidators(t *testing.T) { ck, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -179,7 +179,7 @@ func TestGetLastSovereignValidators(t *testing.T) { require.False(t, ck.IsPreCCV(ctx)) require.Panics(t, func() { ck.GetLastSovereignValidators(ctx) }) - // Set the pre-CCV state to true and get the last sovereign validators from mock + // Set the pre-CCV state to true and get the last standalone validators from mock ck.SetPreCCVTrue(ctx) require.True(t, ck.IsPreCCV(ctx)) cId1 := crypto.NewCryptoIdentityFromIntSeed(11) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 70dc3b7315..ef0c6a0c77 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -14,7 +14,7 @@ import ( // // TODO: Address https://github.com/cosmos/interchain-security/issues/781 in this file. // Particularly, we need to better define which keepers are responsible for slashing capabilities -// during/after a sovereign to consumer changeover. +// during/after a standalone to consumer changeover. // // TODO: make unit tests for all of: MVP consumer, democ consumer, and pre-ccv consumer // for previously unimplemented methods, if they're implemented to solve the above issue. diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index e5321f06a1..56c84ae112 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -173,10 +173,10 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // EndBlock implements the AppModule interface // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. // -// TODO: e2e tests confirming behavior with and without sovereign -> consumer changeover +// TODO: e2e tests confirming behavior with and without standalone -> consumer changeover func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { - // If PreCCV state is active, consumer is a previously sovereign chain + // If PreCCV state is active, consumer is a previously standalone chain // that was just upgraded to include the consumer ccv module, execute changeover logic. if am.keeper.IsPreCCV(ctx) { initialValUpdates := am.keeper.ChangeoverToConsumer(ctx) diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 3543f83d58..aa8113605e 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -77,8 +77,8 @@ const ( // InitialValSetByteKey is the byte to store the initial validator set for a consumer InitialValSetByteKey - // LastSovereignHeightByteKey is the byte that will store last sovereign height - LastSovereignHeightByteKey + // LastStandaloneHeightByteKey is the byte that will store last standalone height + LastStandaloneHeightByteKey ) // PortKey returns the key to the port ID in the store @@ -119,8 +119,8 @@ func InitialValSetKey() []byte { return []byte{InitialValSetByteKey} } -func LastSovereignHeightKey() []byte { - return []byte{LastSovereignHeightByteKey} +func LastStandaloneHeightKey() []byte { + return []byte{LastStandaloneHeightByteKey} } // PacketMaturityTimeKey returns the key for storing the maturity time for a given received VSC packet id diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index f8d93a4a1f..d2eaf26adb 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -55,7 +55,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, // for returning the initial validator set. // // Note: InitGenesis is not called during the soft upgrade of a module -// (as a part of a changeover from sovereign -> consumer chain), +// (as a part of a changeover from standalone -> consumer chain), // so there is no special handling needed in this method for a consumer being in the pre-CCV state. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState @@ -72,7 +72,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // for returning the initial validator set. // // Note: This method does not require any special handling for PreCCV being true -// (as a part of the changeover from sovereign -> consumer chain). +// (as a part of the changeover from standalone -> consumer chain). // The ccv consumer Endblocker is ordered to run before the staking Endblocker, // so if PreCCV is true during one block, the ccv consumer Enblocker will return the proper validator updates, // the PreCCV flag will be toggled to false, and no validator updates should be returned by this method. diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index 02ac8c81d3..79e6f2052d 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -43,7 +43,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { } // Note that MatureUnbondingOps aren't stored across blocks, but it - // might be used after implementing sovereign to consumer transition + // might be used after implementing standalone to consumer transition if genState.MatureUnbondingOps != nil { k.AppendMaturedUnbondingOps(ctx, genState.MatureUnbondingOps.Ids) } From b80fe0f07c9044a9a4b4545ab690338ea44cf160 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 08:24:29 -0700 Subject: [PATCH 46/71] missed a file --- x/ccv/consumer/keeper/changeover.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 156f57877b..a1a4c5c09a 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -6,20 +6,20 @@ import ( ) // ChangeoverToConsumer includes the logic that needs to execute during the process of a -// sovereign to consumer changeover, where the previously sovereign chain has +// standalone to consumer changeover, where the previously standalone chain has // just been upgraded to include the consumer ccv module, but the provider valset is not // yet responsible for POS/block production. This method constructs validator updates // that will be given to tendermint, which allows the consumer chain to -// start using the provider valset, while the sovereign valset is given zero voting power where appropriate. +// start using the provider valset, while the standalone valset is given zero voting power where appropriate. func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci.ValidatorUpdate) { initialValUpdates = k.GetInitialValSet(ctx) - // set last sovereign height - k.SetLastSovereignHeight(ctx, ctx.BlockHeight()) + // set last standalone height + k.SetLastStandaloneHeight(ctx, ctx.BlockHeight()) // populate cross chain validators states with initial valset k.ApplyCCValidatorChanges(ctx, initialValUpdates) - // Add validator updates to initialValUpdates, such that the "old" validators returned from sovereign staking module + // Add validator updates to initialValUpdates, such that the "old" validators returned from standalone staking module // are given zero power, and the provider validators are given their full power. initialUpdatesFlag := make(map[string]bool) for _, val := range initialValUpdates { From 17f020ae7e14e3284a0a9e1842b8c48902b3dd78 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 08:37:02 -0700 Subject: [PATCH 47/71] builds now --- x/ccv/consumer/keeper/changeover.go | 2 +- x/ccv/consumer/keeper/keeper_test.go | 6 +++--- x/ccv/consumer/types/keys_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index a1a4c5c09a..607a2d47bc 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -25,7 +25,7 @@ func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci. for _, val := range initialValUpdates { initialUpdatesFlag[val.PubKey.String()] = true } - for _, val := range k.GetLastSovereignValidators(ctx) { + for _, val := range k.GetLastStandaloneValidators(ctx) { zeroPowerUpdate := val.ABCIValidatorUpdateZero() if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { initialValUpdates = append(initialValUpdates, zeroPowerUpdate) diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 82b83dbc0c..1efaff9571 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -171,13 +171,13 @@ func TestGetLastSovereignValidators(t *testing.T) { // Should panic if pre-CCV is true but staking keeper is not set ck.SetPreCCVTrue(ctx) - require.Panics(t, func() { ck.GetLastSovereignValidators(ctx) }) + require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) // Should panic if staking keeper is set but pre-CCV is false ck.SetStakingKeeper(mocks.MockStakingKeeper) ck.DeletePreCCV(ctx) require.False(t, ck.IsPreCCV(ctx)) - require.Panics(t, func() { ck.GetLastSovereignValidators(ctx) }) + require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) // Set the pre-CCV state to true and get the last standalone validators from mock ck.SetPreCCVTrue(ctx) @@ -190,7 +190,7 @@ func TestGetLastSovereignValidators(t *testing.T) { val, }), ) - lastSovVals := ck.GetLastSovereignValidators(ctx) + lastSovVals := ck.GetLastStandaloneValidators(ctx) require.Equal(t, []stakingtypes.Validator{val}, lastSovVals) require.Equal(t, "sanity check this is the correctly serialized val", lastSovVals[0].Description.Moniker) diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index 9c7b91e2be..abe0e20453 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -43,7 +43,7 @@ func getSingleByteKeys() [][]byte { keys[i], i = PendingChangesKey(), i+1 keys[i], i = PreCCVKey(), i+1 keys[i], i = InitialValSetKey(), i+1 - keys[i], i = LastSovereignHeightKey(), i+1 + keys[i], i = LastStandaloneHeightKey(), i+1 keys[i], i = []byte{HistoricalInfoBytePrefix}, i+1 keys[i], i = []byte{PacketMaturityTimeBytePrefix}, i+1 keys[i], i = []byte{HeightValsetUpdateIDBytePrefix}, i+1 From 2a76cd108fcdf414cee64d542bb15b26007e8e19 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 15:14:22 -0700 Subject: [PATCH 48/71] update comment after debug --- app/consumer-democracy/app.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 059869cb70..bb5c098644 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -658,12 +658,14 @@ func New( appCodec.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis) consumerGenesis.PreCCV = true - // TODO: confirm InitiGenesis is not automatically called when a module is added during upgrade. - // We should only call InitGenesis once. app.ConsumerKeeper.InitGenesis(ctx, &consumerGenesis) ctx.Logger().Info("start to run module migrations...") + // Note: consumer ccv module is added to app.MM.Modules constructor above, + // meaning the consumer ccv module will have an entry in fromVM. + // Since a consumer ccv module entry exists in fromVM, the RunMigrations method + // will not call the consumer ccv module's InitGenesis method a second time. return app.MM.RunMigrations(ctx, app.configurator, fromVM) }, ) From d091971d8898d27681ba99cef1c89b90fd0483f3 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 15:40:13 -0700 Subject: [PATCH 49/71] ChangeoverIsComplete method --- x/ccv/consumer/keeper/changeover.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 607a2d47bc..2ae4113079 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -5,6 +5,12 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { + // TODO: confirm correctness here. + // Also consider the idea of using "first consumer height" instead of "last standalone height" + return ctx.BlockHeight() > k.GetLastStandaloneHeight(ctx)+2 +} + // ChangeoverToConsumer includes the logic that needs to execute during the process of a // standalone to consumer changeover, where the previously standalone chain has // just been upgraded to include the consumer ccv module, but the provider valset is not From 751acb7dd05ec205647bf6a4b9aad8da9ba395fc Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Mon, 20 Mar 2023 18:00:20 -0700 Subject: [PATCH 50/71] small refactors, comments, slash and jail code --- app/consumer-democracy/app.go | 2 +- x/ccv/consumer/keeper/changeover.go | 8 +++- x/ccv/consumer/keeper/changeover_test.go | 4 +- x/ccv/consumer/keeper/keeper.go | 60 ++++++++++++------------ x/ccv/consumer/keeper/keeper_test.go | 2 +- x/ccv/consumer/keeper/validators.go | 26 ++++++++-- 6 files changed, 63 insertions(+), 39 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index bb5c098644..df60100dfe 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -428,7 +428,7 @@ func New( ) // Setting the staking keeper is only needed for standalone to consumer changeover chains - app.ConsumerKeeper.SetStakingKeeper(app.StakingKeeper) + app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface // of the slashing module diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 2ae4113079..082a6783b6 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -7,8 +7,12 @@ import ( func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { // TODO: confirm correctness here. - // Also consider the idea of using "first consumer height" instead of "last standalone height" - return ctx.BlockHeight() > k.GetLastStandaloneHeight(ctx)+2 + return ctx.BlockHeight() > k.FirstConsumerHeight(ctx) +} + +// TODO: store this height directly in a better way +func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { + return k.GetLastStandaloneHeight(ctx) + 2 } // ChangeoverToConsumer includes the logic that needs to execute during the process of a diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index 730c8ed5cb..e9efe9b4f7 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -96,8 +96,8 @@ func TestChangeoverToConsumer(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetLastValidators(ctx).Return(tc.lastSovVals), ) - // Add ref to staking keeper - consumerKeeper.SetStakingKeeper(mocks.MockStakingKeeper) + // Add ref to standalone staking keeper + consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) returnedInitialValUpdates := consumerKeeper.ChangeoverToConsumer(ctx) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 781b34d05f..5baa0aa8ee 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -36,15 +36,17 @@ type Keeper struct { portKeeper ccv.PortKeeper connectionKeeper ccv.ConnectionKeeper clientKeeper ccv.ClientKeeper - // stakingKeeper is only needed for standalone to consumer changeovers, and therefore is set after constructor - stakingKeeper ccv.StakingKeeper - slashingKeeper ccv.SlashingKeeper - hooks ccv.ConsumerHooks - bankKeeper ccv.BankKeeper - authKeeper ccv.AccountKeeper - ibcTransferKeeper ccv.IBCTransferKeeper - ibcCoreKeeper ccv.IBCCoreKeeper - feeCollectorName string + // standaloneStakingKeeper is the staking keeper that managed proof of stake for a previously standalone chain, + // before the chain went through a standalone to consumer changeover. + // This keeper is not used for consumers that launched with ICS, and is therefore set after the constructor. + standaloneStakingKeeper ccv.StakingKeeper + slashingKeeper ccv.SlashingKeeper + hooks ccv.ConsumerHooks + bankKeeper ccv.BankKeeper + authKeeper ccv.AccountKeeper + ibcTransferKeeper ccv.IBCTransferKeeper + ibcCoreKeeper ccv.IBCCoreKeeper + feeCollectorName string } // NewKeeper creates a new Consumer Keeper instance @@ -65,29 +67,29 @@ func NewKeeper( } k := Keeper{ - storeKey: key, - cdc: cdc, - paramStore: paramSpace, - scopedKeeper: scopedKeeper, - channelKeeper: channelKeeper, - portKeeper: portKeeper, - connectionKeeper: connectionKeeper, - clientKeeper: clientKeeper, - slashingKeeper: slashingKeeper, - bankKeeper: bankKeeper, - authKeeper: accountKeeper, - ibcTransferKeeper: ibcTransferKeeper, - ibcCoreKeeper: ibcCoreKeeper, - feeCollectorName: feeCollectorName, - stakingKeeper: nil, + storeKey: key, + cdc: cdc, + paramStore: paramSpace, + scopedKeeper: scopedKeeper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + connectionKeeper: connectionKeeper, + clientKeeper: clientKeeper, + slashingKeeper: slashingKeeper, + bankKeeper: bankKeeper, + authKeeper: accountKeeper, + ibcTransferKeeper: ibcTransferKeeper, + ibcCoreKeeper: ibcCoreKeeper, + feeCollectorName: feeCollectorName, + standaloneStakingKeeper: nil, } k.mustValidateFields() return k } -func (k *Keeper) SetStakingKeeper(stakingKeeper ccv.StakingKeeper) { - k.stakingKeeper = stakingKeeper +func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { + k.standaloneStakingKeeper = sk } // Validates that the consumer keeper is initialized with non-zero and @@ -308,10 +310,10 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { } func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) []stakingtypes.Validator { - if !k.IsPreCCV(ctx) || k.stakingKeeper == nil { - panic("cannot get last standalone validators if not in pre-ccv state, or if staking keeper is nil") + if !k.IsPreCCV(ctx) || k.standaloneStakingKeeper == nil { + panic("cannot get last standalone validators if not in pre-ccv state, or if standalone staking keeper is nil") } - return k.stakingKeeper.GetLastValidators(ctx) + return k.standaloneStakingKeeper.GetLastValidators(ctx) } // GetElapsedPacketMaturityTimes returns a slice of already elapsed PacketMaturityTimes, sorted by maturity times, diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 1efaff9571..e510ca9960 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -174,7 +174,7 @@ func TestGetLastSovereignValidators(t *testing.T) { require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) // Should panic if staking keeper is set but pre-CCV is false - ck.SetStakingKeeper(mocks.MockStakingKeeper) + ck.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) ck.DeletePreCCV(ctx) require.False(t, ck.IsPreCCV(ctx)) require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index ef0c6a0c77..c9ade1a542 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -11,10 +11,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// -// TODO: Address https://github.com/cosmos/interchain-security/issues/781 in this file. -// Particularly, we need to better define which keepers are responsible for slashing capabilities -// during/after a standalone to consumer changeover. // // TODO: make unit tests for all of: MVP consumer, democ consumer, and pre-ccv consumer // for previously unimplemented methods, if they're implemented to solve the above issue. @@ -83,6 +79,11 @@ func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.Val // IsJailed returns the outstanding slashing flag for the given validator adddress func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { + // if the changeover is not complete, return the standalone staking keeper's jailed status + if !k.ChangeoverIsComplete(ctx) { + return k.standaloneStakingKeeper.IsValidatorJailed(ctx, addr) + } + // Otherwise, return the ccv consumer keeper's notion of a validator being jailed return k.OutstandingDowntime(ctx, addr) } @@ -104,10 +105,19 @@ func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.V // Slash queues a slashing request for the the provider chain // All queued slashing requests will be cleared in EndBlock func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, _ sdk.Dec, infraction stakingtypes.InfractionType) { + if infraction == stakingtypes.InfractionEmpty { return } + // If infraction happened before the changeover was completed, slash only on the standalone staking keeper. + if infractionHeight < k.FirstConsumerHeight(ctx) { + k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, sdk.Dec{}, infraction) + return + } + + // Otherwise infraction happened after the changeover was completed. + // get VSC ID for infraction height vscID := k.GetHeightValsetUpdateID(ctx, uint64(infractionHeight)) @@ -127,9 +137,17 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p } // Jail - unimplemented on CCV keeper +// +// This method should be a no-op even during a standalone to consumer changeover. +// Once the upgrade has happened as a part of the changeover, +// the provider validator set will soon be in effect, and jailing is n/a. func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) {} // Unjail - unimplemented on CCV keeper +// +// This method should be a no-op even during a standalone to consumer changeover. +// Once the upgrade has happened as a part of the changeover, +// the provider validator set will soon be in effect, and jailing is n/a. func (k Keeper) Unjail(sdk.Context, sdk.ConsAddress) {} // Delegation - unimplemented on CCV keeper From 8cf1da308da08e1e1a75981e9a4a6e54319a6983 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 21 Mar 2023 08:02:58 -0700 Subject: [PATCH 51/71] naming refactor --- app/consumer-democracy/app.go | 2 +- x/ccv/consumer/keeper/changeover_test.go | 4 +- x/ccv/consumer/keeper/keeper.go | 60 ++++++++++++------------ x/ccv/consumer/keeper/keeper_test.go | 2 +- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index bb5c098644..df60100dfe 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -428,7 +428,7 @@ func New( ) // Setting the staking keeper is only needed for standalone to consumer changeover chains - app.ConsumerKeeper.SetStakingKeeper(app.StakingKeeper) + app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface // of the slashing module diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index 730c8ed5cb..e9efe9b4f7 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -96,8 +96,8 @@ func TestChangeoverToConsumer(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetLastValidators(ctx).Return(tc.lastSovVals), ) - // Add ref to staking keeper - consumerKeeper.SetStakingKeeper(mocks.MockStakingKeeper) + // Add ref to standalone staking keeper + consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) returnedInitialValUpdates := consumerKeeper.ChangeoverToConsumer(ctx) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 781b34d05f..5baa0aa8ee 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -36,15 +36,17 @@ type Keeper struct { portKeeper ccv.PortKeeper connectionKeeper ccv.ConnectionKeeper clientKeeper ccv.ClientKeeper - // stakingKeeper is only needed for standalone to consumer changeovers, and therefore is set after constructor - stakingKeeper ccv.StakingKeeper - slashingKeeper ccv.SlashingKeeper - hooks ccv.ConsumerHooks - bankKeeper ccv.BankKeeper - authKeeper ccv.AccountKeeper - ibcTransferKeeper ccv.IBCTransferKeeper - ibcCoreKeeper ccv.IBCCoreKeeper - feeCollectorName string + // standaloneStakingKeeper is the staking keeper that managed proof of stake for a previously standalone chain, + // before the chain went through a standalone to consumer changeover. + // This keeper is not used for consumers that launched with ICS, and is therefore set after the constructor. + standaloneStakingKeeper ccv.StakingKeeper + slashingKeeper ccv.SlashingKeeper + hooks ccv.ConsumerHooks + bankKeeper ccv.BankKeeper + authKeeper ccv.AccountKeeper + ibcTransferKeeper ccv.IBCTransferKeeper + ibcCoreKeeper ccv.IBCCoreKeeper + feeCollectorName string } // NewKeeper creates a new Consumer Keeper instance @@ -65,29 +67,29 @@ func NewKeeper( } k := Keeper{ - storeKey: key, - cdc: cdc, - paramStore: paramSpace, - scopedKeeper: scopedKeeper, - channelKeeper: channelKeeper, - portKeeper: portKeeper, - connectionKeeper: connectionKeeper, - clientKeeper: clientKeeper, - slashingKeeper: slashingKeeper, - bankKeeper: bankKeeper, - authKeeper: accountKeeper, - ibcTransferKeeper: ibcTransferKeeper, - ibcCoreKeeper: ibcCoreKeeper, - feeCollectorName: feeCollectorName, - stakingKeeper: nil, + storeKey: key, + cdc: cdc, + paramStore: paramSpace, + scopedKeeper: scopedKeeper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + connectionKeeper: connectionKeeper, + clientKeeper: clientKeeper, + slashingKeeper: slashingKeeper, + bankKeeper: bankKeeper, + authKeeper: accountKeeper, + ibcTransferKeeper: ibcTransferKeeper, + ibcCoreKeeper: ibcCoreKeeper, + feeCollectorName: feeCollectorName, + standaloneStakingKeeper: nil, } k.mustValidateFields() return k } -func (k *Keeper) SetStakingKeeper(stakingKeeper ccv.StakingKeeper) { - k.stakingKeeper = stakingKeeper +func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { + k.standaloneStakingKeeper = sk } // Validates that the consumer keeper is initialized with non-zero and @@ -308,10 +310,10 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { } func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) []stakingtypes.Validator { - if !k.IsPreCCV(ctx) || k.stakingKeeper == nil { - panic("cannot get last standalone validators if not in pre-ccv state, or if staking keeper is nil") + if !k.IsPreCCV(ctx) || k.standaloneStakingKeeper == nil { + panic("cannot get last standalone validators if not in pre-ccv state, or if standalone staking keeper is nil") } - return k.stakingKeeper.GetLastValidators(ctx) + return k.standaloneStakingKeeper.GetLastValidators(ctx) } // GetElapsedPacketMaturityTimes returns a slice of already elapsed PacketMaturityTimes, sorted by maturity times, diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 1efaff9571..e510ca9960 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -174,7 +174,7 @@ func TestGetLastSovereignValidators(t *testing.T) { require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) // Should panic if staking keeper is set but pre-CCV is false - ck.SetStakingKeeper(mocks.MockStakingKeeper) + ck.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) ck.DeletePreCCV(ctx) require.False(t, ck.IsPreCCV(ctx)) require.Panics(t, func() { ck.GetLastStandaloneValidators(ctx) }) From b032f91512218f2e0043913301d068811d5230ac Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 21 Mar 2023 08:27:39 -0700 Subject: [PATCH 52/71] fix last standalone height --- x/ccv/consumer/keeper/changeover.go | 12 +++++++++--- x/ccv/consumer/keeper/changeover_test.go | 4 +++- x/ccv/consumer/keeper/keeper.go | 8 ++++---- x/ccv/consumer/keeper/keeper_test.go | 12 +++++++++--- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 082a6783b6..c82ac06a37 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -7,12 +7,18 @@ import ( func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { // TODO: confirm correctness here. - return ctx.BlockHeight() > k.FirstConsumerHeight(ctx) + return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx) } -// TODO: store this height directly in a better way +// TODO: store this height directly in a better way when prov valset is used func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { - return k.GetLastStandaloneHeight(ctx) + 2 + lastStandaloneHeight, found := k.GetLastStandaloneHeight(ctx) + // If last standalone height not found, chain has always been consumer + if !found { + return 0 + } + // Else first consumer height is 2 blocks after last standalone height + return lastStandaloneHeight + 2 } // ChangeoverToConsumer includes the logic that needs to execute during the process of a diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index e9efe9b4f7..eb195f15c8 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -105,7 +105,9 @@ func TestChangeoverToConsumer(t *testing.T) { require.False(t, consumerKeeper.IsPreCCV(ctx)) // Last standalone height should be set to current block height - require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastStandaloneHeight(ctx)) + lastStandaloneHeight, found := consumerKeeper.GetLastStandaloneHeight(ctx) + require.True(t, found) + require.Equal(t, ctx.BlockHeight(), lastStandaloneHeight) // Cross chain validator states should be populated with initial valset ccVals := consumerKeeper.GetAllCCValidator(ctx) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 5baa0aa8ee..2a546769dd 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -256,14 +256,14 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } -func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) int64 { +func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) (height int64, found bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.LastStandaloneHeightKey()) if bz == nil { - return 0 + return 0, false } - height := sdk.BigEndianToUint64(bz) - return int64(height) + height = int64(sdk.BigEndianToUint64(bz)) + return height, true } func (k Keeper) SetLastStandaloneHeight(ctx sdk.Context, height int64) { diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index e510ca9960..70476531db 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -90,15 +90,21 @@ func TestLastSovereignHeight(t *testing.T) { defer ctrl.Finish() // Default value should be 0 without any setter - require.Equal(t, int64(0), consumerKeeper.GetLastStandaloneHeight(ctx)) + lastStandaloneHeight, found := consumerKeeper.GetLastStandaloneHeight(ctx) + require.False(t, found) + require.Equal(t, int64(0), lastStandaloneHeight) // Set/get the last standalone height being 10 consumerKeeper.SetLastStandaloneHeight(ctx, 10) - require.Equal(t, int64(10), consumerKeeper.GetLastStandaloneHeight(ctx)) + lastStandaloneHeight, found = consumerKeeper.GetLastStandaloneHeight(ctx) + require.True(t, found) + require.Equal(t, int64(10), lastStandaloneHeight) // Set/get the last standalone height being 43234426 consumerKeeper.SetLastStandaloneHeight(ctx, 43234426) - require.Equal(t, int64(43234426), consumerKeeper.GetLastStandaloneHeight(ctx)) + lastStandaloneHeight, found = consumerKeeper.GetLastStandaloneHeight(ctx) + require.True(t, found) + require.Equal(t, int64(43234426), lastStandaloneHeight) } // TestPreCCV tests the getter, setter and deletion methods for the pre-CCV state flag From df86b2a4397ec84e0c0144188f05cfa5aaceac38 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 5 Apr 2023 19:16:29 -0700 Subject: [PATCH 53/71] Update module.go --- x/ccv/consumer/module.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 9f0014228d..43947ec542 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -149,7 +149,6 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // Set the VSC ID for the subsequent block to the same value as the current block // Panic if the provider's channel was established and then closed func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - channelID, found := am.keeper.GetProviderChannel(ctx) if found && am.keeper.IsChannelClosed(ctx, channelID) { // The CCV channel was established, but it was then closed; From 71af3a17268b5bb0eddbb6b0cca0639d226d1366 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:25:58 -0700 Subject: [PATCH 54/71] needed refactors --- app/consumer-democracy/app.go | 5 +++-- x/ccv/consumer/keeper/changeover.go | 18 +++++++++--------- x/ccv/consumer/keeper/changeover_test.go | 3 +-- x/ccv/consumer/keeper/keeper.go | 14 ++++++++++---- x/ccv/consumer/keeper/keeper_test.go | 12 ++++-------- x/ccv/consumer/keeper/validators.go | 11 +++++++---- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 47740febcb..71ec8ee36a 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -427,8 +427,9 @@ func New( authtypes.FeeCollectorName, ) - // Setting the staking keeper is only needed for standalone to consumer changeover chains - app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) + // Setting the standalone staking keeper is only needed for standalone to consumer changeover chains + // We do not set the keeper here since this app.go was originally designed as a normal democracry consumer. + // app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface // of the slashing module diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index d0e1a7a48e..10daf96727 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -5,20 +5,20 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// TODO: tests around this logic +// ChangeoverIsComplete returns whether the standalone to consumer changeover process is complete. func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { - // TODO: confirm correctness here. + if !k.IsPrevStandaloneChain() { + panic("ChangeoverIsComplete should only be called on previously standalone consumers") + } return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx) } -// TODO: store this height directly in a better way when prov valset is used +// The first height that the ccv valset will be in effect is 2 blocks after last standalone height +// (aka height that the ccv module first returned updates to tendermint), because the new valset is committed +// in block N+1, and in effect for block N+2. func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { - lastStandaloneHeight, found := k.GetLastStandaloneHeight(ctx) - // If last standalone height not found, chain has always been consumer - if !found { - return 0 - } - // Else first consumer height is 2 blocks after last standalone height - return lastStandaloneHeight + 2 + return k.GetLastStandaloneHeight(ctx) + 2 } // ChangeoverToConsumer includes the logic that needs to execute during the process of a diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index bac7b91b4b..40e0817bc8 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -112,8 +112,7 @@ func TestChangeoverToConsumer(t *testing.T) { require.False(t, consumerKeeper.IsPreCCV(ctx)) // Last standalone height should be set to current block height - lastStandaloneHeight, found := consumerKeeper.GetLastStandaloneHeight(ctx) - require.True(t, found) + lastStandaloneHeight := consumerKeeper.GetLastStandaloneHeight(ctx) require.Equal(t, ctx.BlockHeight(), lastStandaloneHeight) // Cross chain validator states should be populated with initial valset diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 59f0676dc7..10a0946827 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -87,10 +87,16 @@ func NewKeeper( return k } +// SetStandaloneStakingKeeper sets the standalone staking keeper for the consumer chain. +// This method should only be called for previously standalone chains that are now consumers. func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { k.standaloneStakingKeeper = sk } +func (k Keeper) IsPrevStandaloneChain() bool { + return k.standaloneStakingKeeper != nil +} + // Validates that the consumer keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { @@ -254,14 +260,14 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } -func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) (height int64, found bool) { +func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) bz := store.Get(types.LastStandaloneHeightKey()) if bz == nil { - return 0, false + panic("last standalone height not set") } - height = int64(sdk.BigEndianToUint64(bz)) - return height, true + height := sdk.BigEndianToUint64(bz) + return int64(height) } func (k Keeper) SetLastStandaloneHeight(ctx sdk.Context, height int64) { diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 69dd492a7f..619663f3cf 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -87,21 +87,17 @@ func TestLastSovereignHeight(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - // Default value should be 0 without any setter - lastStandaloneHeight, found := consumerKeeper.GetLastStandaloneHeight(ctx) - require.False(t, found) - require.Equal(t, int64(0), lastStandaloneHeight) + // Panics without setter + require.Panics(t, func() { consumerKeeper.GetLastStandaloneHeight(ctx) }) // Set/get the last standalone height being 10 consumerKeeper.SetLastStandaloneHeight(ctx, 10) - lastStandaloneHeight, found = consumerKeeper.GetLastStandaloneHeight(ctx) - require.True(t, found) + lastStandaloneHeight := consumerKeeper.GetLastStandaloneHeight(ctx) require.Equal(t, int64(10), lastStandaloneHeight) // Set/get the last standalone height being 43234426 consumerKeeper.SetLastStandaloneHeight(ctx, 43234426) - lastStandaloneHeight, found = consumerKeeper.GetLastStandaloneHeight(ctx) - require.True(t, found) + lastStandaloneHeight = consumerKeeper.GetLastStandaloneHeight(ctx) require.Equal(t, int64(43234426), lastStandaloneHeight) } diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 08bcf4f0e6..7db62387c3 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -78,8 +78,9 @@ func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.Val // IsJailed returns the outstanding slashing flag for the given validator adddress func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { - // if the changeover is not complete, return the standalone staking keeper's jailed status - if !k.ChangeoverIsComplete(ctx) { + // if the changeover is not complete for prev standalone chain, + // return the standalone staking keeper's jailed status + if k.IsPrevStandaloneChain() && !k.ChangeoverIsComplete(ctx) { return k.standaloneStakingKeeper.IsValidatorJailed(ctx, addr) } // Otherwise, return the ccv consumer keeper's notion of a validator being jailed @@ -103,14 +104,16 @@ func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.V // Slash queues a slashing request for the the provider chain // All queued slashing requests will be cleared in EndBlock +// TODO: UT for this func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, _ sdk.Dec, infraction stakingtypes.InfractionType) { if infraction == stakingtypes.InfractionEmpty { return } - // If infraction happened before the changeover was completed, slash only on the standalone staking keeper. - if infractionHeight < k.FirstConsumerHeight(ctx) { + // If this is a previously standalone chain and infraction happened before the changeover was completed, + // slash only on the standalone staking keeper. + if k.IsPrevStandaloneChain() && infractionHeight < k.FirstConsumerHeight(ctx) { k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, sdk.Dec{}, infraction) return } From 14f88767d8c16110701a6fd9daa474587cb19829 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:28:35 -0700 Subject: [PATCH 55/71] rm unneeded diffs --- x/ccv/consumer/keeper/changeover_test.go | 3 +-- x/ccv/consumer/keeper/keeper_test.go | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index 40e0817bc8..742e52d1ab 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -112,8 +112,7 @@ func TestChangeoverToConsumer(t *testing.T) { require.False(t, consumerKeeper.IsPreCCV(ctx)) // Last standalone height should be set to current block height - lastStandaloneHeight := consumerKeeper.GetLastStandaloneHeight(ctx) - require.Equal(t, ctx.BlockHeight(), lastStandaloneHeight) + require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastStandaloneHeight(ctx)) // Cross chain validator states should be populated with initial valset ccVals := consumerKeeper.GetAllCCValidator(ctx) diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 619663f3cf..e36cf6607a 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -92,13 +92,11 @@ func TestLastSovereignHeight(t *testing.T) { // Set/get the last standalone height being 10 consumerKeeper.SetLastStandaloneHeight(ctx, 10) - lastStandaloneHeight := consumerKeeper.GetLastStandaloneHeight(ctx) - require.Equal(t, int64(10), lastStandaloneHeight) + require.Equal(t, int64(10), consumerKeeper.GetLastStandaloneHeight(ctx)) // Set/get the last standalone height being 43234426 consumerKeeper.SetLastStandaloneHeight(ctx, 43234426) - lastStandaloneHeight = consumerKeeper.GetLastStandaloneHeight(ctx) - require.Equal(t, int64(43234426), lastStandaloneHeight) + require.Equal(t, int64(43234426), consumerKeeper.GetLastStandaloneHeight(ctx)) } // TestPreCCV tests the getter, setter and deletion methods for the pre-CCV state flag From b3156deda8d571bd08ae9f6095d3e20666a34c58 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:56:38 -0700 Subject: [PATCH 56/71] two UTs --- x/ccv/consumer/keeper/changeover.go | 1 - x/ccv/consumer/keeper/validators.go | 5 +- x/ccv/consumer/keeper/validators_test.go | 81 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 10daf96727..b7ff635c68 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -5,7 +5,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// TODO: tests around this logic // ChangeoverIsComplete returns whether the standalone to consumer changeover process is complete. func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { if !k.IsPrevStandaloneChain() { diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 7db62387c3..ac7c700d7a 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -104,8 +104,7 @@ func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.V // Slash queues a slashing request for the the provider chain // All queued slashing requests will be cleared in EndBlock -// TODO: UT for this -func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, _ sdk.Dec, infraction stakingtypes.InfractionType) { +func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infraction stakingtypes.InfractionType) { if infraction == stakingtypes.InfractionEmpty { return @@ -114,7 +113,7 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p // If this is a previously standalone chain and infraction happened before the changeover was completed, // slash only on the standalone staking keeper. if k.IsPrevStandaloneChain() && infractionHeight < k.FirstConsumerHeight(ctx) { - k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, sdk.Dec{}, infraction) + k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, slashFactor, infraction) return } diff --git a/x/ccv/consumer/keeper/validators_test.go b/x/ccv/consumer/keeper/validators_test.go index 9aa70470a3..87c0ab0b74 100644 --- a/x/ccv/consumer/keeper/validators_test.go +++ b/x/ccv/consumer/keeper/validators_test.go @@ -106,6 +106,87 @@ func TestApplyCCValidatorChanges(t *testing.T) { } } +// TestIsValidatorJailed tests the IsValidatorJailed method for a consumer keeper +func TestIsValidatorJailed(t *testing.T) { + consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Consumer keeper from test setup should return false for IsPrevStandaloneChain() + require.False(t, consumerKeeper.IsPrevStandaloneChain()) + + // IsValidatorJailed should return false for an arbitrary consensus address + consAddr := []byte{0x01, 0x02, 0x03} + require.False(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) + + // Set outstanding downtime for that addr + consumerKeeper.SetOutstandingDowntime(ctx, consAddr) + + // Now confirm IsValidatorJailed returns true + require.True(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) + + // Next, we set a value for the standalone staking keeper so IsPrevStandaloneChain() returns true + consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) + require.True(t, consumerKeeper.IsPrevStandaloneChain()) + + // Set LastStandaloneHeight to current block height so that ChangeoverIsComplete() is false + consumerKeeper.SetLastStandaloneHeight(ctx, ctx.BlockHeight()) + require.False(t, consumerKeeper.ChangeoverIsComplete(ctx)) + + // At this point, the state of the consumer keeper is s.t. IsValidatorJailed() queries the standalone staking keeper + + // Now mock that a validator is jailed from the standalone staking keeper + mocks.MockStakingKeeper.EXPECT().IsValidatorJailed(ctx, consAddr).Return(true).Times(1) + + // Confirm IsValidatorJailed returns true + require.True(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) +} + +func TestSlash(t *testing.T) { + consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // If we call slash with infraction type empty, no slash packet will be queued + consumerKeeper.Slash(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.InfractionEmpty) + pendingPackets := consumerKeeper.GetPendingPackets(ctx) + require.Len(t, pendingPackets.List, 0) + + // Consumer keeper from test setup should return false for IsPrevStandaloneChain() + require.False(t, consumerKeeper.IsPrevStandaloneChain()) + + // Now setup a value for vscID mapped to infraction height + consumerKeeper.SetHeightValsetUpdateID(ctx, 5, 6) + + // Call slash with valid infraction type and confirm 1 slash packet is queued + consumerKeeper.Slash(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.Downtime) + pendingPackets = consumerKeeper.GetPendingPackets(ctx) + require.Len(t, pendingPackets.List, 1) + + // Next, we set a value for the standalone staking keeper so IsPrevStandaloneChain() returns true + consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) + require.True(t, consumerKeeper.IsPrevStandaloneChain()) + + // At this point, the state of the consumer keeper is s.t. + // Slash() calls the standalone staking keeper's Slash() + + // If we call slash with infraction type empty, standalone staking keeper's slash will not be called + // (if it was called, test would panic without mocking the call) + consumerKeeper.Slash(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.InfractionEmpty) + + // Now setup a mock for Slash, and confirm that it is called against + // standalone staking keeper with valid infraction type + infractionHeight := int64(5) + mocks.MockStakingKeeper.EXPECT().Slash( + ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, int64(6), + sdk.MustNewDecFromStr("0.05"), stakingtypes.Downtime).Times(1) + + // Also setup last standalone height s.t. infraction height is before first consumer height + consumerKeeper.SetLastStandaloneHeight(ctx, 4) + require.Equal(t, consumerKeeper.FirstConsumerHeight(ctx), int64(6)) + + consumerKeeper.Slash(ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, 6, + sdk.MustNewDecFromStr("0.05"), stakingtypes.Downtime) +} + // Tests the getter and setter behavior for historical info func TestHistoricalInfo(t *testing.T) { keeperParams := testkeeper.NewInMemKeeperParams(t) From f80428152fe8cfad23af73b3b1363eca883d9faa Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:31:21 -0700 Subject: [PATCH 57/71] sanity check integration test --- tests/integration/slashing.go | 38 ++++++++++++++++++++++++++++++ testutil/integration/debug_test.go | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go index a4f4a829f3..baead260fb 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -665,3 +665,41 @@ func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() { suite.Require().Empty(dataPackets) suite.Require().Len(dataPackets.GetList(), 0) } + +// TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or +// have any undesired behavior when a slash packet is queued before the CCV channel is established. +// Then once the CCV channel is established, the slash packet should be sent soon after. +func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() { + consumerKeeper := suite.consumerApp.GetConsumerKeeper() + + // Check pending packets is empty + pendingPackets := consumerKeeper.GetPendingPackets(suite.consumerCtx()) + suite.Require().Len(pendingPackets.List, 0) + + consumerKeeper.Slash(suite.consumerCtx(), []byte{0x01, 0x02, 0x3}, + 66, 4324, sdk.MustNewDecFromStr("0.05"), stakingtypes.Downtime) + + // Check slash packet was queued + pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx()) + suite.Require().Len(pendingPackets.List, 1) + + // Pass 5 blocks, confirming the consumer doesn't panic + suite.consumerChain.NextBlock() + suite.consumerChain.NextBlock() + suite.consumerChain.NextBlock() + suite.consumerChain.NextBlock() + suite.consumerChain.NextBlock() + + // Check packet is still queued + pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx()) + suite.Require().Len(pendingPackets.List, 1) + + // establish ccv channel + suite.SetupCCVChannel(suite.path) + suite.SendEmptyVSCPacket() + + // Pass one more block, and confirm the packet is sent now that ccv channel is established + suite.consumerChain.NextBlock() + pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx()) + suite.Require().Len(pendingPackets.List, 0) +} diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 98fab083f4..350601fb55 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -141,6 +141,10 @@ func TestQueueAndSendSlashPacket(t *testing.T) { runCCVTestByName(t, "TestQueueAndSendSlashPacket") } +func TestCISBeforeCCVEstablished(t *testing.T) { + runCCVTestByName(t, "TestCISBeforeCCVEstablished") +} + // // Stop consumer tests // From edb491fcd0524dcbcc37dd3970130920c4053a0e Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:35:33 -0700 Subject: [PATCH 58/71] gofumpt --- x/ccv/consumer/keeper/validators.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index ac7c700d7a..f9dfe7cce7 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -105,7 +105,6 @@ func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.V // Slash queues a slashing request for the the provider chain // All queued slashing requests will be cleared in EndBlock func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infraction stakingtypes.InfractionType) { - if infraction == stakingtypes.InfractionEmpty { return } From d0640e189c20215c29661d92735c92db2a1a7983 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:10:10 -0700 Subject: [PATCH 59/71] last standalone height -> init genesis height --- app/consumer-democracy/app.go | 3 +-- x/ccv/consumer/keeper/changeover.go | 12 +++++------- x/ccv/consumer/keeper/changeover_test.go | 3 --- x/ccv/consumer/keeper/genesis.go | 1 + x/ccv/consumer/keeper/keeper.go | 4 ++-- x/ccv/consumer/keeper/keeper_test.go | 18 +++++++++--------- x/ccv/consumer/keeper/validators_test.go | 8 ++++---- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 71ec8ee36a..de2362bc84 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -428,8 +428,7 @@ func New( ) // Setting the standalone staking keeper is only needed for standalone to consumer changeover chains - // We do not set the keeper here since this app.go was originally designed as a normal democracry consumer. - // app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) + app.ConsumerKeeper.SetStandaloneStakingKeeper(app.StakingKeeper) // consumer keeper satisfies the staking keeper interface // of the slashing module diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index b7ff635c68..6c5576e17c 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -13,11 +13,11 @@ func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx) } -// The first height that the ccv valset will be in effect is 2 blocks after last standalone height -// (aka height that the ccv module first returned updates to tendermint), because the new valset is committed -// in block N+1, and in effect for block N+2. +// The first height that the ccv valset will be in effect is 2 blocks after init genesis height +// (aka height that the ccv module first returned updates to tendermint), because if init genesis is block N, +// the new valset is committed in block N+1, and in effect for block N+2. func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { - return k.GetLastStandaloneHeight(ctx) + 2 + return k.GetInitGenesisHeight(ctx) + 2 } // ChangeoverToConsumer includes the logic that needs to execute during the process of a @@ -27,10 +27,8 @@ func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { // that will be given to tendermint, which allows the consumer chain to // start using the provider valset, while the standalone valset is given zero voting power where appropriate. func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci.ValidatorUpdate) { - initialValUpdates = k.GetInitialValSet(ctx) - // set last standalone height - k.SetLastStandaloneHeight(ctx, ctx.BlockHeight()) // populate cross chain validators states with initial valset + initialValUpdates = k.GetInitialValSet(ctx) k.ApplyCCValidatorChanges(ctx, initialValUpdates) // Add validator updates to initialValUpdates, such that the "old" validators returned from standalone staking module diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index 742e52d1ab..7c5bfe1171 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -111,9 +111,6 @@ func TestChangeoverToConsumer(t *testing.T) { // PreCCV should now be toggled false require.False(t, consumerKeeper.IsPreCCV(ctx)) - // Last standalone height should be set to current block height - require.Equal(t, ctx.BlockHeight(), consumerKeeper.GetLastStandaloneHeight(ctx)) - // Cross chain validator states should be populated with initial valset ccVals := consumerKeeper.GetAllCCValidator(ctx) require.Len(t, ccVals, len(tc.initialValUpdates)) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 30ac8693a3..b10e5ddb98 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -27,6 +27,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) k.SetPreCCVTrue(ctx) k.SetInitialValSet(ctx, state.InitialValSet) } + k.SetInitGenesisHeight(ctx, ctx.BlockHeight()) // Usually 0, but not the case for changeover chains k.SetParams(ctx, state.Params) // TODO: Remove enabled flag and find a better way to setup integration tests diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 10a0946827..304eee97e9 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -260,7 +260,7 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { store.Delete(types.PendingChangesKey()) } -func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) int64 { +func (k Keeper) GetInitGenesisHeight(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) bz := store.Get(types.LastStandaloneHeightKey()) if bz == nil { @@ -270,7 +270,7 @@ func (k Keeper) GetLastStandaloneHeight(ctx sdk.Context) int64 { return int64(height) } -func (k Keeper) SetLastStandaloneHeight(ctx sdk.Context, height int64) { +func (k Keeper) SetInitGenesisHeight(ctx sdk.Context, height int64) { bz := sdk.Uint64ToBigEndian(uint64(height)) store := ctx.KVStore(k.storeKey) store.Set(types.LastStandaloneHeightKey(), bz) diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index e36cf6607a..5fb0c9f0e7 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -82,21 +82,21 @@ func TestPendingChanges(t *testing.T) { require.Nil(t, gotPd, "got non-nil pending changes after Delete") } -// TestLastSovereignHeight tests the getter and setter for the last standalone height -func TestLastSovereignHeight(t *testing.T) { +// TestLastSovereignHeight tests the getter and setter for the ccv init genesis height +func TestInitGenesisHeight(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() // Panics without setter - require.Panics(t, func() { consumerKeeper.GetLastStandaloneHeight(ctx) }) + require.Panics(t, func() { consumerKeeper.GetInitGenesisHeight(ctx) }) - // Set/get the last standalone height being 10 - consumerKeeper.SetLastStandaloneHeight(ctx, 10) - require.Equal(t, int64(10), consumerKeeper.GetLastStandaloneHeight(ctx)) + // Set/get the height being 10 + consumerKeeper.SetInitGenesisHeight(ctx, 10) + require.Equal(t, int64(10), consumerKeeper.GetInitGenesisHeight(ctx)) - // Set/get the last standalone height being 43234426 - consumerKeeper.SetLastStandaloneHeight(ctx, 43234426) - require.Equal(t, int64(43234426), consumerKeeper.GetLastStandaloneHeight(ctx)) + // Set/get the height being 43234426 + consumerKeeper.SetInitGenesisHeight(ctx, 43234426) + require.Equal(t, int64(43234426), consumerKeeper.GetInitGenesisHeight(ctx)) } // TestPreCCV tests the getter, setter and deletion methods for the pre-CCV state flag diff --git a/x/ccv/consumer/keeper/validators_test.go b/x/ccv/consumer/keeper/validators_test.go index 87c0ab0b74..85d3cfe805 100644 --- a/x/ccv/consumer/keeper/validators_test.go +++ b/x/ccv/consumer/keeper/validators_test.go @@ -128,8 +128,8 @@ func TestIsValidatorJailed(t *testing.T) { consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) require.True(t, consumerKeeper.IsPrevStandaloneChain()) - // Set LastStandaloneHeight to current block height so that ChangeoverIsComplete() is false - consumerKeeper.SetLastStandaloneHeight(ctx, ctx.BlockHeight()) + // Set init genesis height to current block height so that ChangeoverIsComplete() is false + consumerKeeper.SetInitGenesisHeight(ctx, ctx.BlockHeight()) require.False(t, consumerKeeper.ChangeoverIsComplete(ctx)) // At this point, the state of the consumer keeper is s.t. IsValidatorJailed() queries the standalone staking keeper @@ -179,8 +179,8 @@ func TestSlash(t *testing.T) { ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, int64(6), sdk.MustNewDecFromStr("0.05"), stakingtypes.Downtime).Times(1) - // Also setup last standalone height s.t. infraction height is before first consumer height - consumerKeeper.SetLastStandaloneHeight(ctx, 4) + // Also setup init genesis height s.t. infraction height is before first consumer height + consumerKeeper.SetInitGenesisHeight(ctx, 4) require.Equal(t, consumerKeeper.FirstConsumerHeight(ctx), int64(6)) consumerKeeper.Slash(ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, 6, From 134e8e665f4a2834ebec5095af92bee9a04f5ddc Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:03:11 -0700 Subject: [PATCH 60/71] wiring --- x/ccv/consumer/ibc_module.go | 13 ++++++++++++- x/ccv/consumer/keeper/distribution.go | 5 +++++ x/ccv/consumer/keeper/keeper.go | 14 ++++++++++++++ x/ccv/consumer/keeper/keeper_test.go | 13 +++++++++++++ x/ccv/consumer/types/keys.go | 10 ++++++++++ x/ccv/consumer/types/keys_test.go | 2 ++ 6 files changed, 56 insertions(+), 1 deletion(-) diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 2b20b48c4e..4b467b841d 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -138,7 +138,18 @@ func (am AppModule) OnChanOpenAck( /////////////////////////////////////////////////// // Initialize distribution token transfer channel - // + + // First check if an existing transfer channel exists, if this consumer was a previously standalone chain. + if am.keeper.IsPrevStandaloneChain() { + transChannelID := am.keeper.GetStandaloneTransferChannelID(ctx) + found := am.keeper.TransferChannelExists(ctx, transChannelID) + if found { + // If existing transfer channel is found, persist that channel ID and return + am.keeper.SetDistributionTransmissionChannel(ctx, transChannelID) + return nil + } + } + // NOTE The handshake for this channel is handled by the ibc-go/transfer // module. If the transfer-channel fails here (unlikely) then the transfer // channel should be manually created and ccv parameters set accordingly. diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index f2a499d21e..140e135c12 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -178,6 +178,11 @@ func (k Keeper) ChannelOpenInit(ctx sdk.Context, msg *channeltypes.MsgChannelOpe return k.ibcCoreKeeper.ChannelOpenInit(sdk.WrapSDKContext(ctx), msg) } +func (k Keeper) TransferChannelExists(ctx sdk.Context, channelID string) bool { + _, found := k.channelKeeper.GetChannel(ctx, transfertypes.PortID, channelID) + return found +} + func (k Keeper) GetConnectionHops(ctx sdk.Context, srcPort, srcChan string) ([]string, error) { ch, found := k.channelKeeper.GetChannel(ctx, srcPort, srcChan) if !found { diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 304eee97e9..3e64e6ea08 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -607,3 +607,17 @@ func (k Keeper) AppendPendingPacket(ctx sdk.Context, packet ...ccv.ConsumerPacke list := append(pending.GetList(), packet...) k.SetPendingPackets(ctx, ccv.ConsumerPacketDataList{List: list}) } + +// SetStandaloneTransferChannelID sets the channelID of an existing transfer channel, +// for a chain which used to be a standalone chain. +func (k Keeper) SetStandaloneTransferChannelID(ctx sdk.Context, channelID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.StandaloneTransferChannelIDKey(), []byte(channelID)) +} + +// GetStandaloneTransferChannelID returns the channelID of an existing transfer channel, +// for a chain which used to be a standalone chain. +func (k Keeper) GetStandaloneTransferChannelID(ctx sdk.Context) string { + store := ctx.KVStore(k.storeKey) + return string(store.Get(types.StandaloneTransferChannelIDKey())) +} diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 5fb0c9f0e7..f5b2f8ec5b 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -544,3 +544,16 @@ func TestGetAllOutstandingDowntimes(t *testing.T) { require.Len(t, result, len(addresses)) require.Equal(t, result, expectedGetAllOrder) } + +// TestStandaloneTransferChannelID tests the getter and setter for the existing transfer channel id +func TestStandaloneTransferChannelID(t *testing.T) { + ck, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Test that the default value is empty + require.Equal(t, "", ck.GetStandaloneTransferChannelID(ctx)) + + // Test that the value can be set and retrieved + ck.SetStandaloneTransferChannelID(ctx, "channelID1234") + require.Equal(t, "channelID1234", ck.GetStandaloneTransferChannelID(ctx)) +} diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 2ecb444d52..72a3fa3bac 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -65,6 +65,10 @@ const ( // LastStandaloneHeightByteKey is the byte that will store last standalone height LastStandaloneHeightByteKey + // StandaloneTransferChannelIDByteKey is the byte storing the channelID of transfer channel + // that existed from a standalone chain changing over to a consumer + StandaloneTransferChannelIDByteKey + // HistoricalInfoKey is the byte prefix that will store the historical info for a given height HistoricalInfoBytePrefix @@ -136,6 +140,12 @@ func LastStandaloneHeightKey() []byte { return []byte{LastStandaloneHeightByteKey} } +// StandaloneTransferChannelIDKey returns the key to the transfer channelID that existed from a standalone chain +// changing over to a consumer +func StandaloneTransferChannelIDKey() []byte { + return []byte{StandaloneTransferChannelIDByteKey} +} + // HistoricalInfoKey returns the key to historical info to a given block height func HistoricalInfoKey(height int64) []byte { hBytes := make([]byte, 8) diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index eb61088f10..c1ac224f01 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -31,6 +31,7 @@ func getAllKeyPrefixes() []byte { PreCCVByteKey, InitialValSetByteKey, LastStandaloneHeightByteKey, + StandaloneTransferChannelIDByteKey, HistoricalInfoBytePrefix, PacketMaturityTimeBytePrefix, HeightValsetUpdateIDBytePrefix, @@ -62,6 +63,7 @@ func getAllFullyDefinedKeys() [][]byte { PreCCVKey(), InitialValSetKey(), LastStandaloneHeightKey(), + StandaloneTransferChannelIDKey(), HistoricalInfoKey(0), PacketMaturityTimeKey(0, time.Time{}), HeightValsetUpdateIDKey(0), From 21fb41784764557f1b85c27a5fd4f1d5651536a2 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:28:53 -0700 Subject: [PATCH 61/71] integration test and refactor to enable it --- app/consumer-democracy/app.go | 6 +++ tests/integration/changeover.go | 50 ++++++++++++++++++++++++ tests/integration/setup.go | 3 ++ testutil/integration/debug_test.go | 8 ++++ x/ccv/consumer/ibc_module.go | 2 +- x/ccv/consumer/keeper/changeover.go | 2 +- x/ccv/consumer/keeper/genesis.go | 1 + x/ccv/consumer/keeper/keeper.go | 14 +++++-- x/ccv/consumer/keeper/keeper_test.go | 12 ++++++ x/ccv/consumer/keeper/validators.go | 4 +- x/ccv/consumer/keeper/validators_test.go | 16 +++++--- x/ccv/consumer/types/keys.go | 8 ++++ 12 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 tests/integration/changeover.go diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index de2362bc84..74bdd2beff 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -642,6 +642,12 @@ func New( // upgrade handler code is application specific. However, as an example, standalone to consumer // changeover chains should utilize customized upgrade handler code similar to below. + // Setting the standalone transfer channel ID is only needed for standalone to consumer changeover chains + // who wish to preserve existing IBC transfer denoms. Here's an example. + // + // Note: This setter needs to execute before the ccv channel handshake is initiated. + app.ConsumerKeeper.SetStandaloneTransferChannelID(ctx, "hardcoded-existing-channel-id") + // TODO: should have a way to read from current node home userHomeDir, err := os.UserHomeDir() if err != nil { diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go new file mode 100644 index 0000000000..ee1ab780cd --- /dev/null +++ b/tests/integration/changeover.go @@ -0,0 +1,50 @@ +package integration + +import ( + transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" +) + +func (suite *CCVTestSuite) TestRecycleTransferChannel() { + + consumerKeeper := suite.consumerApp.GetConsumerKeeper() + + // Only create a connection between consumer and provider + suite.coordinator.CreateConnections(suite.path) + + // Confirm transfer channel has not been persisted + transChan := consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx()) + suite.Require().Empty(transChan) + + // Create transfer channel manually + distrTransferMsg := channeltypes.NewMsgChannelOpenInit( + transfertypes.PortID, + transfertypes.Version, + channeltypes.UNORDERED, + []string{suite.path.EndpointA.ConnectionID}, + transfertypes.PortID, + "", // signer unused + ) + resp, err := consumerKeeper.ChannelOpenInit(suite.consumerCtx(), distrTransferMsg) + suite.Require().NoError(err) + + // Confirm transfer channel still not persisted + transChan = consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx()) + suite.Require().Empty(transChan) + + // Setup state s.t. the consumer keeper emulates a consumer that was previously standalone + consumerKeeper.MarkAsPrevStandaloneChain(suite.consumerCtx()) + suite.Require().True(consumerKeeper.IsPrevStandaloneChain(suite.consumerCtx())) + suite.consumerApp.GetConsumerKeeper().SetStandaloneTransferChannelID(suite.consumerCtx(), resp.ChannelId) + + // Now finish setting up CCV channel + suite.ExecuteCCVChannelHandshake(suite.path) + + // Confirm transfer channel is now persisted with expected channel id from open init response + transChan = consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx()) + suite.Require().Equal(resp.ChannelId, transChan) + + // Confirm channel exists + found := consumerKeeper.TransferChannelExists(suite.consumerCtx(), transChan) + suite.Require().True(found) +} diff --git a/tests/integration/setup.go b/tests/integration/setup.go index ae2a608415..59e03301af 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -239,7 +239,10 @@ func (suite *CCVTestSuite) SetupAllCCVChannels() { func (suite *CCVTestSuite) SetupCCVChannel(path *ibctesting.Path) { suite.coordinator.CreateConnections(path) + suite.ExecuteCCVChannelHandshake(path) +} +func (suite *CCVTestSuite) ExecuteCCVChannelHandshake(path *ibctesting.Path) { err := path.EndpointA.ChanOpenInit() suite.Require().NoError(err) diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 350601fb55..8549d12217 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -244,3 +244,11 @@ func TestPacketRoundtrip(t *testing.T) { func TestQueueAndSendVSCMaturedPackets(t *testing.T) { runCCVTestByName(t, "TestQueueAndSendVSCMaturedPackets") } + +// +// Changeover tests +// + +func TestRecycleTransferChannel(t *testing.T) { + runCCVTestByName(t, "TestRecycleTransferChannel") +} diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 4b467b841d..87c876097b 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -140,7 +140,7 @@ func (am AppModule) OnChanOpenAck( // Initialize distribution token transfer channel // First check if an existing transfer channel exists, if this consumer was a previously standalone chain. - if am.keeper.IsPrevStandaloneChain() { + if am.keeper.IsPrevStandaloneChain(ctx) { transChannelID := am.keeper.GetStandaloneTransferChannelID(ctx) found := am.keeper.TransferChannelExists(ctx, transChannelID) if found { diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 6c5576e17c..38f871c175 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -7,7 +7,7 @@ import ( // ChangeoverIsComplete returns whether the standalone to consumer changeover process is complete. func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { - if !k.IsPrevStandaloneChain() { + if !k.IsPrevStandaloneChain(ctx) { panic("ChangeoverIsComplete should only be called on previously standalone consumers") } return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index b10e5ddb98..121ab07134 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -25,6 +25,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) // stick around for slashing/jailing purposes. if state.PreCCV { k.SetPreCCVTrue(ctx) + k.MarkAsPrevStandaloneChain(ctx) k.SetInitialValSet(ctx, state.InitialValSet) } k.SetInitGenesisHeight(ctx, ctx.BlockHeight()) // Usually 0, but not the case for changeover chains diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 3e64e6ea08..7d5d07059b 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -93,10 +93,6 @@ func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { k.standaloneStakingKeeper = sk } -func (k Keeper) IsPrevStandaloneChain() bool { - return k.standaloneStakingKeeper != nil -} - // Validates that the consumer keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { @@ -608,6 +604,16 @@ func (k Keeper) AppendPendingPacket(ctx sdk.Context, packet ...ccv.ConsumerPacke k.SetPendingPackets(ctx, ccv.ConsumerPacketDataList{List: list}) } +func (k Keeper) MarkAsPrevStandaloneChain(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PrevStandaloneChainKey(), []byte{}) +} + +func (k Keeper) IsPrevStandaloneChain(ctx sdk.Context) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.PrevStandaloneChainKey()) +} + // SetStandaloneTransferChannelID sets the channelID of an existing transfer channel, // for a chain which used to be a standalone chain. func (k Keeper) SetStandaloneTransferChannelID(ctx sdk.Context, channelID string) { diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index f5b2f8ec5b..84c3619e19 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -557,3 +557,15 @@ func TestStandaloneTransferChannelID(t *testing.T) { ck.SetStandaloneTransferChannelID(ctx, "channelID1234") require.Equal(t, "channelID1234", ck.GetStandaloneTransferChannelID(ctx)) } + +func TestPrevStandaloneChainFlag(t *testing.T) { + ck, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Test that the default value is false + require.False(t, ck.IsPrevStandaloneChain(ctx)) + + // Test that the value can be set and retrieved + ck.MarkAsPrevStandaloneChain(ctx) + require.True(t, ck.IsPrevStandaloneChain(ctx)) +} diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index f9dfe7cce7..49a94e961f 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -80,7 +80,7 @@ func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.Val func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { // if the changeover is not complete for prev standalone chain, // return the standalone staking keeper's jailed status - if k.IsPrevStandaloneChain() && !k.ChangeoverIsComplete(ctx) { + if k.IsPrevStandaloneChain(ctx) && !k.ChangeoverIsComplete(ctx) { return k.standaloneStakingKeeper.IsValidatorJailed(ctx, addr) } // Otherwise, return the ccv consumer keeper's notion of a validator being jailed @@ -111,7 +111,7 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p // If this is a previously standalone chain and infraction happened before the changeover was completed, // slash only on the standalone staking keeper. - if k.IsPrevStandaloneChain() && infractionHeight < k.FirstConsumerHeight(ctx) { + if k.IsPrevStandaloneChain(ctx) && infractionHeight < k.FirstConsumerHeight(ctx) { k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, slashFactor, infraction) return } diff --git a/x/ccv/consumer/keeper/validators_test.go b/x/ccv/consumer/keeper/validators_test.go index 85d3cfe805..0b4d697098 100644 --- a/x/ccv/consumer/keeper/validators_test.go +++ b/x/ccv/consumer/keeper/validators_test.go @@ -112,7 +112,7 @@ func TestIsValidatorJailed(t *testing.T) { defer ctrl.Finish() // Consumer keeper from test setup should return false for IsPrevStandaloneChain() - require.False(t, consumerKeeper.IsPrevStandaloneChain()) + require.False(t, consumerKeeper.IsPrevStandaloneChain(ctx)) // IsValidatorJailed should return false for an arbitrary consensus address consAddr := []byte{0x01, 0x02, 0x03} @@ -124,9 +124,11 @@ func TestIsValidatorJailed(t *testing.T) { // Now confirm IsValidatorJailed returns true require.True(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) - // Next, we set a value for the standalone staking keeper so IsPrevStandaloneChain() returns true + // Next, we set a value for the standalone staking keeper, + // and mark the consumer keeper as being from a previous standalone chain consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) - require.True(t, consumerKeeper.IsPrevStandaloneChain()) + consumerKeeper.MarkAsPrevStandaloneChain(ctx) + require.True(t, consumerKeeper.IsPrevStandaloneChain(ctx)) // Set init genesis height to current block height so that ChangeoverIsComplete() is false consumerKeeper.SetInitGenesisHeight(ctx, ctx.BlockHeight()) @@ -151,7 +153,7 @@ func TestSlash(t *testing.T) { require.Len(t, pendingPackets.List, 0) // Consumer keeper from test setup should return false for IsPrevStandaloneChain() - require.False(t, consumerKeeper.IsPrevStandaloneChain()) + require.False(t, consumerKeeper.IsPrevStandaloneChain(ctx)) // Now setup a value for vscID mapped to infraction height consumerKeeper.SetHeightValsetUpdateID(ctx, 5, 6) @@ -161,9 +163,11 @@ func TestSlash(t *testing.T) { pendingPackets = consumerKeeper.GetPendingPackets(ctx) require.Len(t, pendingPackets.List, 1) - // Next, we set a value for the standalone staking keeper so IsPrevStandaloneChain() returns true + // Next, we set a value for the standalone staking keeper, + // and mark the consumer keeper as being from a previous standalone chain consumerKeeper.SetStandaloneStakingKeeper(mocks.MockStakingKeeper) - require.True(t, consumerKeeper.IsPrevStandaloneChain()) + consumerKeeper.MarkAsPrevStandaloneChain(ctx) + require.True(t, consumerKeeper.IsPrevStandaloneChain(ctx)) // At this point, the state of the consumer keeper is s.t. // Slash() calls the standalone staking keeper's Slash() diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 72a3fa3bac..1580e9c637 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -69,6 +69,9 @@ const ( // that existed from a standalone chain changing over to a consumer StandaloneTransferChannelIDByteKey + // PrevStandaloneChainByteKey is the byte storing the flag marking whether this chain was previously standalone + PrevStandaloneChainByteKey + // HistoricalInfoKey is the byte prefix that will store the historical info for a given height HistoricalInfoBytePrefix @@ -146,6 +149,11 @@ func StandaloneTransferChannelIDKey() []byte { return []byte{StandaloneTransferChannelIDByteKey} } +// PrevStandaloneChainKey returns the key to the flag marking whether this chain was previously standalone +func PrevStandaloneChainKey() []byte { + return []byte{PrevStandaloneChainByteKey} +} + // HistoricalInfoKey returns the key to historical info to a given block height func HistoricalInfoKey(height int64) []byte { hBytes := make([]byte, 8) From 5b3896b9f97b29b2a15826a32b289f55fe62693c Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:31:40 -0700 Subject: [PATCH 62/71] sanity check --- tests/integration/changeover.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go index ee1ab780cd..8edf939617 100644 --- a/tests/integration/changeover.go +++ b/tests/integration/changeover.go @@ -47,4 +47,8 @@ func (suite *CCVTestSuite) TestRecycleTransferChannel() { // Confirm channel exists found := consumerKeeper.TransferChannelExists(suite.consumerCtx(), transChan) suite.Require().True(found) + + // Sanity check, only two channels should exist, one transfer and one ccv + channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx()) + suite.Require().Len(channels, 2) } From c31efc703576fb44c3872a5fe3929dcd14f76127 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:39:03 -0700 Subject: [PATCH 63/71] Update changeover.go --- tests/integration/changeover.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go index 8edf939617..3bf4e11932 100644 --- a/tests/integration/changeover.go +++ b/tests/integration/changeover.go @@ -6,7 +6,6 @@ import ( ) func (suite *CCVTestSuite) TestRecycleTransferChannel() { - consumerKeeper := suite.consumerApp.GetConsumerKeeper() // Only create a connection between consumer and provider From e153a37e10fd0bceff0566daf1d40eaaf747fb61 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 11 Apr 2023 14:12:46 -0700 Subject: [PATCH 64/71] Use ValidatorUpdateDelay --- x/ccv/consumer/keeper/changeover.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 6c5576e17c..b8814aebbf 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -15,9 +15,9 @@ func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { // The first height that the ccv valset will be in effect is 2 blocks after init genesis height // (aka height that the ccv module first returned updates to tendermint), because if init genesis is block N, -// the new valset is committed in block N+1, and in effect for block N+2. +// the new valset is committed in block N+ValidatorUpdateDelay, and in effect for block N+ValidatorUpdateDelay+1. func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { - return k.GetInitGenesisHeight(ctx) + 2 + return k.GetInitGenesisHeight(ctx) + sdk.ValidatorUpdateDelay + 1 } // ChangeoverToConsumer includes the logic that needs to execute during the process of a From cb9a1ec93fdbed4c8f09cd4152deac687e46dd45 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 13 Apr 2023 07:17:49 -0700 Subject: [PATCH 65/71] for loop --- tests/integration/slashing.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go index baead260fb..f39c027c90 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -684,11 +684,9 @@ func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() { suite.Require().Len(pendingPackets.List, 1) // Pass 5 blocks, confirming the consumer doesn't panic - suite.consumerChain.NextBlock() - suite.consumerChain.NextBlock() - suite.consumerChain.NextBlock() - suite.consumerChain.NextBlock() - suite.consumerChain.NextBlock() + for i := 0; i < 5; i++ { + suite.consumerChain.NextBlock() + } // Check packet is still queued pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx()) From 861c484975541ca4cf57b688e306cb971787db67 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:24:01 -0700 Subject: [PATCH 66/71] fix key name --- x/ccv/consumer/keeper/keeper.go | 4 ++-- x/ccv/consumer/types/keys.go | 8 ++++---- x/ccv/consumer/types/keys_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 7d5d07059b..d1aa2499b3 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -258,7 +258,7 @@ func (k Keeper) DeletePendingChanges(ctx sdk.Context) { func (k Keeper) GetInitGenesisHeight(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.LastStandaloneHeightKey()) + bz := store.Get(types.InitGenesisHeightKey()) if bz == nil { panic("last standalone height not set") } @@ -269,7 +269,7 @@ func (k Keeper) GetInitGenesisHeight(ctx sdk.Context) int64 { func (k Keeper) SetInitGenesisHeight(ctx sdk.Context, height int64) { bz := sdk.Uint64ToBigEndian(uint64(height)) store := ctx.KVStore(k.storeKey) - store.Set(types.LastStandaloneHeightKey(), bz) + store.Set(types.InitGenesisHeightKey(), bz) } func (k Keeper) IsPreCCV(ctx sdk.Context) bool { diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index eafb85e258..3387e1f586 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -62,8 +62,8 @@ const ( // InitialValSetByteKey is the byte to store the initial validator set for a consumer InitialValSetByteKey - // LastStandaloneHeightByteKey is the byte that will store last standalone height - LastStandaloneHeightByteKey + // InitGenesisHeightByteKey is the byte that will store the init genesis height + InitGenesisHeightByteKey // SmallestNonOptOutPowerByteKey is the byte that will store the smallest val power that cannot opt out SmallestNonOptOutPowerByteKey @@ -142,8 +142,8 @@ func InitialValSetKey() []byte { return []byte{InitialValSetByteKey} } -func LastStandaloneHeightKey() []byte { - return []byte{LastStandaloneHeightByteKey} +func InitGenesisHeightKey() []byte { + return []byte{InitGenesisHeightByteKey} } func SmallestNonOptOutPowerKey() []byte { diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index 091386f824..83c83d1344 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -31,7 +31,7 @@ func getAllKeyPrefixes() []byte { PreCCVByteKey, InitialValSetByteKey, SmallestNonOptOutPowerByteKey, - LastStandaloneHeightByteKey, + InitGenesisHeightByteKey, StandaloneTransferChannelIDByteKey, HistoricalInfoBytePrefix, PacketMaturityTimeBytePrefix, @@ -64,7 +64,7 @@ func getAllFullyDefinedKeys() [][]byte { PreCCVKey(), InitialValSetKey(), SmallestNonOptOutPowerKey(), - LastStandaloneHeightKey(), + InitGenesisHeightKey(), StandaloneTransferChannelIDKey(), HistoricalInfoKey(0), PacketMaturityTimeKey(0, time.Time{}), From 02b4f7588fe107b06dd5736eea7dbcb069b5d21a Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 14 Apr 2023 08:57:10 -0700 Subject: [PATCH 67/71] Update x/ccv/consumer/keeper/changeover.go Co-authored-by: Simon Noetzlin --- x/ccv/consumer/keeper/changeover.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index b8814aebbf..5b8bc8aac2 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -13,7 +13,7 @@ func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool { return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx) } -// The first height that the ccv valset will be in effect is 2 blocks after init genesis height +// FirstConsumerHeight returns the first height that the ccv valset will be in effect is 2 blocks after init genesis height // (aka height that the ccv module first returned updates to tendermint), because if init genesis is block N, // the new valset is committed in block N+ValidatorUpdateDelay, and in effect for block N+ValidatorUpdateDelay+1. func (k Keeper) FirstConsumerHeight(ctx sdk.Context) int64 { From 014722943301b36c00805b0f4ccf142fc6961dfe Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 14 Apr 2023 09:02:20 -0700 Subject: [PATCH 68/71] Update x/ccv/consumer/keeper/validators.go Co-authored-by: Simon Noetzlin --- x/ccv/consumer/keeper/validators.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 12331badbc..2e6e07c7f8 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -112,7 +112,7 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p // If this is a previously standalone chain and infraction happened before the changeover was completed, // slash only on the standalone staking keeper. if k.IsPrevStandaloneChain() && infractionHeight < k.FirstConsumerHeight(ctx) { - k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, slashFactor, infraction) + k.standaloneStakingKeeper.Slash(ctx, addr, infractionHeight, power, slashFactor, stakingtypes.InfractionEmpty) return } From 256bbd3e512088a34f589dbe20f0cb8a8fc8fd89 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 14 Apr 2023 09:09:33 -0700 Subject: [PATCH 69/71] fix test --- x/ccv/consumer/keeper/validators_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/keeper/validators_test.go b/x/ccv/consumer/keeper/validators_test.go index 2a2a325bc8..b3bf37918d 100644 --- a/x/ccv/consumer/keeper/validators_test.go +++ b/x/ccv/consumer/keeper/validators_test.go @@ -175,7 +175,7 @@ func TestSlash(t *testing.T) { infractionHeight := int64(5) mocks.MockStakingKeeper.EXPECT().Slash( ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, int64(6), - sdk.MustNewDecFromStr("0.05"), stakingtypes.Downtime).Times(1) + sdk.MustNewDecFromStr("0.05"), stakingtypes.InfractionEmpty).Times(1) // We pass empty infraction to standalone staking keeper since it's not used // Also setup init genesis height s.t. infraction height is before first consumer height consumerKeeper.SetInitGenesisHeight(ctx, 4) From 9f36094ecca157407f04559b19ddf36cf28d599f Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 14 Apr 2023 09:36:30 -0700 Subject: [PATCH 70/71] rm dup method --- x/ccv/consumer/keeper/keeper.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 3004dc0cbc..d1aa2499b3 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -93,10 +93,6 @@ func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { k.standaloneStakingKeeper = sk } -func (k Keeper) IsPrevStandaloneChain() bool { - return k.standaloneStakingKeeper != nil -} - // Validates that the consumer keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { From 7b48350b17fd08014b09bf39f5c24421fa723a32 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 14 Apr 2023 09:41:12 -0700 Subject: [PATCH 71/71] Update keys_test.go --- x/ccv/consumer/types/keys_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index 83c83d1344..fc214380b9 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -30,9 +30,10 @@ func getAllKeyPrefixes() []byte { PendingDataPacketsByteKey, PreCCVByteKey, InitialValSetByteKey, - SmallestNonOptOutPowerByteKey, InitGenesisHeightByteKey, + SmallestNonOptOutPowerByteKey, StandaloneTransferChannelIDByteKey, + PrevStandaloneChainByteKey, HistoricalInfoBytePrefix, PacketMaturityTimeBytePrefix, HeightValsetUpdateIDBytePrefix, @@ -63,9 +64,10 @@ func getAllFullyDefinedKeys() [][]byte { PendingDataPacketsKey(), PreCCVKey(), InitialValSetKey(), - SmallestNonOptOutPowerKey(), InitGenesisHeightKey(), + SmallestNonOptOutPowerKey(), StandaloneTransferChannelIDKey(), + PrevStandaloneChainKey(), HistoricalInfoKey(0), PacketMaturityTimeKey(0, time.Time{}), HeightValsetUpdateIDKey(0),