From 2bba43ab5898c5e0514d82e19fdbc900326fb78b Mon Sep 17 00:00:00 2001 From: Yurii Oleksyshyn Date: Mon, 15 Jul 2024 18:49:28 +0300 Subject: [PATCH] Apply suggestions from PR review --- state/protocol/protocol_state/epochs/base_statemachine.go | 4 ++-- state/protocol/protocol_state/epochs/identity_ejector.go | 8 ++++---- state/protocol/protocol_state/epochs/statemachine_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/state/protocol/protocol_state/epochs/base_statemachine.go b/state/protocol/protocol_state/epochs/base_statemachine.go index 54238a5a129..414d71d3836 100644 --- a/state/protocol/protocol_state/epochs/base_statemachine.go +++ b/state/protocol/protocol_state/epochs/base_statemachine.go @@ -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 diff --git a/state/protocol/protocol_state/epochs/identity_ejector.go b/state/protocol/protocol_state/epochs/identity_ejector.go index 99ea82d0124..8c068a28b94 100644 --- a/state/protocol/protocol_state/epochs/identity_ejector.go +++ b/state/protocol/protocol_state/epochs/identity_ejector.go @@ -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} diff --git a/state/protocol/protocol_state/epochs/statemachine_test.go b/state/protocol/protocol_state/epochs/statemachine_test.go index 02fe50b0b8a..44b4654597b 100644 --- a/state/protocol/protocol_state/epochs/statemachine_test.go +++ b/state/protocol/protocol_state/epochs/statemachine_test.go @@ -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(