Skip to content

Commit ac630c8

Browse files
durkmurderAlexander Hentschel
andauthored
Apply suggestions from code review
Co-authored-by: Alexander Hentschel <[email protected]>
1 parent 9a84691 commit ac630c8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

state/protocol/badger/mutator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ func (m *FollowerState) epochTransitionMetricsAndEventsOnBlockFinalized(block *f
859859
//
860860
// A <-- ... <-- C(Seal_A)
861861
//
862-
// Suppose an EpochSetup service event is emitted in block A. C seals A, therefore
862+
// Suppose an EpochSetup service event is emitted during execution of block A. C seals A, therefore
863863
// we apply the metrics/events when C is finalized. The first block of the EpochSetup
864864
// phase is block C.
865865
//
@@ -975,7 +975,8 @@ func (m *FollowerState) epochStatus(block *flow.Header, epochFallbackTriggered b
975975
// seal for block A. This is because we rely on the sealing subsystem to validate
976976
// correctness of the service event before processing it.
977977
// Consequently, any change to the protocol state introduced by a service event
978-
// emitted in A would only become visible when querying C or later (C's children).
978+
// emitted during execution of block A would only become visible when querying
979+
// C or its descendants.
979980
//
980981
// This method will only apply service-event-induced state changes when the
981982
// input block has the form of block C (ie. contains a seal for a block in

state/protocol/badger/snapshot_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ func TestSealingSegment(t *testing.T) {
291291
// build a valid child B3 to ensure we have a QC
292292
buildBlock(t, state, unittest.BlockWithParentFixture(block3.Header))
293293

294-
// sealing segment should contain B1 and B2
295-
// B2 is reference of snapshot, B1 is latest sealed
294+
// sealing segment should contain B1, B2, B3
295+
// B3 is reference of snapshot, B1 is latest sealed
296296
unittest.AssertEqualBlocksLenAndOrder(t, []*flow.Block{block1, block2, block3}, segment.Blocks)
297297
assert.Len(t, segment.ExecutionResults, 1)
298298
assertSealingSegmentBlocksQueryableAfterBootstrap(t, state.AtBlockID(block3.ID()))
@@ -316,7 +316,11 @@ func TestSealingSegment(t *testing.T) {
316316
// build a large chain of intermediary blocks
317317
for i := 0; i < 100; i++ {
318318
next := unittest.BlockWithParentFixture(parent.Header)
319-
next.SetPayload(unittest.PayloadFixture(unittest.WithReceipts(receipt1)))
319+
if i == 0 {
320+
// Repetitions of the same receipt in one fork would be a protocol violation.
321+
// Hence, we include the result only once in the direct child of B1.
322+
next.SetPayload(unittest.PayloadFixture(unittest.WithReceipts(receipt1)))
323+
}
320324
buildFinalizedBlock(t, state, next)
321325
parent = next
322326
}
@@ -833,17 +837,17 @@ func TestLatestSealedResult(t *testing.T) {
833837
err = state.ExtendCertified(context.Background(), block4, block5.Header.QuorumCertificate())
834838
require.NoError(t, err)
835839

836-
// B1 <- B2(S1) <- B3(S1)
840+
// B1 <- B2(S1) <- B3(S1) <- B4(R2,R3)
837841
// querying B3 should still return (R1,S1) even though they are in parent block
838842
t.Run("reference block contains no seal", func(t *testing.T) {
839-
gotResult, gotSeal, err := state.AtBlockID(block3.ID()).SealedResult()
843+
gotResult, gotSeal, err := state.AtBlockID(block4.ID()).SealedResult()
840844
require.NoError(t, err)
841845
assert.Equal(t, &receipt1.ExecutionResult, gotResult)
842846
assert.Equal(t, seal1, gotSeal)
843847
})
844848

845849
// B1 <- B2(R1) <- B3(S1) <- B4(R2,R3) <- B5(S2,S3)
846-
// There are two seals in B4 - should return latest by height (S3,R3)
850+
// There are two seals in B5 - should return latest by height (S3,R3)
847851
t.Run("reference block contains multiple seals", func(t *testing.T) {
848852
err = state.ExtendCertified(context.Background(), block5, unittest.CertifyBlock(block5.Header))
849853
require.NoError(t, err)

0 commit comments

Comments
 (0)