Skip to content

feat(state-sync): show download/apply parts progress in sync status#15391

Merged
darioush merged 4 commits into
near:masterfrom
darioush:sync-add-apply-parts
Mar 17, 2026
Merged

feat(state-sync): show download/apply parts progress in sync status#15391
darioush merged 4 commits into
near:masterfrom
darioush:sync-add-apply-parts

Conversation

@darioush

@darioush darioush commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Add per-part progress to the StateDownloadParts and StateApplyInProgress sync status so that the RPC status endpoint shows e.g. "apply in progress (42/100)" instead of just "apply in progress". This makes it easier to monitor state sync progress during the (often slow) apply phase.

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.00%. Comparing base (734d7d8) to head (13e417d).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
chain/client-primitives/src/types.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15391      +/-   ##
==========================================
- Coverage   69.02%   69.00%   -0.02%     
==========================================
  Files         934      934              
  Lines      209214   209222       +8     
  Branches   209214   209222       +8     
==========================================
- Hits       144405   144372      -33     
- Misses      58823    58862      +39     
- Partials     5986     5988       +2     
Flag Coverage Δ
pytests-nightly 1.16% <0.00%> (-0.01%) ⬇️
unittests 68.25% <75.00%> (-0.01%) ⬇️
unittests-nightly 68.42% <75.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copilot AI left a comment

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.

Pull request overview

Adds per-part progress reporting to shard state sync statuses so RPC status output can show incremental progress (e.g. apply in progress (42/100)) during long-running state part download/apply phases.

Changes:

  • Extend ShardSyncStatus variants for “download parts” and “apply in progress” to carry { done, total }.
  • Update state sync shard logic to incrementally update the status as parts finish downloading/applying.
  • Update metrics reporting to use ShardSyncStatus::repr() instead of casting the enum.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
chain/client/src/sync/state/shard.rs Tracks and publishes per-part progress while downloading and applying state parts.
chain/client/src/sync/state/mod.rs Updates shard sync stage metric emission to use repr() for the now-data-carrying enum.
chain/client-primitives/src/types.rs Extends ShardSyncStatus to include progress counters and renders them into the RPC-facing string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chain/client/src/sync/state/shard.rs
Comment thread chain/client/src/sync/state/shard.rs Outdated
darioush

This comment was marked as outdated.

@darioush darioush requested a review from shreyan-gupta March 17, 2026 03:50
@darioush darioush marked this pull request as ready for review March 17, 2026 03:50
@darioush darioush requested a review from a team as a code owner March 17, 2026 03:50
@darioush darioush changed the title feat(state-sync): show apply parts progress in sync status feat(state-sync): show download/apply parts progress in sync status Mar 17, 2026
metrics::STATE_SYNC_STAGE
.with_label_values(&[&shard_id.to_string()])
.set(status as i64);
.set(status.repr() as i64);

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.

I just hope we are not grouping by this metric somewhere in grafana

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 guess we are actually, but the call to repr here returns the expected 0, 1, 2, 3, value

@shreyan-gupta shreyan-gupta left a comment

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.

Nice!

@darioush darioush added this pull request to the merge queue Mar 17, 2026
Merged via the queue into near:master with commit 57064d6 Mar 17, 2026
33 of 34 checks passed
@darioush darioush deleted the sync-add-apply-parts branch March 17, 2026 20:49
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.

4 participants