Skip to content

Commit 8203b59

Browse files
committed
update mutator docs for service event change
1 parent d88fdf5 commit 8203b59

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
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,

0 commit comments

Comments
 (0)