feat: Implement Reorg-Aware Event Indexer with zk-SNARK Quality Attestation Pipeline (#1319) - #1330
Open
Neelr1912 wants to merge 6 commits into
Open
feat: Implement Reorg-Aware Event Indexer with zk-SNARK Quality Attestation Pipeline (#1319)#1330Neelr1912 wants to merge 6 commits into
Neelr1912 wants to merge 6 commits into
Conversation
|
@Neelr1912 is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
… Python-2.0 license (Nitya-003#1319)
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.
Closes #1319
📌 Context & Problem Statement
Currently, CropChain relies on basic real-time event listeners which are vulnerable to state desynchronization from blockchain reorganizations (reorgs) and socket drops. Furthermore, confidential crop quality compliance data (pesticide PPM, moisture percentage, organic grading) needs to be attested on-chain without revealing sensitive farm trade secrets.
This PR implements a resilient Reorg-Aware Blockchain Event Indexer Engine combined with a Zero-Knowledge Proof (zk-SNARK) quality verification pipeline.
🏗️ Summary of Changes
1. Circom zk-SNARK Quality Attestation Circuit (
smart-contracts/circuits/)QualityAttestation.circomcircuit to confidentially enforce:Pesticide_PPM < ThresholdMoisture_Percentagewithin acceptable bounds[MIN, MAX]Grade == CertifiedGradecompile-circuit.jsscript to automate.wasm,.zkey, and Groth16 Solidity verifier artifact exports.2. On-Chain zk-SNARK Verification & Replay Protection (
smart-contracts/contracts/)Verifier.solwith standardGroth16Verifiercontract implementation.CropChain.solwithverifyQualityAttestation()to validate ZK proofs before state transitions.spentProofHashesnullifier map to prevent proof replay attacks.3. Reorg-Aware Event Indexer Engine (
backend/)BlockHeaderandIndexedEventMongoose models to track block parent hash continuity and event status (UNFINALIZEDvsFINALIZED).chunkSize = 100) viaeth_getLogsfor RPC recovery.4. Dead Letter Queue (DLQ) & Admin Reconciliation API (
backend/)DeadLetterEventmodel andindexerDlqService.jsto push unprocessable events to DLQ with exponential backoff retries.POST /api/v1/indexer/reconcilefor manual forced state synchronization.🧪 Edge Cases Handled
✅ Testing & Verification
npm run test:ciinsmart-contracts/)npx jest tests/reorgIndexer.test.js)node scripts/compile-circuit.jsexecuted cleanly.