Skip to content

Feat(newstate): migrate to new state on pruned db - #4210

Open
NazariiDenha wants to merge 3 commits into
mainfrom
feat/newstate-migrate-pruned
Open

NazariiDenha wants to merge 3 commits into
mainfrom
feat/newstate-migrate-pruned

Conversation

@NazariiDenha

@NazariiDenha NazariiDenha commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

PR Type

Enhancement, Tests


Description

  • Remove mutual exclusivity between --prune-mode and --new-state flags

  • Update new state migrator to calculate and respect a history floor (the oldest retained block)

  • Refactor nonceIngestor and storageIngestor to anchor pruned historical data at the computed floor

  • Add comprehensive test suites verifying pruned history migration, including crash and interruption recovery


File Walkthrough

Relevant files
Configuration changes
2 files
juno.go
Remove CLI flag restriction for --new-state and --prune-mode
+2/-3     
node.go
Remove node init validation conflicting new state with prune mode
+0/-5     
Tests
4 files
chain_test.go
Add test utilities for generating and verifying pruned chains
+143/-0 
resume_test.go
Update phase tests to pass the new floor argument               
+6/-6     
migrator_test.go
Add tests for history pruning, crashes, and migration resilience
+140/-31
node_test.go
Remove unit tests enforcing new state and prune mode mutual
exclusivity
+0/-8     
Enhancement
3 files
migrator.go
Calculate history floor and pass it to ingestors                 
+29/-8   
nonce_ingestor.go
Adapt nonce ingestor to write floor values when history is pruned
+50/-15 
storage_ingestor.go
Adapt storage ingestor to process floor logic and headless tries
+79/-32 
Documentation
1 files
_config-options.md
Update documentation to allow combining prune-mode and new-state
+2/-2     

@NazariiDenha
NazariiDenha added this pull request to stack #4193 October 23, 2026 10:35
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

@NazariiDenha
NazariiDenha force-pushed the feat/newstate-migrate-pruned branch from 247a8de to 9e95695 Compare October 23, 2026 10:48
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.69565% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.13%. Comparing base (4ecbf38) to head (4144169).

Files with missing lines Patch % Lines
...tate/newstate/internal/history/storage_ingestor.go 82.00% 9 Missing ⚠️
.../state/newstate/internal/history/nonce_ingestor.go 86.36% 3 Missing ⚠️
...ration/state/newstate/internal/history/migrator.go 86.66% 2 Missing ⚠️
migration/state/newstate/internal/history/parse.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4210      +/-   ##
==========================================
- Coverage   81.18%   81.13%   -0.05%     
==========================================
  Files         478      478              
  Lines       35585    35634      +49     
==========================================
+ Hits        28888    28912      +24     
- Misses       6691     6716      +25     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

Base automatically changed from feat/newstate-runtime-pruning to main October 27, 2026 10:38
@NazariiDenha
NazariiDenha force-pushed the feat/newstate-migrate-pruned branch from 9e95695 to 3e43e0c Compare October 27, 2026 10:39
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Title

(Describe updated until commit 4144169)

Feat(newstate): migrate to new state on pruned db


PR Type

Enhancement


Description

  • Remove mutual exclusion between --prune-mode and --new-state flags.

  • Implement logic in the history migrator to handle pruned databases by computing a floor block (oldest retained block).

  • Update nonceIngestor and storageIngestor to respect the history floor, writing floor entries when necessary and correctly skipping pruned history.

  • Add extensive tests for migrating chains with pruned histories, including handling of cancellations and crashes.


File Walkthrough

Relevant files
Documentation
2 files
juno.go
Update CLI flag usage strings                                                       
+2/-3     
_config-options.md
Update configuration options documentation                             
+2/-2     
Tests
4 files
chain_test.go
Add helper functions for creating deprecated state test chains
+143/-0 
resume_test.go
Update resume test to pass floor parameters                           
+6/-6     
migrator_test.go
Add test suite for pruned history migration                           
+143/-31
node_test.go
Remove test checking prune and new-state mutual exclusion
+0/-8     
Enhancement
4 files
migrator.go
Add history floor computation and pass it to ingestors     
+29/-8   
nonce_ingestor.go
Adapt nonce migration to handle pruned block histories     
+41/-15 
parse.go
Add `hasEntries` utility function                                               
+10/-0   
storage_ingestor.go
Update storage ingestor to migrate correctly above history floor
+88/-33 
Configuration changes
1 files
node.go
Allow combining prune config with new-state config             
+0/-5     

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

// pre-value, or the head leaf when no history is left. Unpruned, it is always zero.
// Deprecated rows are wiped with the whole bucket once the phase completes.
//
//nolint:gocyclo,funlen // one lockstep walk over the history and the head trie

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we avoid the nolint and refactor it instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried moving things outside the function, but it looks like the only thing that can be moved cleanly is writeLeavesBefore. Even with writeLeavesBefore outside gocyclo complexity is still 21 with target 15

// cancellations and a restart after a crash, and checks every read from the
// floor up against the deprecated state before pruning.
// retained == blocks means no pruning.
func TestMigratePrunedHistory(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These three scenarios should be subtests rather than blocks separated by assert messages, so a failure names the scenario and each can be run on its own.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

splitted test

@NazariiDenha
NazariiDenha force-pushed the feat/newstate-migrate-pruned branch from deb1be6 to 4144169 Compare October 29, 2026 10:29
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, files changed)
  • Review migrator.go changes
  • Review nonce_ingestor.go changes
  • Review storage_ingestor.go / parse.go changes
  • Review chain_test.go / migrator_test.go / resume_test.go
  • Review cmd/juno/juno.go, node/node.go changes
  • Post findings

View job run

This branch was successfully deployed

1 active (outdated) deployment
Development — deb1be6c Deployed Oct 27, 2026 by NazariiDenha via dev_deploy_test / deploy #6204
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.

2 participants