Skip to content

fix(nonce): Koios fallback for η_ph in TICKN computation#80

Merged
wcatz merged 1 commit intomasterfrom
fix/tickn-koios-fallback
Feb 17, 2026
Merged

fix(nonce): Koios fallback for η_ph in TICKN computation#80
wcatz merged 1 commit intomasterfrom
fix/tickn-koios-fallback

Conversation

@wcatz
Copy link
Copy Markdown
Owner

@wcatz wcatz commented Feb 17, 2026

Summary

  • TICKN nonce computation failed because blocks table has gaps (epochs 284-612 missing)
  • Added fetchLastBlockHashFromKoios() fallback when DB doesn't have blocks for the required epoch
  • Enables epoch 614 leaderlog computation before epoch starts

Test plan

  • All 20 tests pass
  • go vet clean
  • Deploy and verify epoch 614 leaderlog computes

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Improved nonce computation resilience with enhanced data retrieval: The system now implements a two-tier approach for obtaining epoch data—attempting local cache first, then automatically falling back to external data sources if needed—ensuring more reliable nonce calculations even during synchronization interruptions.

TICKN computation for next epoch nonce failed because historical sync
has block gaps (epochs 284-612 missing due to keep-alive timeouts).
Added Koios blocks API fallback in GetLastBlockHashForEpoch path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wcatz wcatz merged commit 9b2687a into master Feb 17, 2026
@wcatz wcatz deleted the fix/tickn-koios-fallback branch February 17, 2026 11:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 17, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes modify GetNonceForEpoch in fullMode to implement a fallback strategy: when the previous epoch's last block hash is unavailable locally, the code queries Koios instead. A new helper method fetchLastBlockHashFromKoios handles this external API lookup, enabling epoch nonce computation even when local data is missing.

Changes

Cohort / File(s) Summary
Nonce Fallback Logic
nonce.go
Added fetchLastBlockHashFromKoios method to query Koios for a given epoch's last block hash. Modified GetNonceForEpoch (fullMode) to use this fallback when local DB lookup fails or returns empty, enabling graceful degradation to external API when internal data is unavailable.

Sequence Diagram

sequenceDiagram
    participant Client
    participant GetNonceForEpoch
    participant LocalDB
    participant Koios
    
    Client->>GetNonceForEpoch: GetNonceForEpoch(fullMode, candidateNonce exists)
    GetNonceForEpoch->>LocalDB: Query previous epoch's last block hash
    alt Local DB has data
        LocalDB-->>GetNonceForEpoch: Return block hash
        GetNonceForEpoch-->>Client: Compute & return nonce
    else Local DB empty or error
        LocalDB-->>GetNonceForEpoch: Empty/Error
        GetNonceForEpoch->>Koios: fetchLastBlockHashFromKoios(epoch)
        Koios-->>GetNonceForEpoch: Return hex hash
        GetNonceForEpoch-->>Client: Compute & return nonce
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A nonce needs a path, both local and far,
When the database sleeps, we look to a star,
Koios retrieves what the cache cannot hold,
Fallback paths shimmer, resilience takes fold! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/tickn-koios-fallback

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.

wcatz added a commit that referenced this pull request Feb 18, 2026
fix(nonce): Koios fallback for η_ph in TICKN computation
wcatz added a commit that referenced this pull request Feb 18, 2026
fix(nonce): Koios fallback for η_ph in TICKN computation
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