use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter in project besu by hyperledger.
the class EthCall method resultByBlockHash.
@Override
protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
JsonCallParameter callParams = JsonCallParameterUtil.validateAndGetCallParams(request);
final BlockHeader header = blockchainQueries.get().getBlockHeaderByHash(blockHash).orElse(null);
if (header == null) {
return errorResponse(request, BLOCK_NOT_FOUND);
}
return transactionSimulator.process(callParams, buildTransactionValidationParams(header, callParams), OperationTracer.NO_TRACING, header).map(result -> result.getValidationResult().either((() -> result.isSuccessful() ? new JsonRpcSuccessResponse(request.getRequest().getId(), result.getOutput().toString()) : errorResponse(request, result)), reason -> new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcErrorConverter.convertTransactionInvalidReason(reason)))).orElse(errorResponse(request, INTERNAL_ERROR));
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter in project besu by hyperledger.
the class EthEstimateGas method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final JsonCallParameter callParams = validateAndGetCallParams(requestContext);
final BlockHeader blockHeader = blockHeader();
if (blockHeader == null) {
return errorResponse(requestContext, JsonRpcError.INTERNAL_ERROR);
}
if (!blockchainQueries.getWorldStateArchive().isWorldStateAvailable(blockHeader.getStateRoot(), blockHeader.getHash())) {
return errorResponse(requestContext, JsonRpcError.WORLD_STATE_UNAVAILABLE);
}
final CallParameter modifiedCallParams = overrideGasLimitAndPrice(callParams, blockHeader.getGasLimit());
final EstimateGasOperationTracer operationTracer = new EstimateGasOperationTracer();
return transactionSimulator.process(modifiedCallParams, ImmutableTransactionValidationParams.builder().from(TransactionValidationParams.transactionSimulator()).isAllowExceedingBalance(!callParams.isMaybeStrict().orElse(Boolean.FALSE)).build(), operationTracer, blockHeader.getNumber()).map(gasEstimateResponse(requestContext, operationTracer)).orElse(errorResponse(requestContext, JsonRpcError.INTERNAL_ERROR));
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter in project besu by hyperledger.
the class EthCallTest method shouldAutoSelectIsAllowedExeceedingBalanceToTrueWhenGasPriceIsZero.
@Test
public void shouldAutoSelectIsAllowedExeceedingBalanceToTrueWhenGasPriceIsZero() {
JsonCallParameter callParameters = callParameter(Wei.ZERO, null, null);
internalAutoSelectIsAllowedExeecdBalance(callParameters, Optional.empty(), true);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter in project besu by hyperledger.
the class EthCallTest method shouldAutoSelectIsAllowedExeceedingBalanceToTrueWhenFeesAreZero.
@Test
public void shouldAutoSelectIsAllowedExeceedingBalanceToTrueWhenFeesAreZero() {
JsonCallParameter callParameters = callParameter(null, Wei.ZERO, Wei.ZERO);
internalAutoSelectIsAllowedExeecdBalance(callParameters, Optional.of(Wei.ONE), true);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter in project besu by hyperledger.
the class EthCallTest method shouldAutoSelectIsAllowedExeceedingBalanceToFalseWhenGasPriceIsNotZeroAfterEIP1559.
@Test
public void shouldAutoSelectIsAllowedExeceedingBalanceToFalseWhenGasPriceIsNotZeroAfterEIP1559() {
JsonCallParameter callParameters = callParameter(Wei.ONE, null, null);
internalAutoSelectIsAllowedExeecdBalance(callParameters, Optional.of(Wei.ONE), false);
}
Aggregations