LEZ event exposure review — logos-docs journey issue #507

Reviewed against logos-blockchain/logos-execution-zone, tag v0.3.0 (commit db66590ab821a4e142c211017a3866d007f6fa77, 2026-09-29). The issue pins its test commands at f7fda38a4428b9989f1db1dbf5d2411484848fd4 (2026-09-26); confirmed that commit is an ancestor of v0.3.0, so testing at the tag is a strict superset. RISC0_DEV_MODE=1 throughout (ZK proof generation skipped, guest compilation not skipped — the real RISC0 riscv32im Rust toolchain via rzup was required and installed).

Update: the live three-process round trip has now been done, Docker-free. A real, single-validator Bedrock L1 node was built and run directly from the repo's own bedrock/node-config.yaml/deployment-settings.yaml (the same config its docker-compose.yml uses, just without the Docker wrapper — no testcontainers needed for this). A real sequencer_service (default features, i.e. the real BedrockActor, not the standalone mock) and a real indexer_service were pointed at it. Over actual local JSON-RPC: getEvents happy path — 5 genuine Deposit events from the real bridge program, selector byte-for-byte matching Deposit::SELECTOR; exact-and-conjunctive filtering — pinned-correct/pinned-wrong and selector-correct/selector-wrong all behave exactly as the unit tests predict; UncoveredEventQuery, live — an indexer with event_filter omitted rejects every query with exactly that error, over the wire. subscribeToEvents accepted and held open a real subscription (server logs confirm it), but no notification arrived in the test window — chasing that down surfaced a genuine, reproducible surprise (the indexer's own background sync silently stalled after an initial catch-up burst in this single-node setup, most likely an artifact of that setup rather than a protocol bug) — see finding #6 and the evidence folder for the full story.
Original verdict (superseded by the update above, kept for context): the event-exposure journey validates, with one environment-caused gap in "end-to-end." The documented mechanism — ProgramEvent → PlanOutput.events → full block re-execution (apply_block_to_state) → indexer ingest/filter → getEvents / subscribeToEvents — is implemented exactly as described and is backed by a strong, entirely passing test suite at every layer this sandbox could run (sequencer/state-machine, indexer core, indexer RPC service, bridge program — 173 tests total, 0 failures, plus 2 new probe tests added and verified live during this review). The one hop not completed live at the time was a real two-process (sequencer↔indexer) network RPC round trip, which the repo's only existing automated test for it requires Docker to exercise (via testcontainers, to run a real Bedrock L1 node for a joining/staking harness).

Summary

#FindingSeverityStatus
1Events are silently dropped for privacy-preserving transactions, with zero error or signal, and no test anywhere checks thisHighreproduced
2Selector collision/spoofing is practically reachable today: a selector-only query can't tell two different programs' events apart, and nothing on-chain verifies a selector's honestyHighreproduced — unit-level AND live over real JSON-RPC
3The bridge's Withdraw event is dead code — any non-Deposit instruction panics unconditionallyMediuminspected
4Sequencer FFI's event-coverage check uses a different (weaker) mechanism than the indexer's; currently masked, not yet exploitableMedium (latent)inspected
5Unconfigured-indexer footgun (event_filter unset ⇒ keeps/covers nothing ⇒ every query rejected) — correctly fail-closed, and a startup warning for it already existsLow (by design)reproduced — unit-level AND live over real JSON-RPC
6New, from the live run: a standalone indexer's background sync silently stalled after an initial catch-up burst (status stayed "CaughtUp" at a fixed block while the sequencer kept advancing) — likely an artifact of this review's minimal single-node setup, not confirmed as a protocol bugMedium (unconfirmed root cause)reproduced, reproducible across 2 independent indexer instances; root cause not isolated
—Live two-process sequencer↔indexer network RPC round trip—done — see the update at the top. Only the repo's own Docker-backed FFI test (sequencer_ffi_starting_events_produced_correctly) remains untested.

Findings

HIGH — 1. Events are silently dropped for privacy-preserving transactions

