Skip to content

Commit

Permalink
RPC - eth_getLogs: Return block not found instead of empty logs (hype…
Browse files Browse the repository at this point in the history
…rledger#8290)

Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored Feb 13, 2025
1 parent 90015fc commit 6342f5d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Additions and Improvements
- Add TLS/mTLS options and configure the GraphQL HTTP service[#7910](https://github.com/hyperledger/besu/pull/7910)
- Allow plugins to propose transactions during block creation [#8268](https://github.com/hyperledger/besu/pull/8268)
- Update `eth_getLogs` to return a `Block not found` error when the requested block is not found. [#8290](https://github.com/hyperledger/besu/pull/8290)
### Bug fixes
- Upgrade Netty to version 4.1.118 to fix CVE-2025-24970 [#8275](https://github.com/hyperledger/besu/pull/8275)
- Add missing RPC method `debug_accountRange` to `RpcMethod.java` and implemented its handler. [#8153](https://github.com/hyperledger/besu/issues/8153)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
.getBlockHash()
.map(
blockHash ->
blockchain.matchingLogs(
blockHash, filter.getLogsQuery(), requestContext::isAlive))
blockchain
.getBlockHeaderByHash(blockHash)
.map(
blockHeader ->
blockchain.matchingLogs(
blockHeader.getBlockHash(),
filter.getLogsQuery(),
requestContext::isAlive))
.orElseThrow(
() ->
new InvalidJsonRpcParameters(
"Block not found", RpcErrorType.BLOCK_NOT_FOUND)))
.orElseGet(
() -> {
final long fromBlockNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"response": {
"jsonrpc": "2.0",
"id": 406,
"result" : [ ]
"error" : {
"code": -32000,
"message": "Block not found"
}
},
"statusCode": 200
}

0 comments on commit 6342f5d

Please sign in to comment.