Implement debug_getRawReceipts (#5476)

Co-authored-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Adrian Sutton <adrian@symphonious.net>
pull/5495/head
Adrian Sutton 1 year ago committed by GitHub
parent e4a8e1da30
commit 7053ee5656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java
  3. 61
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawReceipts.java
  4. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java

@ -13,6 +13,7 @@
- New optional feature to save the txpool content to file on shutdown and reloading it on startup [#5434](https://github.com/hyperledger/besu/pull/5434)
- New option to send SNI header in TLS ClientHello message [#5439](https://github.com/hyperledger/besu/pull/5439)
- Early access - layered transaction pool implementation [#5290](https://github.com/hyperledger/besu/pull/5290)
- New RPC method `debug_getRawReceipts`
### Bug Fixes
- Fix eth_feeHistory response for the case in which blockCount is higher than highestBlock requested. [#5397](https://github.com/hyperledger/besu/pull/5397)

@ -48,6 +48,7 @@ public enum RpcMethod {
DEBUG_GET_BAD_BLOCKS("debug_getBadBlocks"),
DEBUG_GET_RAW_HEADER("debug_getRawHeader"),
DEBUG_GET_RAW_BLOCK("debug_getRawBlock"),
DEBUG_GET_RAW_RECEIPTS("debug_getRawReceipts"),
ENGINE_GET_PAYLOAD_V1("engine_getPayloadV1"),
ENGINE_GET_PAYLOAD_V2("engine_getPayloadV2"),
ENGINE_NEW_PAYLOAD_V1("engine_newPayloadV1"),

@ -0,0 +1,61 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
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.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.rlp.RLP;
import java.util.List;
import com.google.common.base.Suppliers;
public class DebugGetRawReceipts extends AbstractBlockParameterOrBlockHashMethod {
public DebugGetRawReceipts(final BlockchainQueries blockchain) {
super(Suppliers.ofInstance(blockchain));
}
@Override
public String getName() {
return RpcMethod.DEBUG_GET_RAW_RECEIPTS.getMethodName();
}
@Override
protected BlockParameterOrBlockHash blockParameterOrBlockHash(
final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameterOrBlockHash.class);
}
@Override
protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
return blockchainQueries
.get()
.getBlockchain()
.getTxReceipts(blockHash)
.map(this::toRLP)
.orElseGet(() -> new String[0]);
}
private String[] toRLP(final List<TransactionReceipt> receipts) {
return receipts.stream()
.map(receipt -> RLP.encode(receipt::writeTo).toHexString())
.toArray(String[]::new);
}
}

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugBatchSend
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugGetBadBlocks;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugGetRawBlock;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugGetRawHeader;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugGetRawReceipts;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugMetrics;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugResyncWorldstate;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugSetHead;
@ -109,6 +110,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
() -> new TransactionTracer(blockReplay), blockchainQueries, protocolSchedule, dataDir),
new DebugAccountAt(blockchainQueries, () -> new BlockTracer(blockReplay)),
new DebugGetRawHeader(blockchainQueries),
new DebugGetRawBlock(blockchainQueries));
new DebugGetRawBlock(blockchainQueries),
new DebugGetRawReceipts(blockchainQueries));
}
}

Loading…
Cancel
Save