Skip to content

Optionally disable multichain rewind lock#3028

Open
Wizdave97 wants to merge 4 commits intosubquery:mainfrom
Wizdave97:david/disable-rewind-lock
Open

Optionally disable multichain rewind lock#3028
Wizdave97 wants to merge 4 commits intosubquery:mainfrom
Wizdave97:david/disable-rewind-lock

Conversation

@Wizdave97
Copy link

@Wizdave97 Wizdave97 commented Mar 23, 2026

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have tested locally
  • I have performed a self review of my changes
  • Updated any relevant documentation
  • Linked to any relevant issues
  • I have added tests relevant to my changes
  • Any dependent changes have been merged and published in downstream modules
  • My code is up to date with the base branch
  • I have updated relevant changelogs. We suggest using chan

Summary by CodeRabbit

  • New Features

    • Added a CLI option and config to disable multichain rewind locking (default: false).
  • Behavior Changes

    • When enabled, indexing skips multichain rewind lock coordination and will not wait for other chains to finish rewinding.
  • Tests

    • Added/updated tests asserting the default is false and verifying behavior when the option is enabled.

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Added a new boolean config flag disableMultichainRewindLock (default false), exposed via CLI and NodeConfig. FetchService and MultiChainRewindService consult the flag to bypass multichain rewind-lock coordination when enabled. Tests updated to cover default and enabled behaviors.

Changes

Cohort / File(s) Summary
Configuration Definition
packages/node-core/src/configure/NodeConfig.ts, packages/node-core/src/configure/NodeConfig.spec.ts
Add disableMultichainRewindLock to IConfig/DEFAULT_CONFIG, expose NodeConfig.disableMultichainRewindLock getter, and add tests for default false and true cases.
CLI Option
packages/node-core/src/yargs.ts
Add --disable-multichain-rewind-lock boolean CLI option (default: false).
Indexer Services
packages/node-core/src/indexer/fetch.service.ts, packages/node-core/src/indexer/fetch.service.spec.ts, packages/node-core/src/indexer/multiChainRewind.service.ts
FetchService skips the rewind-completion wait when the flag is enabled; MultiChainRewindService adds disableRewindLock getter and early-return behavior for init/acquire/release when disabled; tests updated to assert suppressed rewind-wait logging.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant NodeConfig
  participant FetchService
  participant MultiChainRewindService
  participant Store

  CLI->>NodeConfig: parse --disable-multichain-rewind-lock
  NodeConfig-->>FetchService: config.disableMultichainRewindLock
  NodeConfig-->>MultiChainRewindService: config.disableMultichainRewindLock

  alt disableMultichainRewindLock == false
    FetchService->>MultiChainRewindService: query rewind status
    MultiChainRewindService->>Store: acquireGlobalRewindLock()
    Store-->>MultiChainRewindService: lock result
    MultiChainRewindService-->>FetchService: may block until complete
  else disableMultichainRewindLock == true
    FetchService->>MultiChainRewindService: skip rewind-wait gate
    MultiChainRewindService-->>FetchService: immediate allow (acquire returns true)
  end

  FetchService->>FetchService: continue fillNextBlockBuffer / processing
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I flipped a tiny switch today,
Rewinds step back so chains can play,
Configured true — the locks unbind,
Hops and fetches now aligned,
Carrots cheer the freer way 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Optionally disable multichain rewind lock' directly and clearly describes the main feature addition: introducing optional configuration to disable multichain rewind lock functionality across multiple service components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/node-core/src/indexer/fetch.service.spec.ts`:
- Around line 830-838: The test is flaky because fetchService.init(10) spins off
an async loop and the negative assertion may run before that loop checks the
rewind lock; make it deterministic by ensuring the loop iteration that would
perform the rewind-check runs (or is advanced) before asserting. Specifically,
in this test modify the flow around fetchService.init, nodeConfig.merge, and
(multichainRewindService as any).status: either use Jest fake timers and call
jest.useFakeTimers() then advance timers (e.g., jest.runOnlyPendingTimers() /
jest.advanceTimersByTime()) to force the loop iteration, or await a known
promise/observable the loop awaits (or spy on the specific method that performs
the rewind-check and wait for it to be called/settled) before asserting that
logger.info was not called with the rewind message; keep the negative assertion
only after the loop has been deterministically progressed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e62ef57f-37e9-450b-b7f5-5e33fcee78ee

📥 Commits

Reviewing files that changed from the base of the PR and between 264145d and 923240c.

📒 Files selected for processing (6)
  • packages/node-core/src/configure/NodeConfig.spec.ts
  • packages/node-core/src/configure/NodeConfig.ts
  • packages/node-core/src/indexer/fetch.service.spec.ts
  • packages/node-core/src/indexer/fetch.service.ts
  • packages/node-core/src/indexer/multiChainRewind.service.ts
  • packages/node-core/src/yargs.ts

@Wizdave97
Copy link
Author

@ianhe8x Please take a look

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/node-core/src/indexer/multiChainRewind.service.ts (1)

216-218: Consider adding a debug/info log for observability.

When the lock is disabled, the early return bypasses the "Rewind success" log at line 223. For consistent debugging and operational visibility, consider adding a log statement here.

♻️ Optional: Add logging for consistency
   if (this.disableRewindLock) {
+    logger.info(`Rewind lock disabled, skipping chain lock release for chainId: ${this.chainId}`);
     return 0;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/node-core/src/indexer/multiChainRewind.service.ts` around lines 216
- 218, Add an informational/debug log right before the early return when
this.disableRewindLock is true so that skipping the rewind is visible in logs;
use the same logger used for the "Rewind success" message (e.g.,
this.logger.info or whatever logger instance the service uses) and emit a
message like "Rewind lock disabled, skipping rewind" including any available
context (chain id or job id) before returning 0.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/node-core/src/indexer/multiChainRewind.service.ts`:
- Around line 216-218: Add an informational/debug log right before the early
return when this.disableRewindLock is true so that skipping the rewind is
visible in logs; use the same logger used for the "Rewind success" message
(e.g., this.logger.info or whatever logger instance the service uses) and emit a
message like "Rewind lock disabled, skipping rewind" including any available
context (chain id or job id) before returning 0.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1bc477e5-8035-45d8-9c5d-1bad8dde4d06

📥 Commits

Reviewing files that changed from the base of the PR and between d75a918 and 13216d1.

📒 Files selected for processing (1)
  • packages/node-core/src/indexer/multiChainRewind.service.ts

@Wizdave97
Copy link
Author

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