fix(route): drop silent zero fallbacks for absent required fields#860
Closed
samcm wants to merge 8 commits into
Closed
fix(route): drop silent zero fallbacks for absent required fields#860samcm wants to merge 8 commits into
samcm wants to merge 8 commits into
Conversation
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.
fe53cb0 to
7040d0e
Compare
This was referenced Jun 25, 2026
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).