Skip to content

Commit f6d19c5

Browse files
authored
Merge pull request #4153 from onflow/jordan/suggestions-for-pr-4149
Suggestions for PR #4149
2 parents d88fdf5 + 9400dc2 commit f6d19c5

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

state/protocol/badger/mutator.go

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -857,15 +857,11 @@ func (m *FollowerState) epochTransitionMetricsAndEventsOnBlockFinalized(block *f
857857
//
858858
// Convention:
859859
//
860-
// A <-- ... <-- P(Seal_A) <----- B
861-
// ↑ ↑
862-
// block sealing service event first block of new Epoch phase
863-
// for epoch-phase transition (e.g. EpochSetup phase)
864-
// (e.g. EpochSetup event)
860+
// A <-- ... <-- C(Seal_A)
865861
//
866-
// Per convention, protocol events for epoch phase changes are emitted when
867-
// the first block of the new phase (eg. EpochSetup phase) is _finalized_.
868-
// Meaning that the new phase has started.
862+
// Suppose an EpochSetup service event is emitted in block A. C seals A, therefore
863+
// we apply the metrics/events when C is finalized. The first block of the EpochSetup
864+
// phase is block C.
869865
//
870866
// This function should only be called when epoch fallback *has not already been triggered*.
871867
// No errors are expected during normal operation.
@@ -965,27 +961,25 @@ func (m *FollowerState) epochStatus(block *flow.Header, epochFallbackTriggered b
965961

966962
// handleEpochServiceEvents handles applying state changes which occur as a result
967963
// of service events being included in a block payload:
968-
// * inserting incorporated service events
969-
// * updating EpochStatus for the candidate block
964+
// - inserting incorporated service events
965+
// - updating EpochStatus for the candidate block
970966
//
971967
// Consider a chain where a service event is emitted during execution of block A.
972-
// Block B contains a receipt for A. Block C contains a seal for block A. Block
973-
// D contains a QC for C.
968+
// Block B contains a receipt for A. Block C contains a seal for block A.
974969
//
975-
// A <- B(RA) <- C(SA) <- D
970+
// A <- .. <- B(RA) <- .. <- C(SA)
976971
//
977972
// Service events are included within execution results, which are stored
978973
// opaquely as part of the block payload in block B. We only validate and insert
979-
// the typed service event to storage once we have received a valid QC for the
980-
// block containing the seal for A. This occurs once we mark block D as valid
981-
// with MarkValid. Because of this, any change to the protocol state introduced
982-
// by a service event emitted in A would only become visible when querying D or
983-
// later (D's children).
984-
// TODO(active-pacemaker) update docs here (remove reference to MarkValid) https://github.com/dapperlabs/flow-go/issues/6254
974+
// the typed service event to storage once we process C, the block containing the
975+
// seal for block A. This is because we rely on the sealing subsystem to validate
976+
// correctness of the service event before processing it.
977+
// 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).
985979
//
986980
// This method will only apply service-event-induced state changes when the
987-
// input block has the form of block D (ie. has a parent, which contains a seal
988-
// for a block in which a service event was emitted).
981+
// input block has the form of block C (ie. contains a seal for a block in
982+
// which a service event was emitted).
989983
//
990984
// Return values:
991985
// - dbUpdates - If the service events are valid, or there are no service events,

state/protocol/badger/mutator_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,18 +573,18 @@ func TestExtendReceiptsValid(t *testing.T) {
573573
// event, then a commit event, then finalizing the first block of the next epoch.
574574
// Also tests that appropriate epoch transition events are fired.
575575
//
576-
// Epoch information becomes available in the protocol state in the block when processing
577-
// the block with relevant service event.
576+
// Epoch information becomes available in the protocol state in the block containing the seal
577+
// for the block in which the relevant service event was emitted.
578578
//
579579
// ROOT <- B1 <- B2(R1) <- B3(S1) <- B4 <- B5(R2) <- B6(S2) <- B7 <-|- B8
580580
//
581581
// B3 seals B1, in which EpochSetup is emitted.
582-
// * we can query the EpochSetup beginning with B3
583-
// * EpochSetupPhaseStarted triggered when B3 is finalized
582+
// - we can query the EpochSetup beginning with B3
583+
// - EpochSetupPhaseStarted triggered when B3 is finalized
584584
//
585585
// B6 seals B2, in which EpochCommitted is emitted.
586-
// * we can query the EpochCommit beginning with B6
587-
// * EpochSetupPhaseStarted triggered when B6 is finalized
586+
// - we can query the EpochCommit beginning with B6
587+
// - EpochCommittedPhaseStarted triggered when B6 is finalized
588588
//
589589
// B7 is the final block of the epoch.
590590
// B8 is the first block of the NEXT epoch.
@@ -1604,8 +1604,8 @@ func TestEmergencyEpochFallback(t *testing.T) {
16041604
})
16051605

16061606
// if an invalid epoch service event is incorporated, we should:
1607-
// * not apply the phase transition corresponding to the invalid service event
1608-
// * immediately trigger EECC
1607+
// - not apply the phase transition corresponding to the invalid service event
1608+
// - immediately trigger EECC
16091609
//
16101610
// Epoch Boundary
16111611
// |

0 commit comments

Comments
 (0)