From cda715b955fca4f72294acf13d042ee8061b12bc Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Thu, 30 Mar 2023 16:22:49 -0400 Subject: [PATCH 1/2] re-enable SN epoch integration test - fix a bug introduced in https://github.com/onflow/flow-go/pull/3947, which resulted in some QCs being un-queriable --- .../tests/epochs/epoch_join_and_leave_sn_test.go | 3 +-- integration/tests/epochs/suite.go | 2 +- state/protocol/badger/state.go | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/integration/tests/epochs/epoch_join_and_leave_sn_test.go b/integration/tests/epochs/epoch_join_and_leave_sn_test.go index fd340aabceb..a5ed6a7ca74 100644 --- a/integration/tests/epochs/epoch_join_and_leave_sn_test.go +++ b/integration/tests/epochs/epoch_join_and_leave_sn_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/onflow/flow-go/model/flow" - "github.com/onflow/flow-go/utils/unittest" ) func TestEpochJoinAndLeaveSN(t *testing.T) { @@ -20,6 +19,6 @@ type EpochJoinAndLeaveSNSuite struct { // TestEpochJoinAndLeaveSN should update consensus nodes and assert healthy network conditions // after the epoch transition completes. See health check function for details. func (s *EpochJoinAndLeaveSNSuite) TestEpochJoinAndLeaveSN() { - unittest.SkipUnless(s.T(), unittest.TEST_FLAKY, "fails on CI regularly") + //unittest.SkipUnless(s.T(), unittest.TEST_FLAKY, "fails on CI regularly") s.runTestEpochJoinAndLeave(flow.RoleConsensus, s.assertNetworkHealthyAfterSNChange) } diff --git a/integration/tests/epochs/suite.go b/integration/tests/epochs/suite.go index f8d84702c47..3c7e60e76cb 100644 --- a/integration/tests/epochs/suite.go +++ b/integration/tests/epochs/suite.go @@ -672,7 +672,7 @@ func (s *Suite) runTestEpochJoinAndLeave(role flow.Role, checkNetworkHealth node s.TimedLogf("retrieved header after entering EpochSetup phase: root_height=%d, root_view=%d, segment_heights=[%d-%d], segment_views=[%d-%d]", header.Height, header.View, segment.Sealed().Header.Height, segment.Highest().Header.Height, - segment.Sealed().Header.View, segment.Highest().Header.Height) + segment.Sealed().Header.View, segment.Highest().Header.View) testContainer.WriteRootSnapshot(rootSnapshot) testContainer.Container.Start(s.ctx) diff --git a/state/protocol/badger/state.go b/state/protocol/badger/state.go index db95326d142..60027776f0a 100644 --- a/state/protocol/badger/state.go +++ b/state/protocol/badger/state.go @@ -194,11 +194,15 @@ func (state *State) bootstrapSealingSegment(segment *flow.SealingSegment, head * height := block.Header.Height err := state.blocks.StoreTx(block)(tx) if err != nil { - return fmt.Errorf("could not insert root block: %w", err) + return fmt.Errorf("could not insert SealingSegment extra block: %w", err) } err = transaction.WithTx(operation.IndexBlockHeight(height, blockID))(tx) if err != nil { - return fmt.Errorf("could not index root block segment (id=%x): %w", blockID, err) + return fmt.Errorf("could not index SealingSegment extra block (id=%x): %w", blockID, err) + } + err = state.qcs.StoreTx(block.Header.QuorumCertificate())(tx) + if err != nil { + return fmt.Errorf("could not store qc for SealingSegment extra block (id=%x): %w", blockID, err) } } @@ -208,11 +212,15 @@ func (state *State) bootstrapSealingSegment(segment *flow.SealingSegment, head * err := state.blocks.StoreTx(block)(tx) if err != nil { - return fmt.Errorf("could not insert root block: %w", err) + return fmt.Errorf("could not insert SealingSegment block: %w", err) } err = transaction.WithTx(operation.IndexBlockHeight(height, blockID))(tx) if err != nil { - return fmt.Errorf("could not index root block segment (id=%x): %w", blockID, err) + return fmt.Errorf("could not index SealingSegment block (id=%x): %w", blockID, err) + } + err = state.qcs.StoreTx(block.Header.QuorumCertificate())(tx) + if err != nil { + return fmt.Errorf("could not store qc for SealingSegment block (id=%x): %w", blockID, err) } // index the latest seal as of this block From 9c8b78a40c59d8b31ccf96a1df3e9bb5dc05faa1 Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Thu, 30 Mar 2023 16:31:31 -0400 Subject: [PATCH 2/2] add test for reading qcs after bootstrap --- .../tests/epochs/epoch_join_and_leave_sn_test.go | 1 - state/protocol/badger/state_test.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/integration/tests/epochs/epoch_join_and_leave_sn_test.go b/integration/tests/epochs/epoch_join_and_leave_sn_test.go index a5ed6a7ca74..a3763420cdc 100644 --- a/integration/tests/epochs/epoch_join_and_leave_sn_test.go +++ b/integration/tests/epochs/epoch_join_and_leave_sn_test.go @@ -19,6 +19,5 @@ type EpochJoinAndLeaveSNSuite struct { // TestEpochJoinAndLeaveSN should update consensus nodes and assert healthy network conditions // after the epoch transition completes. See health check function for details. func (s *EpochJoinAndLeaveSNSuite) TestEpochJoinAndLeaveSN() { - //unittest.SkipUnless(s.T(), unittest.TEST_FLAKY, "fails on CI regularly") s.runTestEpochJoinAndLeave(flow.RoleConsensus, s.assertNetworkHealthyAfterSNChange) } diff --git a/state/protocol/badger/state_test.go b/state/protocol/badger/state_test.go index b67d146c195..ec31ee8ae5b 100644 --- a/state/protocol/badger/state_test.go +++ b/state/protocol/badger/state_test.go @@ -280,6 +280,16 @@ func TestBootstrapNonRoot(t *testing.T) { bootstrap(t, after, func(state *bprotocol.State, err error) { require.NoError(t, err) unittest.AssertSnapshotsEqual(t, after, state.Final()) + // should be able to read all QCs + segment, err := state.Final().SealingSegment() + require.NoError(t, err) + for _, block := range segment.Blocks { + snapshot := state.AtBlockID(block.ID()) + _, err := snapshot.QuorumCertificate() + require.NoError(t, err) + _, err = snapshot.RandomSource() + require.NoError(t, err) + } }) })