From ac62aa6917cc9f6951c559388fe419ce178543f7 Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Wed, 8 Nov 2023 17:08:44 -0800 Subject: [PATCH 1/3] test2.3 --- .../tests/epochs/cohort2/epoch_join_and_leave_vn_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go b/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go index 65569dacd08..3fadf466669 100644 --- a/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go +++ b/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go @@ -28,7 +28,7 @@ func (s *EpochJoinAndLeaveVNSuite) SetupTest() { s.DKGPhaseLen = 100 s.EpochLen = 450 s.EpochCommitSafetyThreshold = 20 - s.DynamicEpochTransitionSuite.SetupTest() + s.DynamicEpochTransitionSuite.Suite.SetupTest() } // TestEpochJoinAndLeaveVN should update verification nodes and assert healthy network conditions From b22d99348f1ca9673e24fe04a23247c92ddd456d Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Wed, 8 Nov 2023 17:11:00 -0800 Subject: [PATCH 2/3] test 2.3 --- engine/access/rpc/backend/backend.go | 2 +- integration/tests/epochs/suite.go | 10 ++++++---- integration/tests/lib/util.go | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/engine/access/rpc/backend/backend.go b/engine/access/rpc/backend/backend.go index 4bf1d77ad9a..25961ee51ab 100644 --- a/engine/access/rpc/backend/backend.go +++ b/engine/access/rpc/backend/backend.go @@ -34,7 +34,7 @@ const DefaultMaxHeightRange = 250 // DefaultSnapshotHistoryLimit the amount of blocks to look back in state // when recursively searching for a valid snapshot -const DefaultSnapshotHistoryLimit = 50 +const DefaultSnapshotHistoryLimit = 500 // DefaultLoggedScriptsCacheSize is the default size of the lookup cache used to dedupe logs of scripts sent to ENs // limiting cache size to 16MB and does not affect script execution, only for keeping logs tidy diff --git a/integration/tests/epochs/suite.go b/integration/tests/epochs/suite.go index afb0d285822..8ab1decc1b3 100644 --- a/integration/tests/epochs/suite.go +++ b/integration/tests/epochs/suite.go @@ -451,18 +451,20 @@ func (s *Suite) getContainerToReplace(role flow.Role) *testnet.Container { // AwaitEpochPhase waits for the given phase, in the given epoch. func (s *Suite) AwaitEpochPhase(ctx context.Context, expectedEpoch uint64, expectedPhase flow.EpochPhase, waitFor, tick time.Duration) { + var actualEpoch uint64 + var actualPhase flow.EpochPhase condition := func() bool { snapshot, err := s.Client.GetLatestProtocolSnapshot(ctx) require.NoError(s.T(), err) - actualEpoch, err := snapshot.Epochs().Current().Counter() + actualEpoch, err = snapshot.Epochs().Current().Counter() require.NoError(s.T(), err) - actualPhase, err := snapshot.Phase() + actualPhase, err = snapshot.Phase() require.NoError(s.T(), err) return actualEpoch == expectedEpoch && actualPhase == expectedPhase } - require.Eventuallyf(s.T(), condition, waitFor, tick, "did not reach expectedEpoch %d phase %s within %s", expectedEpoch, expectedPhase, waitFor) + require.Eventuallyf(s.T(), condition, waitFor, tick, "did not reach expectedEpoch %d phase %s within %s. Last saw epoch=%d and phase=%s", expectedEpoch, expectedPhase, waitFor, actualEpoch, actualPhase) } // AssertInEpochPhase checks if we are in the phase of the given epoch. @@ -640,7 +642,7 @@ func (s *Suite) RunTestEpochJoinAndLeave(role flow.Role, checkNetworkHealth node // wait for epoch setup phase before we start our container and pause the old container s.TimedLogf("waiting for EpochSetup phase of first epoch to begin") - s.AwaitEpochPhase(s.Ctx, 0, flow.EpochPhaseSetup, 3*time.Minute, 500*time.Millisecond) + s.AwaitEpochPhase(s.Ctx, 0, flow.EpochPhaseSetup, time.Minute, 500*time.Millisecond) s.TimedLogf("successfully reached EpochSetup phase of first epoch") // get the latest snapshot and start new container with it diff --git a/integration/tests/lib/util.go b/integration/tests/lib/util.go index cd74bd73fb1..99e5d739780 100644 --- a/integration/tests/lib/util.go +++ b/integration/tests/lib/util.go @@ -220,28 +220,28 @@ func WithChainID(chainID flow.ChainID) func(tx *sdk.Transaction) { // LogStatus logs current information about the test network state. func LogStatus(t *testing.T, ctx context.Context, log zerolog.Logger, client *testnet.Client) { + // retrieves latest FINALIZED snapshot snapshot, err := client.GetLatestProtocolSnapshot(ctx) if err != nil { - log.Err(err).Msg("failed to get sealed snapshot") - return - } - finalized, err := client.GetLatestFinalizedBlockHeader(ctx) - if err != nil { - log.Err(err).Msg("failed to get finalized header") + log.Err(err).Msg("failed to get finalized snapshot") return } - sealed, err := snapshot.Head() + sealingSegment, err := snapshot.SealingSegment() require.NoError(t, err) + sealed := sealingSegment.Sealed() + finalized := sealingSegment.Finalized() + phase, err := snapshot.Phase() require.NoError(t, err) epoch := snapshot.Epochs().Current() counter, err := epoch.Counter() require.NoError(t, err) - log.Info().Uint64("final_height", finalized.Height). - Uint64("sealed_height", sealed.Height). - Uint64("sealed_view", sealed.View). + log.Info().Uint64("final_height", finalized.Header.Height). + Uint64("final_view", finalized.Header.View). + Uint64("sealed_height", sealed.Header.Height). + Uint64("sealed_view", sealed.Header.View). Str("cur_epoch_phase", phase.String()). Uint64("cur_epoch_counter", counter). Msg("test run status") From 54bdfc2d23e8eb2061a69273388f9f43778f8036 Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Wed, 8 Nov 2023 17:38:01 -0800 Subject: [PATCH 3/3] test 2.4 - slow block rate --- .../tests/epochs/cohort2/epoch_join_and_leave_vn_test.go | 3 +++ integration/tests/epochs/suite.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go b/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go index 3fadf466669..01f823f3c86 100644 --- a/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go +++ b/integration/tests/epochs/cohort2/epoch_join_and_leave_vn_test.go @@ -2,6 +2,7 @@ package cohort2 import ( "testing" + "time" "github.com/stretchr/testify/suite" @@ -20,6 +21,8 @@ type EpochJoinAndLeaveVNSuite struct { func (s *EpochJoinAndLeaveVNSuite) SetupTest() { // require approvals for seals to verify that the joining VN is producing valid seals in the second epoch s.RequiredSealApprovals = 1 + // slow down consensus, as sealing tends to lag behind + s.ConsensusProposalDuration = time.Millisecond * 250 // increase epoch length to account for greater sealing lag due to above // NOTE: this value is set fairly aggressively to ensure shorter test times. // If flakiness due to failure to complete staking operations in time is observed, diff --git a/integration/tests/epochs/suite.go b/integration/tests/epochs/suite.go index 8ab1decc1b3..14b6ee1b814 100644 --- a/integration/tests/epochs/suite.go +++ b/integration/tests/epochs/suite.go @@ -64,10 +64,16 @@ type Suite struct { // Whether approvals are required for sealing (we only enable for VN tests because // requiring approvals requires a longer DKG period to avoid flakiness) RequiredSealApprovals uint // defaults to 0 (no approvals required) + // Consensus Node proposal duration + ConsensusProposalDuration time.Duration } // SetupTest is run automatically by the testing framework before each test case. func (s *Suite) SetupTest() { + // If unset, use default value 100ms + if s.ConsensusProposalDuration == 0 { + s.ConsensusProposalDuration = time.Millisecond * 100 + } minEpochLength := s.StakingAuctionLen + s.DKGPhaseLen*3 + 20 // ensure epoch lengths are set correctly @@ -85,7 +91,7 @@ func (s *Suite) SetupTest() { testnet.WithLogLevel(zerolog.WarnLevel)} consensusConfigs := []func(config *testnet.NodeConfig){ - testnet.WithAdditionalFlag("--cruise-ctl-fallback-proposal-duration=100ms"), + testnet.WithAdditionalFlag(fmt.Sprintf("--cruise-ctl-fallback-proposal-duration=%s", s.ConsensusProposalDuration)), testnet.WithAdditionalFlag(fmt.Sprintf("--required-verification-seal-approvals=%d", s.RequiredSealApprovals)), testnet.WithAdditionalFlag(fmt.Sprintf("--required-construction-seal-approvals=%d", s.RequiredSealApprovals)), testnet.WithLogLevel(zerolog.WarnLevel)}