Skip to content

Commit ac9319d

Browse files
committed
Apply suggestions from PR review.
1 parent ac630c8 commit ac9319d

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

state/protocol/badger/mutator.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,18 @@ func (m *FollowerState) epochPhaseMetricsAndEventsOnBlockFinalized(block *flow.B
870870
events []func(),
871871
err error,
872872
) {
873-
// track service event driven metrics and protocol events that should be emitted
874-
for _, seal := range block.Payload.Seals {
875873

874+
// block payload may not specify seals in order, so order them by block height before processing
875+
orderedSeals, err := protocol.OrderedSeals(block.Payload, m.headers)
876+
if err != nil {
877+
if errors.Is(err, storage.ErrNotFound) {
878+
return nil, nil, fmt.Errorf("ordering seals: parent payload contains seals for unknown block: %s", err.Error())
879+
}
880+
return nil, nil, fmt.Errorf("unexpected error ordering seals: %w", err)
881+
}
882+
883+
// track service event driven metrics and protocol events that should be emitted
884+
for _, seal := range orderedSeals {
876885
result, err := m.results.ByID(seal.ResultID)
877886
if err != nil {
878887
return nil, nil, fmt.Errorf("could not retrieve result (id=%x) for seal (id=%x): %w", seal.ResultID, seal.ID(), err)
@@ -976,7 +985,7 @@ func (m *FollowerState) epochStatus(block *flow.Header, epochFallbackTriggered b
976985
// correctness of the service event before processing it.
977986
// Consequently, any change to the protocol state introduced by a service event
978987
// emitted during execution of block A would only become visible when querying
979-
// C or its descendants.
988+
// C or its descendants.
980989
//
981990
// This method will only apply service-event-induced state changes when the
982991
// input block has the form of block C (ie. contains a seal for a block in

state/protocol/badger/mutator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func TestExtendReceiptsValid(t *testing.T) {
574574
// Also tests that appropriate epoch transition events are fired.
575575
//
576576
// 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.
577+
// for the block whose execution emitted the service event.
578578
//
579579
// ROOT <- B1 <- B2(R1) <- B3(S1) <- B4 <- B5(R2) <- B6(S2) <- B7 <-|- B8
580580
//

state/protocol/badger/snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func TestSealingSegment(t *testing.T) {
318318
next := unittest.BlockWithParentFixture(parent.Header)
319319
if i == 0 {
320320
// 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.
321+
// Hence, we include the result only once in the direct child of B1.
322322
next.SetPayload(unittest.PayloadFixture(unittest.WithReceipts(receipt1)))
323323
}
324324
buildFinalizedBlock(t, state, next)

0 commit comments

Comments
 (0)