Skip to content

Commit 96f42bf

Browse files
Merge #4134
4134: Re-enable SN epoch integration test r=jordanschalm a=jordanschalm ## Context The test failure was caused by this fatal error from the Consensus Node brought up to join in the second epoch: `··· DOCK: 2023-03-30 19:48:34.635587 +0000 UTC (clogs ) consensus_test_3 (16726f0fad5781fa651f6a048c007e9f6a4202f8111811cbec685ac96774c32a) - �{"level":"fatal","node_role":"consensus","node_id":"522f1406e6e0c2267dbcc49519539c18d866a584df709e1a277bdbc28bd2d40c","error":"component sealing engine initialization failed: could not repopulate assignment collectors tree: internal error while traversing fork: visitor errored on block 6058fc1a85eaff3f46fe1d2a530ea7fe648cef771c75594bcfeef66238450bda at height 57: could not process incorporated result from block 6058fc1a85eaff3f46fe1d2a530ea7fe648cef771c75594bcfeef66238450bda: could not process incorporated incRes: could not process incorporated result 741f4ba4ad5ff7918b7aaa615306f136ae2e2b9b13a729e115e9fb48c2713b03: could not determine chunk assignment: failed to retrieve source of randomness: could not retrieve quorum certificate for (6058fc1a85eaff3f46fe1d2a530ea7fe648cef771c75594bcfeef66238450bda): could not retrieve resource: key not found","time":"2023-03-30T19:48:34.634479451Z","message":"unhandled irrecoverable error"}` The problem is that, the sealing engine attempts to populate its state using the sealing segment, but it cannot read the QC for some of these blocks. In #3947, we changed to read QCs from storage directly in all cases. However, these QCs were not stored in QC storage for all blocks, in particular sealing segment blocks. ## Changes - Fixes the bug by inserting QCs explicitly for all sealing segment blocks and adds a test case - Re-enables the integration test Co-authored-by: Jordan Schalm <[email protected]>
2 parents 243a5e3 + 9c8b78a commit 96f42bf

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

integration/tests/epochs/epoch_join_and_leave_sn_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/stretchr/testify/suite"
77

88
"github.com/onflow/flow-go/model/flow"
9-
"github.com/onflow/flow-go/utils/unittest"
109
)
1110

1211
func TestEpochJoinAndLeaveSN(t *testing.T) {
@@ -20,6 +19,5 @@ type EpochJoinAndLeaveSNSuite struct {
2019
// TestEpochJoinAndLeaveSN should update consensus nodes and assert healthy network conditions
2120
// after the epoch transition completes. See health check function for details.
2221
func (s *EpochJoinAndLeaveSNSuite) TestEpochJoinAndLeaveSN() {
23-
unittest.SkipUnless(s.T(), unittest.TEST_FLAKY, "fails on CI regularly")
2422
s.runTestEpochJoinAndLeave(flow.RoleConsensus, s.assertNetworkHealthyAfterSNChange)
2523
}

integration/tests/epochs/suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ func (s *Suite) runTestEpochJoinAndLeave(role flow.Role, checkNetworkHealth node
672672
s.TimedLogf("retrieved header after entering EpochSetup phase: root_height=%d, root_view=%d, segment_heights=[%d-%d], segment_views=[%d-%d]",
673673
header.Height, header.View,
674674
segment.Sealed().Header.Height, segment.Highest().Header.Height,
675-
segment.Sealed().Header.View, segment.Highest().Header.Height)
675+
segment.Sealed().Header.View, segment.Highest().Header.View)
676676

677677
testContainer.WriteRootSnapshot(rootSnapshot)
678678
testContainer.Container.Start(s.ctx)

state/protocol/badger/state.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,15 @@ func (state *State) bootstrapSealingSegment(segment *flow.SealingSegment, head *
194194
height := block.Header.Height
195195
err := state.blocks.StoreTx(block)(tx)
196196
if err != nil {
197-
return fmt.Errorf("could not insert root block: %w", err)
197+
return fmt.Errorf("could not insert SealingSegment extra block: %w", err)
198198
}
199199
err = transaction.WithTx(operation.IndexBlockHeight(height, blockID))(tx)
200200
if err != nil {
201-
return fmt.Errorf("could not index root block segment (id=%x): %w", blockID, err)
201+
return fmt.Errorf("could not index SealingSegment extra block (id=%x): %w", blockID, err)
202+
}
203+
err = state.qcs.StoreTx(block.Header.QuorumCertificate())(tx)
204+
if err != nil {
205+
return fmt.Errorf("could not store qc for SealingSegment extra block (id=%x): %w", blockID, err)
202206
}
203207
}
204208

@@ -208,11 +212,15 @@ func (state *State) bootstrapSealingSegment(segment *flow.SealingSegment, head *
208212

209213
err := state.blocks.StoreTx(block)(tx)
210214
if err != nil {
211-
return fmt.Errorf("could not insert root block: %w", err)
215+
return fmt.Errorf("could not insert SealingSegment block: %w", err)
212216
}
213217
err = transaction.WithTx(operation.IndexBlockHeight(height, blockID))(tx)
214218
if err != nil {
215-
return fmt.Errorf("could not index root block segment (id=%x): %w", blockID, err)
219+
return fmt.Errorf("could not index SealingSegment block (id=%x): %w", blockID, err)
220+
}
221+
err = state.qcs.StoreTx(block.Header.QuorumCertificate())(tx)
222+
if err != nil {
223+
return fmt.Errorf("could not store qc for SealingSegment block (id=%x): %w", blockID, err)
216224
}
217225

218226
// index the latest seal as of this block

state/protocol/badger/state_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ func TestBootstrapNonRoot(t *testing.T) {
280280
bootstrap(t, after, func(state *bprotocol.State, err error) {
281281
require.NoError(t, err)
282282
unittest.AssertSnapshotsEqual(t, after, state.Final())
283+
// should be able to read all QCs
284+
segment, err := state.Final().SealingSegment()
285+
require.NoError(t, err)
286+
for _, block := range segment.Blocks {
287+
snapshot := state.AtBlockID(block.ID())
288+
_, err := snapshot.QuorumCertificate()
289+
require.NoError(t, err)
290+
_, err = snapshot.RandomSource()
291+
require.NoError(t, err)
292+
}
283293
})
284294
})
285295

0 commit comments

Comments
 (0)