-
Notifications
You must be signed in to change notification settings - Fork 841
refactor(vmsync): extract SyncStrategy pattern for static state sync
#4652
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
base: master
Are you sure you want to change the base?
Conversation
Restructure the vmsync package to separate concerns and prepare for future dynamic state sync support. - Extract `finalizer.go` - VM state finalization logic (`finishSync`, `commitMarkers`) moved to dedicated `finalizer` struct. - Add `SyncStrategy` interface with `Start` method for sync execution. - Implement `staticStrategy` for current sequential sync behavior. - Simplify `client.go` to orchestrate sync lifecycle via strategy. This refactoring enables adding dynamic state sync as a separate strategy implementation without modifying existing static sync logic. resolves #4651 Signed-off-by: Tsvetan Dimitrov ([email protected])
SyncStrategy pattern for static state sync
| GetEthBlock() *types.Block | ||
| // SyncStrategy defines how state sync is executed. | ||
| // Implementations handle the sync lifecycle differently based on sync mode. | ||
| type SyncStrategy 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.
The name SyncStrategy indicates to me that this interface has something to do with a strategy, which is just not true. It just syncs. Additionally, the name Start indicates that it only starts the syncers, and then returns. Your comments are correct and the code works here, I just don't like the names
May I suggest SyncOperation and Sync? I honestly don't eve know if this needs to be a whole interface (does it?) You could also just define:
type SyncOperation func(context.Context, message.Syncable) error
| } | ||
|
|
||
| // newFinalizer creates a new finalizer with the given dependencies. | ||
| func newFinalizer( |
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.
Is this creator going to have more work to do? I'm not sure abstracting this into a struct is productive
Why this should be merged
Check #4651
How this works
Restructure the
vmsyncpackage to separate concerns and prepare for future dynamic state sync support.finalizer.go- VM state finalization logic (finishSync,commitMarkers) moved to dedicatedfinalizerstruct.SyncStrategyinterface withStartmethod for sync execution.staticStrategyfor current sequential sync behavior.client.goto orchestrate sync lifecycle via strategy.This refactoring enables adding dynamic state sync as a separate strategy implementation without modifying existing static sync logic.
How this was tested
existing UT
Need to be documented in RELEASES.md?
no
resolves #4651
Signed-off-by: Tsvetan Dimitrov ([email protected])