Skip to content

Commit

Permalink
Apply suggestions from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
durkmurder committed Jul 15, 2024
1 parent 0d5d18e commit 2bba43a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions state/protocol/protocol_state/epochs/base_statemachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ func (u *baseStateMachine) EjectIdentity(nodeID flow.Identifier) error {
// No errors are expected during normal operations.
func (u *baseStateMachine) TransitionToNextEpoch() error {
nextEpoch := u.state.NextEpoch
if nextEpoch == nil { // nextEpoch ≠ nil if and only if next epoch was already set up (on the happy path)
if nextEpoch == nil { // nextEpoch ≠ nil if and only if next epoch was already set up
return fmt.Errorf("protocol state for next epoch has not yet been setup")
}
if nextEpoch.CommitID == flow.ZeroID { // nextEpoch.CommitID ≠ flow.ZeroID if and only if next epoch was already committed (on the happy path)
if nextEpoch.CommitID == flow.ZeroID { // nextEpoch.CommitID ≠ flow.ZeroID if and only if next epoch was already committed
return fmt.Errorf("protocol state for next epoch has not yet been committed")
}
// Check if we are at the next epoch, only then a transition is allowed
Expand Down
8 changes: 4 additions & 4 deletions state/protocol/protocol_state/epochs/identity_ejector.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ func (e *ejector) Eject(nodeID flow.Identifier) bool {
}
e.ejected = append(e.ejected, nodeID)

var ejected bool
var nodeFound bool
for i := 0; i < l; i++ {
dynamicIdentity, found := e.identityLists[i].identityLookup[nodeID]
if found {
ejected = true
nodeFound = true
dynamicIdentity.Ejected = true
}
}
return ejected
return nodeFound
}

// TrackDynamicIdentityList tracks a new DynamicIdentityList in the state machine.
// It is not allowed to readmit nodes that were ejected. Whenever a new DynamicIdentityList is tracked,
// we ensure that the ejection status of previously ejected nodes is not reverted.
// If a node was previously ejected and the new DynamicIdentityList contains the node with an `Ejected`
// If a node was previously ejected and the new DynamicIdentityList contains the node with an `Ejected`
// status of `false`, a `protocol.InvalidServiceEventError` is returned and the ejector remains unchanged.
func (e *ejector) TrackDynamicIdentityList(list flow.DynamicIdentityEntryList) error {
tracker := trackedDynamicIdentityList{dynamicIdentities: list}
Expand Down
4 changes: 2 additions & 2 deletions state/protocol/protocol_state/epochs/statemachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ func (s *EpochStateMachineSuite) TestEvolveStateTransitionToNextEpoch_WithInvali
"See for details https://github.com/onflow/flow-go/issues/5631.")
s.parentEpochState = unittest.EpochStateFixture(unittest.WithNextEpochProtocolState())
s.candidate.View = s.parentEpochState.NextEpochSetup.FirstView
happyPathTelemetryFactory := protocol_statemock.NewStateMachineEventsTelemetryFactory(s.T())
fallbackTelemetryFactory := protocol_statemock.NewStateMachineEventsTelemetryFactory(s.T())
happyPathTelemetry := protocol_statemock.NewStateMachineTelemetryConsumer(s.T())
fallbackPathTelemetry := protocol_statemock.NewStateMachineTelemetryConsumer(s.T())
happyPathTelemetryFactory := protocol_statemock.NewStateMachineEventsTelemetryFactory(s.T())
fallbackTelemetryFactory := protocol_statemock.NewStateMachineEventsTelemetryFactory(s.T())
happyPathTelemetryFactory.On("Execute", s.candidate.View).Return(happyPathTelemetry).Once()
fallbackTelemetryFactory.On("Execute", s.candidate.View).Return(fallbackPathTelemetry).Once()
stateMachine, err := epochs.NewEpochStateMachineFactory(
Expand Down

0 comments on commit 2bba43a

Please sign in to comment.