Skip to content

fix(ethrpc): block responses and eth_getLogs - #384

Merged
sadiq1971 merged 2 commits into
mainfrom
fix/ethrpc-blocks-logs
Oct 7, 2026
Merged

sadiq1971 merged 2 commits into
mainfrom
fix/ethrpc-blocks-logs

Conversation

@sadiq1971

@sadiq1971 sadiq1971 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Makes the facade's blocks and logs readable by standard Ethereum clients (outstanding item O-6, M2-AC2), with the smallest change that does it.

  • Blocks. Synthetic blocks list no transactions, so they now carry the empty-list hashes that clients validate against: sha3Uncles = EmptyUncleHash, transactionsRoot = EmptyTxsHash, receiptsRoot = EmptyReceiptsHash, stateRoot = EmptyRootHash. Previously go-ethereum's ethclient rejected every block at its uncle-list check.
  • eth_getLogs block tags. fromBlock and toBlock accept latest, earliest, pending, safe, finalized or a hex number. ethclient sends latest by default. Tags resolve to the latest mined block, the last one with logs.
  • Omitted bounds are unchanged: fromBlock is 0 and toBlock is the latest mined block. The reference dApp relies on this.

Verification

  • Unit tests cover the block shape, tag decoding and how bounds resolve.
  • E2E: TestRPC_GetBlockByNumber and TestRPC_GetBlockByHash are unskipped. TestRPC_GetLogs adds an open-range query.

Not in scope

Blocks stay synthetic shells:

  • no transaction lists;
  • number × 12 timestamps;
  • eth_getBlockByHash falls back to the latest block for hashes it has not stored.

eth_getLogs still matches a single address and an exact topic0. Wallets and the dApp read receipts and logs, so none of this blocks them.

@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@f2c973c). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #384   +/-   ##
=======================================
  Coverage        ?   34.35%           
=======================================
  Files           ?      163           
  Lines           ?    12655           
  Branches        ?        0           
=======================================
  Hits            ?     4348           
  Misses          ?     7966           
  Partials        ?      341           
Flag Coverage Δ
unittests 34.35% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/ethrpc/service/service.go 81.55% <100.00%> (ø)
pkg/ethrpc/types.go 40.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sadiq1971
sadiq1971 requested a review from salindne October 7, 2026 09:50
@sadiq1971
sadiq1971 marked this pull request as ready for review October 7, 2026 09:50
Comment thread pkg/ethrpc/service/service.go Outdated
Comment thread pkg/ethrpc/service/blocks.go Outdated
Comment thread pkg/ethrpc/service/service.go Outdated
Comment thread pkg/ethrpc/service/blocks.go Outdated
sadiq1971 added a commit that referenced this pull request Oct 7, 2026
Address review of #384:

- Persist a block clock in evm_state (migration 16). The head is the latest
  mined block or the clock, whichever is ahead, and the miner numbers each
  new block ahead of the clock, so a number served as an empty block is never
  mined later. This replaces the per-process start time and the 12-block
  buffer: replicas agree and the head no longer resets on restart.
- Blocks on the clock are timestamped one second apart; older blocks keep
  their mining time.
- eth_getLogs: an omitted fromBlock again means the earliest block, which the
  reference dApp relies on; toBlock is clamped to the head; addresses and
  topics per position are capped at 1000; wildcard positions require that
  many topics; an unknown blockHash is "unknown block" (-32000).
- eth_getBlockByHash resolves hashes near the head before the store lookup
  and renders a block mined mid-request with its transactions.
- Receipts report cumulative gas; blocks carry mixHash and transactions
  blockTimestamp.
- Index evm_transactions.block_hash and evm_logs by block position, and
  backfill legacy log timestamps (migration 17).
- Reject empty block numbers and EIP-1898 objects naming both a number and a
  hash; accept tags in EIP-1898 objects.
@sadiq1971
sadiq1971 force-pushed the fix/ethrpc-blocks-logs branch from 6a93428 to 36f2e3a Compare October 7, 2026 13:03
- Synthetic blocks carry the empty-list uncle, transaction, receipt and
  state hashes, so go-ethereum clients accept them.
- eth_getLogs fromBlock/toBlock accept block tags, which resolve to the
  latest mined block. Omitted bounds behave as before.
- Unskip the e2e block tests and query logs with an open range.
@sadiq1971
sadiq1971 force-pushed the fix/ethrpc-blocks-logs branch from 36f2e3a to d672845 Compare October 7, 2026 13:28
@sadiq1971
sadiq1971 requested a review from salindne October 7, 2026 18:05
@sadiq1971
sadiq1971 merged commit 0e8aad0 into main Oct 7, 2026
4 checks passed
@sadiq1971
sadiq1971 deleted the fix/ethrpc-blocks-logs branch October 7, 2026 18:37
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.

3 participants