Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: throttle with retries, consumer changes #1024

Merged
merged 101 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
f8dbfd2
wip
shaspitz Jun 15, 2023
9500954
wip
shaspitz Jun 16, 2023
09b0080
bouncing slash constructor and nits
shaspitz Jun 16, 2023
9b2db5e
UT
shaspitz Jun 16, 2023
0e1c7e8
define cross chain ack enum
shaspitz Jun 16, 2023
4b133ac
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jun 16, 2023
5bb3e14
wip
shaspitz Jun 19, 2023
6b6eabe
tests
shaspitz Jun 19, 2023
84e0250
tests
shaspitz Jun 19, 2023
0eafb05
update genesis tests
shaspitz Jun 19, 2023
1af896f
comments
shaspitz Jun 19, 2023
cf2359d
migration and changelog
shaspitz Jun 19, 2023
1c7e7df
migration test
shaspitz Jun 19, 2023
81d88e3
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jun 20, 2023
84d4a75
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jun 20, 2023
98dd226
lints
shaspitz Jun 20, 2023
35a464b
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jun 21, 2023
d4393e9
merge fixes
shaspitz Jun 21, 2023
18f852a
clean
shaspitz Jun 21, 2023
0e1bd28
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jun 22, 2023
9737d0f
Update ccv.pb.go
shaspitz Jun 22, 2023
189c1da
add to ADR
shaspitz Jun 22, 2023
1c33106
address some PR comments
shaspitz Jun 23, 2023
394f709
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jun 23, 2023
2e554b3
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jun 23, 2023
327ffab
rebuild protos
shaspitz Jun 23, 2023
13cd51e
v3s
shaspitz Jun 23, 2023
cf78884
lint
shaspitz Jun 23, 2023
da2003b
Merge branch 'shawn/optimize-pending-packets-storage' into shawn/thro…
shaspitz Jun 23, 2023
0778dc2
regen pbs
shaspitz Jun 23, 2023
90266ab
refactor for simplicity
shaspitz Jun 23, 2023
a42229a
comment
shaspitz Jun 26, 2023
6848464
changes with slash record type
shaspitz Jun 26, 2023
a3be915
wip
shaspitz Jun 27, 2023
05acaba
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jun 29, 2023
d918fb4
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jul 1, 2023
f517201
Update ccv.pb.go
shaspitz Jul 1, 2023
4d0cd80
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jul 1, 2023
24d9e3c
Update ccv.pb.go
shaspitz Jul 1, 2023
e3f2133
Merge branch 'main' into shawn/optimize-pending-packets-storage
shaspitz Jul 6, 2023
56f1c92
Merge branch 'shawn/optimize-pending-packets-storage' into shawn/thro…
shaspitz Jul 6, 2023
7de2877
update SendPackets and test
shaspitz Jul 6, 2023
3143ed9
test packet sending permitted
shaspitz Jul 6, 2023
96444ce
test for OnAckPacket
shaspitz Jul 6, 2023
13fcec3
note on FSM design
shaspitz Jul 6, 2023
b544e93
CRUD UT
shaspitz Jul 6, 2023
6b5755c
packet sending permitted UT
shaspitz Jul 10, 2023
dcaa9c6
nits
shaspitz Jul 10, 2023
81f2f9d
Update throttle_retry.go
shaspitz Jul 10, 2023
7b6be09
v1 result and change tests
shaspitz Jul 10, 2023
2fa1a1b
Update relay.go
shaspitz Jul 13, 2023
e10d84c
expectation func
shaspitz Jul 13, 2023
34a1c4e
Merge branch 'main' into shawn/fix-send-packets
shaspitz Jul 13, 2023
9bfba90
reg test
shaspitz Jul 13, 2023
66c2bfe
Merge branch 'shawn/fix-send-packets' of https://github.com/cosmos/in…
shaspitz Jul 13, 2023
7032a8e
Update CHANGELOG.md
shaspitz Jul 13, 2023
707a298
Merge branch 'main' into shawn/fix-send-packets
shaspitz Jul 13, 2023
fc51cdf
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jul 13, 2023
25486c4
Merge branch 'shawn/fix-send-packets' into shawn/throttle-with-retrie…
shaspitz Jul 13, 2023
d7fdfa2
lints
shaspitz Jul 13, 2023
109aa26
doc on upgrade order
shaspitz Jul 14, 2023
bc853b3
small updates
shaspitz Jul 14, 2023
0e1df65
vsc matured handled res
shaspitz Jul 14, 2023
46d49e1
handle vsc matured acks
shaspitz Jul 14, 2023
cf3e324
adjust TestSendPacketsDeletion
shaspitz Jul 14, 2023
572d16d
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jul 18, 2023
7eb06b0
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jul 18, 2023
c6a3d94
Update relay_test.go
shaspitz Jul 18, 2023
2adee4a
Merge branch 'shawn/throttle-with-retries-consumer-changes' of https:…
shaspitz Jul 18, 2023
3ea9e0a
fix integration test
shaspitz Jul 18, 2023
d891843
fix send slash packet deletion test
shaspitz Jul 18, 2023
0f6111c
Merge branch 'main' into shawn/throttle-with-retries-consumer-changes
shaspitz Jul 18, 2023
30c7560
fix TestConsumerPacketSendExpiredClient
shaspitz Jul 20, 2023
1d050a0
lint
shaspitz Jul 20, 2023
ea4dd25
fix more tests
shaspitz Jul 20, 2023
914ccb6
final test fixes
shaspitz Jul 20, 2023
66fd18f
disable diff tests
shaspitz Jul 20, 2023
46251c9
smalls
shaspitz Jul 20, 2023
9b39582
Update steps_downtime.go
shaspitz Jul 21, 2023
25fc40a
Update slashing.go
shaspitz Jul 21, 2023
ebe3cd5
Update CHANGELOG.md
shaspitz Jul 21, 2023
f64d34d
Update x/ccv/consumer/keeper/throttle_retry.go
shaspitz Aug 7, 2023
81f47fb
Update throttle_retry.go
shaspitz Aug 7, 2023
f5831c4
Merge branch 'shawn/throttle-with-retries-consumer-changes' of https:…
shaspitz Aug 7, 2023
8c266f5
Update x/ccv/consumer/keeper/throttle_retry.go
shaspitz Aug 7, 2023
6566b7c
docstrings
shaspitz Aug 7, 2023
a670544
Merge branch 'shawn/throttle-with-retries-consumer-changes' of https:…
shaspitz Aug 7, 2023
130de0d
comment
shaspitz Aug 7, 2023
8a35533
DeleteHeadOfPendingPackets unit tests
shaspitz Aug 7, 2023
a972fd4
fix dup deletion
shaspitz Aug 7, 2023
9d111a8
better comment
shaspitz Aug 7, 2023
03daa2a
const
shaspitz Aug 7, 2023
569599a
rm todo and unneeded call
shaspitz Aug 7, 2023
18a86c3
linting is very important
shaspitz Aug 7, 2023
f57aa64
break instead of return
shaspitz Aug 8, 2023
afbe04c
return instead of just print
shaspitz Aug 8, 2023
34ccf91
fix test
shaspitz Aug 8, 2023
99c5df5
fix slashing test
shaspitz Aug 8, 2023
281527b
comment
shaspitz Aug 10, 2023
9ed7195
camel case
shaspitz Aug 10, 2023
a834a5b
FSM event explanation
shaspitz Aug 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release.

