feat(migration): headstate migration#3657
Open
MaksymMalicki wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3657 +/- ##
==========================================
- Coverage 76.25% 76.18% -0.08%
==========================================
Files 396 400 +4
Lines 36424 36571 +147
==========================================
+ Hits 27775 27861 +86
- Misses 6677 6715 +38
- Partials 1972 1995 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0f8a352 to
c2eacce
Compare
brbrr
reviewed
May 26, 2026
| elapsed := now.Sub(c.start).Seconds() | ||
| if elapsed > c.timeLogRate.Seconds() { | ||
| mbs := float64(c.size) / float64(db.Megabyte) | ||
| c.logger.Info( |
Contributor
There was a problem hiding this comment.
example log output:
juno | 11:22:12.007 26/05/2026 +00:00 INFO headstate/counter.go:35 write speed {"MB": 377.31350898742676, "MB/s": 3.1230496120267954, "completedContracts": 3768018, "completedContracts/s": 31188.141618862945, "time": 120.815726889}
ideally, we should round to ~last 2 digits after .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
headstatemigration: a resume-safe transform that consolidates the deprecated per-field contract layout (ContractClassHash,ContractNonce,ContractDeploymentHeight) into the singleContractrecord introduced by the new-state work. Gated behind the existing--new-stateflag. First of three new-state migrations.How it works
Iterates the
ContractClassHashbucket to discover every contract address. Four worker goroutines (ingestorCount) read the three deprecated fields per address into shareddb.Batches; one committer drains batches at 96 MB. A semaphore caps in-flight batches atingestorCount + 1. After all records are written, the three deprecated buckets are wiped viaDeleteRange.StorageRootis left zero on each new record — the running node lazily backfills it on the contract's first storage write.What changes
migration/headstate/package (migrator, ingestor, committer, counter, tests).node/migration.goas an optional migration gated bycfg.NewState.state.WriteContractincore/state/accessors.gogains a public overload taking raw fields, used by the migration.Resume safety
state.HasContractskips addresses whose Contract record already exists — no overwrite of newer running-node data.DeleteRangeover any residual ranges; already-empty ranges are no-ops.(shouldRerun, ctx.Err())so the runner re-invokes on next start.