Skip to content

Conversation

@pinebit
Copy link
Collaborator

@pinebit pinebit commented Jan 15, 2026

Add cluster lock hash validation to privkey lock file

Enhances the private key lock mechanism to prevent race conditions during cluster configuration changes.

Changes

  • Track cluster_lock_hash in the privkey lock file metadata
  • Introduce 2-epoch grace period (768s) after cluster edits before allowing restart with new configuration
  • Update privkeylock.New() signature to accept cluster lock file path
  • Handle missing cluster lock files gracefully (for DKG scenarios)
  • Skip grace period check for migrations from old format (empty hash)
  • Edit commands copying the lock file, if present.

Why

After cluster edits (adding/removing operators), validators shouldn't immediately start with the new configuration. The grace period ensures:

  • Old configuration finishes duties gracefully
  • Network has time to finalize pending attestations
  • Prevents double-signing between old/new configurations

category: feature
ticket: #4200

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 73.46939% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.01%. Comparing base (941bb21) to head (41ba52c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
app/privkeylock/privkeylock.go 76.74% 5 Missing and 5 partials ⚠️
dkg/protocolsteps.go 50.00% 1 Missing and 1 partial ⚠️
app/app.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4226      +/-   ##
==========================================
+ Coverage   56.96%   57.01%   +0.05%     
==========================================
  Files         237      237              
  Lines       30688    30721      +33     
==========================================
+ Hits        17482    17517      +35     
+ Misses      10976    10974       -2     
  Partials     2230     2230              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

@pinebit pinebit marked this pull request as ready for review January 16, 2026 10:33
// New returns new private key locking service. It errors if a recently-updated private key lock file exists.
func New(path, command string) (Service, error) {
content, err := os.ReadFile(path)
func New(privKeyFilePath, clusterLockFilePath, command string) (Service, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: can we rename that to privKeyFileLockPath? Reading it as privKeyFilePath I've assumed it's the actual privKey

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.

3 participants