diff --git a/docs/quality_assurance.md b/docs/quality_assurance.md
index 45691f7528..3143393c92 100644
--- a/docs/quality_assurance.md
+++ b/docs/quality_assurance.md
@@ -49,10 +49,10 @@ IBC packets:
| -- | ------- | ----------- | ------------ | ----------- | ------------- | ------- |
| 2.01 | Create IBC clients | `Scheduled` (ibc-go) | `Done` [TestCreateConsumerClient](../x/ccv/provider/keeper/proposal_test.go#117), [TestInitGenesis](../x/ccv/consumer/keeper/genesis_test.go#26) | `Done` [SetupTest](../tests/e2e/setup_test.go#39), [TestConsumerGenesis](../tests/e2e/channel_init_test.go#21) | `Future work` | `Scheduled` |
| 2.02 | Create CCV channel (handshake) | `Scheduled` (ibc-go) | `Done` [provider/ibc_module_test.go](../x/ccv/provider/ibc_module_test.go), [consumer/ibc_module_test.go](../x/ccv/consumer/ibc_module_test.go) | `Done` [SetupCCVChannel](../tests/e2e/setup_test.go#125) | `Future work` | `Scheduled` |
-| 2.03 | Sending IBC packets
[SendIBCPacket](../x/ccv/utils/utils.go#40) | `Scheduled` (ibc-go) | `NA` | `Done` [TestSendVSCMaturedPackets](../tests/e2e/valset_update_test.go#39), [TestSendSlashPacket](../tests/e2e/slashing_test.go#648) | `Done` | `Scheduled` |
+| 2.03 | Sending IBC packets | `Scheduled` (ibc-go) | `NA` | `Done` [TestSendVSCMaturedPackets](../tests/e2e/valset_update_test.go#39), [TestSendSlashPacket](../tests/e2e/slashing_test.go#648) | `Done` | `Scheduled` |
| 2.04 | Handling acknowledgments | `Scheduled` (ibc-go) | [Scheduled](https://github.com/cosmos/interchain-security/issues/362) | `Partial coverage` [TestOnAcknowledgementPacket](../x/ccv/consumer/keeper/relay_test.go#152), [TestSlashPacketAcknowldgement](../tests/e2e/slashing_test.go#258) | `Done` | `Scheduled` |
| 2.05 | Handling timeouts | `Scheduled` (ibc-go) | [Scheduled](https://github.com/cosmos/interchain-security/issues/362) |`NA` | `Future work` | `Scheduled` |
-| 2.06 | Handling IBC client expiration
- high priority| `Scheduled` (ibc-go) | `NA` | `NA` | `Future work` | `Scheduled` |
+| 2.06 | Handling IBC client expiration | `Scheduled` (ibc-go) | `NA` | `Done` [expired_client.go](../tests/e2e/expired_client.go) | `Future work` | `Scheduled` |
| 2.07 | ICS-20 channel creation | `Scheduled` (ibc-go) | `NA` | `Done` [SetupTransferChannel](../tests/e2e/setup_test.go#152) |`Future work` | `Scheduled` |
| 2.08 | ICS-20 transfer | `Scheduled` (ibc-go) | `NA` | `Done` [TestRewardsDistribution](../tests/e2e/distribution_test.go#17) | `NA` | `Scheduled` |
| 2.09 | Changes in IBC-GO testing suite | `Scheduled` (ibc-go) | `NA` | `NA` | `Partial coverage` | `NA` |
@@ -63,7 +63,7 @@ IBC packets:
| ID | Concern | Code Review | Unit Testing | E2E Testing | Diff. Testing | Testnet |
| -- | ------- | ----------- | ------------ | ----------- | ------------- | ------- |
-| 3.01 | Changes to staking module | `Done` | `Done` (Cosmos-SDK side) | `Partial coverage`
[unbonding_test.go](../tests/e2e/unbonding_test.go)
redelegation could be expanded, validator unbonding missing | `Partial coverage` | `Scheduled` |
+| 3.01 | Changes to staking module | `Done` | `Done` [unbonding_test.go](https://github.com/cosmos/cosmos-sdk/blob/interchain-security-rebase.0.45.6/x/staking/keeper/unbonding_test.go) | `Partial coverage`
[unbonding_test.go](../tests/e2e/unbonding_test.go)
redelegation could be expanded, validator unbonding missing | `Partial coverage` | `Scheduled` |
| 3.02 | Changes to slashing module | `Done` | `NA` | `Done`
[TestValidatorDowntime](../tests/e2e/slashing_test.go#L502)
| `Partial coverage` | `Scheduled` |
| 3.03 | Changes to evidence module | `Done` | `NA` | `Done`
[TestValidatorDoubleSigning](../tests/e2e/slashing_test.go#L584)
| `NA` | `Scheduled` |
diff --git a/proto/interchain_security/ccv/consumer/v1/consumer.proto b/proto/interchain_security/ccv/consumer/v1/consumer.proto
index ae2a2b7bad..d13dad2cc0 100644
--- a/proto/interchain_security/ccv/consumer/v1/consumer.proto
+++ b/proto/interchain_security/ccv/consumer/v1/consumer.proto
@@ -6,7 +6,6 @@ import "interchain_security/ccv/v1/ccv.proto";
option go_package = "github.com/cosmos/interchain-security/x/ccv/consumer/types";
import "google/protobuf/any.proto";
-import "cosmos/staking/v1beta1/staking.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/duration.proto";
@@ -69,14 +68,26 @@ message CrossChainValidator {
];
}
-// SlashRequest defines a slashing request for CCV consumer module
-message SlashRequest {
- interchain_security.ccv.v1.SlashPacketData packet = 1;
- cosmos.staking.v1beta1.InfractionType infraction = 2;
+// ConsumerPacketType indicates the consumer packet type.
+enum ConsumerPacketType {
+ option (gogoproto.goproto_enum_prefix) = false;
+
+ // UNSPECIFIED packet type
+ CONSUMER_PACKET_TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UnspecifiedPacket"];
+ // Slash packet
+ CONSUMER_PACKET_TYPE_SLASH = 1 [(gogoproto.enumvalue_customname) = "SlashPacket"];
+ // VSCMatured packet
+ CONSUMER_PACKET_TYPE_VSCM = 2 [(gogoproto.enumvalue_customname) = "VscMaturedPacket"];
+}
+
+// DataPacket is a data packet for a specific type of packet
+message DataPacket {
+ ConsumerPacketType type = 1;
+ bytes data = 2;
}
-// SlashRequests is a list of slash requests for CCV consumer module
-message SlashRequests {
- repeated SlashRequest requests = 1
+// DataPackets is a list of data packets
+message DataPackets {
+ repeated DataPacket list = 1
[ (gogoproto.nullable) = false ];
}
diff --git a/proto/interchain_security/ccv/consumer/v1/genesis.proto b/proto/interchain_security/ccv/consumer/v1/genesis.proto
index c71aecd64a..d0798b33dd 100644
--- a/proto/interchain_security/ccv/consumer/v1/genesis.proto
+++ b/proto/interchain_security/ccv/consumer/v1/genesis.proto
@@ -32,9 +32,6 @@ message GenesisState {
// OutstandingDowntimes nil on new chain, filled on restart.
repeated OutstandingDowntime outstanding_downtime_slashing = 10
[ (gogoproto.nullable) = false ];
- // PendingSlashRequests filled in on new chain, nil on restart.
- interchain_security.ccv.consumer.v1.SlashRequests pending_slash_requests = 11
- [ (gogoproto.nullable) = false ];
}
// MaturingVSCPacket defines the genesis information for the
diff --git a/tests/difference/core/driver/core_test.go b/tests/difference/core/driver/core_test.go
index 39542f846b..53d687d391 100644
--- a/tests/difference/core/driver/core_test.go
+++ b/tests/difference/core/driver/core_test.go
@@ -381,8 +381,8 @@ func (s *CoreSuite) TestAssumptions() {
s.T().Fatal(FAIL_MSG)
}
- // Consumer has no slash requests
- s.Require().Empty(s.consumerKeeper().GetPendingSlashRequests(s.ctx(C)))
+ // Consumer has no pending data packets
+ s.Require().Empty(s.consumerKeeper().GetPendingDataPackets(s.ctx(C)))
// Consumer has no maturities
s.consumerKeeper().IteratePacketMaturityTime(s.ctx(C),
diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go
index d3becc2912..4f6240dce1 100644
--- a/tests/difference/core/driver/setup.go
+++ b/tests/difference/core/driver/setup.go
@@ -482,7 +482,7 @@ func (b *Builder) createConsumerGenesis(tmConfig *ibctesting.TendermintConfig) *
consumertypes.DefaultHistoricalEntries,
consumertypes.DefaultConsumerUnbondingPeriod,
)
- return consumertypes.NewInitialGenesisState(providerClient, providerConsState, valUpdates, consumertypes.SlashRequests{}, params)
+ return consumertypes.NewInitialGenesisState(providerClient, providerConsState, valUpdates, params)
}
func (b *Builder) createLink() {
diff --git a/tests/e2e/README.md b/tests/e2e/README.md
index b8ad9d1970..2aa1ead3f8 100644
--- a/tests/e2e/README.md
+++ b/tests/e2e/README.md
@@ -12,6 +12,7 @@ E2e tests are categorized into files as follows:
- `distribution.go` - e2e tests for the _Reward Distribution_ sub-protocol
- `stop_consumer.go` - e2e tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - e2e tests for _normal operations_ of ICS enabled chains
+- `expired_client.go` - e2e tests for testing expired clients
- `instance_test.go` - ties the e2e test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback
To run the e2e tests defined in this repo on any arbitrary consumer and provider implementation, copy the pattern exemplified in `instance_test.go`
diff --git a/tests/e2e/channel_init.go b/tests/e2e/channel_init.go
index 044b6e5272..f202aaeba6 100644
--- a/tests/e2e/channel_init.go
+++ b/tests/e2e/channel_init.go
@@ -166,7 +166,7 @@ func (suite *CCVTestSuite) TestInitTimeout() {
suite.providerChain.NextBlock()
// increment time
- incrementTimeBy(suite, initTimeout)
+ incrementTime(suite, initTimeout)
// check whether the chain was removed
_, found = providerKeeper.GetConsumerClientId(suite.providerCtx(), chainID)
diff --git a/tests/e2e/common.go b/tests/e2e/common.go
index 5f0906c775..5fef1c3843 100644
--- a/tests/e2e/common.go
+++ b/tests/e2e/common.go
@@ -7,7 +7,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/interchain-security/testutil/e2e"
- consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/x/ccv/types"
"github.com/stretchr/testify/require"
@@ -17,6 +16,7 @@ import (
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
+ ibctm "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
)
@@ -212,29 +212,16 @@ func relayAllCommittedPackets(
// Note that it is expected for the provider unbonding period
// to be one day larger than the consumer unbonding period.
func incrementTimeByUnbondingPeriod(s *CCVTestSuite, chainType ChainType) {
- // Get unboding period from staking keeper
+ // Get unboding periods
providerUnbondingPeriod := s.providerApp.GetStakingKeeper().UnbondingTime(s.providerCtx())
consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerCtx())
- // Note: the assertions below are not strictly necessary, and rely on default values
- s.Require().Equal(consumertypes.DefaultConsumerUnbondingPeriod+24*time.Hour, providerUnbondingPeriod, "unexpected provider unbonding period")
- s.Require().Equal(consumertypes.DefaultConsumerUnbondingPeriod, consumerUnbondingPeriod, "unexpected consumer unbonding period")
var jumpPeriod time.Duration
if chainType == Provider {
jumpPeriod = providerUnbondingPeriod
} else {
jumpPeriod = consumerUnbondingPeriod
}
- // Make sure the clients do not expire
- jumpPeriod = jumpPeriod/4 + time.Hour
- for i := 0; i < 4; i++ {
- s.coordinator.IncrementTimeBy(jumpPeriod)
- // Update the provider client on the consumer
- err := s.path.EndpointA.UpdateClient()
- s.Require().NoError(err)
- // Update the consumer client on the provider
- err = s.path.EndpointB.UpdateClient()
- s.Require().NoError(err)
- }
+ incrementTime(s, jumpPeriod)
}
func checkStakingUnbondingOps(s *CCVTestSuite, id uint64, found bool, onHold bool, msgAndArgs ...interface{}) {
@@ -350,25 +337,74 @@ func (suite *CCVTestSuite) commitSlashPacket(ctx sdk.Context, packetData ccv.Sla
return channeltypes.CommitPacket(suite.consumerChain.App.AppCodec(), packet)
}
-// incrementTimeBy increments the overall time by jumpPeriod
-func incrementTimeBy(s *CCVTestSuite, jumpPeriod time.Duration) {
- // Get unboding period from staking keeper
- consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerChain.GetContext())
- split := 1
- trustingPeriodFraction := s.providerApp.GetProviderKeeper().GetTrustingPeriodFraction(s.providerCtx())
- if jumpPeriod > consumerUnbondingPeriod/time.Duration(trustingPeriodFraction) {
- // Make sure the clients do not expire
- split = 4
- jumpPeriod = jumpPeriod / 4
+// incrementTime increments the overall time by jumpPeriod
+// while updating to not expire the clients
+func incrementTime(s *CCVTestSuite, jumpPeriod time.Duration) {
+ // get trusting period of client on provider endpoint
+ cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), s.path.EndpointB.ClientID)
+ s.Require().True(ok)
+ providerEndpointTP := cs.(*ibctm.ClientState).TrustingPeriod
+ // get trusting period of client on consumer endpoint
+ cs, ok = s.consumerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.consumerCtx(), s.path.EndpointA.ClientID)
+ s.Require().True(ok)
+ consumerEndpointTP := cs.(*ibctm.ClientState).TrustingPeriod
+ // find the minimum trusting period
+ var minTP time.Duration
+ if providerEndpointTP < consumerEndpointTP {
+ minTP = providerEndpointTP
+ } else {
+ minTP = consumerEndpointTP
}
- for i := 0; i < split; i++ {
- s.coordinator.IncrementTimeBy(jumpPeriod)
- // Update the provider client on the consumer
+ // jumpStep is the maximum interval at which both clients are updated
+ jumpStep := minTP / 2
+ for jumpPeriod > 0 {
+ var step time.Duration
+ if jumpPeriod < jumpStep {
+ step = jumpPeriod
+ } else {
+ step = jumpStep
+ }
+ s.coordinator.IncrementTimeBy(step)
+ // update the provider client on the consumer
err := s.path.EndpointA.UpdateClient()
s.Require().NoError(err)
- // Update the consumer client on the provider
+ // update the consumer client on the provider
err = s.path.EndpointB.UpdateClient()
s.Require().NoError(err)
+ jumpPeriod -= step
+ }
+}
+
+// incrementTimeWithoutUpdate increments the overall time by jumpPeriod
+// without updating the client to the `noUpdate` chain
+func incrementTimeWithoutUpdate(s *CCVTestSuite, jumpPeriod time.Duration, noUpdate ChainType) {
+ var trustingPeriod time.Duration
+ var endpointToUpdate *ibctesting.Endpoint
+ if noUpdate == Consumer {
+ cs, ok := s.consumerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.consumerCtx(), s.path.EndpointA.ClientID)
+ s.Require().True(ok)
+ trustingPeriod = cs.(*ibctm.ClientState).TrustingPeriod
+ endpointToUpdate = s.path.EndpointA
+ } else {
+ cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), s.path.EndpointB.ClientID)
+ s.Require().True(ok)
+ trustingPeriod = cs.(*ibctm.ClientState).TrustingPeriod
+ endpointToUpdate = s.path.EndpointB
+ }
+ // jumpStep is the maximum interval at which the client on endpointToUpdate is updated
+ jumpStep := trustingPeriod / 2
+ for jumpPeriod > 0 {
+ var step time.Duration
+ if jumpPeriod < jumpStep {
+ step = jumpPeriod
+ } else {
+ step = jumpStep
+ }
+ s.coordinator.IncrementTimeBy(step)
+ // update the client
+ err := endpointToUpdate.UpdateClient()
+ s.Require().NoError(err)
+ jumpPeriod -= step
}
}
diff --git a/tests/e2e/expired_client.go b/tests/e2e/expired_client.go
new file mode 100644
index 0000000000..943350f1b0
--- /dev/null
+++ b/tests/e2e/expired_client.go
@@ -0,0 +1,277 @@
+package e2e
+
+import (
+ "time"
+
+ "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
+ clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
+ ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported"
+ ibctm "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
+ ibctesting "github.com/cosmos/ibc-go/v3/testing"
+ ccv "github.com/cosmos/interchain-security/x/ccv/types"
+ abci "github.com/tendermint/tendermint/abci/types"
+)
+
+// TestVSCPacketSendWithExpiredClient tests the provider sending VSCPackets
+// when the consumer client is expired
+func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
+ providerKeeper := s.providerApp.GetProviderKeeper()
+
+ s.SetupCCVChannel()
+
+ expireClient(s, Consumer)
+
+ // bond some tokens on provider to change validator powers
+ bondAmt := sdk.NewInt(1000000)
+ delAddr := s.providerChain.SenderAccount.GetAddress()
+ delegate(s, delAddr, bondAmt)
+
+ // try to send CCV packet to consumer
+ s.providerChain.NextBlock()
+
+ // check that the packet was added to the list of pending VSC packets
+ packets, found := providerKeeper.GetPendingVSCs(s.providerCtx(), s.consumerChain.ChainID)
+ s.Require().True(found, "no pending VSC packets found")
+ s.Require().Equal(1, len(packets), "unexpected number of pending VSC packets")
+
+ // try again to send CCV packet to consumer
+ s.providerChain.NextBlock()
+
+ // check that the packet is still in the list of pending VSC packets
+ packets, found = providerKeeper.GetPendingVSCs(s.providerCtx(), s.consumerChain.ChainID)
+ s.Require().True(found, "no pending VSC packets found")
+ s.Require().Equal(1, len(packets), "unexpected number of pending VSC packets")
+
+ // bond more tokens on provider to change validator powers
+ delegate(s, delAddr, bondAmt)
+
+ // try again to send CCV packets to consumer
+ s.providerChain.NextBlock()
+
+ // check that the packets are still in the list of pending VSC packets
+ packets, found = providerKeeper.GetPendingVSCs(s.providerCtx(), s.consumerChain.ChainID)
+ s.Require().True(found, "no pending VSC packets found")
+ s.Require().Equal(2, len(packets), "unexpected number of pending VSC packets")
+
+ // upgrade expired client to the consumer
+ upgradeExpiredClient(s, Consumer)
+
+ // go to next block
+ s.providerChain.NextBlock()
+
+ // check that the packets are not in the list of pending VSC packets
+ _, found = providerKeeper.GetPendingVSCs(s.providerCtx(), s.consumerChain.ChainID)
+ s.Require().False(found, "pending VSC packets found")
+
+ // check that validator updates work
+ // - bond more tokens on provider to change validator powers
+ delegate(s, delAddr, bondAmt)
+ // - send CCV packet to consumer
+ s.providerChain.NextBlock()
+ // - relay all VSC packet from provider to consumer
+ relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 3)
+ // - increment time so that the unbonding period ends on the consumer
+ incrementTimeByUnbondingPeriod(s, Consumer)
+ // - relay all VSCMatured packet from consumer to provider
+ relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 3)
+}
+
+// TestConsumerPacketSendExpiredClient tests the consumer sending packets
+// when the provider client is expired
+func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
+ providerKeeper := s.providerApp.GetProviderKeeper()
+ consumerKeeper := s.consumerApp.GetConsumerKeeper()
+
+ s.SetupCCVChannel()
+
+ // bond some tokens on provider to change validator powers
+ bondAmt := sdk.NewInt(1000000)
+ delAddr := s.providerChain.SenderAccount.GetAddress()
+ delegate(s, delAddr, bondAmt)
+
+ // send CCV packet to consumer
+ s.providerChain.NextBlock()
+
+ // bond more tokens on provider to change validator powers
+ delegate(s, delAddr, bondAmt)
+
+ // send CCV packets to consumer
+ s.providerChain.NextBlock()
+
+ // check that the packets are not in the list of pending VSC packets
+ _, found := providerKeeper.GetPendingVSCs(s.providerCtx(), s.consumerChain.ChainID)
+ s.Require().False(found, "pending VSC packets found")
+
+ // relay all VSC packet from provider to consumer
+ relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 2)
+
+ // expire client to provider
+ expireClient(s, Provider)
+
+ // check that the client to the consumer is active
+ checkClientExpired(s, Consumer, false)
+
+ // increment time so that the unbonding period ends on the consumer;
+ // do not try to update the client to the provider since it's expired
+ consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerCtx())
+ incrementTimeWithoutUpdate(s, consumerUnbondingPeriod+time.Hour, Provider)
+
+ // check that the packets were added to the list of pending data packets
+ dataPackets, found := consumerKeeper.GetPendingDataPackets(s.consumerCtx())
+ s.Require().True(found)
+ s.Require().Equal(2, len(dataPackets.GetList()), "unexpected number of pending data packets")
+
+ // try to send slash packet for downtime infraction
+ addr := ed25519.GenPrivKey().PubKey().Address()
+ val := abci.Validator{Address: addr}
+ consumerKeeper.SendSlashPacket(s.consumerCtx(), val, 2, stakingtypes.Downtime)
+ // try to send slash packet for the same downtime infraction
+ consumerKeeper.SendSlashPacket(s.consumerCtx(), val, 3, stakingtypes.Downtime)
+ // try to send slash packet for the double-sign infraction
+ consumerKeeper.SendSlashPacket(s.consumerCtx(), val, 3, stakingtypes.DoubleSign)
+
+ // check that the packets were added to the list of pending data packets
+ dataPackets, found = consumerKeeper.GetPendingDataPackets(s.consumerCtx())
+ s.Require().True(found)
+ s.Require().Equal(4, len(dataPackets.GetList()), "unexpected number of pending data packets")
+
+ // upgrade expired client to the consumer
+ upgradeExpiredClient(s, Provider)
+
+ // go to next block to trigger SendPendingDataPackets
+ s.consumerChain.NextBlock()
+
+ // check that the list of pending data packets is emptied
+ dataPackets, found = consumerKeeper.GetPendingDataPackets(s.consumerCtx())
+ s.Require().False(found)
+ s.Require().Equal(0, len(dataPackets.GetList()), "unexpected number of pending data packets")
+
+ // relay all packet from consumer to provider
+ relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 4)
+
+ // check that everything works
+ // - bond more tokens on provider to change validator powers
+ delegate(s, delAddr, bondAmt)
+ // - send CCV packet to consumer
+ s.providerChain.NextBlock()
+ // - relay 1 VSC packet from provider to consumer
+ relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 1)
+ // - increment time so that the unbonding period ends on the provider
+ incrementTimeByUnbondingPeriod(s, Consumer)
+ // - relay 1 VSCMatured packet from consumer to provider
+ relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1)
+}
+
+// expireClient expires the client to the `clientTo` chain
+func expireClient(s *CCVTestSuite, clientTo ChainType) {
+ var hostEndpoint *ibctesting.Endpoint
+ var hostChain *ibctesting.TestChain
+ if clientTo == Consumer {
+ hostEndpoint = s.path.EndpointB
+ hostChain = s.providerChain
+ } else {
+ hostEndpoint = s.path.EndpointA
+ hostChain = s.consumerChain
+ }
+ cs, ok := hostChain.App.GetIBCKeeper().ClientKeeper.GetClientState(hostChain.GetContext(), hostEndpoint.ClientID)
+ s.Require().True(ok)
+ trustingPeriod := cs.(*ibctm.ClientState).TrustingPeriod
+
+ // increment time without updating the `clientTo` client
+ incrementTimeWithoutUpdate(s, trustingPeriod+time.Hour, clientTo)
+
+ // check that the client is not active
+ checkClientExpired(s, clientTo, true)
+}
+
+// checkClientIsExpired checks whether the client to `clientTo` is expired
+func checkClientExpired(s *CCVTestSuite, clientTo ChainType, expectedExpired bool) {
+ var hostEndpoint *ibctesting.Endpoint
+ var hostChain *ibctesting.TestChain
+ if clientTo == Consumer {
+ hostEndpoint = s.path.EndpointB
+ hostChain = s.providerChain
+ } else {
+ hostEndpoint = s.path.EndpointA
+ hostChain = s.consumerChain
+ }
+ // check that the client to the consumer is not active
+ cs, ok := hostChain.App.GetIBCKeeper().ClientKeeper.GetClientState(hostChain.GetContext(), hostEndpoint.ClientID)
+ s.Require().True(ok)
+ clientStore := hostChain.App.GetIBCKeeper().ClientKeeper.ClientStore(hostChain.GetContext(), hostEndpoint.ClientID)
+ status := cs.Status(hostChain.GetContext(), clientStore, hostChain.App.AppCodec())
+ if expectedExpired {
+ s.Require().NotEqual(ibcexported.Active, status, "client is active")
+ } else {
+ s.Require().Equal(ibcexported.Active, status, "client is not active")
+ }
+}
+
+// upgradeExpiredClient upgrades an expired client to `clientTo`
+func upgradeExpiredClient(s *CCVTestSuite, clientTo ChainType) {
+ subjectPath := s.path
+ substitutePath := ibctesting.NewPath(s.consumerChain, s.providerChain)
+ var subject, subjectCounterparty string
+ var hostNewEndpoint, targetNewEndpoint *ibctesting.Endpoint
+ var hostChain *ibctesting.TestChain
+ var targetChain *ibctesting.TestChain
+ if clientTo == Consumer {
+ subject = subjectPath.EndpointB.ClientID // client to consumer
+ subjectCounterparty = subjectPath.EndpointA.ClientID // client to provider
+ hostNewEndpoint = substitutePath.EndpointB
+ targetNewEndpoint = substitutePath.EndpointA
+ hostChain = s.providerChain
+ targetChain = s.consumerChain
+ } else {
+ subject = subjectPath.EndpointA.ClientID // client to provider
+ subjectCounterparty = subjectPath.EndpointB.ClientID // client to consumer
+ hostNewEndpoint = substitutePath.EndpointA
+ targetNewEndpoint = substitutePath.EndpointB
+ hostChain = s.consumerChain
+ targetChain = s.providerChain
+ }
+
+ subjectClientState := hostChain.GetClientState(subject)
+
+ // create substitute client with same unbonding period
+ hostTmConfig, ok := hostNewEndpoint.ClientConfig.(*ibctesting.TendermintConfig)
+ s.Require().True(ok)
+ hostTmConfig.UnbondingPeriod = subjectClientState.(*ibctm.ClientState).UnbondingPeriod
+ hostTmConfig.TrustingPeriod = subjectClientState.(*ibctm.ClientState).TrustingPeriod
+ targetTmConfig, ok := targetNewEndpoint.ClientConfig.(*ibctesting.TendermintConfig)
+ s.Require().True(ok)
+ subjectCounterpartyCS := targetChain.GetClientState(subjectCounterparty)
+ targetTmConfig.UnbondingPeriod = subjectCounterpartyCS.(*ibctm.ClientState).UnbondingPeriod
+ targetTmConfig.TrustingPeriod = subjectCounterpartyCS.(*ibctm.ClientState).TrustingPeriod
+ s.coordinator.SetupClients(substitutePath)
+ substitute := hostNewEndpoint.ClientID
+
+ // update substitute twice
+ err := hostNewEndpoint.UpdateClient()
+ s.Require().NoError(err)
+ err = hostNewEndpoint.UpdateClient()
+ s.Require().NoError(err)
+ substituteClientState := hostChain.GetClientState(substitute)
+
+ tmClientState, ok := subjectClientState.(*ibctm.ClientState)
+ s.Require().True(ok)
+ tmClientState.AllowUpdateAfterMisbehaviour = true
+ tmClientState.AllowUpdateAfterExpiry = true
+ tmClientState.FrozenHeight = tmClientState.LatestHeight
+ hostChain.App.GetIBCKeeper().ClientKeeper.SetClientState(hostChain.GetContext(), subject, tmClientState)
+
+ tmClientState, ok = substituteClientState.(*ibctm.ClientState)
+ s.Require().True(ok)
+ tmClientState.AllowUpdateAfterMisbehaviour = true
+ tmClientState.AllowUpdateAfterExpiry = true
+ hostChain.App.GetIBCKeeper().ClientKeeper.SetClientState(hostChain.GetContext(), substitute, tmClientState)
+
+ content := clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute)
+
+ updateProp, ok := content.(*clienttypes.ClientUpdateProposal)
+ s.Require().True(ok)
+ err = hostChain.App.GetIBCKeeper().ClientKeeper.ClientUpdateProposal(hostChain.GetContext(), updateProp)
+ s.Require().NoError(err)
+}
diff --git a/tests/e2e/slashing.go b/tests/e2e/slashing.go
index f7a6736fae..b870f91cea 100644
--- a/tests/e2e/slashing.go
+++ b/tests/e2e/slashing.go
@@ -650,7 +650,8 @@ func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
suite.Require().EqualValues(expCommit, gotCommit)
}
-// TestSendSlashPacket tests the functionality of SendSlashPacket and asserts state changes related to that method
+// TestSendSlashPacket tests the functionality of SendSlashPacket
+// and asserts state changes related to that method
func (suite *CCVTestSuite) TestSendSlashPacket() {
suite.SetupCCVChannel()
@@ -690,9 +691,11 @@ func (suite *CCVTestSuite) TestSendSlashPacket() {
consumerKeeper.SendSlashPacket(ctx, sv.validator, 0, sv.infraction)
}
- // verify that all requests are stored
- requests := consumerKeeper.GetPendingSlashRequests(ctx)
- suite.Require().Len(requests.GetRequests(), 16)
+ // verify that all requests are stored except for
+ // the downtime slash request duplicates
+ dataPackets, found := consumerKeeper.GetPendingDataPackets(ctx)
+ suite.Require().True(found)
+ suite.Require().Len(dataPackets.GetList(), 12)
// save consumer next sequence
seq, _ := consumerIBCKeeper.ChannelKeeper.GetNextSequenceSend(ctx, ccv.ConsumerPortID, channelID)
@@ -700,35 +703,29 @@ func (suite *CCVTestSuite) TestSendSlashPacket() {
// establish ccv channel by sending an empty VSC packet to consumer endpoint
suite.SendEmptyVSCPacket()
- // check that each pending slash requests is sent once
- // and that the downtime slash request duplicates are skipped (due to the outstanding downtime flag)
- for i := 0; i < 16; i++ {
+ // check that each pending data packet is sent once
+ for i := 0; i < 12; i++ {
commit := consumerIBCKeeper.ChannelKeeper.GetPacketCommitment(ctx, ccv.ConsumerPortID, channelID, seq+uint64(i))
- if i > 11 {
- suite.Require().Nil(commit)
- continue
- }
suite.Require().NotNil(commit)
}
// check that outstanding downtime flags
// are all set to true for validators slashed for downtime requests
- for _, r := range requests.GetRequests() {
- downtime := r.Infraction == stakingtypes.Downtime
- if downtime {
- consAddr := sdk.ConsAddress(r.Packet.Validator.Address)
- suite.Require().True(consumerKeeper.OutstandingDowntime(ctx, consAddr))
- }
+ for i := 0; i < 4; i++ {
+ consAddr := sdk.ConsAddress(slashedVals[i].validator.Address)
+ suite.Require().True(consumerKeeper.OutstandingDowntime(ctx, consAddr))
}
- // check that pending slash requests get cleared after being sent
- requests = consumerKeeper.GetPendingSlashRequests(ctx)
- suite.Require().Len(requests.GetRequests(), 0)
+ // check that pending data packets get cleared after being sent
+ dataPackets, found = consumerKeeper.GetPendingDataPackets(ctx)
+ suite.Require().False(found)
+ suite.Require().Len(dataPackets.GetList(), 0)
// check that slash requests aren't stored when channel is established
consumerKeeper.SendSlashPacket(ctx, abci.Validator{}, 0, stakingtypes.Downtime)
consumerKeeper.SendSlashPacket(ctx, abci.Validator{}, 0, stakingtypes.DoubleSign)
- requests = consumerKeeper.GetPendingSlashRequests(ctx)
- suite.Require().Len(requests.GetRequests(), 0)
+ dataPackets, found = consumerKeeper.GetPendingDataPackets(ctx)
+ suite.Require().False(found)
+ suite.Require().Len(dataPackets.GetList(), 0)
}
diff --git a/tests/e2e/stop_consumer.go b/tests/e2e/stop_consumer.go
index a14c6e413d..faeb35606f 100644
--- a/tests/e2e/stop_consumer.go
+++ b/tests/e2e/stop_consumer.go
@@ -77,7 +77,7 @@ func (s *CCVTestSuite) TestStopConsumerChain() {
func(suite *CCVTestSuite) error {
providerKeeper.SetSlashAcks(s.providerCtx(), consumerChainID, []string{"validator-1", "validator-2", "validator-3"})
providerKeeper.SetLockUnbondingOnTimeout(s.providerCtx(), consumerChainID)
- providerKeeper.AppendPendingVSC(s.providerCtx(), consumerChainID, ccv.ValidatorSetChangePacketData{ValsetUpdateId: 1})
+ providerKeeper.AppendPendingVSCs(s.providerCtx(), consumerChainID, ccv.ValidatorSetChangePacketData{ValsetUpdateId: 1})
return nil
},
},
diff --git a/tests/e2e/unbonding.go b/tests/e2e/unbonding.go
index 566a0a130e..9763697f06 100644
--- a/tests/e2e/unbonding.go
+++ b/tests/e2e/unbonding.go
@@ -9,8 +9,8 @@ import (
ccv "github.com/cosmos/interchain-security/x/ccv/types"
)
-// TestUndelegationNormalOperation tests that undelegations complete after
-// the unbonding period elapses on both the consumer and provider, without
+// TestUndelegationNormalOperation tests that undelegations complete after
+// the unbonding period elapses on both the consumer and provider, without
// VSC packets timing out.
func (s *CCVTestSuite) TestUndelegationNormalOperation() {
unbondConsumer := func(expectedPackets int) {
@@ -159,7 +159,7 @@ func (s *CCVTestSuite) TestUndelegationVscTimeout() {
"unexpected balance after provider unbonding")
// increment time
- incrementTimeBy(s, vscTimeout)
+ incrementTime(s, vscTimeout)
// check whether the chain was removed
chainID := s.consumerChain.ChainID
diff --git a/tests/e2e/valset_update.go b/tests/e2e/valset_update.go
index 22fe4e5cc2..8e352809fa 100644
--- a/tests/e2e/valset_update.go
+++ b/tests/e2e/valset_update.go
@@ -75,7 +75,7 @@ func (suite *CCVTestSuite) TestSendVSCMaturedPackets() {
suite.Require().True(ack.Success(), "OnRecvVSCPacket did not return a Success Acknowledgment")
// increase time
- incrementTimeBy(suite, time.Hour)
+ incrementTime(suite, time.Hour)
// update time and send second packet
pd.ValidatorUpdates[0].Power = 15
@@ -87,7 +87,7 @@ func (suite *CCVTestSuite) TestSendVSCMaturedPackets() {
suite.Require().True(ack.Success(), "OnRecvVSCPacket did not return a Success Acknowledgment")
// increase time
- incrementTimeBy(suite, 24*time.Hour)
+ incrementTime(suite, 24*time.Hour)
// update time and send third packet
pd.ValidatorUpdates[1].Power = 40
@@ -101,7 +101,7 @@ func (suite *CCVTestSuite) TestSendVSCMaturedPackets() {
// increase time such that first two packets are unbonded but third is not.
unbondingPeriod := consumerKeeper.GetUnbondingPeriod(suite.consumerChain.GetContext())
// increase time
- incrementTimeBy(suite, unbondingPeriod-time.Hour)
+ incrementTime(suite, unbondingPeriod-time.Hour)
err = consumerKeeper.SendVSCMaturedPackets(suite.consumerChain.GetContext())
suite.Require().NoError(err)
diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go
index e06c5c4ab7..0320c719e7 100644
--- a/x/ccv/consumer/keeper/genesis.go
+++ b/x/ccv/consumer/keeper/genesis.go
@@ -176,7 +176,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt
panic("provider consensus state is not tendermint consensus state")
}
// export client states and pending slashing requests into a new chain genesis
- genesis = consumertypes.NewInitialGenesisState(tmCs, tmConsState, valset, k.GetPendingSlashRequests(ctx), params)
+ genesis = consumertypes.NewInitialGenesisState(tmCs, tmConsState, valset, params)
}
return
diff --git a/x/ccv/consumer/keeper/genesis_test.go b/x/ccv/consumer/keeper/genesis_test.go
index 9640fe70d2..139446e7ea 100644
--- a/x/ccv/consumer/keeper/genesis_test.go
+++ b/x/ccv/consumer/keeper/genesis_test.go
@@ -5,7 +5,6 @@ import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
- stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
testkeeper "github.com/cosmos/interchain-security/testutil/keeper"
consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper"
@@ -41,9 +40,6 @@ func TestInitGenesis(t *testing.T) {
// create consensus state using a single validator
consensusState := testutil.GetConsensusState(clientID, time.Time{}, validator)
- slashRequests := consumertypes.SlashRequests{
- Requests: []consumertypes.SlashRequest{{Infraction: stakingtypes.Downtime}},
- }
matPacket := consumertypes.MaturingVSCPacket{
VscId: uint64(1),
MaturityTime: uint64(time.Now().UnixNano()),
@@ -76,7 +72,7 @@ func TestInitGenesis(t *testing.T) {
)
},
genesis: consumertypes.NewInitialGenesisState(testutil.GetClientState(""), consensusState,
- []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(validator)}, slashRequests, params),
+ []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(validator)}, params),
assertStates: func(ctx sdk.Context, ck consumerkeeper.Keeper, gs *consumertypes.GenesisState) {
require.Equal(t, gs.Params, ck.GetParams(ctx))
@@ -149,9 +145,6 @@ func TestExportGenesis(t *testing.T) {
channelID := "channelID"
// define the states exported into genesis
- slashRequests := consumertypes.SlashRequests{
- Requests: []consumertypes.SlashRequest{{Infraction: stakingtypes.Downtime}},
- }
restartHeight := uint64(0)
matPacket := consumertypes.MaturingVSCPacket{
VscId: uint64(1),
@@ -192,10 +185,6 @@ func TestExportGenesis(t *testing.T) {
require.NoError(t, err)
ck.SetCCValidator(ctx, cVal)
ck.SetProviderClientID(ctx, clientID)
- ck.SetPendingSlashRequests(
- ctx,
- slashRequests,
- )
// set the mock calls executed during the export
gomock.InOrder(
@@ -205,7 +194,7 @@ func TestExportGenesis(t *testing.T) {
},
expGenesis: consumertypes.NewInitialGenesisState(testutil.GetClientState(""), consensusState,
- []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(validator)}, slashRequests, params),
+ []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(validator)}, params),
},
{
name: "export a chain that has an established CCV channel",
diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go
index ca576e1fb4..932d744e8e 100644
--- a/x/ccv/consumer/keeper/keeper.go
+++ b/x/ccv/consumer/keeper/keeper.go
@@ -393,43 +393,42 @@ func (k Keeper) GetAllCCValidator(ctx sdk.Context) (validators []types.CrossChai
return validators
}
-// SetPendingSlashRequests sets the pending slash requests in store
-func (k Keeper) SetPendingSlashRequests(ctx sdk.Context, requests types.SlashRequests) {
+// SetPendingDataPackets sets the pending data packets in store
+func (k Keeper) SetPendingDataPackets(ctx sdk.Context, dataPackets types.DataPackets) {
store := ctx.KVStore(k.storeKey)
- bz, err := requests.Marshal()
+ bz, err := dataPackets.Marshal()
if err != nil {
panic(fmt.Errorf("failed to encode slash request json: %w", err))
}
- store.Set([]byte{types.PendingSlashRequestsBytePrefix}, bz)
+ store.Set([]byte{types.PendingDataPacketsBytePrefix}, bz)
}
-// GetPendingSlashRequest returns the pending slash requests in store
-func (k Keeper) GetPendingSlashRequests(ctx sdk.Context) types.SlashRequests {
+// GetPendingDataPackets returns the pending data packets from the store
+func (k Keeper) GetPendingDataPackets(ctx sdk.Context) (dataPackets types.DataPackets, found bool) {
store := ctx.KVStore(k.storeKey)
- bz := store.Get([]byte{types.PendingSlashRequestsBytePrefix})
+ bz := store.Get([]byte{types.PendingDataPacketsBytePrefix})
if bz == nil {
- return types.SlashRequests{}
+ return types.DataPackets{}, false
}
- var sr types.SlashRequests
- err := sr.Unmarshal(bz)
+ err := dataPackets.Unmarshal(bz)
if err != nil {
- panic(fmt.Errorf("failed to decode slash request json: %w", err))
+ panic(fmt.Errorf("failed to unmarshal pending data packets: %w", err))
}
- return sr
+ return dataPackets, true
}
-// ClearPendingSlashRequests clears the pending slash requests in store
-func (k Keeper) DeletePendingSlashRequests(ctx sdk.Context) {
+// DeletePendingDataPackets clears the pending data packets in store
+func (k Keeper) DeletePendingDataPackets(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
- store.Delete([]byte{types.PendingSlashRequestsBytePrefix})
+ store.Delete([]byte{types.PendingDataPacketsBytePrefix})
}
-// AppendPendingSlashRequests appends the given slash request to the pending slash requests in store
-func (k Keeper) AppendPendingSlashRequests(ctx sdk.Context, req types.SlashRequest) {
- sr := k.GetPendingSlashRequests(ctx)
- srArray := sr.GetRequests()
- srArray = append(srArray, req)
- k.SetPendingSlashRequests(ctx, types.SlashRequests{Requests: srArray})
+// AppendPendingDataPacket appends the given data packet to the pending data packets in store
+func (k Keeper) AppendPendingDataPacket(ctx sdk.Context, dataPacket types.DataPacket) {
+ dp, _ := k.GetPendingDataPackets(ctx)
+ dpArray := dp.GetList()
+ dpArray = append(dpArray, dataPacket)
+ k.SetPendingDataPackets(ctx, types.DataPackets{List: dpArray})
}
diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go
index 431f0b6dd5..7e258ab45f 100644
--- a/x/ccv/consumer/keeper/keeper_test.go
+++ b/x/ccv/consumer/keeper/keeper_test.go
@@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
+ stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
conntypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
testkeeper "github.com/cosmos/interchain-security/testutil/keeper"
"github.com/cosmos/interchain-security/x/ccv/consumer/types"
@@ -153,40 +154,63 @@ func TestCrossChainValidator(t *testing.T) {
require.False(t, found)
}
-// TestPendingSlashRequests tests the getter, setter, appending method, and deletion method for pending slash requests
-func TestPendingSlashRequests(t *testing.T) {
+func TestPendingDataPackets(t *testing.T) {
consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()
- // prepare test setup by storing 10 pending slash requests
- requests := []types.SlashRequest{}
- for i := 0; i < 10; i++ {
- requests = append(requests, types.SlashRequest{})
- consumerKeeper.SetPendingSlashRequests(ctx, types.SlashRequests{Requests: requests})
+ // prepare test setup
+ dataPackets := []types.DataPacket{
+ {
+ Type: types.VscMaturedPacket,
+ Data: ccv.NewVSCMaturedPacketData(1).GetBytes(),
+ },
+ {
+ Type: types.VscMaturedPacket,
+ Data: ccv.NewVSCMaturedPacketData(2).GetBytes(),
+ },
+ {
+ Type: types.SlashPacket,
+ Data: ccv.NewSlashPacketData(
+ abci.Validator{Address: ed25519.GenPrivKey().PubKey().Address(), Power: int64(0)},
+ 3,
+ stakingtypes.DoubleSign,
+ ).GetBytes(),
+ },
+ {
+ Type: types.VscMaturedPacket,
+ Data: ccv.NewVSCMaturedPacketData(3).GetBytes(),
+ },
}
+ consumerKeeper.SetPendingDataPackets(ctx, types.DataPackets{List: dataPackets})
- // test set, append and clear operations
- testCases := []struct {
- operation func()
- expLen int
- }{{
- operation: func() {},
- expLen: 10,
- }, {
- operation: func() { consumerKeeper.AppendPendingSlashRequests(ctx, types.SlashRequest{}) },
- expLen: 11,
- }, {
- operation: func() { consumerKeeper.DeletePendingSlashRequests(ctx) },
- expLen: 0,
- },
- }
+ storedDataPackets, found := consumerKeeper.GetPendingDataPackets(ctx)
+ require.True(t, found)
+ require.Equal(t, dataPackets, storedDataPackets.List)
- for _, tc := range testCases {
- tc.operation()
- requests := consumerKeeper.GetPendingSlashRequests(ctx)
- require.Len(t, requests.Requests, tc.expLen)
- }
+ slashPacket := ccv.NewSlashPacketData(
+ abci.Validator{Address: ed25519.GenPrivKey().PubKey().Address(),
+ Power: int64(2)},
+ uint64(4),
+ stakingtypes.Downtime,
+ )
+ dataPackets = append(dataPackets, types.DataPacket{Type: types.SlashPacket, Data: slashPacket.GetBytes()})
+ consumerKeeper.AppendPendingDataPacket(ctx, dataPackets[len(dataPackets)-1])
+ storedDataPackets, found = consumerKeeper.GetPendingDataPackets(ctx)
+ require.True(t, found)
+ require.Equal(t, dataPackets, storedDataPackets.List)
+
+ vscMaturedPakcet := ccv.NewVSCMaturedPacketData(4)
+ dataPackets = append(dataPackets, types.DataPacket{Type: types.VscMaturedPacket, Data: vscMaturedPakcet.GetBytes()})
+ consumerKeeper.AppendPendingDataPacket(ctx, dataPackets[len(dataPackets)-1])
+ storedDataPackets, found = consumerKeeper.GetPendingDataPackets(ctx)
+ require.True(t, found)
+ require.Equal(t, dataPackets, storedDataPackets.List)
+
+ consumerKeeper.DeletePendingDataPackets(ctx)
+ storedDataPackets, found = consumerKeeper.GetPendingDataPackets(ctx)
+ require.False(t, found)
+ require.Len(t, storedDataPackets.List, 0)
}
// TestVerifyProviderChain tests the VerifyProviderChain method for the consumer keeper
diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go
index 83692c7eef..dd9d6ac2b5 100644
--- a/x/ccv/consumer/keeper/relay.go
+++ b/x/ccv/consumer/keeper/relay.go
@@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
+ clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
"github.com/cosmos/interchain-security/x/ccv/consumer/types"
@@ -34,8 +35,8 @@ func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, new
// the first packet from the provider chain
// - mark the CCV channel as established
k.SetProviderChannel(ctx, packet.DestinationChannel)
- // - send pending slash requests in states
- k.SendPendingSlashRequests(ctx)
+ // - send pending data packets
+ k.SendPendingDataPackets(ctx, packet.DestinationChannel)
}
// Set pending changes by accumulating changes from this packet with all prior changes
var pendingChanges []abci.ValidatorUpdate
@@ -84,6 +85,12 @@ func (k Keeper) SendVSCMaturedPackets(ctx sdk.Context) error {
return nil
}
+ // try sending pending data packets first
+ if clientExpired := k.SendPendingDataPackets(ctx, channelID); clientExpired {
+ // the client is expired; try again later
+ return nil
+ }
+
store := ctx.KVStore(k.storeKey)
maturityIterator := sdk.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix})
defer maturityIterator.Close()
@@ -93,11 +100,11 @@ func (k Keeper) SendVSCMaturedPackets(ctx sdk.Context) error {
for maturityIterator.Valid() {
vscId := types.IdFromPacketMaturityTimeKey(maturityIterator.Key())
if currentTime >= binary.BigEndian.Uint64(maturityIterator.Value()) {
- // send VSCMatured packet
- // - construct validator set change packet data
+ // construct validator set change packet data
packetData := ccv.NewVSCMaturedPacketData(vscId)
- // - send packet over IBC
- err := utils.SendIBCPacket(
+
+ // prepare to send the packetData to the consumer
+ packet, channelCap, err := utils.PrepareIBCPacketSend(
ctx,
k.scopedKeeper,
k.channelKeeper,
@@ -107,8 +114,26 @@ func (k Keeper) SendVSCMaturedPackets(ctx sdk.Context) error {
k.GetCCVTimeoutPeriod(ctx),
)
if err != nil {
+ // something went wrong when preparing the packet
return err
}
+
+ // send packet over IBC channel
+ err = k.channelKeeper.SendPacket(ctx, channelCap, packet)
+ if err != nil {
+ // note that the client could be expired
+ if clienttypes.ErrClientNotActive.Is(err) {
+ // IBC client expired:
+ // append the VSCMatured packet data to pending data packets
+ // to be sent once the client is upgraded
+ k.AppendPendingDataPacket(ctx, types.DataPacket{
+ Type: types.VscMaturedPacket,
+ Data: packetData.GetBytes(),
+ })
+ } else {
+ return err
+ }
+ }
k.DeletePacketMaturityTime(ctx, vscId)
} else {
break
@@ -128,22 +153,42 @@ func (k Keeper) SendSlashPacket(ctx sdk.Context, validator abci.Validator, valse
return
}
+ if downtime {
+ // set outstanding downtime to not send multiple
+ // slashing requests for the same downtime infraction
+ k.SetOutstandingDowntime(ctx, consAddr)
+ }
+
// construct slash packet data
packetData := ccv.NewSlashPacketData(validator, valsetUpdateID, infraction)
// check that provider channel is established
- // if not, append slashing packet to pending slash requests
- channelID, ok := k.GetProviderChannel(ctx)
- if !ok {
- k.AppendPendingSlashRequests(ctx, types.SlashRequest{
- Packet: &packetData,
- Infraction: infraction},
- )
+ channelID, found := k.GetProviderChannel(ctx)
+ if !found {
+ // CCV channel not established:
+ // append the Slash packet data to pending data packets
+ // to be sent once the CCV channel is established
+ k.AppendPendingDataPacket(ctx, types.DataPacket{
+ Type: types.SlashPacket,
+ Data: packetData.GetBytes(),
+ })
return
}
- // send packet over IBC
- err := utils.SendIBCPacket(
+ // try sending pending data packets first
+ if clientExpired := k.SendPendingDataPackets(ctx, channelID); clientExpired {
+ // IBC client expired:
+ // append the Slash packet data to pending data packets
+ // to be sent once the client is upgraded
+ k.AppendPendingDataPacket(ctx, types.DataPacket{
+ Type: types.SlashPacket,
+ Data: packetData.GetBytes(),
+ })
+ return
+ }
+
+ // prepare to send the packetData to the consumer
+ packet, channelCap, err := utils.PrepareIBCPacketSend(
ctx,
k.scopedKeeper,
k.channelKeeper,
@@ -153,55 +198,68 @@ func (k Keeper) SendSlashPacket(ctx sdk.Context, validator abci.Validator, valse
k.GetCCVTimeoutPeriod(ctx),
)
if err != nil {
- panic(err)
+ // something went wrong when preparing the packet
+ panic(fmt.Errorf("packet could not be prepared for IBC send: %w", err))
}
- // set outstanding downtime if slash request sent is for downtime
- if downtime {
- k.SetOutstandingDowntime(ctx, consAddr)
+ // send packet over IBC channel
+ err = k.channelKeeper.SendPacket(ctx, channelCap, packet)
+ if err != nil {
+ // note that the client could be expired
+ if clienttypes.ErrClientNotActive.Is(err) {
+ // IBC client expired:
+ // append the Slash packet data to pending data packets
+ // to be sent once the client is upgraded
+ k.AppendPendingDataPacket(ctx, types.DataPacket{
+ Type: types.SlashPacket,
+ Data: packetData.GetBytes(),
+ })
+ } else {
+ // something went wrong when sending the packet
+ panic(fmt.Errorf("packet could not be sent over IBC: %w", err))
+ }
}
}
-// SendPendingSlashRequests iterates over the stored pending slash requests in reverse order
-// and sends the embedded slash packets to the provider chain
-func (k Keeper) SendPendingSlashRequests(ctx sdk.Context) {
- channelID, ok := k.GetProviderChannel(ctx)
- if !ok {
- panic(fmt.Errorf("%s: CCV channel not set", channeltypes.ErrChannelNotFound))
+// SendPendingDataPackets sends the stored pending data packet to the provider chain.
+// Returns true if the client is expired.
+func (k Keeper) SendPendingDataPackets(ctx sdk.Context, channelID string) (clientExpired bool) {
+ dataPackets, found := k.GetPendingDataPackets(ctx)
+ if !found {
+ // This method is a no-op if there are no pending data packets
+ return false
}
+ for _, dp := range dataPackets.GetList() {
+ // prepare to send the packetData to the consumer
+ packet, channelCap, err := utils.PrepareIBCPacketSend(
+ ctx,
+ k.scopedKeeper,
+ k.channelKeeper,
+ channelID, // source channel id
+ ccv.ConsumerPortID, // source port id
+ dp.Data,
+ k.GetCCVTimeoutPeriod(ctx),
+ )
+ if err != nil {
+ // something went wrong when preparing the packet
+ panic(fmt.Errorf("packet could not be prepared for IBC send: %w", err))
+ }
- // iterate over pending slash requests in reverse order
- requests := k.GetPendingSlashRequests(ctx).Requests
- for i := len(requests) - 1; i >= 0; i-- {
- slashReq := requests[i]
-
- // send the emebdded slash packet to the CCV channel
- // if the outstanding downtime flag is false for the validator
- downtime := slashReq.Infraction == stakingtypes.Downtime
- if !downtime || !k.OutstandingDowntime(ctx, sdk.ConsAddress(slashReq.Packet.Validator.Address)) {
- // send packet over IBC
- err := utils.SendIBCPacket(
- ctx,
- k.scopedKeeper,
- k.channelKeeper,
- channelID, // source channel id
- ccv.ConsumerPortID, // source port id
- slashReq.Packet.GetBytes(),
- k.GetCCVTimeoutPeriod(ctx),
- )
- if err != nil {
- panic(err)
- }
-
- // set validator outstanding downtime flag to true
- if downtime {
- k.SetOutstandingDowntime(ctx, sdk.ConsAddress(slashReq.Packet.Validator.Address))
+ // send packet over IBC channel
+ err = k.channelKeeper.SendPacket(ctx, channelCap, packet)
+ if err != nil {
+ if clienttypes.ErrClientNotActive.Is(err) {
+ // IBC client expired:
+ // leave the packet data stored to be sent once the client is upgraded
+ return true
}
+ // something went wrong when sending the packet
+ panic(fmt.Errorf("packet could not be sent over IBC: %w", err))
}
}
-
- // clear pending slash requests
- k.DeletePendingSlashRequests(ctx)
+ // clear pending data packets
+ k.DeletePendingDataPackets(ctx)
+ return false
}
// OnAcknowledgementPacket executes application logic for acknowledgments of sent VSCMatured and Slash packets
diff --git a/x/ccv/consumer/types/consumer.pb.go b/x/ccv/consumer/types/consumer.pb.go
index 8def5aad90..c335266893 100644
--- a/x/ccv/consumer/types/consumer.pb.go
+++ b/x/ccv/consumer/types/consumer.pb.go
@@ -6,8 +6,7 @@ package types
import (
fmt "fmt"
types "github.com/cosmos/cosmos-sdk/codec/types"
- types2 "github.com/cosmos/cosmos-sdk/x/staking/types"
- types1 "github.com/cosmos/interchain-security/x/ccv/types"
+ _ "github.com/cosmos/interchain-security/x/ccv/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
@@ -31,6 +30,38 @@ var _ = time.Kitchen
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
+// ConsumerPacketType indicates the consumer packet type.
+type ConsumerPacketType int32
+
+const (
+ // UNSPECIFIED packet type
+ UnspecifiedPacket ConsumerPacketType = 0
+ // Slash packet
+ SlashPacket ConsumerPacketType = 1
+ // VSCMatured packet
+ VscMaturedPacket ConsumerPacketType = 2
+)
+
+var ConsumerPacketType_name = map[int32]string{
+ 0: "CONSUMER_PACKET_TYPE_UNSPECIFIED",
+ 1: "CONSUMER_PACKET_TYPE_SLASH",
+ 2: "CONSUMER_PACKET_TYPE_VSCM",
+}
+
+var ConsumerPacketType_value = map[string]int32{
+ "CONSUMER_PACKET_TYPE_UNSPECIFIED": 0,
+ "CONSUMER_PACKET_TYPE_SLASH": 1,
+ "CONSUMER_PACKET_TYPE_VSCM": 2,
+}
+
+func (x ConsumerPacketType) String() string {
+ return proto.EnumName(ConsumerPacketType_name, int32(x))
+}
+
+func (ConsumerPacketType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_5b27a82b276e7f93, []int{0}
+}
+
// Params defines the parameters for CCV consumer module
type Params struct {
// TODO: Remove enabled flag and find a better way to setup e2e tests
@@ -269,24 +300,24 @@ func (m *CrossChainValidator) GetPubkey() *types.Any {
return nil
}
-// SlashRequest defines a slashing request for CCV consumer module
-type SlashRequest struct {
- Packet *types1.SlashPacketData `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet,omitempty"`
- Infraction types2.InfractionType `protobuf:"varint,2,opt,name=infraction,proto3,enum=cosmos.staking.v1beta1.InfractionType" json:"infraction,omitempty"`
+// DataPacket is a data packet for a specific type of packet
+type DataPacket struct {
+ Type ConsumerPacketType `protobuf:"varint,1,opt,name=type,proto3,enum=interchain_security.ccv.consumer.v1.ConsumerPacketType" json:"type,omitempty"`
+ Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
-func (m *SlashRequest) Reset() { *m = SlashRequest{} }
-func (m *SlashRequest) String() string { return proto.CompactTextString(m) }
-func (*SlashRequest) ProtoMessage() {}
-func (*SlashRequest) Descriptor() ([]byte, []int) {
+func (m *DataPacket) Reset() { *m = DataPacket{} }
+func (m *DataPacket) String() string { return proto.CompactTextString(m) }
+func (*DataPacket) ProtoMessage() {}
+func (*DataPacket) Descriptor() ([]byte, []int) {
return fileDescriptor_5b27a82b276e7f93, []int{3}
}
-func (m *SlashRequest) XXX_Unmarshal(b []byte) error {
+func (m *DataPacket) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
-func (m *SlashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+func (m *DataPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
- return xxx_messageInfo_SlashRequest.Marshal(b, m, deterministic)
+ return xxx_messageInfo_DataPacket.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@@ -296,49 +327,49 @@ func (m *SlashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
return b[:n], nil
}
}
-func (m *SlashRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_SlashRequest.Merge(m, src)
+func (m *DataPacket) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DataPacket.Merge(m, src)
}
-func (m *SlashRequest) XXX_Size() int {
+func (m *DataPacket) XXX_Size() int {
return m.Size()
}
-func (m *SlashRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_SlashRequest.DiscardUnknown(m)
+func (m *DataPacket) XXX_DiscardUnknown() {
+ xxx_messageInfo_DataPacket.DiscardUnknown(m)
}
-var xxx_messageInfo_SlashRequest proto.InternalMessageInfo
+var xxx_messageInfo_DataPacket proto.InternalMessageInfo
-func (m *SlashRequest) GetPacket() *types1.SlashPacketData {
+func (m *DataPacket) GetType() ConsumerPacketType {
if m != nil {
- return m.Packet
+ return m.Type
}
- return nil
+ return UnspecifiedPacket
}
-func (m *SlashRequest) GetInfraction() types2.InfractionType {
+func (m *DataPacket) GetData() []byte {
if m != nil {
- return m.Infraction
+ return m.Data
}
- return types2.InfractionEmpty
+ return nil
}
-// SlashRequests is a list of slash requests for CCV consumer module
-type SlashRequests struct {
- Requests []SlashRequest `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests"`
+// DataPackets is a list of data packets
+type DataPackets struct {
+ List []DataPacket `protobuf:"bytes,1,rep,name=list,proto3" json:"list"`
}
-func (m *SlashRequests) Reset() { *m = SlashRequests{} }
-func (m *SlashRequests) String() string { return proto.CompactTextString(m) }
-func (*SlashRequests) ProtoMessage() {}
-func (*SlashRequests) Descriptor() ([]byte, []int) {
+func (m *DataPackets) Reset() { *m = DataPackets{} }
+func (m *DataPackets) String() string { return proto.CompactTextString(m) }
+func (*DataPackets) ProtoMessage() {}
+func (*DataPackets) Descriptor() ([]byte, []int) {
return fileDescriptor_5b27a82b276e7f93, []int{4}
}
-func (m *SlashRequests) XXX_Unmarshal(b []byte) error {
+func (m *DataPackets) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
-func (m *SlashRequests) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+func (m *DataPackets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
- return xxx_messageInfo_SlashRequests.Marshal(b, m, deterministic)
+ return xxx_messageInfo_DataPackets.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@@ -348,31 +379,32 @@ func (m *SlashRequests) XXX_Marshal(b []byte, deterministic bool) ([]byte, error
return b[:n], nil
}
}
-func (m *SlashRequests) XXX_Merge(src proto.Message) {
- xxx_messageInfo_SlashRequests.Merge(m, src)
+func (m *DataPackets) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DataPackets.Merge(m, src)
}
-func (m *SlashRequests) XXX_Size() int {
+func (m *DataPackets) XXX_Size() int {
return m.Size()
}
-func (m *SlashRequests) XXX_DiscardUnknown() {
- xxx_messageInfo_SlashRequests.DiscardUnknown(m)
+func (m *DataPackets) XXX_DiscardUnknown() {
+ xxx_messageInfo_DataPackets.DiscardUnknown(m)
}
-var xxx_messageInfo_SlashRequests proto.InternalMessageInfo
+var xxx_messageInfo_DataPackets proto.InternalMessageInfo
-func (m *SlashRequests) GetRequests() []SlashRequest {
+func (m *DataPackets) GetList() []DataPacket {
if m != nil {
- return m.Requests
+ return m.List
}
return nil
}
func init() {
+ proto.RegisterEnum("interchain_security.ccv.consumer.v1.ConsumerPacketType", ConsumerPacketType_name, ConsumerPacketType_value)
proto.RegisterType((*Params)(nil), "interchain_security.ccv.consumer.v1.Params")
proto.RegisterType((*LastTransmissionBlockHeight)(nil), "interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight")
proto.RegisterType((*CrossChainValidator)(nil), "interchain_security.ccv.consumer.v1.CrossChainValidator")
- proto.RegisterType((*SlashRequest)(nil), "interchain_security.ccv.consumer.v1.SlashRequest")
- proto.RegisterType((*SlashRequests)(nil), "interchain_security.ccv.consumer.v1.SlashRequests")
+ proto.RegisterType((*DataPacket)(nil), "interchain_security.ccv.consumer.v1.DataPacket")
+ proto.RegisterType((*DataPackets)(nil), "interchain_security.ccv.consumer.v1.DataPackets")
}
func init() {
@@ -380,55 +412,60 @@ func init() {
}
var fileDescriptor_5b27a82b276e7f93 = []byte{
- // 765 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xeb, 0x44,
- 0x14, 0x8e, 0x49, 0x9b, 0xa6, 0x93, 0x02, 0x65, 0x08, 0xad, 0x5b, 0x24, 0x27, 0x0d, 0x15, 0x8a,
- 0x84, 0x6a, 0x2b, 0xa9, 0xd8, 0x74, 0xd7, 0xa4, 0x54, 0xe5, 0x47, 0x10, 0xdc, 0x88, 0x05, 0x2c,
- 0xac, 0xf1, 0x78, 0xe2, 0x8c, 0xe2, 0xcc, 0x98, 0x99, 0xb1, 0xc1, 0x6f, 0xc1, 0x12, 0x89, 0x17,
- 0xe0, 0x01, 0x78, 0x88, 0x8a, 0x55, 0x97, 0x77, 0xd5, 0x7b, 0xd5, 0xbe, 0xc1, 0xd5, 0x7d, 0x80,
- 0x2b, 0xff, 0xa5, 0x49, 0xef, 0x8d, 0xd4,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63, 0x8e, 0x32, 0xf8, 0x05, 0x52, 0xc8, 0x2e, 0xa8, 0xf0, 0x12, 0x00, 0xca,
- 0x16, 0xa3, 0x4e, 0x3d, 0x7d, 0xd4, 0xff, 0xd2, 0x2c, 0x7e, 0xa4, 0x3c, 0x15, 0xc5, 0xe9, 0x30,
- 0xbf, 0x5d, 0x20, 0xc7, 0x49, 0x48, 0xec, 0x25, 0x66, 0xc7, 0x03, 0x1f, 0x2e, 0xff, 0x9c, 0x84,
- 0xd7, 0xa0, 0x2e, 0x8a, 0x58, 0xd7, 0xda, 0xd5, 0x6e, 0xa3, 0xdf, 0x33, 0x9f, 0x71, 0xf7, 0xcc,
- 0x65, 0x95, 0xc1, 0x46, 0x3a, 0x70, 0x7b, 0x21, 0x34, 0x18, 0xdf, 0xdc, 0x1b, 0xda, 0xed, 0xbd,
- 0xa1, 0xbd, 0xba, 0x37, 0xb4, 0xbf, 0x1e, 0x8c, 0xca, 0xed, 0x83, 0x51, 0x79, 0xf1, 0x60, 0x54,
- 0x7e, 0x3d, 0xf3, 0xa9, 0x9a, 0x46, 0xae, 0x89, 0xf9, 0xbc, 0xb8, 0x57, 0xd6, 0xe3, 0xd7, 0x4e,
- 0x16, 0x07, 0xf4, 0xcf, 0xd5, 0xdb, 0xac, 0x92, 0x90, 0x48, 0xb7, 0x96, 0x0d, 0xe9, 0xf4, 0x6d,
- 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xe5, 0x65, 0xb8, 0xcc, 0x05, 0x00, 0x00,
+ // 840 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xdb, 0x46,
+ 0x10, 0x16, 0x63, 0x45, 0x49, 0x56, 0x41, 0xa3, 0x6c, 0x95, 0x44, 0x56, 0x01, 0x9a, 0x51, 0x73,
+ 0x10, 0x0a, 0x98, 0x44, 0x64, 0x14, 0x05, 0xdc,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c7, 0x27, 0x56, 0xe3, 0x50, 0xe2, 0x3d, 0xa4, 0x12, 0x51, 0xbe, 0xd2, 0xae, 0xfe,
+ 0xf4, 0xab, 0x59, 0xe9, 0x8f, 0xdf, 0x9c, 0x9a, 0xc6, 0xdb, 0x53, 0xd3, 0xf8, 0xe7, 0xd4, 0x34,
+ 0x7e, 0x3e, 0x33, 0x2b, 0x6f, 0xcf, 0xcc, 0xca, 0x5f, 0x67, 0x66, 0xe5, 0xbb, 0xf5, 0x29, 0x55,
+ 0xb3, 0x24, 0xb0, 0x31, 0x9f, 0x17, 0x47, 0xd3, 0xb9, 0xf0, 0x69, 0xf5, 0xfc, 0x3e, 0xff, 0x78,
+ 0xf5, 0xf4, 0x67, 0x23, 0x90, 0x41, 0x4d, 0x6f, 0xca, 0xda, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff,
+ 0xbd, 0xf6, 0x26, 0xf9, 0x2b, 0x06, 0x00, 0x00,
}
func (m *Params) Marshal() (dAtA []byte, err error) {
@@ -594,7 +631,7 @@ func (m *CrossChainValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
-func (m *SlashRequest) Marshal() (dAtA []byte, err error) {
+func (m *DataPacket) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@@ -604,37 +641,32 @@ func (m *SlashRequest) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
-func (m *SlashRequest) MarshalTo(dAtA []byte) (int, error) {
+func (m *DataPacket) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
-func (m *SlashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+func (m *DataPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
- if m.Infraction != 0 {
- i = encodeVarintConsumer(dAtA, i, uint64(m.Infraction))
+ if len(m.Data) > 0 {
+ i -= len(m.Data)
+ copy(dAtA[i:], m.Data)
+ i = encodeVarintConsumer(dAtA, i, uint64(len(m.Data)))
i--
- dAtA[i] = 0x10
+ dAtA[i] = 0x12
}
- if m.Packet != nil {
- {
- size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintConsumer(dAtA, i, uint64(size))
- }
+ if m.Type != 0 {
+ i = encodeVarintConsumer(dAtA, i, uint64(m.Type))
i--
- dAtA[i] = 0xa
+ dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
-func (m *SlashRequests) Marshal() (dAtA []byte, err error) {
+func (m *DataPackets) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@@ -644,20 +676,20 @@ func (m *SlashRequests) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
-func (m *SlashRequests) MarshalTo(dAtA []byte) (int, error) {
+func (m *DataPackets) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
-func (m *SlashRequests) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+func (m *DataPackets) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
- if len(m.Requests) > 0 {
- for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- {
+ if len(m.List) > 0 {
+ for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- {
{
- size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
@@ -750,30 +782,30 @@ func (m *CrossChainValidator) Size() (n int) {
return n
}
-func (m *SlashRequest) Size() (n int) {
+func (m *DataPacket) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
- if m.Packet != nil {
- l = m.Packet.Size()
- n += 1 + l + sovConsumer(uint64(l))
+ if m.Type != 0 {
+ n += 1 + sovConsumer(uint64(m.Type))
}
- if m.Infraction != 0 {
- n += 1 + sovConsumer(uint64(m.Infraction))
+ l = len(m.Data)
+ if l > 0 {
+ n += 1 + l + sovConsumer(uint64(l))
}
return n
}
-func (m *SlashRequests) Size() (n int) {
+func (m *DataPackets) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
- if len(m.Requests) > 0 {
- for _, e := range m.Requests {
+ if len(m.List) > 0 {
+ for _, e := range m.List {
l = e.Size()
n += 1 + l + sovConsumer(uint64(l))
}
@@ -1298,7 +1330,7 @@ func (m *CrossChainValidator) Unmarshal(dAtA []byte) error {
}
return nil
}
-func (m *SlashRequest) Unmarshal(dAtA []byte) error {
+func (m *DataPacket) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@@ -1321,17 +1353,17 @@ func (m *SlashRequest) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
- return fmt.Errorf("proto: SlashRequest: wiretype end group for non-group")
+ return fmt.Errorf("proto: DataPacket: wiretype end group for non-group")
}
if fieldNum <= 0 {
- return fmt.Errorf("proto: SlashRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ return fmt.Errorf("proto: DataPacket: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType)
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
- var msglen int
+ m.Type = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsumer
@@ -1341,33 +1373,16 @@ func (m *SlashRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- msglen |= int(b&0x7F) << shift
+ m.Type |= ConsumerPacketType(b&0x7F) << shift
if b < 0x80 {
break
}
}
- if msglen < 0 {
- return ErrInvalidLengthConsumer
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthConsumer
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Packet == nil {
- m.Packet = &types1.SlashPacketData{}
- }
- if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Infraction", wireType)
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
- m.Infraction = 0
+ var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsumer
@@ -1377,11 +1392,26 @@ func (m *SlashRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- m.Infraction |= types2.InfractionType(b&0x7F) << shift
+ byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
+ if byteLen < 0 {
+ return ErrInvalidLengthConsumer
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthConsumer
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipConsumer(dAtA[iNdEx:])
@@ -1403,7 +1433,7 @@ func (m *SlashRequest) Unmarshal(dAtA []byte) error {
}
return nil
}
-func (m *SlashRequests) Unmarshal(dAtA []byte) error {
+func (m *DataPackets) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@@ -1426,15 +1456,15 @@ func (m *SlashRequests) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
- return fmt.Errorf("proto: SlashRequests: wiretype end group for non-group")
+ return fmt.Errorf("proto: DataPackets: wiretype end group for non-group")
}
if fieldNum <= 0 {
- return fmt.Errorf("proto: SlashRequests: illegal tag %d (wire type %d)", fieldNum, wire)
+ return fmt.Errorf("proto: DataPackets: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field List", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -1461,8 +1491,8 @@ func (m *SlashRequests) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- m.Requests = append(m.Requests, SlashRequest{})
- if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ m.List = append(m.List, DataPacket{})
+ if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
diff --git a/x/ccv/consumer/types/genesis.go b/x/ccv/consumer/types/genesis.go
index a2fdbe38a9..1576b57ad0 100644
--- a/x/ccv/consumer/types/genesis.go
+++ b/x/ccv/consumer/types/genesis.go
@@ -13,7 +13,7 @@ import (
// NewInitialGenesisState returns a consumer GenesisState for a completely new consumer chain.
func NewInitialGenesisState(cs *ibctmtypes.ClientState, consState *ibctmtypes.ConsensusState,
- initValSet []abci.ValidatorUpdate, slashRequests SlashRequests, params Params) *GenesisState {
+ initValSet []abci.ValidatorUpdate, params Params) *GenesisState {
return &GenesisState{
Params: params,
@@ -21,12 +21,12 @@ func NewInitialGenesisState(cs *ibctmtypes.ClientState, consState *ibctmtypes.Co
ProviderClientState: cs,
ProviderConsensusState: consState,
InitialValSet: initValSet,
- PendingSlashRequests: slashRequests,
}
}
// NewRestartGenesisState returns a consumer GenesisState that has already been established.
-func NewRestartGenesisState(clientID, channelID string,
+func NewRestartGenesisState(
+ clientID, channelID string,
maturingPackets []MaturingVSCPacket,
initValSet []abci.ValidatorUpdate,
heightToValsetUpdateIDs []HeightToValsetUpdateID,
diff --git a/x/ccv/consumer/types/genesis.pb.go b/x/ccv/consumer/types/genesis.pb.go
index 5a5f0bb33c..74fef7f071 100644
--- a/x/ccv/consumer/types/genesis.pb.go
+++ b/x/ccv/consumer/types/genesis.pb.go
@@ -44,8 +44,6 @@ type GenesisState struct {
HeightToValsetUpdateId []HeightToValsetUpdateID `protobuf:"bytes,9,rep,name=height_to_valset_update_id,json=heightToValsetUpdateId,proto3" json:"height_to_valset_update_id"`
// OutstandingDowntimes nil on new chain, filled on restart.
OutstandingDowntimeSlashing []OutstandingDowntime `protobuf:"bytes,10,rep,name=outstanding_downtime_slashing,json=outstandingDowntimeSlashing,proto3" json:"outstanding_downtime_slashing"`
- // PendingSlashRequests filled in on new chain, nil on restart.
- PendingSlashRequests SlashRequests `protobuf:"bytes,11,opt,name=pending_slash_requests,json=pendingSlashRequests,proto3" json:"pending_slash_requests"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@@ -151,13 +149,6 @@ func (m *GenesisState) GetOutstandingDowntimeSlashing() []OutstandingDowntime {
return nil
}
-func (m *GenesisState) GetPendingSlashRequests() SlashRequests {
- if m != nil {
- return m.PendingSlashRequests
- }
- return SlashRequests{}
-}
-
// MaturingVSCPacket defines the genesis information for the
// unbonding VSC packet
type MaturingVSCPacket struct {
@@ -324,53 +315,51 @@ func init() {
}
var fileDescriptor_2db73a6057a27482 = []byte{
- // 729 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x4f, 0x1b, 0x39,
- 0x14, 0xce, 0x2c, 0x21, 0x10, 0x03, 0x0b, 0x18, 0x36, 0x9a, 0x25, 0xda, 0x6c, 0x36, 0x5c, 0x22,
- 0x6d, 0x3b, 0xa3, 0xa4, 0x52, 0x55, 0xb5, 0x52, 0xa5, 0x02, 0x52, 0x9b, 0x43, 0x29, 0x9a, 0x40,
- 0x0e, 0x5c, 0x46, 0x8e,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, 0xcd, 0x3b, 0xde, 0x6b, 0xe6, 0x07, 0xd9, 0x8c, 0x61,
+ 0xad, 0x33, 0xb0, 0x3d, 0xa7, 0x4b, 0xf8, 0x0e, 0xd4, 0xb3, 0x62, 0xdc, 0x53, 0x4f, 0x1d, 0xf9,
+ 0x7e, 0x42, 0x84, 0xde, 0x12, 0xd5, 0xde, 0xa3, 0x71, 0xca, 0xf8, 0xf5, 0xbe, 0xd7, 0x09, 0x07,
+ 0xa7, 0x57, 0x37, 0x0d, 0xeb, 0xfa, 0xa6, 0x61, 0xfd, 0xb9, 0x69, 0x58, 0x3f, 0x6e, 0x1b, 0xa5,
+ 0xeb, 0xdb, 0x46, 0xe9, 0xe7, 0x6d, 0xa3, 0x74, 0xfe, 0x26, 0xa0, 0x32, 0x4c, 0x87, 0x0e, 0xe6,
+ 0xb1, 0x8b, 0xb9, 0x88, 0xb9, 0x70, 0x27, 0xa3, 0x78, 0x31, 0x5e, 0x6f, 0x5f, 0x67, 0x17, 0x9c,
+ 0xda, 0x5e, 0xc3, 0x8a, 0x5a, 0x5f, 0x2f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xa8, 0x41,
+ 0x3e, 0xd3, 0x05, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -393,16 +382,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
- {
- size, err := m.PendingSlashRequests.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x5a
if len(m.OutstandingDowntimeSlashing) > 0 {
for iNdEx := len(m.OutstandingDowntimeSlashing) - 1; iNdEx >= 0; iNdEx-- {
{
@@ -678,8 +657,6 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l))
}
}
- l = m.PendingSlashRequests.Size()
- n += 1 + l + sovGenesis(uint64(l))
return n
}
@@ -1086,39 +1063,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PendingSlashRequests", 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 err := m.PendingSlashRequests.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go
index 165e4abcce..410ba28a7e 100644
--- a/x/ccv/consumer/types/genesis_test.go
+++ b/x/ccv/consumer/types/genesis_test.go
@@ -55,29 +55,29 @@ func TestValidateInitialGenesisState(t *testing.T) {
}{
{
"valid new consumer genesis state",
- types.NewInitialGenesisState(cs, consensusState, valUpdates, types.SlashRequests{}, params),
+ types.NewInitialGenesisState(cs, consensusState, valUpdates, params),
false,
},
{
"invalid new consumer genesis state: nil client state",
- types.NewInitialGenesisState(nil, consensusState, valUpdates, types.SlashRequests{}, params),
+ types.NewInitialGenesisState(nil, consensusState, valUpdates, params),
true,
},
{
"invalid new consumer genesis state: invalid client state",
types.NewInitialGenesisState(&ibctmtypes.ClientState{ChainId: "badClientState"},
- consensusState, valUpdates, types.SlashRequests{}, params),
+ consensusState, valUpdates, params),
true,
},
{
"invalid new consumer genesis state: nil consensus state",
- types.NewInitialGenesisState(cs, nil, valUpdates, types.SlashRequests{}, params),
+ types.NewInitialGenesisState(cs, nil, valUpdates, params),
true,
},
{
"invalid new consumer genesis state: invalid consensus state",
types.NewInitialGenesisState(cs, &ibctmtypes.ConsensusState{Timestamp: time.Now()},
- valUpdates, types.SlashRequests{}, params),
+ valUpdates, params),
true,
},
{
@@ -93,7 +93,6 @@ func TestValidateInitialGenesisState(t *testing.T) {
valUpdates,
nil,
nil,
- types.SlashRequests{},
},
true,
},
@@ -110,7 +109,6 @@ func TestValidateInitialGenesisState(t *testing.T) {
valUpdates,
nil,
nil,
- types.SlashRequests{},
},
true,
},
@@ -127,13 +125,12 @@ func TestValidateInitialGenesisState(t *testing.T) {
valUpdates,
nil,
nil,
- types.SlashRequests{},
},
true,
},
{
"invalid new consumer genesis state: nil initial validator set",
- types.NewInitialGenesisState(cs, consensusState, nil, types.SlashRequests{}, params),
+ types.NewInitialGenesisState(cs, consensusState, nil, params),
true,
},
{
@@ -141,12 +138,12 @@ func TestValidateInitialGenesisState(t *testing.T) {
types.NewInitialGenesisState(
cs, ibctmtypes.NewConsensusState(
time.Now(), commitmenttypes.NewMerkleRoot([]byte("apphash")), []byte("wrong_hash")),
- valUpdates, types.SlashRequests{}, params),
+ valUpdates, params),
true,
},
{
"invalid new consumer genesis state: invalid params",
- types.NewInitialGenesisState(cs, consensusState, valUpdates, types.SlashRequests{},
+ types.NewInitialGenesisState(cs, consensusState, valUpdates,
types.NewParams(
true,
types.DefaultBlocksPerDistributionTransmission,
@@ -247,7 +244,6 @@ func TestValidateRestartGenesisState(t *testing.T) {
valUpdates,
nil,
nil,
- types.SlashRequests{},
},
true,
},
@@ -264,7 +260,6 @@ func TestValidateRestartGenesisState(t *testing.T) {
valUpdates,
nil,
nil,
- types.SlashRequests{},
},
true,
},
diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go
index 422cbd1528..46fb5e9b8a 100644
--- a/x/ccv/consumer/types/keys.go
+++ b/x/ccv/consumer/types/keys.go
@@ -59,9 +59,11 @@ const (
// OutstandingDowntimePrefix is the byte prefix that will store the validators outstanding downtime by consensus address
OutstandingDowntimeBytePrefix
- // PendingSlashRequestsPrefix is the byte prefix that will store a list of slash request that must be sent
- // to the provider chain once the CCV channel is established
- PendingSlashRequestsBytePrefix
+ // PendingDataPacketsBytePrefix is the byte prefix for storing
+ // a list of data packets that cannot be sent yet to the provider
+ // chain either because the CCV channel is not established or
+ // because the client is expired
+ PendingDataPacketsBytePrefix
// CrossChainValidatorPrefix is the byte prefix that will store cross-chain validators by consensus address
CrossChainValidatorBytePrefix
diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go
index f3bcc0dd15..7df0e45607 100644
--- a/x/ccv/consumer/types/keys_test.go
+++ b/x/ccv/consumer/types/keys_test.go
@@ -32,7 +32,7 @@ func TestNoDuplicates(t *testing.T) {
// any of which should be a single, unique byte.
func getSingleByteKeys() [][]byte {
- keys := make([][]byte, 12)
+ keys := make([][]byte, 32)
i := 0
keys[i], i = PortKey(), i+1
@@ -45,8 +45,8 @@ func getSingleByteKeys() [][]byte {
keys[i], i = []byte{PacketMaturityTimeBytePrefix}, i+1
keys[i], i = []byte{HeightValsetUpdateIDBytePrefix}, i+1
keys[i], i = []byte{OutstandingDowntimeBytePrefix}, i+1
- keys[i], i = []byte{PendingSlashRequestsBytePrefix}, i+1
- keys[i] = []byte{CrossChainValidatorBytePrefix}
+ keys[i], i = []byte{PendingDataPacketsBytePrefix}, i+1
+ keys[i], i = []byte{CrossChainValidatorBytePrefix}, i+1
- return keys
+ return keys[:i]
}
diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go
index 3f91a0f02b..312886dec4 100644
--- a/x/ccv/provider/keeper/genesis.go
+++ b/x/ccv/provider/keeper/genesis.go
@@ -71,9 +71,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {
k.SetUnbondingOpIndex(ctx, chainID, ubdOpIndex.ValsetUpdateId, ubdOpIndex.UnbondingOpIndex)
}
} else {
- for _, vsc := range cs.PendingValsetChanges {
- k.AppendPendingVSC(ctx, chainID, vsc)
- }
+ k.AppendPendingVSCs(ctx, chainID, cs.PendingValsetChanges...)
}
}
@@ -112,10 +110,10 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
)
return true
})
- } else {
- if pendingVSC, found := k.GetPendingVSCs(ctx, chainID); found {
- cs.PendingValsetChanges = pendingVSC
- }
+ }
+
+ if pendingVSC, found := k.GetPendingVSCs(ctx, chainID); found {
+ cs.PendingValsetChanges = pendingVSC
}
consumerStates = append(consumerStates, cs)
diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go
index ca740fa11c..63372e9ad6 100644
--- a/x/ccv/provider/keeper/keeper.go
+++ b/x/ccv/provider/keeper/keeper.go
@@ -698,10 +698,10 @@ func (k Keeper) GetPendingVSCs(ctx sdk.Context, chainID string) (packets []ccv.V
// AppendPendingVSC adds the given ValidatorSetChange packet to the list
// of pending ValidatorSetChange packets stored under chain ID
-func (k Keeper) AppendPendingVSC(ctx sdk.Context, chainID string, packet ccv.ValidatorSetChangePacketData) {
+func (k Keeper) AppendPendingVSCs(ctx sdk.Context, chainID string, newPackets ...ccv.ValidatorSetChangePacketData) {
packets, _ := k.GetPendingVSCs(ctx, chainID)
// append works also on a nil list
- packets = append(packets, packet)
+ packets = append(packets, newPackets...)
store := ctx.KVStore(k.storeKey)
var data [][]byte
@@ -720,16 +720,10 @@ func (k Keeper) AppendPendingVSC(ctx sdk.Context, chainID string, packet ccv.Val
store.Set(types.PendingVSCsKey(chainID), buf.Bytes())
}
-// ConsumePendingVSCs empties and returns the list of pending ValidatorSetChange packets for chain ID (if it exists)
-func (k Keeper) ConsumePendingVSCs(ctx sdk.Context, chainID string) (packets []ccv.ValidatorSetChangePacketData) {
- packets, found := k.GetPendingVSCs(ctx, chainID)
- if !found {
- // there is no list of pending ValidatorSetChange packets
- return nil
- }
+// DeletePendingVSCs deletes the list of pending ValidatorSetChange packets for chain ID
+func (k Keeper) DeletePendingVSCs(ctx sdk.Context, chainID string) {
store := ctx.KVStore(k.storeKey)
store.Delete(types.PendingVSCsKey(chainID))
- return packets
}
// GetLockUnbondingOnTimeout returns the mapping from the given consumer chain ID to a boolean value indicating whether
diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go
index df91c5a4c4..3a96ada97d 100644
--- a/x/ccv/provider/keeper/keeper_test.go
+++ b/x/ccv/provider/keeper/keeper_test.go
@@ -142,9 +142,7 @@ func TestPendingVSCs(t *testing.T) {
ValsetUpdateId: 2,
},
}
- for _, packet := range packetList {
- providerKeeper.AppendPendingVSC(ctx, chainID, packet)
- }
+ providerKeeper.AppendPendingVSCs(ctx, chainID, packetList...)
packets, found := providerKeeper.GetPendingVSCs(ctx, chainID)
require.True(t, found)
@@ -156,12 +154,14 @@ func TestPendingVSCs(t *testing.T) {
},
ValsetUpdateId: 3,
}
- providerKeeper.AppendPendingVSC(ctx, chainID, newPacket)
- vscs := providerKeeper.ConsumePendingVSCs(ctx, chainID)
+ providerKeeper.AppendPendingVSCs(ctx, chainID, newPacket)
+ vscs, found := providerKeeper.GetPendingVSCs(ctx, chainID)
+ require.True(t, found)
require.Len(t, vscs, 3)
require.True(t, vscs[len(vscs)-1].ValsetUpdateId == 3)
require.True(t, vscs[len(vscs)-1].GetValidatorUpdates()[0].PubKey.String() == ppks[3].String())
+ providerKeeper.DeletePendingVSCs(ctx, chainID)
_, found = providerKeeper.GetPendingVSCs(ctx, chainID)
require.False(t, found)
}
diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go
index b235476260..2fabd5dc1a 100644
--- a/x/ccv/provider/keeper/proposal.go
+++ b/x/ccv/provider/keeper/proposal.go
@@ -153,7 +153,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, lockUbd, clos
k.DeleteInitChainHeight(ctx, chainID)
k.ConsumeSlashAcks(ctx, chainID)
- k.ConsumePendingVSCs(ctx, chainID)
+ k.DeletePendingVSCs(ctx, chainID)
// release unbonding operations if they aren't locked
var vscIDs []uint64
diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go
index 2b7d0debf6..64a6b57df7 100644
--- a/x/ccv/provider/keeper/relay.go
+++ b/x/ccv/provider/keeper/relay.go
@@ -8,6 +8,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
+ clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
@@ -137,8 +138,10 @@ func (k Keeper) sendValidatorUpdates(ctx sdk.Context) {
valUpdates := k.stakingKeeper.GetValidatorUpdates(ctx)
k.IterateConsumerChains(ctx, func(ctx sdk.Context, chainID, clientID string) (stop bool) {
// check whether there is an established CCV channel to this consumer chain
- if channelID, found := k.GetChainToChannel(ctx, chainID); found {
- // Send pending VSC packets to consumer chain
+ channelID, found := k.GetChainToChannel(ctx, chainID)
+ if found {
+ // CCV channel established:
+ // try sending the pending VSC packets, if any
k.SendPendingVSCPackets(ctx, chainID, channelID)
}
@@ -150,26 +153,41 @@ func (k Keeper) sendValidatorUpdates(ctx sdk.Context) {
// construct validator set change packet data
packetData := ccv.NewValidatorSetChangePacketData(valUpdates, valUpdateID, k.ConsumeSlashAcks(ctx, chainID))
- // check whether there is an established CCV channel to this consumer chain
- if channelID, found := k.GetChainToChannel(ctx, chainID); found {
- // send this validator set change packet data to the consumer chain
- err := utils.SendIBCPacket(
- ctx,
- k.scopedKeeper,
- k.channelKeeper,
- channelID, // source channel id
- ccv.ProviderPortID, // source port id
- packetData.GetBytes(),
- k.GetParams(ctx).CcvTimeoutPeriod,
- )
- if err != nil {
- panic(fmt.Errorf("packet could not be sent over IBC: %w", err))
- }
+ if !found {
+ // CCV channel not established:
+ // store the packet data to be sent once the CCV channel is established
+ k.AppendPendingVSCs(ctx, chainID, packetData)
+ return true // go to next consumer chain
+ }
+
+ // prepare to send the packetData to the consumer
+ packet, channelCap, err := utils.PrepareIBCPacketSend(
+ ctx,
+ k.scopedKeeper,
+ k.channelKeeper,
+ channelID, // source channel id
+ ccv.ProviderPortID, // source port id
+ packetData.GetBytes(),
+ k.GetCCVTimeoutPeriod(ctx),
+ )
+ if err != nil {
+ // something went wrong when preparing the packet
+ panic(fmt.Errorf("packet could not be prepared for IBC send: %w", err))
+ }
+
+ // send packet over IBC channel
+ err = k.channelKeeper.SendPacket(ctx, channelCap, packet)
+ if err == nil {
+ // successful send:
// set the VSC send timestamp for this packet
k.SetVscSendTimestamp(ctx, chainID, packetData.ValsetUpdateId, ctx.BlockTime())
+ } else if clienttypes.ErrClientNotActive.Is(err) {
+ // IBC client expired:
+ // store the packet data to be sent once the client is upgraded
+ k.AppendPendingVSCs(ctx, chainID, packetData)
} else {
- // store the packet data to be sent once the CCV channel is established
- k.AppendPendingVSC(ctx, chainID, packetData)
+ // something went wrong when sending the packet
+ panic(fmt.Errorf("packet could not be sent over IBC: %w", err))
}
}
return true // do not stop the iteration
@@ -177,21 +195,38 @@ func (k Keeper) sendValidatorUpdates(ctx sdk.Context) {
k.IncrementValidatorSetUpdateId(ctx)
}
-// Sends all pending ValidatorSetChangePackets to the specified chain
+// SendPendingVSCPackets sends all pending ValidatorSetChangePackets to the specified chain
func (k Keeper) SendPendingVSCPackets(ctx sdk.Context, chainID, channelID string) {
- pendingPackets := k.ConsumePendingVSCs(ctx, chainID)
+ pendingPackets, found := k.GetPendingVSCs(ctx, chainID)
+ if !found {
+ // this method is a no-op if there are no pending packets
+ return
+ }
for _, data := range pendingPackets {
- // send packet over IBC
- err := utils.SendIBCPacket(
+ // prepare to send the data to the consumer
+ packet, channelCap, err := utils.PrepareIBCPacketSend(
ctx,
k.scopedKeeper,
k.channelKeeper,
channelID, // source channel id
ccv.ProviderPortID, // source port id
data.GetBytes(),
- k.GetParams(ctx).CcvTimeoutPeriod,
+ k.GetCCVTimeoutPeriod(ctx),
)
if err != nil {
+ // something went wrong when preparing the packet
+ panic(fmt.Errorf("packet could not be prepared for IBC send: %w", err))
+ }
+
+ // send packet over IBC channel
+ err = k.channelKeeper.SendPacket(ctx, channelCap, packet)
+ if err != nil {
+ if clienttypes.ErrClientNotActive.Is(err) {
+ // IBC client expired:
+ // leave the packet data stored to be sent once the client is upgraded
+ return
+ }
+ // something went wrong when sending the packet
panic(fmt.Errorf("packet could not be sent over IBC: %w", err))
}
// set the VSC send timestamp for this packet;
@@ -199,6 +234,7 @@ func (k Keeper) SendPendingVSCPackets(ctx sdk.Context, chainID, channelID string
// are actually sent over IBC
k.SetVscSendTimestamp(ctx, chainID, data.ValsetUpdateId, ctx.BlockTime())
}
+ k.DeletePendingVSCs(ctx, chainID)
}
// EndBlockCIS contains the EndBlock logic needed for
diff --git a/x/ccv/utils/utils.go b/x/ccv/utils/utils.go
index 8cfd01220c..787e1ca96f 100644
--- a/x/ccv/utils/utils.go
+++ b/x/ccv/utils/utils.go
@@ -6,6 +6,7 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+ capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
@@ -41,9 +42,10 @@ func GetChangePubKeyAddress(change abci.ValidatorUpdate) (addr []byte) {
return pk.Address()
}
-// SendIBCPacket sends an IBC packet with packetData
-// over the source channelID and portID
-func SendIBCPacket(
+// PrepareIBCPacketSend prepares the send an IBC packet with packetData
+// over the source channelID and portID. If successful, it returns the
+// packet and the channel capability.
+func PrepareIBCPacketSend(
ctx sdk.Context,
scopedKeeper ccv.ScopedKeeper,
channelKeeper ccv.ChannelKeeper,
@@ -51,20 +53,26 @@ func SendIBCPacket(
portID string,
packetData []byte,
timeoutPeriod time.Duration,
-) error {
+) (*channeltypes.Packet, *capabilitytypes.Capability, error) {
channel, ok := channelKeeper.GetChannel(ctx, portID, channelID)
if !ok {
- return sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for channel ID: %s", channelID)
+ return nil, nil, sdkerrors.Wrapf(
+ channeltypes.ErrChannelNotFound,
+ "channel not found for channel ID: %s", channelID,
+ )
}
channelCap, ok := scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID))
if !ok {
- return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
+ return nil, nil, sdkerrors.Wrap(
+ channeltypes.ErrChannelCapabilityNotFound,
+ "module does not own channel capability",
+ )
}
// get the next sequence
sequence, found := channelKeeper.GetNextSequenceSend(ctx, portID, channelID)
if !found {
- return sdkerrors.Wrapf(
+ return nil, channelCap, sdkerrors.Wrapf(
channeltypes.ErrSequenceSendNotFound,
"source port: %s, source channel: %s", portID, channelID,
)
@@ -75,5 +83,5 @@ func SendIBCPacket(
channel.Counterparty.PortId, channel.Counterparty.ChannelId,
clienttypes.Height{}, uint64(ctx.BlockTime().Add(timeoutPeriod).UnixNano()),
)
- return channelKeeper.SendPacket(ctx, channelCap, packet)
+ return &packet, channelCap, nil
}