Fix the error retrurned when the PMT fails because the intrinsic gas exeeds the gas limit. (#616)

* Fix the error retrurned when the PMT cannot be added to the transaction pool because the intrinsic gas exeeds the gas limit.

Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
pull/634/head
Stefan Pingel 5 years ago committed by GitHub
parent a4143dc410
commit ce031f1973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java
  2. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  3. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java

@ -28,6 +28,7 @@ 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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.EnclavePublicKeyProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -146,8 +147,7 @@ public class EeaSendRawTransaction implements JsonRpcMethod {
.addLocalTransaction(privacyMarkerTransaction)
.either(
() -> new JsonRpcSuccessResponse(id, privacyMarkerTransaction.getHash().toString()),
errorReason ->
new JsonRpcErrorResponse(id, convertTransactionInvalidReason(errorReason)));
errorReason -> getJsonRpcErrorResponse(id, errorReason));
} catch (final MultiTenancyValidationException e) {
LOG.error("Unauthorized privacy multi-tenancy rpc request. {}", e.getMessage());
return new JsonRpcErrorResponse(id, ENCLAVE_ERROR);
@ -158,6 +158,14 @@ public class EeaSendRawTransaction implements JsonRpcMethod {
}
}
JsonRpcErrorResponse getJsonRpcErrorResponse(
final Object id, final TransactionInvalidReason errorReason) {
if (errorReason.equals(TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT)) {
return new JsonRpcErrorResponse(id, JsonRpcError.PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT);
}
return new JsonRpcErrorResponse(id, convertTransactionInvalidReason(errorReason));
}
private String buildCompoundKey(
final String enclaveKey, final Optional<String> addPayloadEnclaveKey) {
return addPayloadEnclaveKey.isPresent()

@ -112,13 +112,16 @@ public enum JsonRpcError {
DELETE_PRIVACY_GROUP_ERROR(-50100, "Error deleting privacy group"),
FIND_PRIVACY_GROUP_ERROR(-50100, "Error finding privacy group"),
FIND_ON_CHAIN_PRIVACY_GROUP_ERROR(-50100, "Error finding on-chain privacy group"),
VALUE_NOT_ZERO(-50100, "We cannot transfer ether in private transaction yet."),
VALUE_NOT_ZERO(-50100, "We cannot transfer ether in a private transaction yet."),
DECODE_ERROR(-50100, "Unable to decode the private signed raw transaction"),
GET_PRIVATE_TRANSACTION_NONCE_ERROR(-50100, "Unable to determine nonce for account in group."),
PRIVACY_GROUP_DOES_NOT_EXIST(-50100, "Privacy group does not exist."),
ONCHAIN_PRIVACY_GROUP_NOT_ENABLED(-50100, "Onchain privacy groups not enabled."),
OFFCHAIN_PRIVACY_GROUP_NOT_ENABLED(
-50100, "Offchain privacy group can't be used with Onchain privacy groups enabled."),
PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT(
-50100,
"Private Marker Transaction failed due to intrinsic gas exeeding the limit. Gas limit used from the Private Transaction."),
CANT_CONNECT_TO_LOCAL_PEER(-32100, "Cannot add local node as peer."),

@ -450,7 +450,7 @@ public class EeaSendRawTransactionTest {
public void transactionWithIntrinsicGasExceedingGasLimitIsRejected() {
verifyErrorForInvalidTransaction(
TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
JsonRpcError.INTRINSIC_GAS_EXCEEDS_LIMIT);
JsonRpcError.PMT_FAILED_INTRINSIC_GAS_EXCEEDS_LIMIT);
}
@Test

Loading…
Cancel
Save