Skip to content

Conversation

@powerslider
Copy link
Contributor

@powerslider powerslider commented Dec 3, 2025

Why this should be merged

Check #4651

How this works

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.

How this was tested

existing UT

Need to be documented in RELEASES.md?

no

resolves #4651

Signed-off-by: Tsvetan Dimitrov ([email protected])

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])
@powerslider powerslider self-assigned this Dec 3, 2025
@powerslider powerslider requested a review from a team as a code owner December 3, 2025 20:01
@powerslider powerslider changed the title refactor(vmsync): extract SyncStrategy pattern for static state sync refactor(vmsync): extract SyncStrategy pattern for static state sync Dec 3, 2025
GetEthBlock() *types.Block
// SyncStrategy defines how state sync is executed.
// Implementations handle the sync lifecycle differently based on sync mode.
type SyncStrategy interface {
Copy link
Contributor

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(
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Transform sync client to execute based on static or dynamic sync strategy

4 participants