feat(mirror): itsl_mirror.py — ITSL/blocks/rewards → nedbd sidecar daemon#2
Open
Eth-Interchained wants to merge 1 commit into
Open
feat(mirror): itsl_mirror.py — ITSL/blocks/rewards → nedbd sidecar daemon#2Eth-Interchained wants to merge 1 commit into
Eth-Interchained wants to merge 1 commit into
Conversation
…emon
Bridges an ITC Core node to a running nedbd instance, populating three
collections that power the Vision NEDB showcase:
itsl_ops — every ITSL token operation with native caused_by causal
links (enables TRACE queries) and bi-temporal valid_from
(enables VALID AS OF date queries)
blocks — full block headers with parent caused_by chain
reward_splits — per-block coinbase split (miner / governance / operator)
with percentage fields for GROUP BY analytics
Also ships:
itsl_mirror.service — production systemd unit (EnvironmentFile pattern)
itsl_mirror.env.example — config template for the service
DEPLOY.md section 7 — full NEDB integration guide with NQL examples
Design notes:
- Stdlib only (no httpx/requests) — runs with bare nedb-engine Python install
- Cursor state persisted in nedbd itself (_mirror db, cursors collection)
so restarts resume without reprocessing
- Idempotent: op _id = {token}::{sha256(op_fields)} so re-runs are safe
- Handles node/nedbd downtime gracefully — logs warnings and retries next pass
- --once / --once-blocks / --dry-run / --reset-cursor / --verbose flags
- SIGTERM-safe: finishes current pass before exiting
NQL queries unlocked after first run:
FROM itsl_ops WHERE token = "0x...tok" TRACE caused_by
FROM itsl_ops VALID AS OF "2026-01-01"
FROM reward_splits GROUP BY governance_address SUM governance_reward
FROM blocks ORDER BY height DESC LIMIT 1 AS OF <seq>
Co-Authored-By: NEDB Maintainer (Claude Sonnet 4.6) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
backend/scripts/itsl_mirror.py— standalone daemon (stdlib-only, no extra deps beyond nedb-engine) that polls the ITC node and writes to nedbditsl_mirror.service— systemd unit for productionitsl_mirror.env.example— config templateDEPLOY.md §7— full NEDB integration guide with NQL examplesCollections populated
itsl_opscaused_byTRACE caused_by,AS OF seq,VALID AS OF dateblocksAS OF seqtime-travelreward_splitsGROUP BYtreasury analyticsWhy this matters
Without the mirror, the
/nedbshowcase page on Vision has nothing to query. With it running for even one sync pass, users can:AS OF seqGROUP BYDepends on
Merging PR #1 (
hyperagent/vision-nedb-store) first. The mirror is independent but the/api/nedb/traceand/api/nedb/token-history?as_of=Nroutes from PR #1 are what the frontend calls to display results.Tests run
python3 -m py_compile)Generated by NEDB Maintainer — Claude Sonnet 4.6 × Interchained LLC