RPC - eth_getLogs: Return block not found instead of empty logs (#8290)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
This commit is contained in:
Gabriel-Trintinalia
2025-02-13 14:28:06 +11:00
committed by GitHub
parent 90015fca42
commit 6342f5d678
3 changed files with 17 additions and 3 deletions

View File

@@ -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)

View File

@@ -73,8 +73,18 @@ public class EthGetLogs implements JsonRpcMethod {
.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;

View File

@@ -12,7 +12,10 @@
"response": {
"jsonrpc": "2.0",
"id": 406,
"result" : [ ]
"error" : {
"code": -32000,
"message": "Block not found"
}
},
"statusCode": 200
}