-
Notifications
You must be signed in to change notification settings - Fork 810
chore(sync/types): add sync/types package (syncer contract types) #4405
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?
Changes from all commits
772bfe1
ee84b72
41ceeb7
09ea80d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why this package exists - it doesn't have the same name, but it feels like an "interfaces" package which is an anti-pattern. This is only used in coreth's On an unrelated note... why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll start addressing all your points one by one:
PS: I know that the coreth structure is really bad and the idea is to finally unify it under vms/evm/sync in avalanchego. For now the atomic syncer will remain in coreth based on the decision we made on the meetings beforehand. So we also need the flexibility of importing the Syncer interface that will be in avalanchego now in coreth as well. |
||
|
||
import "context" | ||
|
||
// Syncer is the common interface for all sync operations. | ||
// This provides a unified interface for atomic state sync and state trie sync. | ||
type Syncer interface { | ||
// Sync completes the full sync operation, returning any errors encountered. | ||
// The sync will respect context cancellation. | ||
Sync(ctx context.Context) error | ||
|
||
// Name returns a human-readable name for this syncer implementation. | ||
Name() string | ||
|
||
// ID returns a stable, machine-oriented identifier (e.g., "state_block_sync", "state_code_sync", | ||
// "state_evm_state_sync", "state_atomic_sync"). Implementations should ensure this is unique and | ||
// stable across renames for logging/metrics/deduplication. | ||
ID() string | ||
Comment on lines
+15
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The caller here already knows about the concrete syncer types being registered, so we don't need to make this part of the interface public contract. Even if we did, it feels like overkill that we're adding this to the interface for duplicate handling because we own the syncers that we're registering - so it shouldn't happen anyways. It also feels leaky that something that just knows about how to perform a sync operation also needs to define its own metrics namespace and it's own "human-readable name". |
||
} |
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.
vms/evm/sync/types/types.go
This is in the correct folder? what other types will be in
sync/types
?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.
Here is the original code. Probably I'll add only
SummaryProvider
in a later PR when I move the code that will use it. Only theExtender
interface will not be migrated for now, because we will not migrate theatomic
syncer (which uses it).