Feat/mpt verification 386 - #393
Open
Guddy0101 wants to merge 5 commits into
Open
Conversation
|
@Guddy0101 is attempting to deploy a commit to the jotelfootball-tech's projects Team on Vercel. A member of the Team first needs to authorize it. |
…ng invariant (Nullifier-Systems#380) Adds an off-chain background worker that watches locked and expired trades for approaching refund timeouts and acts on them: - sendRefundCountdownAlert() in webhook.ts fires a push alert 100 ledgers before a trade's timeout_ledger (AC1), alongside the existing post-refund sendRefundAlert(). - refund-scheduler.ts scans candidate trades each tick: warns within the threshold, auto-invokes refundEscrow() once the timeout is breached (AC2), and mirrors the manual refund route's status and notification bookkeeping. - computeRefundAccounting() verifies seller_payouts + buyer_refund + fees == original_amount on every refund (AC3), reporting violations via an injectable handler or an operations webhook alert. - Wires startRefundCountdownScheduler() into the API bootstrap. No contract change: plain lock() trades are single-tranche on-chain, so refund() and the worker treat plain and multi-tranche trades uniformly. Adds 18 unit tests covering countdown alerts with dedup, auto-refund on breach, refund-failure retry, invariant balancing across fee rates, and violation detection.
…oss-chain proofs (Nullifier-Systems#386) - Add mpt_verifier module with deterministic MPT traversal - Implement core MPT node processing (branch, leaf, extension nodes) - Add TrustedBlockHeaderInfo struct for storing verified block metadata - Add register_trusted_block_header() to manage trusted EVM block headers - Add get_trusted_block_header() to retrieve verified block information - Enhance record_evm_reveal() to accept and validate MPT proofs - Update verify_merkle_proof() to use MPT verification instead of SHA256 stub - Add comprehensive error types for MPT verification failures - Add proof caching mechanism to prevent re-verification This implementation replaces the insecure SHA256 stub with proper Merkle-Patricia Trie verification, preventing malicious relayers from fabricating fake proofs. The verification is deterministic and fully testable without requiring full EVM execution clients. Security improvements: - Malicious relayers can no longer create fake proofs - Only admin-registered block headers are trusted - Proofs must correctly traverse the MPT to the expected value - Block finality requirements remain enforced per-chain
Guddy0101
force-pushed
the
feat/mpt-verification-386
branch
from
August 18, 2026 17:22
6370588 to
e614253
Compare
Contributor
|
@Guddy0101 after review i noticed that the contract ci check failed, kindly fix that i will review it again |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@Guddy0101 Good day |
Align code with Rust formatting standards: - Reorder imports alphabetically - Format long arrays and method chains across multiple lines - Fix comment alignment in test function calls - Remove extra blank lines Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPQEHd2dLVABUSbRQC9CGa
Contributor
|
@Guddy0101 great job 👍 |
- Fix BytesN/Bytes type conversions using .clone().into() pattern - Update Bytes.slice() API calls to use range syntax (.. ) instead of two arguments - Fix type mismatches: usize -> u32 for Bytes.get() indices - Remove unused imports and function parameters - Use BytesN::from_array() instead of non-existent BytesN::new() Resolves CI compilation errors in atomic-swap and session-account contracts. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019vWk5HFtmM12RHD6PdLKVt
Contributor
|
Hey @Guddy0101 , thanks for this. Everything else looks good, but |
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.
Description
Implement Merkle-Patricia Trie (MPT) verification for cross-chain atomic swap proofs, replacing the insecure SHA256 stub with deterministic
cryptographic proof validation.
Changes
Core Implementation
mpt_verifier.rs): Deterministic Merkle-Patricia Trie traversal supporting branch, extension, and leaf nodes withRLP-encoded proof validation
record_evm_reveal(): Now accepts and validates MPT proofs against trusted block headers with block height verificationverify_merkle_proof()with full MPT validation and result caching to prevent re-verification attacksContract Enhancements
register_trusted_block_header()- Admin-only function to register verified EVM blocksget_trusted_block_header()- Retrieve trusted block metadata and state rootsverify_mpt_log_inclusion()- Specialized helper for log verification against MPT rootsTrustedBlockHeaderInfostruct for storing block metadataTesting (20+ test cases)
Documentation
MPT_VERIFICATION.md: Comprehensive guide covering vulnerability analysis, architecture, usage flow, error handling, testing strategy, productionreadiness, and security considerations
Security Improvements
Integration Notes
Relayer Requirements:
register_trusted_block_header()eth_getProofRPC via enhancedrecord_evm_reveal()Admin Requirements:
Testing
Closes #386