Skip to content
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

state sync: initialize snapshots in bootstrap set mode #557

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions plugin/evm/syncervm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type StateSyncClient interface {
ParseStateSummary(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)

// additional methods required by the evm package
StateSyncClearOngoingSummary() error
ClearOngoingSummary() error
Shutdown() error
Error() error
}
Expand Down Expand Up @@ -126,8 +126,8 @@ func (client *stateSyncerClient) GetOngoingSyncStateSummary(context.Context) (bl
return summary, nil
}

// StateSyncClearOngoingSummary clears any marker of an ongoing state sync summary
func (client *stateSyncerClient) StateSyncClearOngoingSummary() error {
// ClearOngoingSummary clears any marker of an ongoing state sync summary
func (client *stateSyncerClient) ClearOngoingSummary() error {
if err := client.metadataDB.Delete(stateSyncSummaryKey); err != nil {
return fmt.Errorf("failed to clear ongoing summary: %w", err)
}
Expand Down Expand Up @@ -173,12 +173,6 @@ func (client *stateSyncerClient) acceptSyncSummary(proposedSummary message.SyncS
"lastAccepted", client.lastAcceptedHeight,
"syncableHeight", proposedSummary.Height(),
)
if err := client.StateSyncClearOngoingSummary(); err != nil {
return block.StateSyncSkipped, fmt.Errorf("failed to clear ongoing summary after skipping state sync: %w", err)
}
// Initialize snapshots if we're skipping state sync, since it will not have been initialized on
// startup.
client.chain.BlockChain().InitializeSnapshots()
return block.StateSyncSkipped, nil
}

Expand Down
9 changes: 8 additions & 1 deletion plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (vm *VM) initializeStateSyncClient(lastAcceptedHeight uint64) error {
// If StateSync is disabled, clear any ongoing summary so that we will not attempt to resume
// sync using a snapshot that has been modified by the node running normal operations.
if !stateSyncEnabled {
return vm.StateSyncClient.StateSyncClearOngoingSummary()
return vm.StateSyncClient.ClearOngoingSummary()
}

return nil
Expand Down Expand Up @@ -1055,6 +1055,13 @@ func (vm *VM) SetState(_ context.Context, state snow.State) error {
if err := vm.StateSyncClient.Error(); err != nil {
return err
}
// After starting bootstrapping, do not attempt to resume a previous state sync.
if err := vm.StateSyncClient.ClearOngoingSummary(); err != nil {
darioush marked this conversation as resolved.
Show resolved Hide resolved
return err
}
// Ensure snapshots are initialized before bootstrapping (i.e., if state sync is skipped).
// Note calling this function has no effect if snapshots are already initialized.
vm.blockChain.InitializeSnapshots()
darioush marked this conversation as resolved.
Show resolved Hide resolved
return vm.fx.Bootstrapping()
case snow.NormalOp:
// Initialize goroutines related to block building once we enter normal operation as there is no need to handle mempool gossip before this point.
Expand Down
Loading