Skip to content

Conversation

JonathanOppenheimer
Copy link
Member

@JonathanOppenheimer JonathanOppenheimer commented Aug 7, 2025

This PR syncs:

Note that the sync package and related items had differences that were years out of date, so this PR also brings in changes that were made in PRs in the past, and just never synced to subnet-evm.

Additionally, this PR brings in a lot of changes that aren't particular useful for subnet-evm, like the extender. This is intended, as I am trying to minimize the difference between coreth's version of these files, and subnet-evms. The eventual goal is the complete merger of all of these files, which is why I am making these changes now.

This PR introduces practically 0 "originally written by me code" - this is a culmination of the code of many other people (and in effect, has already been reviewed)

Also syncs this PR: ava-labs/coreth#1338 as surfaced by @alarso16

MetadataDB: vm.metadataDB,
Acceptor: vm,
Parser: vm.extensionConfig.SyncableParser,
Extender: nil,
Copy link
Member Author

Choose a reason for hiding this comment

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

image

@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review August 8, 2025 21:13
@JonathanOppenheimer JonathanOppenheimer requested a review from a team as a code owner August 8, 2025 21:13
@JonathanOppenheimer JonathanOppenheimer requested a review from a team as a code owner August 11, 2025 14:53
Start []byte `serialize:"true"`
End []byte `serialize:"true"`
Limit uint16 `serialize:"true"`
NodeType NodeType `serialize:"true"`
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 a breaking change?

Copy link
Member Author

Choose a reason for hiding this comment

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

For serialization? It probably is, although this didn't seem to be noted in coreth - are there reprecussions you want to avoid here? Minimizing difference with coreth was the driving goal.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @ceyonur or @ARR4N (who know more about this encoding) should confirm this before you resolve it

@JonathanOppenheimer JonathanOppenheimer added the state-sync-migration Migration of state sync code to `avalanchego`. label Oct 6, 2025
@JonathanOppenheimer JonathanOppenheimer marked this pull request as draft October 7, 2025 14:45
@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review October 10, 2025 15:32
@JonathanOppenheimer JonathanOppenheimer changed the title sync: coreth PR #963,981,1009: align sync package and related items sync: coreth PR #963,981,1009: sync package extension and related items Oct 13, 2025
Copy link
Contributor

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

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

This PR is kinda big, and really seems like two different ideas (block extension, sync extensions). I would feel more confident if it was split up, but it might not be worth the effort at this size.

Start []byte `serialize:"true"`
End []byte `serialize:"true"`
Limit uint16 `serialize:"true"`
NodeType NodeType `serialize:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think @ceyonur or @ARR4N (who know more about this encoding) should confirm this before you resolve it

@JonathanOppenheimer
Copy link
Member Author

This PR is kinda big, and really seems like two different ideas (block extension, sync extensions). I would feel more confident if it was split up, but it might not be worth the effort at this size.

Gotcha - I can split it up further but thought the extension stuff in general could be a single PR. If you think it's worth the effort I will, otherwise will let be!

JonathanOppenheimer and others added 3 commits October 14, 2025 12:42
Co-authored-by: Austin Larson <[email protected]>
Signed-off-by: Jonathan Oppenheimer <[email protected]>
Co-authored-by: Austin Larson <[email protected]>
Signed-off-by: Jonathan Oppenheimer <[email protected]>
JonathanOppenheimer and others added 2 commits October 14, 2025 12:48
Co-authored-by: Austin Larson <[email protected]>
Signed-off-by: Jonathan Oppenheimer <[email protected]>
Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

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

I was in the middle of reviewing but it seems this has some invalid and unrelated changes. It also is too big and it reverts some of previous PRs.

Can we focus on each of these sync PRs one-by-one maybe not mechanically but conceptually. A directy cherry-pick could be end up with massive conflicts.


// Sync settings
StateSyncEnabled bool `json:"state-sync-enabled"`
StateSyncEnabled *bool `json:"state-sync-enabled"` // Pointer distinguishes false (no state sync) and not set (state sync only at genesis).
Copy link
Collaborator

Choose a reason for hiding this comment

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

why have we changed this? This is a substantial change for default value, we should have a separate PR for that if we want to align them.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have changed this because this was a change that Darioush made years ago to coreth, that was never synced to subnet-evm, and then was built on top off. This led to some significant divergence.

See ava-labs/coreth@cd3a14e#diff-6c4b2fd34f767685bfc35038a59ea4fbfadaa6060d70031002e3b008e73a06e7.

I have created a targeted PR for this change (and this change does need to be synced):

#1813

Comment on lines +242 to +250
if constants.ProductionNetworkIDs.Contains(networkID) {
defaultConfig := NewDefaultConfig()
if c.CommitInterval != defaultConfig.CommitInterval {
return fmt.Errorf("cannot start non-local network with commit interval %d different than %d", c.CommitInterval, defaultConfig.CommitInterval)
}
if c.StateSyncCommitInterval != defaultConfig.StateSyncCommitInterval {
return fmt.Errorf("cannot start non-local network with syncable interval %d different than %d", c.StateSyncCommitInterval, defaultConfig.StateSyncCommitInterval)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

simirlay we should not change these here(I don't think we ever change this in those sync PRs)

Comment on lines +282 to +293
if vm.extensionConfig == nil {
// Initialize clock if not already set
if vm.clock == nil {
vm.clock = &mockable.Clock{}
}
vm.extensionConfig = &extension.Config{
SyncSummaryProvider: &message.BlockSyncSummaryProvider{},
SyncableParser: message.NewBlockSyncSummaryParser(),
}
// Provide a clock to the extension config before validation
vm.extensionConfig.Clock = vm.clock
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we resolved this in the previous PR #1743

Comment on lines -1337 to -1360
func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, version *version.Application) error {
vm.vmLock.Lock()
defer vm.vmLock.Unlock()

if err := vm.validatorsManager.Connect(nodeID); err != nil {
return fmt.Errorf("uptime manager failed to connect node %s: %w", nodeID, err)
}
return vm.Network.Connected(ctx, nodeID, version)
}

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error {
vm.vmLock.Lock()
defer vm.vmLock.Unlock()

if err := vm.validatorsManager.Disconnect(nodeID); err != nil {
return fmt.Errorf("uptime manager failed to disconnect node %s: %w", nodeID, err)
func (vm *VM) stateSyncEnabled(lastAcceptedHeight uint64) bool {
if vm.config.StateSyncEnabled != nil {
// if the config is set, use that
return *vm.config.StateSyncEnabled
}

return vm.Network.Disconnected(ctx, nodeID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this does not look correct

@JonathanOppenheimer JonathanOppenheimer marked this pull request as draft October 14, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coreth sync state-sync-migration Migration of state sync code to `avalanchego`.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants