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

[EFM] Added a service event to update EpochExtensionViewCount #6272

Merged
merged 19 commits into from
Aug 7, 2024

Conversation

durkmurder
Copy link
Member

#5725

Context

This PR is the last one to implement in order to close linked issue. It introduces a new service event which will be used to update the EpochExtensionViewCount in the KV store. Additionally, I have added a dedicated state machine which parses the service event and applies it to the KV store.
After implementing service event handling I suspect that we will get similar state machines for simple "set-value" style events. To avoid boilerplate we might introduce a solution based on generics or maybe consolidate all the logic in single state machine.

Additionally refactored unit tests using generics to make future extensions to the list of the service events easier.

@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 63.29114% with 29 lines in your changes missing coverage. Please review.

Project coverage is 41.49%. Comparing base (23159e4) to head (8ff34d9).

Files Patch % Lines
model/flow/service_event.go 10.52% 17 Missing ⚠️
state/protocol/protocol_state/kvstore/factory.go 0.00% 5 Missing ⚠️
...l/protocol_state/kvstore/set_value_statemachine.go 83.33% 3 Missing and 1 partial ⚠️
model/flow/kvstore.go 66.66% 2 Missing ⚠️
...col/protocol_state/kvstore/upgrade_statemachine.go 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           feature/efm-recovery    #6272      +/-   ##
========================================================
+ Coverage                 41.48%   41.49%   +0.01%     
========================================================
  Files                      2000     2003       +3     
  Lines                    142559   142613      +54     
========================================================
+ Hits                      59136    59173      +37     
- Misses                    77249    77263      +14     
- Partials                   6174     6177       +3     
Flag Coverage Δ
unittests 41.49% <63.29%> (+0.01%) ⬆️

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

@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. Most comments are just fixing some copy-paste errors.

After implementing service event handling I suspect that we will get similar state machines for simple "set-value" style events. To avoid boilerplate we might introduce a solution based on generics or maybe consolidate all the logic in single state machine.

I agree, I think handling all these simple "set a single primitive parameter" cases in the SetValue state machine is a good start.

model/flow/service_event.go Outdated Show resolved Hide resolved
durkmurder and others added 4 commits July 31, 2024 16:36
…est.go

Co-authored-by: Jordan Schalm <jordan.schalm@flowfoundation.org>
Co-authored-by: Jordan Schalm <jordan.schalm@flowfoundation.org>
Co-authored-by: Jordan Schalm <jordan.schalm@flowfoundation.org>
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.

solid and very clean code 🎸 with great test coverage 🎶

model/flow/kvstore.go Outdated Show resolved Hide resolved
state/protocol/protocol_state/helper/base_statemachine.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

random side comment:

  • wondering if we should change the type of evolvingState in line 312 to protocol.KVStoreReader
    func (s *MutableProtocolState) build(
    parentStateID flow.Identifier,
    stateMachines []protocol_state.KeyValueStoreStateMachine,
    serviceEvents []flow.ServiceEvent,
    evolvingState protocol_state.KVStoreMutator,

    this would reflect that the build method does not change the evolvingState anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, updated.

model/flow/service_event.go Outdated Show resolved Hide resolved
model/flow/service_event_test.go Outdated Show resolved Hide resolved
model/flow/service_event_test.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the consolidation. very nice and concise tests now. 👏

state/protocol/protocol_state/helper/base_statemachine.go Outdated Show resolved Hide resolved
state/protocol/protocol_state/kvstore/factory.go Outdated Show resolved Hide resolved
durkmurder and others added 2 commits August 7, 2024 11:14
Co-authored-by: Alexander Hentschel <alex.hentschel@flowfoundation.org>
@durkmurder durkmurder merged commit 61e9674 into feature/efm-recovery Aug 7, 2024
55 checks passed
@durkmurder durkmurder deleted the yurii/5725-add-service-events branch August 7, 2024 08:46
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.

5 participants