* (feat!) [#1024](https://github.com/cosmos/interchain-security/pull/1024) throttle with retries, consumer changes
* (fix!) revert consumer packet data changes from #1037 [#1150](https://github.com/cosmos/interchain-security/pull/1150)
* (fix!) proper deletion of pending packets [#1146](https://github.com/cosmos/interchain-security/pull/1146)
* (feat!) optimize pending packets storage on consumer, with migration! [#1037](https://github.com/cosmos/interchain-security/pull/1037)
Expand Down
9 changes: 7 additions & 2 deletions docs/docs/adrs/adr-008-throttle-retries.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: Throttle with retries

* 6/9/23: Initial draft
* 6/22/23: added note on consumer pending packets storage optimization
* 7/14/23: Added note on upgrade order

## Status

Expand Down Expand Up @@ -47,6 +48,8 @@ With the behavior described, we maintain very similar behavior to the current th

In the normal case, when no or a few slash packets are being sent, the VSCMaturedPackets will not be delayed, and hence unbonding will not be delayed.

For implementation of this design, see [throttle_retry.go](../../../x/ccv/consumer/keeper/throttle_retry.go).

### Consumer pending packets storage optimization

In addition to the mentioned consumer changes above. An optimization will need to be made to the consumer's pending packets storage to properly implement the feature from this ADR.
Expand Down Expand Up @@ -86,9 +89,11 @@ If a consumer sends VSCMatured packets too leniently: The consumer is malicious

If a consumer blocks the sending of VSCMatured packets: The consumer is malicious and blocking vsc matured packets that should have been sent. This will block unbonding only up until the VSC timeout period has elapsed. At that time, the consumer is removed. Again the malicious behavior only creates a negative outcome for the chain that is being malicious.

### Splitting of PRs
### Splitting of PRs and Upgrade Order

This feature will implement consumer changes in [#1024](https://github.com/cosmos/interchain-security/pull/1024). Note these changes should be deployed to prod for all consumers before the provider changes are deployed to prod. That is the consumer changes in #1024 are compatible with the current ("v1") provider implementation of throttling that's running on the Cosmos Hub as of July 2023.

We could split this feature into two PRs, one affecting the consumer and one affecting the provider, along with a third PR which could setup a clever way to upgrade the provider in multiple steps, ensuring that queued slash packets at upgrade time are handled properly.
Once all consumers have deployed the changes in #1024, the provider changes from (TBD) can be deployed to prod, fully enabling v2 throttling.

## Consequences

Expand Down
8 changes: 8 additions & 0 deletions proto/interchain_security/ccv/consumer/v1/consumer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ message MaturingVSCPacket {
google.protobuf.Timestamp maturity_time = 2
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}

// A record storing the state of a slash packet sent to the provider chain
// which may bounce back and forth until handled by the provider.
message SlashRecord {
bool waiting_on_reply = 1;
google.protobuf.Timestamp send_time = 2
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}
7 changes: 3 additions & 4 deletions tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package core

import (
"fmt"
"testing"
"time"

channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
Expand Down Expand Up @@ -331,9 +330,9 @@ func (s *CoreSuite) TestTraces() {
fmt.Println("Shortest [traceIx, actionIx]:", shortest, shortestLen)
}

func TestCoreSuite(t *testing.T) {
suite.Run(t, new(CoreSuite))
}
// func TestCoreSuite(t *testing.T) {
shaspitz marked this conversation as resolved.
Show resolved Hide resolved
// suite.Run(t, new(CoreSuite))
// }

// SetupTest sets up the test suite in a 'zero' state which matches
// the initial state in the model.
Expand Down
43 changes: 38 additions & 5 deletions tests/e2e/steps_downtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func stepsThrottledDowntime(consumerName string) []Step {
validator: validatorID("bob"),
},
state: State{
// powers not affected on either chain yet
// slash packet queued on consumer, but powers not affected on either chain yet
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
Expand All @@ -295,6 +295,39 @@ func stepsThrottledDowntime(consumerName string) []Step {
},
},
},
// Relay packets so bob is jailed on provider,
// and consumer receives ack that provider recv the downtime slash.
// The latter is necessary for the consumer to send the second downtime slash.
{
action: relayPacketsAction{
chainA: chainID("provi"),
chainB: chainID(consumerName),
port: "provider",
channel: 0,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 0, // bob is jailed
validatorID("carol"): 500,
},
// no provider throttling engaged yet
GlobalSlashQueueSize: uintPointer(0),
ConsumerChainQueueSizes: &map[chainID]uint{
chainID(consumerName): uint(0),
},
},
chainID(consumerName): ChainState{
// VSC packet applying jailing is not yet relayed to consumer
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
{
action: downtimeSlashAction{
chain: chainID(consumerName),
Expand All @@ -305,11 +338,12 @@ func stepsThrottledDowntime(consumerName string) []Step {
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
chainID(consumerName): ChainState{
// VSC packet applying jailing is not yet relayed to consumer
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500,
Expand Down Expand Up @@ -338,10 +372,9 @@ func stepsThrottledDowntime(consumerName string) []Step {
},
},
chainID(consumerName): ChainState{
// no updates received on consumer
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
Expand Down Expand Up @@ -373,7 +406,7 @@ func stepsThrottledDowntime(consumerName string) []Step {
// no updates received on consumer
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
Expand Down
24 changes: 19 additions & 5 deletions tests/integration/expired_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,34 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
// check that the packets were added to the list of pending data packets
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
s.Require().NotEmpty(consumerPackets)
// At this point we expect 4 packets, two vsc matured packets and two trailing slash packets
s.Require().Len(consumerPackets, 4, "unexpected number of pending data packets")

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

// go to next block to trigger SendPendingDataPackets
// go to next block to trigger SendPendingPackets
s.consumerChain.NextBlock()

// check that the list of pending data packets is emptied
// Check that the leading vsc matured packets were sent and no longer pending
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
s.Require().Empty(consumerPackets)
s.Require().Len(consumerPackets, 2, "unexpected number of pending data packets")

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

// First slash has been acked, now only the second slash packet should remain as pending
consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
s.Require().Len(consumerPackets, 1, "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)
// go to next block to trigger SendPendingPackets
s.consumerChain.NextBlock()

// relay committed packets from consumer to provider, only second slash packet should be committed
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // one slash

consumerPackets = consumerKeeper.GetPendingPackets(s.consumerCtx())
s.Require().Empty(consumerPackets, "pending data packets found")

// check that everything works
// - bond more tokens on provider to change validator powers
Expand Down
72 changes: 58 additions & 14 deletions tests/integration/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,34 @@ func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
s.SetupCCVChannel(s.path)
s.SetupTransferChannel()

packet := channeltypes.NewPacket([]byte{}, 1, ccv.ConsumerPortID, s.path.EndpointA.ChannelID,
// Mock a proper slash packet from consumer
spd := keepertestutil.GetNewSlashPacketData()

// We don't want truly randomized fields, infraction needs to be specified
if spd.Infraction == stakingtypes.Infraction_INFRACTION_UNSPECIFIED {
spd.Infraction = stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN
}
cpd := ccv.NewConsumerPacketData(ccv.SlashPacket,
&ccv.ConsumerPacketData_SlashPacketData{
SlashPacketData: &spd,
},
)
packet := channeltypes.NewPacket(cpd.GetBytes(), // Consumer always sends v1 packet data
1, ccv.ConsumerPortID, s.path.EndpointA.ChannelID,
ccv.ProviderPortID, s.path.EndpointB.ChannelID, clienttypes.Height{}, 0)

ack := providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet,
keepertestutil.GetNewSlashPacketData())
s.Require().NotNil(ack)
// Map infraction height on provider so validation passes and provider returns valid ack result
providerKeeper.SetValsetUpdateBlockHeight(s.providerCtx(), spd.ValsetUpdateId, 47923)

exportedAck := providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, spd)
s.Require().NotNil(exportedAck)

err := consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet, channeltypes.NewResultAcknowledgement(ack.Acknowledgement()))
// Unmarshal ack to struct that's compatible with consumer. IBC does this automatically
ack := channeltypes.Acknowledgement{}
err := channeltypes.SubModuleCdc.UnmarshalJSON(exportedAck.Acknowledgement(), &ack)
s.Require().NoError(err)

err = consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet, ack)
s.Require().NoError(err)

err = consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet, ccv.NewErrorAcknowledgementWithLog(s.consumerCtx(), fmt.Errorf("another error")))
Expand Down Expand Up @@ -492,9 +512,15 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
// clear queue, commit packets
suite.consumerApp.GetConsumerKeeper().SendPackets(ctx)

// check queue was cleared
// Check slash record is created
slashRecord, found := suite.consumerApp.GetConsumerKeeper().GetSlashRecord(suite.consumerCtx())
suite.Require().True(found, "slash record not found")
suite.Require().True(slashRecord.WaitingOnReply)
suite.Require().Equal(slashRecord.SendTime, suite.consumerCtx().BlockTime())

// check queue is not cleared, since no ack has been received from provider
pendingPackets = suite.consumerApp.GetConsumerKeeper().GetPendingPackets(ctx)
suite.Require().Empty(pendingPackets, "pending packets NOT empty")
suite.Require().Len(pendingPackets, 1, "pending packets len should be 1 is %d", len(pendingPackets))

// verify that the slash packet was sent
gotCommit := consumerIBCKeeper.ChannelKeeper.GetPacketCommitment(ctx, ccv.ConsumerPortID, channelID, seq)
Expand Down Expand Up @@ -579,9 +605,15 @@ func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// clear queue, commit packets
suite.consumerApp.GetConsumerKeeper().SendPackets(ctx)

// check queue was cleared
// Check slash record is created
slashRecord, found := suite.consumerApp.GetConsumerKeeper().GetSlashRecord(suite.consumerCtx())
suite.Require().True(found, "slash record not found")
suite.Require().True(slashRecord.WaitingOnReply)
suite.Require().Equal(slashRecord.SendTime, suite.consumerCtx().BlockTime())

// check queue is not cleared, since no ack has been received from provider
pendingPackets = suite.consumerApp.GetConsumerKeeper().GetPendingPackets(ctx)
suite.Require().Empty(pendingPackets, "pending packets NOT empty")
suite.Require().Len(pendingPackets, 1, "pending packets len should be 1 is %d", len(pendingPackets))

// check slash packet is sent
gotCommit := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(ctx, ccv.ConsumerPortID, channelID, seq)
Expand Down Expand Up @@ -644,10 +676,12 @@ func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
// establish ccv channel by sending an empty VSC packet to consumer endpoint
suite.SendEmptyVSCPacket()

// check that each pending data packet is sent once
// check that each pending data packet is sent once, as long as the prev slash packet was relayed/acked.
// Note that consumer throttling blocks packet sending until a slash packet is successfully acked by the provider.
for i := 0; i < 12; i++ {
commit := consumerIBCKeeper.ChannelKeeper.GetPacketCommitment(ctx, ccv.ConsumerPortID, channelID, seq+uint64(i))
suite.Require().NotNil(commit)
relayAllCommittedPackets(suite, suite.consumerChain, suite.path, ccv.ConsumerPortID, channelID, 1)
}

// check that outstanding downtime flags
Expand All @@ -657,8 +691,8 @@ func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
suite.Require().True(consumerKeeper.OutstandingDowntime(ctx, consAddr))
}

// send all pending packets - only slash packets should be queued in this test
consumerKeeper.SendPackets(ctx)
// SendPackets method should have already been called during
// endblockers in relayAllCommittedPackets above

// check that pending data packets got cleared
dataPackets = consumerKeeper.GetPendingPackets(ctx)
Expand All @@ -676,13 +710,21 @@ func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() {
pendingPackets := consumerKeeper.GetPendingPackets(suite.consumerCtx())
suite.Require().Len(pendingPackets, 0)

// No slash record found (no slash sent)
_, found := consumerKeeper.GetSlashRecord(suite.consumerCtx())
suite.Require().False(found)

consumerKeeper.SlashWithInfractionReason(suite.consumerCtx(), []byte{0x01, 0x02, 0x3},
66, 4324, sdk.MustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_DOWNTIME)

// Check slash packet was queued
pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx())
suite.Require().Len(pendingPackets, 1)

// but slash packet is not yet sent
_, found = consumerKeeper.GetSlashRecord(suite.consumerCtx())
suite.Require().False(found)

// Pass 5 blocks, confirming the consumer doesn't panic
for i := 0; i < 5; i++ {
suite.consumerChain.NextBlock()
Expand All @@ -698,6 +740,8 @@ func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() {

// Pass one more block, and confirm the packet is sent now that ccv channel is established
suite.consumerChain.NextBlock()
pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx())
suite.Require().Len(pendingPackets, 0)

// Slash record should now be found (slash sent)
_, found = consumerKeeper.GetSlashRecord(suite.consumerCtx())
suite.Require().True(found)
}
Loading
Loading