Skip to content

PLT-8299: graph-node fork: make the Celo reorg_threshold=0 special case switchable, so post-L2 Celo stops scanning eth_getLogs every block - #7

Merged
bondar-pavel merged 1 commit into
zerion/v0.43.0from
PLT-8299-celo-getlogs-flag
Nov 27, 2026
Merged

bondar-pavel merged 1 commit into
zerion/v0.43.0from
PLT-8299-celo-getlogs-flag

Conversation

@bondar-pavel

Copy link
Copy Markdown
Collaborator

PLT-8299: graph-node fork: make the Celo reorg_threshold=0 special case switchable, so post-L2 Celo stops scanning eth_getLogs every block

EthereumStreamBuilder::build_polling gives every Celo chain id a reorg threshold of 0, so each Celo polling block stream takes the is_on_main_chain + eth_getLogs path on every block. Its premises (instant finality, events only in eth_getLogs) come from the Celo L1; Celo is now an OP-stack L2. This PR makes the override switchable without changing the default.

Changes

  • chain/ethereum/src/env.rs: new EnvVars::celo_force_getlogs, read from GRAPH_ETHEREUM_CELO_FORCE_GETLOGS, default true.
  • chain/ethereum/src/chain.rs: the Celo decision moves into the pure fn polling_reorg_threshold(chain_id, celo_force_getlogs, reorg_threshold). With the flag on (default) Celo gets 0 exactly as before; with it off Celo gets chain.reorg_threshold. Non-Celo chains always get chain.reorg_threshold. The chain_id() lookup still runs for every RPC chain, as before. The code comment now states the L1-era premises and when the flag can be turned off.
  • docs/environment-variables.md: documents the variable.

Acceptance Criteria

  • Default behaviour is unchanged — default true in Inner::celo_force_getlogs; tested by env::tests::celo_force_getlogs_defaults_to_true and chain::tests::polling_reorg_threshold_forces_zero_for_celo_when_flag_on (all three Celo ids get 0, chain 1 keeps its threshold).
  • Env false: Celo uses the normal reorg threshold — tested by env::tests::celo_force_getlogs_can_be_turned_off and chain::tests::polling_reorg_threshold_uses_chain_threshold_for_celo_when_flag_off.
  • Log-vs-receipt parity evidence for N recent post-L2 Celo blocks — OUTSTANDING, not done here. It is a prerequisite for turning the flag off in production, not for merging this PR.
  • PR opened. The chart image bump and env flip are a separate deploy step.

Departures

  • The fork keeps no Zerion changelog: NEWS.md holds upstream release notes only, and the earlier fork patches did not edit it, so only docs/environment-variables.md documents the variable.

Testing

  • cargo test -p graph-chain-ethereum --lib -- polling_reorg_threshold celo_force_getlogs: 4 passed.
  • Mutation check: ignoring the flag in polling_reorg_threshold fails polling_reorg_threshold_uses_chain_threshold_for_celo_when_flag_off; a false default fails celo_force_getlogs_defaults_to_true. Both restored.
  • cargo clippy -p graph-chain-ethereum --all-targets -- -D warnings: clean. cargo check --release -p graph-chain-ethereum: clean. cargo fmt --all: applied.
  • The full workspace suite runs in CI.
  • No migration or ddl.rs change, so the chart's same-schema rule for fork tags holds.

Screenshots

No UI change.

Resolves PLT-8299

🤖 Generated with Claude Code

Produced by a hive session (PLT-8299)

…g threshold override switchable (PLT-8299)

Polling block streams on Celo chain ids get a reorg threshold of 0, so
every block is scanned with eth_getLogs. The premises (instant finality,
events visible only in eth_getLogs) come from the Celo L1. The new flag
defaults to true, keeping that behaviour; false gives Celo the chain's
normal reorg threshold. The decision moves into polling_reorg_threshold,
tested for both flag values, and the env parsing is tested for its default
and for false. Other chains are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zerion-hive-worker[bot] <318250561+zerion-hive-worker[bot]@users.noreply.github.com>
@linear-code

linear-code Bot commented Nov 27, 2026

Copy link
Copy Markdown

PLT-8299

@bondar-pavel

Copy link
Copy Markdown
Collaborator Author

REVIEW REQUEST @ 05ed496 v=1 pr=#7 base=zerion/v0.43.0 patch-id=104adc8cc5785f99e68cd3bd7ca6286146b57dec commits=1 since=none ac=PLT-8299

@bondar-pavel

Copy link
Copy Markdown
Collaborator Author

Reviewer: reviewer-PLT-8299 @ 05ed496
REVIEW STARTED @ 05ed496 v=1 pr=#7 by=reviewer-PLT-8299

@bondar-pavel

Copy link
Copy Markdown
Collaborator Author

Reviewer: reviewer-PLT-8299 @ 05ed496
VERDICT APPROVE @ 05ed496 v=1 pr=#7 patch-id=104adc8cc5785f99e68cd3bd7ca6286146b57dec ci=5/github-actions notes=2

Review: PLT-8299

Acceptance Criteria

  • ✅ Default behaviour is unchanged. Inner::celo_force_getlogs defaults to "true", and polling_reorg_threshold(chain_id, true, t) returns 0 for exactly the three CELO_CHAIN_IDS and t for any other chain, which matches the old inline if. The chain_id() lookup still runs for every ChainClient::Rpc, and the subgraph-composition and panic! arms of EthereumStreamBuilder::build_polling are unchanged. Tests: env::tests::celo_force_getlogs_defaults_to_true and chain::tests::polling_reorg_threshold_forces_zero_for_celo_when_flag_on.
  • ✅ Env false: Celo uses the normal reorg threshold. With the flag off, Celo gets chain.reorg_threshold, the same value every other RPC chain gets on this path. Tests: celo_force_getlogs_can_be_turned_off (parses both false and true) and polling_reorg_threshold_uses_chain_threshold_for_celo_when_flag_off.
  • ⬜ Parity evidence (log vs receipt): outstanding. By the ticket's own wording it is a prerequisite for the production flip, not for merge (deploy-only).
  • ✅ PR opened. The image bump and env flip are separate.

Half-Celo path check

I ran git grep -i celo across chain/, graph/, core/, node/, store/ and runtime/ at the head SHA. The only other Celo-specific code is the epoch-rewards dummy-transaction case in data_source.rs (MatchingTrigger log handling, log.transaction_hash == Some(block.hash())). It is a consumer of logs and works on either path. The ingestor's ancestor_count comes from the generic ENV_VARS.reorg_threshold() (node/src/chain.rs), not from the Celo override, so Celo heads already keep reorg_threshold ancestors in the block store. The near-head branch of PollingBlockStream therefore needs nothing Celo-specific when the flag is off. I found no other code that assumes a threshold of 0.

Code Quality

  • The env var follows the crate's existing convention (an EnvVarBoolean field in Inner with envconfig(from, default), mapped in From<Inner>), the same shape as GRAPH_ETHEREUM_FORCE_RPC_FOR_BLOCK_PTRS.
  • The docs entry in docs/environment-variables.md is accurate and states the flip precondition.
  • Commit trailer: the single commit carries the zerion-hive-worker[bot] Co-authored-by trailer.

Verification

  • I ran cargo test -p graph-chain-ethereum --lib -- polling_reorg_threshold celo_force_getlogs in my own scratch worktree at 05ed496: 4 passed. I did not re-run the mutations; this code does not touch auth, signing or funds, and the engineer's mutation table covers both tests.
  • CI at 05ed496 (github-actions): Build in release mode=success, Check rustfmt style=success, Clippy linting=success, Run unit tests=success, Subgraph Runner integration tests=success. zerion/v0.43.0 has no branch protection, so these 5 jobs are the gate.

Verdict: APPROVE

Scope

Scoped to 05ed496 (patch-id 104adc8cc5785f99e68cd3bd7ca6286146b57dec from hive-engine patch-id).
Carries over automatically to any later head whose patch-id is unchanged, including a clean merge origin/zerion/v0.43.0, and to nothing else.

Notes (non-blocking):

  • drop: the build_polling call site passing ENV_VARS.celo_force_getlogs is not covered by a test; it is a single argument and the pure function plus env parsing are tested.
  • drop (flip-time, not merge): with the flag off, logs near the head come from the receipts of ingested blocks. Celo epoch-reward logs (tx_hash == block hash, the special case in data_source.rs) appear only in eth_getLogs, so AC3 parity must include blocks at epoch boundaries before production is set to false.

@bondar-pavel
bondar-pavel merged commit e87d97f into zerion/v0.43.0 Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant