Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0f79f8c
fix: reject non-hex block numbers in debug_getRawBlock, debug_getRawH…
veyron-kairo Apr 15, 2026
27b0445
refactor: use BlockParameterOrBlockHash in debug_getRawBlock and debu…
veyron-kairo Apr 23, 2026
64f6436
refactor: remove redundant hex validation from DebugGetRawReceipts
veyron-kairo Apr 23, 2026
c7ea896
chore: fix spotless formatting and add changelog entry
veyron-kairo Apr 24, 2026
31bb99f
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 14, 2026
7a322ba
fix: add eth_getProof + debug_getRawTransaction hex validation per ma…
veyron-kairo May 14, 2026
1fe7f6b
fix: revert DebugGetRawTransaction change and consolidate CHANGELOG
veyron-kairo May 15, 2026
863f49d
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 15, 2026
960f1d2
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
macfarla May 18, 2026
684af43
test: derive hex block numbers from blockNumber field in EthGetProofTest
veyron-kairo May 18, 2026
4ee37da
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
macfarla May 19, 2026
34ead67
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 19, 2026
e8d3421
fix: allow negative hex block params to flow to downstream check
veyron-kairo May 19, 2026
5fdec8a
remove -0x carve out and update relevant tests
macfarla May 19, 2026
2498f07
merge and reword changelog entries
macfarla May 20, 2026
db2b2f0
merge
macfarla May 20, 2026
c8d8fed
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 20, 2026
d3907fe
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 21, 2026
a4e725b
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 25, 2026
cc55536
fix: align debug_getRaw* methods with execution-apis BlockNumberOrTag…
veyron-kairo May 25, 2026
803e08b
revert: drop DebugGetRawBlock/DebugGetRawHeader changes per maintaine…
veyron-kairo May 26, 2026
2eb605b
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
macfarla May 27, 2026
b2de592
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 27, 2026
1ae297f
Merge branch 'main' into fix/debug-raw-methods-hex-prefix-validation
veyron-kairo May 28, 2026
60df63d
Merge branch 'main' of github.com:besu-eth/besu into fix/debug-raw-me…
macfarla May 28, 2026
46ed14d
review comments
macfarla May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
## Unreleased

### Breaking Changes
- RPC changes to enhance compatibility with other ELs
Comment thread
veyron-kairo marked this conversation as resolved.
- Block number parameter in RPCs will only support hex values. Non-hex (decimal) block number parameters are now rejected. This affects `debug_getRawBlock`, `debug_getRawHeader`, `debug_getRawReceipts`, and `eth_getProof`. [#10240](https://github.com/besu-eth/besu/pull/10240)

### Upcoming Breaking Changes
- RPC changes to enhance compatibility with other ELs
- Block number parameter in RPCs will only support hex values. Support for non-hex (decimal) block number parameters is deprecated.
- This affects several RPCs, including `admin_logsRemoveCache`, `debug_getRawHeader`, `eth_call`, `eth_simulateV1`, `trace_call` and more.
- Sunsetting features - for more context on the reasoning behind the deprecation of these features, including alternative options, read [this blog post](https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu)
- Proof of Work consensus (PoW)
- `--min-block-occupancy-ratio` is deprecated and will be removed in a future release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
Expand All @@ -26,7 +27,7 @@

import com.google.common.base.Suppliers;

public class DebugGetRawBlock extends AbstractBlockParameterMethod {
public class DebugGetRawBlock extends AbstractBlockParameterOrBlockHashMethod {

public DebugGetRawBlock(final BlockchainQueries blockchain) {
super(Suppliers.ofInstance(blockchain));
Expand All @@ -38,22 +39,21 @@ public String getName() {
}

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
protected BlockParameterOrBlockHash blockParameterOrBlockHash(
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
protected Object resultByBlockNumber(
final JsonRpcRequestContext request, final long blockNumber) {

Comment thread
veyron-kairo marked this conversation as resolved.
protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
return getBlockchainQueries()
.getBlockchain()
.getBlockByNumber(blockNumber)
.getBlockByHash(blockHash)
.<Object>map(block -> RLP.encode(block::writeTo).toString())
.orElseGet(
() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
Expand All @@ -26,7 +27,7 @@

import com.google.common.base.Suppliers;

public class DebugGetRawHeader extends AbstractBlockParameterMethod {
public class DebugGetRawHeader extends AbstractBlockParameterOrBlockHashMethod {

public DebugGetRawHeader(final BlockchainQueries blockchain) {
super(Suppliers.ofInstance(blockchain));
Expand All @@ -38,22 +39,21 @@ public String getName() {
}

@Override
protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
protected BlockParameterOrBlockHash blockParameterOrBlockHash(
final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(0, BlockParameter.class);
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
"Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}

@Override
protected Object resultByBlockNumber(
final JsonRpcRequestContext request, final long blockNumber) {

protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
return getBlockchainQueries()
.blockByNumber(blockNumber)
.<Object>map(block -> RLP.encode(block.getHeader()::writeTo).toString())
.getBlockHeaderByHash(blockHash)
.<Object>map(header -> RLP.encode(header::writeTo).toString())
.orElseGet(
() ->
new JsonRpcErrorResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public BlockParameterOrBlockHash(final Object value) throws JsonProcessingExcept
requireCanonical = false;
} else if (normalizedValue.length() > 16) {
throw new IllegalArgumentException("hex number > 64 bits");
} else if (!normalizedValue.startsWith("0x")) {
Comment thread
fab-10 marked this conversation as resolved.
throw new IllegalArgumentException(
"Invalid block number: must be a hex string with 0x prefix");
} else {
type = BlockParameterType.NUMERIC;
number = OptionalLong.of(Long.decode(value.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ public void assertNullWhenBlockNotFound() {

// move the head to number just after chain head
var resp =
debugSetHead.response(debugSetHead("" + chainTip.getNumber() + 1, Optional.of(TRUE)));
debugSetHead.response(
debugSetHead("0x" + Long.toHexString(chainTip.getNumber() + 1), Optional.of(TRUE)));
// success with null result if block not found
assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS);
assertThat(((JsonRpcSuccessResponse) resp).getResult()).isNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void shouldReturnNullWhenWorldStateUnavailable() {
requestWithParams(
Address.fromHexString("0x0000000000000000000000000000000000000000"),
new String[] {storageKey.toString()},
String.valueOf(501));
"0x1f5");
Comment thread
veyron-kairo marked this conversation as resolved.
Outdated

final JsonRpcResponse response = method.response(request);

Expand All @@ -139,7 +139,7 @@ void getProofWithAccount() {

final JsonRpcRequestContext request =
requestWithParams(
address.toString(), new String[] {storageKey.toString()}, String.valueOf(blockNumber));
address.toString(), new String[] {storageKey.toString()}, "0x1f4");

final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
final GetProofResult result = (GetProofResult) response.getResult();
Expand Down Expand Up @@ -225,7 +225,7 @@ void getProofWithoutAccount() {

final JsonRpcRequestContext request =
requestWithParams(
address.toString(), new String[] {storageKey.toString()}, String.valueOf(blockNumber));
address.toString(), new String[] {storageKey.toString()}, "0x1f4");

final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request);
final GetProofResult result = (GetProofResult) response.getResult();
Expand Down
Loading