@@ -664,7 +664,7 @@ func (m *FollowerState) Finalize(ctx context.Context, blockID flow.Identifier) e
664664 // If epoch emergency fallback is triggered, the current epoch continues until
665665 // the next spork - so skip these updates.
666666 if ! epochFallbackTriggered {
667- epochPhaseMetrics , epochPhaseEvents , err := m .epochPhaseMetricsAndEventsOnBlockFinalized (header , epochStatus )
667+ epochPhaseMetrics , epochPhaseEvents , err := m .epochPhaseMetricsAndEventsOnBlockFinalized (block , epochStatus )
668668 if err != nil {
669669 return fmt .Errorf ("could not determine epoch phase metrics/events for finalized block: %w" , err )
670670 }
@@ -869,19 +869,13 @@ func (m *FollowerState) epochTransitionMetricsAndEventsOnBlockFinalized(block *f
869869//
870870// This function should only be called when epoch fallback *has not already been triggered*.
871871// No errors are expected during normal operation.
872- func (m * FollowerState ) epochPhaseMetricsAndEventsOnBlockFinalized (block * flow.Header , epochStatus * flow.EpochStatus ) (
872+ func (m * FollowerState ) epochPhaseMetricsAndEventsOnBlockFinalized (block * flow.Block , epochStatus * flow.EpochStatus ) (
873873 metrics []func (),
874874 events []func (),
875875 err error ,
876876) {
877-
878- parent , err := m .blocks .ByID (block .ParentID )
879- if err != nil {
880- return nil , nil , fmt .Errorf ("could not get parent (id=%x): %w" , block .ParentID , err )
881- }
882-
883877 // track service event driven metrics and protocol events that should be emitted
884- for _ , seal := range parent .Payload .Seals {
878+ for _ , seal := range block .Payload .Seals {
885879
886880 result , err := m .results .ByID (seal .ResultID )
887881 if err != nil {
@@ -893,12 +887,12 @@ func (m *FollowerState) epochPhaseMetricsAndEventsOnBlockFinalized(block *flow.H
893887 // update current epoch phase
894888 events = append (events , func () { m .metrics .CurrentEpochPhase (flow .EpochPhaseSetup ) })
895889 // track epoch phase transition (staking->setup)
896- events = append (events , func () { m .consumer .EpochSetupPhaseStarted (ev .Counter - 1 , block ) })
890+ events = append (events , func () { m .consumer .EpochSetupPhaseStarted (ev .Counter - 1 , block . Header ) })
897891 case * flow.EpochCommit :
898892 // update current epoch phase
899893 events = append (events , func () { m .metrics .CurrentEpochPhase (flow .EpochPhaseCommitted ) })
900894 // track epoch phase transition (setup->committed)
901- events = append (events , func () { m .consumer .EpochCommittedPhaseStarted (ev .Counter - 1 , block ) })
895+ events = append (events , func () { m .consumer .EpochCommittedPhaseStarted (ev .Counter - 1 , block . Header ) })
902896 // track final view of committed epoch
903897 nextEpochSetup , err := m .epoch .setups .ByID (epochStatus .NextEpoch .SetupID )
904898 if err != nil {
@@ -1025,20 +1019,16 @@ func (m *FollowerState) handleEpochServiceEvents(candidate *flow.Block) (dbUpdat
10251019 return dbUpdates , nil
10261020 }
10271021
1028- // We apply service events from blocks which are sealed by this block's PARENT .
1029- // The parent 's payload might contain epoch preparation service events for the next
1022+ // We apply service events from blocks which are sealed by this candidate block .
1023+ // The block 's payload might contain epoch preparation service events for the next
10301024 // epoch. In this case, we need to update the tentative protocol state.
10311025 // We need to validate whether all information is available in the protocol
10321026 // state to go to the next epoch when needed. In cases where there is a bug
10331027 // in the smart contract, it could be that this happens too late and the
10341028 // chain finalization should halt.
1035- parent , err := m .blocks .ByID (candidate .Header .ParentID )
1036- if err != nil {
1037- return nil , fmt .Errorf ("could not get parent (id=%x): %w" , candidate .Header .ParentID , err )
1038- }
10391029
10401030 // block payload may not specify seals in order, so order them by block height before processing
1041- orderedSeals , err := protocol .OrderedSeals (parent .Payload , m .headers )
1031+ orderedSeals , err := protocol .OrderedSeals (candidate .Payload , m .headers )
10421032 if err != nil {
10431033 if errors .Is (err , storage .ErrNotFound ) {
10441034 return nil , fmt .Errorf ("ordering seals: parent payload contains seals for unknown block: %s" , err .Error ())
0 commit comments