Skip to content

Commit

Permalink
Fix debug_traceCall to handle underpriced transactions (hyperledger#7510
Browse files Browse the repository at this point in the history
)

* Fix debug_traceCall to handle underpriced transactions

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* remove unused methods

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* Add test case and changelog entry for debug_traceCall fix

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

---------

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
7suyash7 and fab-10 committed Sep 13, 2024
1 parent 31c174b commit 5df2a71
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
### Additions and Improvements
- Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569)


### Bug fixes
- Fix for `debug_traceCall` to handle transactions without specified gas price. [#7510](https://github.com/hyperledger/besu/pull/7510)

## 24.9.1

Expand Down Expand Up @@ -50,7 +50,6 @@

This release version has been deprecated release due to CI bug


## 24.8.0

### Upcoming Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.DebugTraceTransactionResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.debug.TraceOptions;
import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.transaction.PreCloseStateHandler;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.vm.DebugOperationTracer;

import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DebugTraceCall extends AbstractTraceCall {
private static final Logger LOG = LoggerFactory.getLogger(DebugTraceCall.class);

public DebugTraceCall(
final BlockchainQueries blockchainQueries,
Expand Down Expand Up @@ -89,7 +87,6 @@ protected PreCloseStateHandler<Object> getSimulatorResultHandler(
maybeSimulatorResult.map(
result -> {
if (result.isInvalid()) {
LOG.error("Invalid simulator result {}", result);
final JsonRpcError error =
new JsonRpcError(
INTERNAL_ERROR, result.getValidationResult().getErrorMessage());
Expand All @@ -103,4 +100,13 @@ protected PreCloseStateHandler<Object> getSimulatorResultHandler(
return new DebugTraceTransactionResult(transactionTrace);
});
}

@Override
protected TransactionValidationParams buildTransactionValidationParams() {
return ImmutableTransactionValidationParams.builder()
.from(TransactionValidationParams.transactionSimulator())
.isAllowExceedingBalance(true)
.allowUnderpriced(true)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"request": {
"jsonrpc": "2.0",
"method": "debug_traceCall",
"params": [
{
"to": "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e",
"data": "0x000000000000000000000000000000000000000000000000000000000001A00E"
},
"latest",
{
"disableMemory": true,
"disableStack": true,
"disableStorage": true
}
],
"id": 1
},
"response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"gas": 21164,
"failed": false,
"returnValue": "",
"structLogs": [
{
"pc": 0,
"op": "STOP",
"gas": 17592186023252,
"gasCost": 0,
"depth": 1,
"stack": null,
"memory": null,
"storage": null,
"reason": null
}
]
}
},
"statusCode": 200
}

0 comments on commit 5df2a71

Please sign in to comment.