[PIE-2223] Tracing API - Handling of various exceptional halt cases. (#334)

* Handling of various exceptional halt cases.

Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
pull/339/head
Abdelhamid Bakhta 5 years ago committed by GitHub
parent 79ccbb5bd2
commit ad48ea512c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/vm/VmTraceGenerator.java
  2. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java
  3. 26
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/chain-data/blocks.json
  4. 15
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/chain-data/genesis.json
  5. 103
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/halt-cases/trace_replayBlockTransactions_halt_case_0x10.json

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace;
import org.hyperledger.besu.ethereum.core.Gas;
import org.hyperledger.besu.ethereum.debug.TraceFrame;
import org.hyperledger.besu.ethereum.vm.Code;
import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason;
import java.util.ArrayDeque;
import java.util.Deque;
@ -97,7 +98,10 @@ public class VmTraceGenerator {
private boolean mustIgnore(final TraceFrame frame) {
if ("STOP".equals(frame.getOpcode()) && transactionTrace.getTraceFrames().size() == 1) {
return true;
} else if (!frame.getExceptionalHaltReasons().isEmpty()) {
} else if (!frame.getExceptionalHaltReasons().isEmpty()
&& !frame
.getExceptionalHaltReasons()
.contains(ExceptionalHaltReason.INVALID_JUMP_DESTINATION)) {
return true;
} else {
return frame.isVirtualOperation();

@ -44,6 +44,10 @@ public class TraceJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest {
@Parameters(name = "{index}: {0}")
public static Object[][] specs() {
return AbstractJsonRpcHttpBySpecTest.findSpecFiles(
"trace/specs/flat", "trace/specs/vm-trace", "trace/specs/statediff", "trace/specs/all");
"trace/specs/flat",
"trace/specs/vm-trace",
"trace/specs/statediff",
"trace/specs/all",
"trace/specs/halt-cases");
}
}

@ -210,6 +210,32 @@
"to": "0x00B0000000000000000000000000000000000000"
}
]
},
{
"number": "0x10",
"transactions": [
{
"comment": "Various exceptional halt cases. Invalid OPCODE (0x1F).",
"secretKey": "0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"gasLimit": "0xFFFFF2",
"gasPrice": "0xEF",
"to": "0x00C0000000000000000000000000000000000000"
},
{
"comment": "Various exceptional halt cases. INSUFFICIENT_STACK_ITEMS.",
"secretKey": "0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"gasLimit": "0xFFFFF2",
"gasPrice": "0xEF",
"to": "0x00D0000000000000000000000000000000000000"
},
{
"comment": "Various exceptional halt cases. INVALID_JUMP_DESTINATION.",
"secretKey": "0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"gasLimit": "0xFFFFF2",
"gasPrice": "0xEF",
"to": "0x00E0000000000000000000000000000000000000"
}
]
}
]
}

@ -81,6 +81,21 @@
"code": "0x608B60045360AA60FF60016004A2",
"balance": "0x0"
},
"00C0000000000000000000000000000000000000": {
"comment": "INVALID_OPERATION (0x1F).",
"code": "0x60011F",
"balance": "0x0"
},
"00D0000000000000000000000000000000000000": {
"comment": "INSUFFICIENT_STACK_ITEMS",
"code": "0x600120",
"balance": "0x0"
},
"00E0000000000000000000000000000000000000": {
"comment": "INVALID_JUMP_DESTINATION",
"code": "0x60FF5660016002",
"balance": "0x0"
},
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"secretKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",

@ -0,0 +1,103 @@
{
"request": {
"jsonrpc": "2.0",
"method": "trace_replayBlockTransactions",
"params": [
"0x10",
[
"vmTrace"
]
],
"id": 415
},
"response": {
"jsonrpc": "2.0",
"result": [
{
"output": "0x",
"stateDiff": null,
"trace": [],
"transactionHash": "0x6aed559a5dcf73efa132d8182585c40fdc6ef3b99a7629d80ffd4a62cb3db622",
"vmTrace": {
"code": "0x60011f",
"ops": [
{
"cost": 3,
"ex": {
"mem": null,
"push": [
"0x1"
],
"store": null,
"used": 16756199
},
"pc": 0,
"sub": null
}
]
}
},
{
"output": "0x",
"stateDiff": null,
"trace": [],
"transactionHash": "0xb39fa8a1cb1db4663dc3733bc014d524e90a862bf2607e028eeb3932d92574fe",
"vmTrace": {
"code": "0x600120",
"ops": [
{
"cost": 3,
"ex": {
"mem": null,
"push": [
"0x1"
],
"store": null,
"used": 16756199
},
"pc": 0,
"sub": null
}
]
}
},
{
"output": "0x",
"stateDiff": null,
"trace": [],
"transactionHash": "0x11a725053a6ece79d8de11cb75dd1f09c40dcd109a1c63573e847ad4f456a296",
"vmTrace": {
"code": "0x60ff5660016002",
"ops": [
{
"cost": 3,
"ex": {
"mem": null,
"push": [
"0xff"
],
"store": null,
"used": 16756199
},
"pc": 0,
"sub": null
},
{
"cost": 8,
"ex": {
"mem": null,
"push": [],
"store": null,
"used": 16756191
},
"pc": 2,
"sub": null
}
]
}
}
],
"id": 415
},
"statusCode": 200
}
Loading…
Cancel
Save