You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ADR 002 and 003 both acknowledge BLAKE3 isn't an EVM precompile and mention "Merkle proof over chunks using keccak256" for PoC. But no ADR specifies:
What chunk size for the Merkle tree?
How does a client construct the proof?
What's the gas cost of verifying a Merkle proof on-chain?
Is the proof over iroh-blobs' internal 1024-byte chunks or the 1 MB payment chunks?
This is critical for slashing to work. Without a concrete spec, slashing for BLAKE3 mismatch is aspirational.
Recommendation
Add a section to ADR 002 or create a new ADR specifying the exact Merkle proof scheme, including chunk size, proof construction, and estimated gas costs.
On-Chain Gas:Low (~30k–50k gas). This solution is highly efficient on-chain because Keccak256 is an EVM-native precompile.
Node Overhead:High. Nodes are required to re-hash all incoming content using Keccak256 during the ingestion process.
Storage:Additional Requirements. This approach requires storing and managing secondary Keccak Merkle trees alongside original data.
Complexity:High Off-Chain. Complexity is shifted to the off-chain environment, as developers must manage and sync two entirely different sets of hashes.
2. BLAKE3 Path Verification (ADR 012)
On-Chain Gas:High (~250k+ gas). Verification is expensive because it requires executing complex BLAKE3 mathematical operations directly in Solidity.
Node Overhead:Zero. This solution is optimized for the Iroh ecosystem, as it aligns perfectly with Iroh's native BLAKE3 content IDs.
Storage:Efficient. There is no extra storage burden; it simply reuses the existing Bao (outboard) files generated by Iroh.
Complexity:High On-Chain. The primary difficulty lies in the smart contract implementation, which requires a robust Solidity version of the BLAKE3 algorithm.
Comparing the two main approaches reveals a trade-off between computational efficiency for nodes and gas efficiency on-chain.
Verdict: The BLAKE3 Path Verification (ADR 012) is technically superior for a decentralized CDN. In a high-throughput network, CPU and I/O overhead on nodes is a far greater bottleneck than the occasional gas cost of a slashing event.
Other Potential Solutions
1. The "Dual-Hash" Hybrid (Metadata Approach)
Instead of forcing the node to hash everything, the Origin Node provides a manifest that includes both the BLAKE3 hash (for delivery) and a Keccak256 root (for the EVM) during ingest.
Pros: Verification is cheap for the contract; nodes only store one extra 32-byte hash per 1MB chunk.
Cons: Breaks the "content-agnostic" principle. If the BLAKE3 hash is the only unique ID, adding a Keccak ID creates a secondary mapping that must be kept in sync across all nodes.
2. ZK-Fraud Proofs (Succinct Verification)
The challenger (client) generates a Zero-Knowledge Proof (like a SNARK) proving: "I have a 1024-byte chunk that hashes to BLAKE3 root X, but contains data Y."
Pros: The contract only verifies a simple proof (~200k gas), never performing BLAKE3 itself.
Cons: Generating ZK proofs for $1024$-byte chunks is computationally expensive for the client and likely too slow for a PoC.
3. Optimistic Fishermen (Off-Chain Arbitration)
When a dispute occurs, the contract does not verify the hash. Instead, it "pings" a set of staked Verifier Nodes. If a majority of verifiers agree the data is bad, the node is slashed.
Pros: No complex cryptography on-chain.
Cons: Introduces a new trust assumption and requires an "honesty majority" of verifiers, which complicates the PoC's simple node/client model.
Recommendation: Stick with BLAKE3 (Bao)
For the project, you should move forward with ADR 012 (BLAKE3 Path Verification).
Why?
Architectural Purity: Your entire stack (Rust, iroh, BLAKE3) is built around content-addressing. Introducing Keccak256 just to satisfy the EVM creates "technical debt" at the core delivery layer.
Incentive Alignment: Slashing is a rare "edge case" event. It is better to pay a higher gas fee once every few months for a slash than to increase the CPU/Storage cost of every single byte ingested into the network.
Future Proofing: If BLAKE3 eventually becomes an EVM precompile (as has been proposed in various EIPs), your code will become significantly cheaper without needing a protocol-wide migration.
Dual-tree architecture: BLAKE3/bao-tree for streaming (off-chain), keccak256 binary Merkle tree for disputes (on-chain)
1 MB chunks matching ADR 003 payment granularity
Voucher integration: keccak root embedded in the ADR 003 voucher — no separate deal registration (saves ~113K gas)
Domain separation:0x00/0x01 leaf/interior prefixes (OpenZeppelin convention) + channel_id in leaf encoding to prevent cross-channel replay
Two dispute types: corruption (Merkle proof) and non-delivery (voucher nonce comparison)
Settlement-gated: content disputes open after settleChannel(), not during close — watchtower (ADR 007) corrects nonce first
Remaining issues to resolve
1. Slash uses ch.stake but stake lives in StakingRegistry (Medium)
ADR 004 defines stake in a separate registry contract, not in the channel struct. The resolution function should call stakingRegistry.slash(provider, amount) instead of modifying a local field.
2. No provider defense function (Medium)
The contract auto-slashes after the content dispute window, but there's no defendCorruptionDispute() function for the provider to prove the data was correct. Simplest PoC approach: provider submits the correct chunk on-chain, contract verifies it reconstructs to the committed root, dispute is dismissed and challenger loses bond.
3. settledAt timestamp not in ADR 003 channel struct (Low)
Content disputes reference ch.settledAt + CONTENT_DISPUTE_WINDOW but ADR 003's settleChannel() doesn't record a settlement timestamp. Needs a small addition to the channel struct.
4. One channel = one blob (Low, design trade-off)
Each channel delivers exactly one blob. Multi-file downloads need multiple channels. Acceptable for PoC, worth noting as a scaling consideration.
5. Client sibling path acquisition (Low)
ADR 012 assumes the client has the Merkle sibling paths but doesn't specify the protocol. Recommended: client builds the tree locally by hashing each 1 MB chunk on receipt.
6. Corruption proof is a plausibility filter, not cryptographic proof (Acknowledged)
The Merkle walk only rejects disputes where the submitted data matches the commitment. For all other cases, security relies on the dispute bond (100 TOKEN per ADR 004) + challenge window + off-chain BLAKE3 verification. This is explicitly acknowledged in the ADR.
Reopening — the dedicated ADR 012 Merkle proof spec added in 0a38eab was deleted in PR #162 (b7412ab), which repurposed ADR 012 for client architecture. The concrete spec (chunk size, proof construction, gas costs) no longer exists on main. Only vague references to "Merkle proof over chunks using keccak256" remain in ADR 002 and 003.
Activity
altanoruc commentedon Mar 31, 2026
1. Keccak256 Merkle Proof
2. BLAKE3 Path Verification (ADR 012)
Comparing the two main approaches reveals a trade-off between computational efficiency for nodes and gas efficiency on-chain.
Verdict: The BLAKE3 Path Verification (ADR 012) is technically superior for a decentralized CDN. In a high-throughput network, CPU and I/O overhead on nodes is a far greater bottleneck than the occasional gas cost of a slashing event.
Other Potential Solutions
1. The "Dual-Hash" Hybrid (Metadata Approach)
Instead of forcing the node to hash everything, the Origin Node provides a manifest that includes both the BLAKE3 hash (for delivery) and a Keccak256 root (for the EVM) during ingest.
Pros: Verification is cheap for the contract; nodes only store one extra 32-byte hash per 1MB chunk.
Cons: Breaks the "content-agnostic" principle. If the BLAKE3 hash is the only unique ID, adding a Keccak ID creates a secondary mapping that must be kept in sync across all nodes.
2. ZK-Fraud Proofs (Succinct Verification)
The challenger (client) generates a Zero-Knowledge Proof (like a SNARK) proving: "I have a 1024-byte chunk that hashes to BLAKE3 root X, but contains data Y."
Pros: The contract only verifies a simple proof (~200k gas), never performing BLAKE3 itself.
Cons: Generating ZK proofs for$1024$ -byte chunks is computationally expensive for the client and likely too slow for a PoC.
3. Optimistic Fishermen (Off-Chain Arbitration)
When a dispute occurs, the contract does not verify the hash. Instead, it "pings" a set of staked Verifier Nodes. If a majority of verifiers agree the data is bad, the node is slashed.
Pros: No complex cryptography on-chain.
Cons: Introduces a new trust assumption and requires an "honesty majority" of verifiers, which complicates the PoC's simple node/client model.
Recommendation: Stick with BLAKE3 (Bao)
For the project, you should move forward with ADR 012 (BLAKE3 Path Verification).
Why?
Architectural Purity: Your entire stack (Rust, iroh, BLAKE3) is built around content-addressing. Introducing Keccak256 just to satisfy the EVM creates "technical debt" at the core delivery layer.
Incentive Alignment: Slashing is a rare "edge case" event. It is better to pay a higher gas fee once every few months for a slash than to increase the CPU/Storage cost of every single byte ingested into the network.
Future Proofing: If BLAKE3 eventually becomes an EVM precompile (as has been proposed in various EIPs), your code will become significantly cheaper without needing a protocol-wide migration.
:
docs: add ADR 012 on-chain Merkle proof scheme for content verificati…
yigitdot commentedon Apr 1, 2026
ADR 012: On-Chain Merkle Proof Scheme — Status & Open Issues
Branch pushed:
adr/012-onchain-merkle-proof-schemeWhat ADR 012 covers
0x00/0x01leaf/interior prefixes (OpenZeppelin convention) +channel_idin leaf encoding to prevent cross-channel replaysettleChannel(), not during close — watchtower (ADR 007) corrects nonce firstRemaining issues to resolve
1. Slash uses
ch.stakebut stake lives inStakingRegistry(Medium)ADR 004 defines stake in a separate registry contract, not in the channel struct. The resolution function should call
stakingRegistry.slash(provider, amount)instead of modifying a local field.2. No provider defense function (Medium)
The contract auto-slashes after the content dispute window, but there's no
defendCorruptionDispute()function for the provider to prove the data was correct. Simplest PoC approach: provider submits the correct chunk on-chain, contract verifies it reconstructs to the committed root, dispute is dismissed and challenger loses bond.3.
settledAttimestamp not in ADR 003 channel struct (Low)Content disputes reference
ch.settledAt + CONTENT_DISPUTE_WINDOWbut ADR 003'ssettleChannel()doesn't record a settlement timestamp. Needs a small addition to the channel struct.4. One channel = one blob (Low, design trade-off)
Each channel delivers exactly one blob. Multi-file downloads need multiple channels. Acceptable for PoC, worth noting as a scaling consideration.
5. Client sibling path acquisition (Low)
ADR 012 assumes the client has the Merkle sibling paths but doesn't specify the protocol. Recommended: client builds the tree locally by hashing each 1 MB chunk on receipt.
6. Corruption proof is a plausibility filter, not cryptographic proof (Acknowledged)
The Merkle walk only rejects disputes where the submitted data matches the commitment. For all other cases, security relies on the dispute bond (100 TOKEN per ADR 004) + challenge window + off-chain BLAKE3 verification. This is explicitly acknowledged in the ADR.
thiras commentedon Apr 3, 2026
Resolved by commit 0a38eab ("docs: add ADR 012 on-chain Merkle proof scheme for content verification (fixes #4)"). The Merkle proof scheme is fully specified in ADR 012.
thiras commentedon Apr 3, 2026
Reopening — the dedicated ADR 012 Merkle proof spec added in
0a38eabwas deleted in PR #162 (b7412ab), which repurposed ADR 012 for client architecture. The concrete spec (chunk size, proof construction, gas costs) no longer exists onmain. Only vague references to "Merkle proof over chunks using keccak256" remain in ADR 002 and 003.docs: add ADR 014 on-chain verification for slashing evidence
refactor(security): collapse per-IP/per-NodeID into per-source via go…
5 remaining items
fix(node): apply consolidated review fixes from PR #643 multi-agent r…
feat(node): cdn/dht/v1 handler + routing table + 3-layer rate limiter…
feat(node,cache): record store + Store/FindValue + cache hook (PR 3/4…
docs(adr): rewrite ADR 009 and 018 — governance + liquidity (v2.1)
docs(adr): post-PR-review fixes from gemini/copilot bots (14 items)
docs(adr): post-PR-review fixes — v2.1 vocabulary drift + broken 026 …
docs(adr): post-review fixes — 5c643ad miss-list (gemini + copilot)
fix(contracts): address @alpergundogdu review — appeal-slot griefing …
refactor(contracts): remove SafetyReserve; escrow-on-slash + 5% bucke…
refactor(node): address PR review — regions serde(default) + idle hea…
feat: per-region bandwidth accounting (#750) (#816)
fix(cli): harden bundle range-dedup resume, planning, sweep, and prog…
feat(cli): bundle pull via chunk-hint range dedup, dormant same-lane …
thiras commentedon Oct 16, 2026