Skip to content

Commit

Permalink
fix state comm stracking
Browse files Browse the repository at this point in the history
- reduce number of state commits to wait for
  • Loading branch information
kc1116 committed Jun 12, 2023
1 parent 7c6a0da commit d24265f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *GossipsubRPCInspectorFalsePositiveNotificationsTestSuite) TestGossipsub
// some artificial network activity.
go s.loaderLoop(ctx, numOfTestAccounts, loaderLoopInterval)
// wait 20 state commitment changes, this ensures we simulated load on network as expected.
s.waitForStateCommitments(s.Ctx, 20, 15*time.Second, 500*time.Millisecond)
s.waitForStateCommitments(s.Ctx, 5, time.Minute, 500*time.Millisecond)

// ensure no node in the network has disseminated an invalid control message notification
metricName := s.inspectorNotificationQSizeMetricName()
Expand Down
21 changes: 10 additions & 11 deletions integration/tests/bft/gossipsub/rpc_inspector/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ func (s *Suite) SetupSuite() {
}

name := "bft_control_message_validation_false_positive_test"
netConfig := testnet.NewNetworkConfig(
name,
s.NodeConfigs,
// set long staking phase to avoid QC/DKG transactions during test run
testnet.WithViewsInStakingAuction(10_000),
testnet.WithViewsInEpoch(100_000),
)

// short epoch lens ensure faster state commitments
stakingAuctionLen := uint64(10)
dkgPhaseLen := uint64(50)
epochLen := uint64(300)
epochCommitSafetyThreshold := uint64(50)
netConfig := testnet.NewNetworkConfigWithEpochConfig(name, s.NodeConfigs, stakingAuctionLen, dkgPhaseLen, epochLen, epochCommitSafetyThreshold)
s.Net = testnet.PrepareFlowNetwork(s.T(), netConfig, flow.BftTestnet)

s.Ctx, s.Cancel = context.WithCancel(context.Background())
Expand Down Expand Up @@ -102,14 +100,15 @@ func (s *Suite) loaderLoop(ctx context.Context, numOfTestAccounts int, interval

// waitStateCommitments waits for n number of state commitment changes.
func (s *Suite) waitForStateCommitments(ctx context.Context, n int, waitFor, tick time.Duration) {
startStateComm := s.getCurrERFinalStateCommitment(ctx)
prevStateComm := s.getCurrERFinalStateCommitment(ctx)
numOfStateCommChanges := 0
require.Eventually(s.T(), func() bool {
currStateComm := s.getCurrERFinalStateCommitment(ctx)
if startStateComm != currStateComm {
if prevStateComm != currStateComm {
numOfStateCommChanges++
prevStateComm = currStateComm
}
return numOfStateCommChanges == n
return numOfStateCommChanges >= n
}, waitFor, tick)
}

Expand Down

0 comments on commit d24265f

Please sign in to comment.