-
Notifications
You must be signed in to change notification settings - Fork 534
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
Feature - State Sync manager #1067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it overall aside from the comments
Codecov Report
@@ Coverage Diff @@
## feature/v3-parity #1067 +/- ##
====================================================
Coverage ? 54.23%
====================================================
Files ? 173
Lines ? 22990
Branches ? 0
====================================================
Hits ? 12469
Misses ? 9524
Partials ? 997 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
2e71bdd
to
5032240
Compare
This function can be safely removed from consensusRuntime (used only in the unit test)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much better 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stateSyncCommitmentSize
can be moved to the manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All functions that are not used in the state anymore and are used only in the manager, for example decodeStateSyncEvent
, would be great to move them to the manager, so we isolate all statesync things in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from comment
562b685
to
e3243b3
Compare
) | ||
|
||
// StateSyncManager is an interface that defines functions for state sync workflow | ||
type StateSyncManager interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the use case to do this abstraction here. The only reason would be to put it inside consensus_runtime
but even that I think this is lightweight enough to not mock it and use it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's really lightweight to mock it. This interface is added only because of the nil
implementation of stateSyncManager
, which we discuss in comment: #1067 (comment)
|
||
c.stateSyncManager = stateSyncManager | ||
} else { | ||
c.stateSyncManager = &dummyStateSyncManager{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the stateSyncManager
is not enabled because the bridge is not enabled, it should never be called. I understand this is a safety measure in case it is ever called. But, I would prefer if we ensure on tests that never happens instead of having extra code to ensure that.
Note that once we have hooks (if we ever do it though) we do not need this check anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I do understand your point, I must agree with Stefan here. Nullable
pattern is a good practice, since it reduces the unnecessary checks and conditions in code, makes testing easier, and it doesn't really add any more complexity (since that nil
or dummy
implementation doesn't do anything). Plus, as you said, it keeps as out of harms way of nil exceptions. To me it makes sense to have it here, and if we ever implement that hook system, then I would agree, we can remove this nil
implementation since we would not need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option would be to make StateSyncManager
aware that he is not active and do nothing when PostEpoch
and PostBlock
get called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that means we will just be moving those checks to the stateSyncManager
😕 . That hook system is looking better by the minute 😄 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot Approve because I made the PR. LGTM except for the comments about the abstraction.
e3243b3
to
02d89b2
Compare
Description
Introduced a concept of
StateSyncManager
, a struct that handles state sync saving workflow, and building and submitting commitments to theStateReceiver
contract.StateSyncManager
is one of the building blocks inconsensus_runtime
, but it encapsulates the state sync logic mentioned above.This makes testing easier (as we can mock the state sync workflow, in
consensus_runtime
tests, much more easily), makes code more granular and separates logic to concerning parts.Changes include
Checklist
Testing