Skip to content

Commit e5b78d8

Browse files
authored
Merge pull request #101 from smartcontractkit/copy-4e96628d8d2688157c4578e6d7cdf20e6655f699
Improvements:
2 parents adbe570 + 769a0ef commit e5b78d8

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

offchainreporting2plus/internal/ocr3/protocol/outcome_generation_follower.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,6 @@ func (outgen *outcomeGenerationState[RI]) backgroundObservation(
257257
}
258258

259259
func (outgen *outcomeGenerationState[RI]) eventComputedObservation(ev EventComputedObservation[RI]) {
260-
if outgen.followerState.phase != outgenFollowerPhaseBackgroundObservation {
261-
outgen.logger.Debug("discarding EventComputedObservation, wrong phase", commontypes.LogFields{
262-
"seqNr": outgen.sharedState.seqNr,
263-
"phase": outgen.followerState.phase,
264-
})
265-
return
266-
}
267-
268260
if ev.Epoch != outgen.sharedState.e || ev.SeqNr != outgen.sharedState.seqNr {
269261
outgen.logger.Debug("discarding EventComputedObservation from old round", commontypes.LogFields{
270262
"seqNr": outgen.sharedState.seqNr,
@@ -274,6 +266,14 @@ func (outgen *outcomeGenerationState[RI]) eventComputedObservation(ev EventCompu
274266
return
275267
}
276268

269+
if outgen.followerState.phase != outgenFollowerPhaseBackgroundObservation {
270+
outgen.logger.Debug("discarding EventComputedObservation, wrong phase", commontypes.LogFields{
271+
"seqNr": outgen.sharedState.seqNr,
272+
"phase": outgen.followerState.phase,
273+
})
274+
return
275+
}
276+
277277
so, err := MakeSignedObservation(outgen.ID(), outgen.sharedState.seqNr, ev.Query, ev.Observation, outgen.offchainKeyring.OffchainSign)
278278
if err != nil {
279279
outgen.logger.Error("MakeSignedObservation returned error", commontypes.LogFields{
@@ -529,14 +529,6 @@ func (outgen *outcomeGenerationState[RI]) backgroundProposalOutcome(
529529
}
530530

531531
func (outgen *outcomeGenerationState[RI]) eventComputedProposalOutcome(ev EventComputedProposalOutcome[RI]) {
532-
if outgen.followerState.phase != outgenFollowerPhaseBackgroundProposalOutcome {
533-
outgen.logger.Debug("discarding EventComputedProposalOutcome, wrong phase", commontypes.LogFields{
534-
"seqNr": outgen.sharedState.seqNr,
535-
"phase": outgen.followerState.phase,
536-
})
537-
return
538-
}
539-
540532
if ev.Epoch != outgen.sharedState.e || ev.SeqNr != outgen.sharedState.seqNr {
541533
outgen.logger.Debug("discarding EventComputedProposalOutcome from old round", commontypes.LogFields{
542534
"seqNr": outgen.sharedState.seqNr,
@@ -546,6 +538,14 @@ func (outgen *outcomeGenerationState[RI]) eventComputedProposalOutcome(ev EventC
546538
return
547539
}
548540

541+
if outgen.followerState.phase != outgenFollowerPhaseBackgroundProposalOutcome {
542+
outgen.logger.Debug("discarding EventComputedProposalOutcome, wrong phase", commontypes.LogFields{
543+
"seqNr": outgen.sharedState.seqNr,
544+
"phase": outgen.followerState.phase,
545+
})
546+
return
547+
}
548+
549549
prepareSignature, err := MakePrepareSignature(
550550
outgen.ID(),
551551
outgen.sharedState.seqNr,

offchainreporting2plus/internal/ocr3/protocol/outcome_generation_leader.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,14 @@ func (outgen *outcomeGenerationState[RI]) eventComputedValidateVerifyObservation
396396
return
397397
}
398398

399+
if outgen.leaderState.phase != outgenLeaderPhaseSentRoundStart && outgen.leaderState.phase != outgenLeaderPhaseGrace {
400+
outgen.logger.Debug("discarding EventComputedValidateVerifyObservation, wrong phase", commontypes.LogFields{
401+
"seqNr": outgen.sharedState.seqNr,
402+
"phase": outgen.leaderState.phase,
403+
})
404+
return
405+
}
406+
399407
outgen.logger.Debug("got valid MessageObservation", commontypes.LogFields{
400408
"sender": ev.Sender,
401409
"seqNr": outgen.sharedState.seqNr,
@@ -471,14 +479,6 @@ func (outgen *outcomeGenerationState[RI]) backgroundObservationQuorum(
471479
}
472480

473481
func (outgen *outcomeGenerationState[RI]) eventComputedObservationQuorumSuccess(ev EventComputedObservationQuorumSuccess[RI]) {
474-
if outgen.leaderState.phase != outgenLeaderPhaseSentRoundStart {
475-
outgen.logger.Debug("discarding EventComputedObservationQuorumSuccess, wrong phase", commontypes.LogFields{
476-
"seqNr": outgen.sharedState.seqNr,
477-
"phase": outgen.leaderState.phase,
478-
})
479-
return
480-
}
481-
482482
if ev.Epoch != outgen.sharedState.e || ev.SeqNr != outgen.sharedState.seqNr {
483483
outgen.logger.Debug("discarding EventComputedObservationQuorumSuccess from old round", commontypes.LogFields{
484484
"seqNr": outgen.sharedState.seqNr,
@@ -488,6 +488,14 @@ func (outgen *outcomeGenerationState[RI]) eventComputedObservationQuorumSuccess(
488488
return
489489
}
490490

491+
if outgen.leaderState.phase != outgenLeaderPhaseSentRoundStart {
492+
outgen.logger.Debug("discarding EventComputedObservationQuorumSuccess, wrong phase", commontypes.LogFields{
493+
"seqNr": outgen.sharedState.seqNr,
494+
"phase": outgen.leaderState.phase,
495+
})
496+
return
497+
}
498+
491499
outgen.logger.Debug("reached observation quorum, starting observation grace period", commontypes.LogFields{
492500
"seqNr": outgen.sharedState.seqNr,
493501
"deltaGrace": outgen.config.DeltaGrace.String(),

0 commit comments

Comments
 (0)