reproduced

State::transition_from_privacy_preserving_transaction (lee/state_machine/src/state/mod.rs:305-314) returns Result<(), LeeError> — there is no return path for events at all — and explicitly discards them:

pub fn transition_from_privacy_preserving_transaction(
    &mut self, tx: &PrivacyPreservingTransaction, block_id: BlockId, timestamp: Timestamp,
) -> Result<(), LeeError> {
    let diff = ValidatedStateDiff::from_privacy_preserving_transaction(tx, self, block_id, timestamp)?;
    drop(self.apply_state_diff(diff));
    Ok(())
}

The private circuit's own complete() takes the parameter as _events: Vec<ProgramEvent> (underscore-prefixed, unused) in lee/state_machine/src/privacy_preserving_transaction/circuit/mod.rs:254-262. The field's own doc comment in lee/state_machine/core/src/program/mod.rs says "Dropped for private transaction for function privacy" — so this is intentional design, not a bug. The gap is that it is completely undocumented in the issue, whose own "Failure modes and limits" section is blank, and whose worked examples ("a deposit, a swap, a delivery") are exactly the kind of operation LEZ lets a user do privately via its shielded-transfer mechanism — in which case no event would ever surface, with no error telling the caller why.

Live evidence: ran lee's own state::tests::events suite (8/8 passed, Docker-free). The one existing test that exercises the private path, event_emitting_program_proves_and_validates_on_the_private_path, only asserts the call succeeds — it never inspects what happened to the events, which is itself evidence the gap is untested as well as undocumented.

Suggested fix: either surface events from the private path too (if privacy requirements allow it — may need a separate, privacy-preserving event channel), or explicitly document "events do not exist for privately-executed calls" in the issue's failure-modes section, and add a test that pins this behavior (currently it's only true by the absence of a return value, easy to silently change).

HIGH — 2. Selector collision/spoofing: practically reachable today, not just theoretical

reproduced (new probe tests added and run)

