Skip to content

[version] Restart services on chain or protocol change #884

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dmtrskv
Copy link
Contributor

@dmtrskv dmtrskv commented May 8, 2025

Syncing nodes stop if the chain or protocol version changed.
Indexer stops if the chain version changed.

Changes:

  • Moved existing version-related stuff to a separate file and refactored a bit for my needs.
  • Added a version check loop to the syncers (called on the main shard syncer only).
  • Added a version check loop to the indexer.
  • Refactored indexer a bit.
  • Implemented version check and db reset in badger indexer.

Fixes #769 and #659

Tested locally:

  1. Start cluster -> Start archive node -> Stop cluster; drop validator keys and db (keep network keys); start the cluster anew -> Archive node stops after discovering the change in the version.
  2. Same for indexer instead of archive.

@dmtrskv dmtrskv force-pushed the restart-on-version-change branch from eaed258 to 8c45672 Compare May 8, 2025 15:54
@dmtrskv dmtrskv force-pushed the restart-on-version-change branch from 8c45672 to c0bbcbc Compare May 9, 2025 11:31
@dmtrskv dmtrskv force-pushed the restart-on-version-change branch from c0bbcbc to f4fa6d7 Compare May 9, 2025 12:43
@dmtrskv dmtrskv requested a review from Copilot May 9, 2025 12:51
@dmtrskv dmtrskv marked this pull request as ready for review May 9, 2025 12:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors version‐related functionality to ensure that nodes and indexers correctly restart or reset their databases when the chain or protocol version changes. Key changes include:

  • Extracting version‐related logic into a separate file and refactoring driver methods (adding FetchVersion and ResetDB).
  • Adding a version check loop to both syncer and indexer processes.
  • Refining worker task setups and logger usage across the indexer and syncer.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nil/services/indexer/indexer.go Refactored version checking, introduced a new logger, and updated worker task configuration.
nil/services/indexer/fetch_block.go Removed unused logger variable.
nil/services/indexer/driver/driver.go Removed SetupScheme; added FetchVersion and ResetDB methods.
nil/services/indexer/clickhouse/clickhouse.go Refactored out SetupScheme in favor of FetchVersion and ResetDB.
nil/services/indexer/badger/badger.go Removed SetupScheme and updated the IndexTxPool receiver.
nil/internal/collate/version.go Added new version handling functionality for both local and remote version fetching.
nil/internal/collate/syncer.go Removed duplicate version retrieval methods and integrated new version check functionality.
nil/internal/collate/bootstrap.go Removed version handler logic now handled by the version package.
nil/common/concurrent/utils.go Added a new RunTickerLoopWithErr function for ticker loops with error propagation.


s.Run("RunArchiveNode", func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added while debugging failing tests

}

var res common.Hash
res, err = v.fetchGenesisBlockHash(ctx, peerId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you can also log error

return nil, err
}

if !bytes.Equal(localVersion[:], remoteVersion[:]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't hashes comparable via ==/!=?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restart services on chain version change
2 participants