Summary
Block object serialization omits required difficulty and totalDifficulty fields in normal dev-node operation.
Why this matters
This is a schema-level contract drift for eth_getBlockByNumber / eth_getBlockByHash. Consumers expecting required fields can break.
Normative contract
docs/specs/json-rpc-contract.md:355-356 marks difficulty and totalDifficulty as required non-null QuantityHex fields for block objects.
Evidence
Block conversion conditionally null/omits both fields:
src/rpc/handlers/block_query_handlers.zig:353-354
.difficulty = if (resp.difficulty > 0) try quantityFromU256(allocator, resp.difficulty) else null,
.totalDifficulty = if (resp.totalDifficulty) |td| try quantityFromU256(allocator, td) else null,
Mined block header currently sets difficulty to zero:
src/rpc/handlers/tx_submission.zig:695
With the current conversion logic, this causes difficulty to be omitted/null instead of required "0x0".
Suggested scope
- Emit
difficulty and totalDifficulty unconditionally as QuantityHex per contract.
- Ensure zero values are serialized as
"0x0", not omitted.
- Add regression tests for both genesis and mined blocks asserting presence and shape of these fields.
Summary
Block object serialization omits required
difficultyandtotalDifficultyfields in normal dev-node operation.Why this matters
This is a schema-level contract drift for
eth_getBlockByNumber/eth_getBlockByHash. Consumers expecting required fields can break.Normative contract
docs/specs/json-rpc-contract.md:355-356marksdifficultyandtotalDifficultyas required non-nullQuantityHexfields for block objects.Evidence
Block conversion conditionally null/omits both fields:
src/rpc/handlers/block_query_handlers.zig:353-354Mined block header currently sets difficulty to zero:
src/rpc/handlers/tx_submission.zig:695With the current conversion logic, this causes
difficultyto be omitted/null instead of required"0x0".Suggested scope
difficultyandtotalDifficultyunconditionally asQuantityHexper contract."0x0", not omitted.