Three facts compose into a real risk:

  1. Selectors are plain, attacker-chosen [u8; 8] values. Nothing on-chain verifies they are honestly derived from sha256("<program>::<Event>") — that's purely a per-program authoring convention, self-checked only against each program's own constants (bridge/core/src/event.rs::event_selectors_match_their_derivations checks only the bridge's own two constants against themselves).
  2. GetEventsFilter and EventSubscriptionFilter (lez/indexer/service/protocol/src/lib.rs:622-639) both allow querying/subscribing by selector alone — program_account_id is a fully independent Option.
  3. EventFilter::covers requires program_account_id to be set for anything but Archival — so a selector-only query is only ever answerable against an Archival-filter domain. And today, the sequencer's StorageActor handler for GetEventFilter is hardcoded to always return EventFilter::Archival (lez/sequencer/actors/storage/src/actor.rs:1482-1494, with an explicit // TODO: update sequencer configs to support custom archival policies), and the shipped indexer debug config also sets "event_filter": "archival". So the selector-only query path is the common case right now, not a corner case.
Live evidence (added to lez/indexer/core/src/event_filter.rs, run live, both passed):
fn a_per_program_filter_entry_is_not_polluted_by_a_colliding_selector_from_another_program() {
    // PROGRAM_A's own filter entry correctly ignores PROGRAM_B's event
    // even though it carries the identical selector bytes.
    assert!(filter.keeps(&honest));   // PROGRAM_A, spoofed_selector
    assert!(!filter.keeps(&spoofed)); // PROGRAM_B, same spoofed_selector
}

fn a_selector_only_query_cannot_distinguish_colliding_programs() {
    // program_account_id: None, selector: Some(X) — BOTH match. The query
    // layer does not disambiguate; only the client checking the returned
    // program_account_id field can.
    assert!(matches_fields(&honest,  None, Some(spoofed_selector)));
    assert!(matches_fields(&spoofed, None, Some(spoofed_selector)));
}
This shows the mitigation (per-program filter entries are correctly scoped — no pollution if a consumer pins program_account_id) and the risk (a selector-only query, or a subscription with program_account_id: None, cannot tell the honest event from a copy-cat one emitted by any other deployed program) in the same breath.
Also confirmed live, over real JSON-RPC against a running indexer_service synced to a real local chain (no second colliding program was deployed — see finding #6's note on why — so this exercises the matching mechanics, not an actual collision):
getEvents({from_block:1, to_block:5, program_account_id: <real bridge>})        -> 5 events
getEvents({from_block:1, to_block:5, program_account_id: <a different real account>}) -> []
getEvents({from_block:1, to_block:5, selector: Deposit::SELECTOR})                 -> 5 events (program_account_id omitted)
getEvents({from_block:1, to_block:5, selector: Withdraw::SELECTOR})                -> [] (never emitted — finding #3)
Full session in evidence/live/wire-level-rpc-session.txt.

Suggested fix: document prominently that program_account_id must always be pinned for any selector a consumer treats as meaningful/trusted (i.e. never rely on a selector alone to mean "this specific program"), and/or consider deriving/verifying selectors against the emitting program's own identity at the protocol level rather than leaving it a pure convention.

MEDIUM — 3. The bridge's Withdraw event is dead code

inspected — confirmed by direct source reading, not separately executed (the panic is a one-line literal in an unconditional branch; a dedicated unit test would need a hand-built PlanInput, judged not worth the marginal confidence gain over reading it)

bridge_core::Instruction::Withdraw (lez/programs/bridge/core/src/lib.rs:33-43) exists with a fully documented account layout. But bridge_program's plan() (lez/programs/bridge/src/main.rs:39-46) destructures only Instruction::Deposit and hits an unconditional panic for anything else:

let Instruction::Deposit { l1_deposit_op_id, recipient_id, amount } = instruction else {
    panic!("Withdraws are disabled in the current version of LEZ");
};

So Withdraw::SELECTOR and the Withdraw event struct are fully implemented and unit-tested for serialization (bridge_core's 5 tests, all passing), but can never actually be emitted by this program as deployed. No test exercises the panic path at all (only the Deposit replay guard is tested). The issue cites the bridge as its production reference for the event pattern without mentioning this.

Suggested fix: either add a #[should_panic] test pinning the current "Withdraws disabled" behavior (so it's a documented, intentional limitation rather than a silent trap for the next reader), or mention it explicitly in the issue text alongside the Deposit example.

MEDIUM (latent, not currently exploitable) — 4. Sequencer FFI's event-coverage check diverges from the indexer's

inspected

The indexer RPC's range coverage check (check_range_coverage → indexer_core::event_filter::covered_over_range) walks the real historical sequence of filter segments, so a block range that was indexed under a narrower filter in the past is correctly flagged uncovered. sequencer_ffi_query_events (lez/sequencer/ffi/src/api/query.rs, around line 653-800) instead asks the storage actor for its single current filter and synthesizes a flat segment list by repeating that one filter for every block in the range:

(from_block..=to_block).map(|block_id| (event_filter.clone(), block_id)).collect()

This assumes "whatever the filter is right now also held for every historical block," which is false in general. It is harmless today only because StorageActor's GetEventFilter handler always answers EventFilter::Archival (finding #2 above) — Archival trivially covers everything regardless of history, so the FFI's shortcut can't yet diverge from the truth. The moment the storage actor's own TODO ("support custom archival policies") ships, the FFI would silently answer "covered" for ranges that were actually indexed under a narrower, since-widened filter — the opposite failure direction from the indexer's fail-closed UncoveredEventQuery design.

Suggested fix: either track real filter history in the FFI path too, or — simpler, if the FFI is meant only for embedded/trusted use — explicitly document that it assumes an always-archival backing store and must be revisited before per-sequencer custom filters ship.

LOW (correct, fail-closed design) — but worth restating precisely — 5. Unconfigured-indexer footgun

reproduced — unit-level AND live, over a real running indexer's JSON-RPC

EventFilter::default() is an empty Sources map, which both keeps_nothing() and covers() treat as "nothing" — so an indexer started without an explicit event_filter key answers every getEvents/subscribeToEvents call with UncoveredEventQuery, not an empty success. This is exactly the issue's own headline risk, and it is correct, deliberate behavior (fail-closed: an indexer refuses to claim coverage it never actually had), not a bug. Every shipped debug config (lez/indexer/service/configs/debug/indexer_config.json) explicitly sets "event_filter": "archival", so a reader following the repo's own configs is safe.

Unit-level: default_covers_nothing, only_an_empty_source_set_keeps_nothing, and uncovered_query_is_rejected all pass in the indexer_core/indexer_service runs (143 tests, 0 failures).

Live, over the wire: ran a real indexer_service with event_filter omitted, synced to the real local chain, and called getEvents on it directly:
{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"UncoveredEventQuery",
  "data":"this indexer's event filter does not cover the requested events;
          query a declared program and selector, or an archival indexer"}}

Correction to this finding's original suggested fix (withdrawn after the live run): a startup warning for exactly this case already exists and fired correctly — [WARN indexer_core::block_store] Configured event filter keeps no events: none are captured and every event query is rejected as uncovered — confirmed present on the unconfigured indexer's startup log and absent from the archival one's. There is no further action item here; this finding is fully closed, both on correctness and on the operator-warning front.

MEDIUM (root cause not isolated) — 6. New from the live run: a standalone indexer's background sync silently stalled

reproduced, reproducible across 2 independent indexer instances

While testing subscribeToEvents/subscribeToFinalizedBlocks live, neither ever delivered a notification. Chasing that down: getStatus kept reporting {"state":"CaughtUp","indexed_block_id":14} unchanged for 60+ seconds, while the sequencer's own getLastBlockId climbed from 14 to 34 in the same window and its log showed it continuously publishing new blocks throughout. The indexer process was alive (not panicked, near-zero CPU — genuinely idle, not spinning on an error) and had correctly accepted the subscriptions server-side (confirmed via its own "Accepted new subscription..." / "Added new ... subscription" log lines). This reproduced identically across two separate indexer instances (the archival one and the unconfigured one from finding #5), both stalling at the exact same block 14, run at different times — so it's a consistent property of this setup, not a one-off fluke.

I could not fully isolate the root cause within this task's time budget, and I'm deliberately not calling this a protocol bug. The most likely explanation: this review's Bedrock node was run directly from bedrock/node-config.yaml/deployment-settings.yaml (the same config the project's own docker-compose.yml mounts), standing in for the project's blessed just run-bedrock/run-sequencer/run-indexer orchestration — which this sandbox can't use (no Docker). The Bedrock node's own log is full of ERROR ... failed to broadcast message to topic ... NoPeersSubscribedToTopic for both its mempool and cryptarchia gossip topics, which is expected for a genuinely peerless single node — the indexer's own Bedrock-sync mechanism may depend on that gossip layer to learn about new blocks in a way the project's blessed setup handles differently (e.g. via a direct local-node fast path that a true single, isolated process doesn't get). It's equally possible this is a real gap that only shows up in a minimal single-sequencer deployment, which is itself a legitimate configuration — I'm flagging it rather than either dismissing or overclaiming it.

Suggested next step: worth a 15-minute check by someone who knows this codebase well: either confirm it's purely an artifact of running Bedrock without its normal peer/gossip context (and if so, maybe worth a line in the docs about single-node devnets needing the Docker compose path for a live indexer), or — if it reproduces even with proper peering — it's a real "indexer stops tracking the chain with no error" bug worth its own ticket, since "CaughtUp" lying about freshness is a bad failure mode for anything depending on subscribeToEvents.

What works well

Not tested

Updated after the live three-process run (see the update banner at the top). Much of this section from the first pass is now done; what's left:

Doc-packet gaps (issue #507 itself)

How to re-run

# Toolchain (one-time)
curl -L https://risczero.com/install -sSf | bash
source ~/.bashrc
rzup install rust
rzup install cargo-risczero
# System deps this review needed that weren't preinstalled:
apt-get install -y clang libclang-dev cmake pkg-config libssl-dev build-essential libpcsclite-dev

git clone https://github.com/logos-blockchain/logos-execution-zone.git lez
cd lez
git checkout v0.3.0   # db66590ab821a4e142c211017a3866d007f6fa77

export PATH="$HOME/.risc0/bin:$HOME/.cargo/bin:$PATH"

# Cheap first check (the issue's own recommended entry point)
RISC0_DEV_MODE=1 cargo test --release -p indexer_core accept_block_captures_emitted_events

# Full layered suite this review ran, all green, Docker-free:
RISC0_DEV_MODE=1 cargo test --release -p indexer_core        # 131 passed (+ 2 probes added here = 133)
RISC0_DEV_MODE=1 cargo test --release -p indexer_service      # 12 passed
RISC0_DEV_MODE=1 cargo test --release -p lee state::tests::events  # 8 passed
RISC0_DEV_MODE=1 cargo test --release -p bridge_program -p bridge_core  # 7 passed

# The one test this review could NOT run (needs Docker + a Bedrock node):
just resolve-host-bedrock-node   # succeeds without Docker, ~18 min source build
RISC0_DEV_MODE=1 cargo test --release -p integration_tests --test sequencer_ffi \
    sequencer_ffi_starting_events_produced_correctly -- --nocapture
# fails here with: "Testcontainers error: failed to initialize a docker client:
# Socket not found: /var/run/docker.sock" — install/start Docker to complete this one.

# The two new probe tests added during this review (selector-collision scoping),
# committed nowhere — they live only in this review's clone at:
#   lez/indexer/core/src/event_filter.rs
#   (a_per_program_filter_entry_is_not_polluted_by_a_colliding_selector_from_another_program,
#    a_selector_only_query_cannot_distinguish_colliding_programs)
# Re-add them from this report's "Finding #2" evidence block if useful upstream.

# ---------------------------------------------------------------------------
# The live three-process round trip (no Docker needed for THIS part):
# ---------------------------------------------------------------------------
just resolve-host-bedrock-node   # as above; produces bedrock/.resolved/logos-blockchain-node

# 1. Run the real single-validator Bedrock L1 node directly (same config its own
#    docker-compose.yml uses, just without Docker):
POL_PROOF_DEV_MODE=true bedrock/.resolved/logos-blockchain-node \
    bedrock/node-config.yaml --deployment bedrock/deployment-settings.yaml &

# 2. Build and run the sequencer WITHOUT --features standalone (default features =
#    the real BedrockActor, pointed at the node above via the debug config):
RISC0_DEV_MODE=1 cargo build --release -p sequencer_service
RISC0_DEV_MODE=1 target/release/sequencer_service \
    lez/sequencer/service/configs/debug/sequencer_config.json --port 3040 &

# 3. Build and run the indexer against the same chain/channel:
RISC0_DEV_MODE=1 cargo build --release -p indexer_service
RISC0_DEV_MODE=1 target/release/indexer_service \
    lez/indexer/service/configs/debug/indexer_config.json --port 8779 --data-dir ./idx-data &

# 4. Happy path — block 1 already carries real Deposit events from genesis:
curl -s -X POST http://localhost:8779 -d \
    '{"jsonrpc":"2.0","id":1,"method":"getEvents","params":[{"from_block":1,"to_block":5}]}'

# 5. Footgun — same chain, a second indexer with event_filter deleted from the config:
curl -s -X POST http://localhost:8780 -d \
    '{"jsonrpc":"2.0","id":1,"method":"getEvents","params":[{"from_block":1,"to_block":5}]}'
# -> {"error":{"code":-32602,"message":"UncoveredEventQuery", ...}}

# Full session transcript, including the subscribeToEvents attempt and the
# finding-#6 stall investigation: evidence/live/wire-level-rpc-session.txt