fix: handle blocks missing size and totalDifficulty fields#18
Merged
rswanson merged 1 commit intosignet-mainfrom Apr 16, 2026
Merged
fix: handle blocks missing size and totalDifficulty fields#18rswanson merged 1 commit intosignet-mainfrom
rswanson merged 1 commit intosignet-mainfrom
Conversation
Some chains (e.g. Signet) return blocks without `size` or `totalDifficulty` fields in their JSON-RPC responses. This caused two fatal crashes: 1. `FunctionClauseError` in `EthereumJSONRPC.Block.do_elixir_to_params/1` because all existing clauses required `size` in their pattern match. Added a catch-all clause that uses `Map.get` with defaults for `size`, `totalDifficulty`, and `baseFeePerGas`. 2. `Protocol.UndefinedError` in `EmptyBlocksSanitizer.classify_blocks_from_result/1` because `block["transactions"]` could be `nil`, and `Enum.empty?/1` does not accept atoms. Fixed by defaulting nil transactions to `[]`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rymcol
approved these changes
Apr 16, 2026
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.
Summary
Fixes the prod blockscout backend crashloop caused by Signet chain blocks missing
sizeandtotalDifficultyfields in JSON-RPC responses.Two crashes fixed:
FunctionClauseErrorinEthereumJSONRPC.Block.do_elixir_to_params/1— All 4 existing pattern-match clauses require"size"in the block map. Signet blocks don't includesizeortotalDifficulty, so none match. Added a catch-all clause (placed last so existing specific clauses take priority) that usesMap.getwith defaults for optional fields.Protocol.UndefinedErrorinEmptyBlocksSanitizer.classify_blocks_from_result/1—Enum.empty?(block["transactions"])crashes when transactions isnil(atom doesn't implementEnumerable). Fixed by defaultingniltransactions to[]before enumeration.Evidence
Dev cluster (old image
sha256:9450e2c7...) is healthy at 35d uptime. Prod cluster (new imagesha256:5b265961...) crashloops in ~13 seconds with these exact errors in logs.Test plan
elixir_to_params/1with a block missingsize,totalDifficulty, andbaseFeePerGas(mirrors actual Signet block from crash logs)sizestill match the more specific clauses first🤖 Generated with Claude Code