Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug_standardTraceBlockToFile JSON RPC method #1392

Merged

Conversation

matkt
Copy link
Contributor

@matkt matkt commented Sep 23, 2020

Signed-off-by: Karim TAAM karim.t2am@gmail.com

PR description

Add debug_standardTraceBlockToFile JSON RPC API. This API accepts a block hash and will replay the block. It returns a list of files containing the result of the trace (one file per transaction). The files are stored in the machine that serves this API.

Request

  • If you want a specific transaction in a block
{
    "jsonrpc": "2.0",
    "method": "debug_standardTraceBlockToFile",
    "params": ["0x346bf832874407208006572fd779be5a6a6e0022be76f21a27a2c88b65b0c323", {
        "txHash": "0xaa190c4ed5375ce3577e6212357671ab0aca47dd8c517c177844bf84b4b5c261",
        "disableMemory": false
    }],
    "id": 1
}
  • If you want all transactions of a block
{
    "jsonrpc": "2.0",
    "method": "debug_standardTraceBlockToFile",
    "params": ["0x346bf832874407208006572fd779be5a6a6e0022be76f21a27a2c88b65b0c323"],
    "id": 1
}
  • If you want disableMemory == false (default is true)
{
    "jsonrpc": "2.0",
    "method": "debug_standardTraceBlockToFile",
    "params": ["0x346bf832874407208006572fd779be5a6a6e0022be76f21a27a2c88b65b0c323", {
        "txHash": "0xaa190c4ed5375ce3577e6212357671ab0aca47dd8c517c177844bf84b4b5c261",
        "disableMemory": false
    }],
    "id": 1
}

Response

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        "/Users/johndoe/private-network/Clique-Network/Node-1/data/traces/block_0x346bf832-0-0x407ec43d-1600951088172"
    ]
}

Changelog

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt marked this pull request as ready for review September 23, 2020 16:37
@@ -34,30 +32,42 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;

class EVMToolTracer implements OperationTracer {
public class EVMToolTracer implements OperationTracer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's been moved out of EVM tool perhaps a different name, StandardJsonTracer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@JsonProperty("txHash")
@Nullable
String transactionHash();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use standard getter/setters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

public TraceOptions traceOptions() {
return new TraceOptions(!disableStorage, !disableMemory, !disableStack);
default Optional<Hash> getTransactionHash() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be renamed, or dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

final Transaction transaction = transactions.get(i);
if (selectedHash.isEmpty()
|| selectedHash.filter(isEqual(transaction.getHash())).isPresent()) {
final File tmpFile =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want these going to tmp? perhaps our data root under traces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on it. I did this to be consistent with the other clients. But I just changed to put it in the data/traces now

@shemnon
Copy link
Contributor

shemnon commented Sep 23, 2020

Not your bug (it's mine) but in the EvmToolTracer we need to show 32 bytes per memory word. I'd do a suggestion but it's too far down.

about line 99

messageFrame.readMemory(UInt256.ZERO, messageFrame.memoryWordSize()).toHexString())

becomes

messageFrame.readMemory(UInt256.ZERO, messageFrame.memoryWordSize().multiply(32)).toHexString())

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt
Copy link
Contributor Author

matkt commented Sep 24, 2020

Not your bug (it's mine) but in the EvmToolTracer we need to show 32 bytes per memory word. I'd do a suggestion but it's too far down.

about line 99

messageFrame.readMemory(UInt256.ZERO, messageFrame.memoryWordSize()).toHexString())

becomes

messageFrame.readMemory(UInt256.ZERO, messageFrame.memoryWordSize().multiply(32)).toHexString())

I just updated the code to fix this issue

@matkt matkt requested a review from shemnon September 25, 2020 07:55
@@ -4,6 +4,7 @@

### Additions and Improvements
* The new version of the [web3js-eea library (v0.10)](https://github.com/PegaSysEng/web3js-eea) supports the onchain privacy group management changes made in Besu v1.5.3.
* Added `debug_standardTraceBlockToFile` JSON-RPC API. This API accepts a block hash and will replay the block. It returns a list of files containing the result of the trace (one file per transaction). [\#1392](https://github.com/hyperledger/besu/pull/1392)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to the 1.6.0-RC1 section once merged.

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
…to-file

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
@matkt matkt merged commit 6034b89 into hyperledger:master Sep 28, 2020
@matkt matkt linked an issue Oct 7, 2020 that may be closed by this pull request
@matkt matkt deleted the feature/add-standard-trace-block-to-file branch October 13, 2020 08:35
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.

Support Standard Bad Blocks JSON-RPC APIs
2 participants