Skip to content

Fix staged sync cycle limit wiring - #12

Open
Frozen wants to merge 1 commit into
mainfrom
fix/staged-sync-cycle-limit
Open

Fix staged sync cycle limit wiring#12
Frozen wants to merge 1 commit into
mainfrom
fix/staged-sync-cycle-limit

Conversation

@Frozen

@Frozen Frozen commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • wire Sync.StagedSyncCfg.MaxBlocksPerSyncCycle into staged sync
  • replace the hard-coded 1024-block cycle cap with the configured value
  • preserve 0 as unlimited and add target-height regression coverage

[Test]

  • go test -mod=readonly ./api/service/synchronize/stagedstreamsync
  • go test -mod=readonly ./cmd/harmony
  • go vet -mod=readonly ./api/service/synchronize/stagedstreamsync ./cmd/harmony
  • git diff --check origin/main...HEAD

Honor StagedSync.MaxBlocksPerSyncCycle when selecting each staged-sync target instead of using the hard-coded 1024-block limit. Preserve zero as unlimited and cover bounded and unbounded targets.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown

Greptile Summary

The PR wires the configured staged-sync block limit through service construction and replaces the fixed 1024-block cycle cap while preserving zero as unlimited.

  • Adds MaxBlocksPerSyncCycle to the staged-sync service configuration.
  • Passes the configured value into StageHeads.
  • Limits each cycle’s target height through a dedicated helper.
  • Adds regression coverage for positive limits and unlimited operation.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The configured value is propagated through the staged-sync construction path, positive values cap the cycle target as intended, zero retains the documented unlimited behavior, and the changed constructor has no stale repository callers.

Important Files Changed

Filename Overview
cmd/harmony/main.go Wires the Harmony staged-sync cycle limit into the synchronization service configuration.
api/service/synchronize/stagedstreamsync/const.go Adds the configured maximum-block count to the staged-sync service configuration, documenting zero as unlimited.
api/service/synchronize/stagedstreamsync/syncing.go Passes the service-level cycle limit into the heads-stage configuration.
api/service/synchronize/stagedstreamsync/stage_heads.go Replaces the hard-coded 1024-block cap with the configured limit and safely handles targets at or below the current height.
api/service/synchronize/stagedstreamsync/stage_heads_test.go Covers smaller and larger limits, a one-block limit, and zero-as-unlimited behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Harmony staged-sync config] -->|MaxBlocksPerSyncCycle| B[syncService.Config]
    B --> C[CreateStagedSync]
    C --> D[StageHeadsCfg]
    D --> E[limitCycleTargetHeight]
    E -->|positive value| F[Cap cycle target]
    E -->|zero| G[Use full target height]
Loading

Reviews (1): Last reviewed commit: "Fix staged sync cycle limit wiring" | Re-trigger Greptile

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.

1 participant