Skip to main content

Module cache

Module cache 

Source
Expand description

A bounded cache of shielded bundle verifications that have already succeeded.

Zebra verifies a transaction’s shielded proofs and signatures when the transaction arrives over mempool gossip, and again when it arrives in a block. This service skips the second verification. The Halo2 Orchard and Ironwood verifiers (super::halo2) and the Sapling verifier (super::sapling) share it, and key their entries the same way.

§Why this is not the mempool bypass

Zebra once skipped whole-transaction verification for transactions already in the mempool, and removed it as a security fix (PR #10494). Transaction validity depends on height, block time and spent outputs, and that cache’s key named none of them.

This cache remembers successful bundle verification by transaction ID, sighash and shielded pool. A hit still runs the whole transaction verifier against the block’s height, time and spent outputs, and skips only the proof and signature checks. Each Orchard circuit era has its own cache, which binds an entry to its verifying key (see super::halo2::orchard_v5_verifier_for); Sapling has one verifying key pair for all of history, so one cache covers it.

Only Ok results are cached. A batch error is not per-item evidence, because Fallback re-verifies failures singly, and it may not be a verdict at all — a shut-down batch worker reports the same way. Caching it would reject a valid block.

Structs§

CacheKey 🔒
A transaction, sighash and shielded pool whose bundle has verified.
CacheMetrics 🔒
Metric handles registered once when a cache is created.
Cached 🔒
A service that skips inner verification for items whose bundle has already verified.
InsertOutcome 🔒
What one VerifiedBundles::insert did, so the caller can report it after releasing the lock.
VerifiedBundles 🔒
A bounded set of keys for bundles that have already verified successfully.

Enums§

ShieldedPool 🔒
The shielded bundle slot a cache entry was verified for.

Constants§

CACHE_CAPACITY 🔒
The number of verified-bundle keys retained per cache.
CACHE_EVICT 🔒
Counts keys dropped to stay within a cache’s capacity.
CACHE_HIT 🔒
Counts verifications answered from a cache.
CACHE_INSERT 🔒
Counts keys recorded as verified.
CACHE_MISS 🔒
Counts verifications that reached a cache’s inner service.
CACHE_SIZE 🔒
Reports how many keys a cache currently remembers.
VERIFIER_LABEL 🔒
The label naming which verifier’s cache a metric belongs to.

Traits§

CachedItem 🔒
An item whose successful verification can be remembered.