Skip to content

Commit c7ab5da

Browse files
mpokegithub-actions
and
github-actions
authored
feat!: remove vscmatured packets (#2372)
* deprecate PacketMaturityTimeKey * remove TestPacketMaturityTime * update genesis logic * remove maturity logic * add migration * fix UT * fix integration tests * update proto files * remove genesis transformation * Update testing documentation * Revert "remove genesis transformation" This reverts commit 89b1d05. * add changelog entries --------- Co-authored-by: github-actions <[email protected]>
1 parent f3959a2 commit c7ab5da

24 files changed

+127
-1068
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `[x/provider]` Allow consumer chains to specify a list of priority validators that are included in the validator set before other validators are considered
2+
([\#2101](https://github.com/cosmos/interchain-security/pull/2101))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `[x/consumer]` Remove `VSCMaturedPackets`. Consumer-side changes for [ADR 018](https://cosmos.github.io/interchain-security/adrs/adr-018-remove-vscmatured#consumer-changes-r2).
2+
([\#2372](https://github.com/cosmos/interchain-security/pull/2372))
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- Allow the chain id of a consumer chain to be updated before the chain
1+
- `[x/provider]` Allow the chain id of a consumer chain to be updated before the chain
22
launches. ([\#2378](https://github.com/cosmos/interchain-security/pull/2378))

.changelog/unreleased/features/provider/2101-introduce-priority-validators.md

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- Allow consumer chains to specify a list of priority validators that are included in the validator set before other validators are considered
1+
- `[x/provider]` Allow consumer chains to specify a list of priority validators that are included in the validator set before other validators are considered
22
([\#2101](https://github.com/cosmos/interchain-security/pull/2101))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `[x/consumer]` Remove `VSCMaturedPackets`. Consumer-side changes for [ADR 018](https://cosmos.github.io/interchain-security/adrs/adr-018-remove-vscmatured#consumer-changes-r2).
2+
([\#2372](https://github.com/cosmos/interchain-security/pull/2372))

proto/interchain_security/ccv/consumer/v1/genesis.proto

+12-18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ import "tendermint/abci/types.proto";
2020
// Note: this type is only used on consumer side and references shared types with
2121
// provider
2222
message GenesisState {
23+
// Reserve 5th slot for removed provider_client_state field
24+
reserved 5;
25+
26+
// Reserve 6th slot for removed provider_consensus_state field
27+
reserved 6;
28+
29+
// Reserve 7th slot for removed maturing_packets field
30+
reserved 7;
31+
32+
// Reserve 8th slot for removed initial_val_set field
33+
reserved 8;
34+
2335
// ConsumerParams is a shared type with provider module
2436
interchain_security.ccv.v1.ConsumerParams params = 1
2537
[ (gogoproto.nullable) = false ];
@@ -29,15 +41,6 @@ message GenesisState {
2941
string provider_channel_id = 3;
3042
// true for new chain, false for chain restart.
3143
bool new_chain = 4;
32-
// !!! DEPRECATED !!! ProviderClientState is deprecated. Use provider.client_state instead
33-
ibc.lightclients.tendermint.v1.ClientState provider_client_state = 5 [ deprecated = true];
34-
// !!! DEPRECATED !!! ProviderConsensusState is deprecated. Use provider.consensus_state instead
35-
ibc.lightclients.tendermint.v1.ConsensusState provider_consensus_state = 6 [ deprecated = true];
36-
// MaturingPackets nil on new chain, filled in on restart.
37-
repeated MaturingVSCPacket maturing_packets = 7
38-
[ (gogoproto.nullable) = false ];
39-
// !!! DEPRECATED !!!! InitialValset is deprecated. Use provider.initial_val_set instead
40-
repeated .tendermint.abci.ValidatorUpdate initial_val_set = 8 [ (gogoproto.nullable) = false, deprecated = true ];
4144
// HeightToValsetUpdateId nil on new chain, filled in on restart.
4245
repeated HeightToValsetUpdateID height_to_valset_update_id = 9
4346
[ (gogoproto.nullable) = false ];
@@ -73,15 +76,6 @@ message OutstandingDowntime { string validator_consensus_address = 1; }
7376
// to the consumer CCV module.
7477
message LastTransmissionBlockHeight { int64 height = 1; }
7578

76-
// MaturingVSCPacket represents a vsc packet that is maturing internal to the
77-
// consumer CCV module, where the consumer has not yet relayed a VSCMatured
78-
// packet back to the provider.
79-
message MaturingVSCPacket {
80-
uint64 vscId = 1;
81-
google.protobuf.Timestamp maturity_time = 2
82-
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
83-
}
84-
8579
// ConsumerPacketDataList is a list of consumer packet data packets.
8680
//
8781
// Note this type is used internally to the consumer CCV module

scripts/test_doc/test_documentation.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
| Function | Short Description |
4949
|----------|-------------------|
5050
[TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L29) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.<details><summary>Details</summary>* Set up a CCV channel and expire the client on consumer chain.<br>* Bond tokens to provider, send CCV packet to consumer and check pending packets.<br>* While the consumer client is expired (or inactive for some reason) all packets will be queued.<br>* The packet sending and checks are then repeated.<br>* More tokens are bonded on provider to change validator powers.<br>* Upgrade expired client to the consumer and all packets are cleared once the consumer client is established.</details> |
51-
[TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L99) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.<details><summary>Details</summary>* Set up a CCV channel and bond tokens on provider.<br>* Send CCV packet to consumer and rebond tokens on provider.<br>* Check for pending VSC packets and relay all VSC packets to consumer.<br>* The provider client is then expired.<br>* Confirm that while the provider client is expired all packets will be queued and then cleared<br>once the provider client is upgraded.</details> |
51+
[TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L95) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.<details><summary>Details</summary>* Set up a CCV channel and bond tokens on provider.<br>* Send CCV packet to consumer and rebond tokens on provider.<br>* Check for pending VSC packets and relay all VSC packets to consumer.<br>* The provider client is then expired.<br>* Confirm that while the provider client is expired all packets will be queued and then cleared<br>once the provider client is upgraded.</details> |
5252
</details>
5353

5454
# [key_assignment.go](../../tests/integration/key_assignment.go)
@@ -135,7 +135,6 @@
135135

136136
| Function | Short Description |
137137
|----------|-------------------|
138-
[TestPacketRoundtrip](../../tests/integration/valset_update.go#L23) | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.<details><summary>Details</summary>* Set up CCV and transfer channels.<br>* Bond some tokens on the provider side in order to change validator power.<br>* Relay a packet from the provider chain to the consumer chain.<br>* Relays a matured packet from the consumer chain back to the provider chain.</details> |
139-
[TestQueueAndSendVSCMaturedPackets](../../tests/integration/valset_update.go#L59) | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.<details><summary>Details</summary>* Set up CCV channel.<br>* Create and simulate the sending of three VSC packets from the provider chain to the consumer chain at different times.<br>* Send the first packet and validate its processing.<br>* Simulate the passage of one hour.<br>* Send the second packet and validate its processing.<br>* Simulate the passage of 24 more hours.<br>* Send the third packet and validate its processing.<br>* Retrieve all packet maturity times from the consumer, and use this to check the maturity status of the packets sent earlier.<br>* Advance the time so that the first two packets reach their unbonding period, while the third packet does not.<br>* Ensure first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.<br>* The third packet is still in the store and has not yet been processed for unbonding.<br>* Checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state.</details> |
138+
[TestPacketRoundtrip](../../tests/integration/valset_update.go#L15) | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.<details><summary>Details</summary>* Set up CCV and transfer channels.<br>* Bond some tokens on the provider side in order to change validator power.<br>* Relay a packet from the provider chain to the consumer chain.<br>* Relays a matured packet from the consumer chain back to the provider chain.</details> |
140139
</details>
141140

tests/integration/expired_client.go

+6-15
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
8282
s.nextEpoch()
8383
// - relay all VSC packet from provider to consumer
8484
relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 3)
85-
// - increment time so that the unbonding period ends on the consumer
86-
incrementTimeByUnbondingPeriod(s, Consumer)
87-
// - relay all VSCMatured packet from consumer to provider
88-
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 3)
8985
}
9086

9187
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
@@ -134,10 +130,9 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
134130
consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerCtx())
135131
incrementTimeWithoutUpdate(s, consumerUnbondingPeriod+time.Hour, Provider)
136132

137-
// check that the packets were added to the list of pending data packets
133+
// check that no packets were added to the list of pending data packets
138134
consumerPackets := consumerKeeper.GetPendingPackets(s.consumerCtx())
139-
s.Require().NotEmpty(consumerPackets)
140-
s.Require().Len(consumerPackets, 2, "unexpected number of pending data packets")
135+
s.Require().Empty(consumerPackets)
141136

142137
// try to send slash packet for downtime infraction
143138
addr := ed25519.GenPrivKey().PubKey().Address()
@@ -151,21 +146,21 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
151146
// check that the packets were added to the list of pending data packets
152147
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
153148
s.Require().NotEmpty(consumerPackets)
154-
// At this point we expect 4 packets, two vsc matured packets and two trailing slash packets
155-
s.Require().Len(consumerPackets, 4, "unexpected number of pending data packets")
149+
// At this point we expect two trailing slash packets
150+
s.Require().Len(consumerPackets, 2, "unexpected number of pending data packets")
156151

157152
// upgrade expired client to the consumer
158153
upgradeExpiredClient(s, Provider)
159154

160155
// go to next block to trigger SendPendingPackets
161156
s.consumerChain.NextBlock()
162157

163-
// Check that the leading vsc matured packets were sent and no longer pending
158+
// Check that both slash packets are still pending
164159
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
165160
s.Require().Len(consumerPackets, 2, "unexpected number of pending data packets")
166161

167162
// relay committed packets from consumer to provider, first slash packet should be committed
168-
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 3) // two vsc matured + one slash
163+
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // one slash
169164

170165
// First slash has been acked, now only the second slash packet should remain as pending
171166
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
@@ -187,10 +182,6 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
187182
s.nextEpoch()
188183
// - relay 1 VSC packet from provider to consumer
189184
relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 1)
190-
// - increment time so that the unbonding period ends on the provider
191-
incrementTimeByUnbondingPeriod(s, Consumer)
192-
// - relay 1 VSCMatured packet from consumer to provider
193-
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1)
194185
}
195186

196187
// expireClient expires the client to the `clientTo` chain

tests/integration/valset_update.go

-132
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
package integration
22

33
import (
4-
"time"
5-
6-
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
7-
84
"cosmossdk.io/math"
95

10-
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
11-
12-
abci "github.com/cometbft/cometbft/abci/types"
13-
146
ccv "github.com/cosmos/interchain-security/v6/x/ccv/types"
157
)
168

@@ -34,128 +26,4 @@ func (s *CCVTestSuite) TestPacketRoundtrip() {
3426

3527
// Relay 1 VSC packet from provider to consumer
3628
relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 1)
37-
38-
// Increment time so that the unbonding period ends on the provider
39-
incrementTimeByUnbondingPeriod(s, Provider)
40-
41-
// Relay 1 VSCMatured packet from consumer to provider
42-
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1)
43-
}
44-
45-
// TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.
46-
// @Long Description@
47-
// * Set up CCV channel.
48-
// * Create and simulate the sending of three VSC packets from the provider chain to the consumer chain at different times.
49-
// * Send the first packet and validate its processing.
50-
// * Simulate the passage of one hour.
51-
// * Send the second packet and validate its processing.
52-
// * Simulate the passage of 24 more hours.
53-
// * Send the third packet and validate its processing.
54-
// * Retrieve all packet maturity times from the consumer, and use this to check the maturity status of the packets sent earlier.
55-
// * Advance the time so that the first two packets reach their unbonding period, while the third packet does not.
56-
// * Ensure first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
57-
// * The third packet is still in the store and has not yet been processed for unbonding.
58-
// * Checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state.
59-
func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets() {
60-
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
61-
62-
// setup CCV channel
63-
suite.SetupCCVChannel(suite.path)
64-
65-
// send 3 packets to consumer chain at different times
66-
pk, err := cryptocodec.FromCmtPubKeyInterface(suite.providerChain.Vals.Validators[0].PubKey)
67-
suite.Require().NoError(err)
68-
pk1, err := cryptocodec.ToCmtProtoPublicKey(pk)
69-
suite.Require().NoError(err)
70-
pk, err = cryptocodec.FromCmtPubKeyInterface(suite.providerChain.Vals.Validators[1].PubKey)
71-
suite.Require().NoError(err)
72-
pk2, err := cryptocodec.ToCmtProtoPublicKey(pk)
73-
suite.Require().NoError(err)
74-
75-
pd := ccv.NewValidatorSetChangePacketData(
76-
[]abci.ValidatorUpdate{
77-
{
78-
PubKey: pk1,
79-
Power: 30,
80-
},
81-
{
82-
PubKey: pk2,
83-
Power: 20,
84-
},
85-
},
86-
1,
87-
nil,
88-
)
89-
90-
// send first packet
91-
packet := suite.newPacketFromProvider(pd.GetBytes(), 1, suite.path, clienttypes.NewHeight(1, 0), 0)
92-
err = consumerKeeper.OnRecvVSCPacket(suite.consumerChain.GetContext(), packet, pd)
93-
suite.Require().Nil(err, "OnRecvVSCPacket did return non-nil error")
94-
95-
// increase time
96-
incrementTime(suite, time.Hour)
97-
98-
// update time and send second packet
99-
pd.ValidatorUpdates[0].Power = 15
100-
pd.ValsetUpdateId = 2
101-
packet.Data = pd.GetBytes()
102-
packet.Sequence = 2
103-
err = consumerKeeper.OnRecvVSCPacket(suite.consumerChain.GetContext(), packet, pd)
104-
suite.Require().Nil(err, "OnRecvVSCPacket did return non-nil error")
105-
106-
// increase time
107-
incrementTime(suite, 24*time.Hour)
108-
109-
// update time and send third packet
110-
pd.ValidatorUpdates[1].Power = 40
111-
pd.ValsetUpdateId = 3
112-
packet.Data = pd.GetBytes()
113-
packet.Sequence = 3
114-
err = consumerKeeper.OnRecvVSCPacket(suite.consumerChain.GetContext(), packet, pd)
115-
suite.Require().Nil(err, "OnRecvVSCPacket did return non-nil error")
116-
117-
packetMaturities := consumerKeeper.GetAllPacketMaturityTimes(suite.consumerChain.GetContext())
118-
119-
// increase time such that first two packets are unbonded but third is not.
120-
unbondingPeriod := consumerKeeper.GetUnbondingPeriod(suite.consumerChain.GetContext())
121-
// increase time
122-
incrementTime(suite, unbondingPeriod-time.Hour)
123-
124-
// ensure first two packets are unbonded and VSCMatured packets are queued
125-
// unbonded time is deleted
126-
suite.Require().False(
127-
consumerKeeper.PacketMaturityTimeExists(
128-
suite.consumerChain.GetContext(),
129-
packetMaturities[0].VscId,
130-
packetMaturities[0].MaturityTime,
131-
),
132-
"maturity time not deleted for mature packet 1",
133-
)
134-
suite.Require().False(
135-
consumerKeeper.PacketMaturityTimeExists(
136-
suite.consumerChain.GetContext(),
137-
packetMaturities[1].VscId,
138-
packetMaturities[1].MaturityTime,
139-
),
140-
"maturity time not deleted for mature packet 2",
141-
)
142-
// ensure that third packet did not get unbonded and is still in store
143-
suite.Require().True(
144-
consumerKeeper.PacketMaturityTimeExists(
145-
suite.consumerChain.GetContext(),
146-
packetMaturities[2].VscId,
147-
packetMaturities[2].MaturityTime,
148-
),
149-
"maturity time for packet 3 is not after current time",
150-
)
151-
152-
// check that the packets are committed in state
153-
commitments := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllPacketCommitmentsAtChannel(
154-
suite.consumerChain.GetContext(),
155-
ccv.ConsumerPortID,
156-
suite.path.EndpointA.ChannelID,
157-
)
158-
suite.Require().Equal(2, len(commitments), "did not find packet commitments")
159-
suite.Require().Equal(uint64(1), commitments[0].Sequence, "did not send VSCMatured packet for VSC packet 1")
160-
suite.Require().Equal(uint64(2), commitments[1].Sequence, "did not send VSCMatured packet for VSC packet 2")
16129
}

x/ccv/consumer/keeper/genesis.go

-6
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) []abci.V
7373
if state.ProviderChannelId != "" {
7474
// set provider channel ID
7575
k.SetProviderChannel(ctx, state.ProviderChannelId)
76-
// set all unbonding sequences
77-
for _, mp := range state.MaturingPackets {
78-
k.SetPacketMaturityTime(ctx, mp.VscId, mp.MaturityTime)
79-
}
8076
// set outstanding downtime slashing requests
8177
for _, od := range state.OutstandingDowntimeSlashing {
8278
consAddr, err := sdk.ConsAddressFromBech32(od.ValidatorConsensusAddress)
@@ -141,7 +137,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *types.GenesisState) {
141137
genesis = types.NewRestartGenesisState(
142138
clientID,
143139
channelID,
144-
k.GetAllPacketMaturityTimes(ctx),
145140
valset,
146141
k.GetAllHeightToValsetUpdateIDs(ctx),
147142
pendingPacketsDepreciated,
@@ -161,7 +156,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *types.GenesisState) {
161156
genesis = types.NewRestartGenesisState(
162157
clientID,
163158
"",
164-
nil,
165159
valset,
166160
k.GetAllHeightToValsetUpdateIDs(ctx),
167161
pendingPacketsDepreciated,

0 commit comments

Comments
 (0)