Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Protocol State] Dedicated protocol state machine for epoch fallback #4931

Conversation

durkmurder
Copy link
Member

@durkmurder durkmurder commented Nov 3, 2023

Context

This PR addresses high priority item from #4649 to consolidate logic of handling service events when invalid state transition has been detected.

In this PR all state machine modifications are treated as one atomic state transition. It either succeeds in its entirety or in case of a failure, there is no update to the protocol state. If invalid state transition has been detected we a special version of protocol state machine for epoch fallback mode. Whenever we have entered epoch fallback mode we will re-process all the events in that block and continue using epoch fallback state machine for subsequent blocks. EFM state machine ignores epoch events and doesn't perform transitions to next epoch but it still handles ejection events.

Most of the implementation is following Alex's comment

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the logic much easier to follow - nice improvement.

My main feedback is to ensure that, for the time being, we do not allow invalid UpdateIdentity events to trigger EFM or halt the chain.

state/protocol/protocol_state/mutator.go Show resolved Hide resolved
state/protocol/protocol_state/mutator.go Show resolved Hide resolved
state/protocol/protocol_state/statemachine.go Outdated Show resolved Hide resolved
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
@durkmurder durkmurder changed the base branch from yurii/4649-handle-invalid-state-transition to yurii/5517-extend-payload November 6, 2023 20:38
Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Personally, I would still like to change the name of the flag for epoch fallback, as mentioned here. Not a blocker, though.

Base automatically changed from yurii/5517-extend-payload to feature/dynamic-protocol-state November 14, 2023 19:38
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (e8c2594) 56.14% compared to head (05921b0) 56.18%.

Files Patch % Lines
state/protocol/protocol_state/mutator.go 84.78% 5 Missing and 2 partials ⚠️
state/protocol/protocol_state/protocol_state.go 73.91% 4 Missing and 2 partials ⚠️
state/protocol/protocol_state/base_statemachine.go 93.33% 2 Missing and 1 partial ⚠️
...e/protocol/protocol_state/protocol_statemachine.go 88.00% 3 Missing ⚠️
utils/unittest/fixtures.go 0.00% 2 Missing ⚠️
model/flow/protocol_state.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                         @@
##           feature/dynamic-protocol-state    #4931      +/-   ##
==================================================================
+ Coverage                           56.14%   56.18%   +0.03%     
==================================================================
  Files                                 974      967       -7     
  Lines                               90574    90142     -432     
==================================================================
- Hits                                50853    50646     -207     
+ Misses                              35934    35712     -222     
+ Partials                             3787     3784       -3     
Flag Coverage Δ
unittests 56.18% <86.74%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@AlexHentschel AlexHentschel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work. My comments are largely suggestions for goDoc revisions, extensions of tests and revisions for code clarity and modularity. All are only minor revision (I hope).

model/flow/epoch.go Outdated Show resolved Hide resolved
model/flow/protocol_state.go Outdated Show resolved Hide resolved
state/protocol/protocol_state/base_statemachine.go Outdated Show resolved Hide resolved
state/protocol/protocol_state/base_statemachine.go Outdated Show resolved Hide resolved
@durkmurder durkmurder merged commit 3984803 into feature/dynamic-protocol-state Nov 16, 2023
54 checks passed
@durkmurder durkmurder deleted the yurii/4649-epoch-fallback-statemachine-attempt-1 branch November 16, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants