Skip to content

fix(route): drop silent zero fallbacks for absent required fields#860

Closed
samcm wants to merge 8 commits into
masterfrom
fix/route-silent-zero-fallbacks
Closed

fix(route): drop silent zero fallbacks for absent required fields#860
samcm wants to merge 8 commits into
masterfrom
fix/route-silent-zero-fallbacks

Conversation

@samcm

@samcm samcm commented Jun 25, 2026

Copy link
Copy Markdown
Member

The ClickHouse route flattener silently fell back to 0/""/zero-hash whenever a required proto wrapper field was absent (e.g. validator/proposer index, slot, epoch, committee index, amount, block_hash), fabricating data indistinguishable from a real value across ~378 sites in 57 of 114 route files. This converts the required-field if/else-zero blocks to the validate()+direct-append pattern (return route.ErrInvalidEvent and drop the event instead of writing a fake zero) across the canonical, beacon, mev, execution, libp2p, and node packages, fixes the generator scaffold so future routes follow the same pattern, makes unknown-block-version fallthroughs return ErrInvalidEvent, and updates the affected snapshot tests; the additional-data/enrichment zone and *_start_date_time derived-timestamp conventions are left unchanged. Remaining genuinely-optional fields on non-Nullable columns (HasIpv6, libp2p latency/size/seqnum, execution profiling + mempool nonce/gas, v3 block_number, validator status/slashed) are noted as needs-nullable follow-up since converting them requires a migration. Verified with go build ./..., go test ./pkg/clickhouse/route/... (incl. -race), and golangci-lint --new-from-rev=origin/master (0 issues).

samcm added 8 commits June 25, 2026 16:08
Steer newly-scaffolded route files away from the silent if/else-zero
fallback (which fabricates data indistinguishable from real values) and
toward a validate() method that returns route.ErrInvalidEvent for absent
required fields, plus direct appends with no zero fallback.
Convert required-field if/else-zero fallbacks to validate()+direct-append
across the canonical beacon tables so absent required wrapper fields (slot,
proposer/validator index, committee index, amount, attestation source/target
epochs, deposit/withdrawal data, etc.) drop the event with
route.ErrInvalidEvent instead of fabricating a zero value indistinguishable
from a real one. The unknown-block-version fallthrough now returns
ErrInvalidEvent rather than writing zeros. Validator pubkey/withdrawal-
credentials rows with absent required fields are skipped. Additional-data
enrichment and *_start_date_time conventions are left unchanged.

Snapshot tests updated to supply the now-required payload fields.
For required wrapper fields already guarded by validate() (block_number,
gas_used/gas_limit, tx_count, blob_count, duration_ms, slot, proposer_index,
requested/returned_count), replace the redundant if-non-nil-else-append-zero
blocks with direct appends. A silent else-zero fabricates data
indistinguishable from a real value.

Left untouched: optional profiling metrics in execution_block_metrics
(timing/state-io/cache sub-messages are non-Nullable schema convention for
'not reported'), the additional-data enrichment epoch/slot zones, and the
mempool_transaction V2 nonce/gas wrappers (mixed scalar/wrapper across V1/V2
needs Nullable schema work).
Validate required payload fields (block_hash, value, pubkeys, fee_recipient,
gas_limit/used, slot, etc.) and return route.ErrInvalidEvent when absent,
then append directly with no else-zero fallback that would fabricate a real-
looking value. Enrichment/additional-data zero conventions left untouched.
Snapshot tests updated to supply the now-required payload fields.
The canonical elaborated-attestation route now validates Data, so the
top-level alias test must supply a populated AttestationDataV2.
@samcm

samcm commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Superseded by #862 (merged) — the spec-verified version of this cleanup: every canonical field was classified required/optional/empty-valid against the beacon-API OpenAPI required[] arrays + consensus-specs SSZ containers, plus the strict halt-on-invalid mechanism for canonical tables.

@samcm samcm closed this Jun 26, 2026
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