Skip to content

fix(chainsync): preserve event channels during auto-reconnect#611

Merged
wolf31o2 merged 1 commit intomainfrom
fix/reconnect-channel-orphaning
Feb 9, 2026
Merged

fix(chainsync): preserve event channels during auto-reconnect#611
wolf31o2 merged 1 commit intomainfrom
fix/reconnect-channel-orphaning

Conversation

@wcatz
Copy link
Copy Markdown
Contributor

@wcatz wcatz commented Feb 9, 2026

Only create eventChan/errorChan when nil, preventing channel orphaning when Start() is called during auto-reconnect without a preceding Stop(). Add WithReconnectCallback option for consumer reconnection awareness.

Closes #610


Summary by cubic

Preserves event and error channels during auto-reconnect to prevent orphaned pipelines, and adds a reconnect callback hook for consumer visibility.

  • Bug Fixes

    • Start() only creates eventChan/errorChan when nil, avoiding channel replacement during auto-reconnect.
    • Tests verify channel reuse on reconnect and new channel creation after Stop().
  • New Features

    • WithReconnectCallback option to run a function after a successful auto-reconnect.

Written for commit dd5a8a1. Summary will update on new commits.

Only create eventChan/errorChan when nil, preventing channel orphaning
when Start() is called during auto-reconnect without a preceding Stop().
Add WithReconnectCallback option for consumer reconnection awareness.

Closes #610

Signed-off-by: wcatz <waynecataldo@gmail.com>
@wcatz wcatz requested a review from a team as a code owner February 9, 2026 15:08
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@wolf31o2 wolf31o2 merged commit 460d03e into main Feb 9, 2026
10 checks passed
@wolf31o2 wolf31o2 deleted the fix/reconnect-channel-orphaning branch February 9, 2026 15:47
wcatz added a commit to wcatz/goduckbot that referenced this pull request Feb 9, 2026
Updates blinklabs-io/adder to commit 460d03e which preserves event
channels during auto-reconnect, preventing silent block delivery
stalls.

Fixes: blinklabs-io/adder#611

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
wcatz added a commit to wcatz/goduckbot that referenced this pull request Feb 9, 2026
* fix(deps): update adder to fix silent reconnect channel orphaning

Updates blinklabs-io/adder to commit 460d03e which preserves event
channels during auto-reconnect, preventing silent block delivery
stalls.

Fixes: blinklabs-io/adder#611

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(config): make NtC query timeout configurable

Add leaderlog.ntcQueryTimeout config option (Go duration string).
Defaults to 10m if not set. Configurable via helm values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(nonce): use XOR for nonce evolution and epoch transitions per Cardano spec

The Cardano Nonce semigroup defines: Nonce a <> Nonce b = Nonce (xor a b)
The code was incorrectly using BLAKE2b-256(a || b) instead of XOR for:
1. Per-block nonce evolution (evolveNonce)
2. Epoch nonce transition (TICKN rule)

Additionally, the epoch transition was using the previous epoch nonce as
the second operand instead of η_ph (prev block hash nonce from TICKN state).

Correct formula per cardano-ledger TICKN rule:
  η(new) = η_c ⊕ η_ph
where η_c = candidate nonce, η_ph = last block hash of prior epoch boundary.

Changes:
- evolveNonce: BLAKE2b-256(a||b) → XOR(a,b)
- Epoch transition: hash(etaC||eta0) → XOR(etaC, prevHashNonce)
- StreamBlockNonces now returns block_hash for η_ph tracking
- Updated both SQLite and PostgreSQL store implementations
- Updated all tests to verify XOR behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: fix nonce evolution description (XOR not BLAKE2b), 60% stability window

- README: nonce evolution uses XOR per Cardano Nonce semigroup
- README: epoch transition uses TICKN rule (η_c XOR η_ph)
- CLAUDE.md: fix stability window references from 70% to 60%
- CLAUDE.md: update nonce evolution description to XOR
- Update adder dependency version reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
wcatz added a commit to wcatz/goduckbot that referenced this pull request Feb 18, 2026
* fix(deps): update adder to fix silent reconnect channel orphaning

Updates blinklabs-io/adder to commit 460d03e which preserves event
channels during auto-reconnect, preventing silent block delivery
stalls.

Fixes: blinklabs-io/adder#611

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(config): make NtC query timeout configurable

Add leaderlog.ntcQueryTimeout config option (Go duration string).
Defaults to 10m if not set. Configurable via helm values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(nonce): use XOR for nonce evolution and epoch transitions per Cardano spec

The Cardano Nonce semigroup defines: Nonce a <> Nonce b = Nonce (xor a b)
The code was incorrectly using BLAKE2b-256(a || b) instead of XOR for:
1. Per-block nonce evolution (evolveNonce)
2. Epoch nonce transition (TICKN rule)

Additionally, the epoch transition was using the previous epoch nonce as
the second operand instead of η_ph (prev block hash nonce from TICKN state).

Correct formula per cardano-ledger TICKN rule:
  η(new) = η_c ⊕ η_ph
where η_c = candidate nonce, η_ph = last block hash of prior epoch boundary.

Changes:
- evolveNonce: BLAKE2b-256(a||b) → XOR(a,b)
- Epoch transition: hash(etaC||eta0) → XOR(etaC, prevHashNonce)
- StreamBlockNonces now returns block_hash for η_ph tracking
- Updated both SQLite and PostgreSQL store implementations
- Updated all tests to verify XOR behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: fix nonce evolution description (XOR not BLAKE2b), 60% stability window

- README: nonce evolution uses XOR per Cardano Nonce semigroup
- README: epoch transition uses TICKN rule (η_c XOR η_ph)
- CLAUDE.md: fix stability window references from 70% to 60%
- CLAUDE.md: update nonce evolution description to XOR
- Update adder dependency version reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

Auto-reconnect silently orphans pipeline event channels

2 participants