Debug logging on Private Transaction failure (#302)

Signed-off-by: Christopher Hare <chris.hare@consensys.net>
pull/303/head
CJ Hare 5 years ago committed by GitHub
parent 838f7aa5e0
commit 5910a91a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java

@ -36,52 +36,61 @@ public class PrivateTransactionValidator {
public ValidationResult<TransactionValidator.TransactionInvalidReason> validate(
final PrivateTransaction transaction, final Long accountNonce) {
LOG.debug("Validating private transaction {} signature ", transaction.hash());
LOG.debug("Validating the signature of Private Transaction {} ", transaction.hash());
final ValidationResult<TransactionValidator.TransactionInvalidReason>
signatureValidationResult = validateTransactionSignature(transaction);
if (!signatureValidationResult.isValid()) {
LOG.debug(
"Private Transaction {}, failed validation {}, {}",
transaction.hash(),
signatureValidationResult.getInvalidReason(),
signatureValidationResult.getErrorMessage());
return signatureValidationResult;
}
final long transactionNonce = transaction.getNonce();
LOG.debug("Validating actual nonce {} with expected nonce {}", transactionNonce, accountNonce);
LOG.debug("Validating actual nonce {}, with expected nonce {}", transactionNonce, accountNonce);
if (accountNonce > transactionNonce) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW,
final String errorMessage =
String.format(
"private transaction nonce %s does not match sender account nonce %s.",
transactionNonce, accountNonce));
"Private Transaction nonce %s, is lower than sender account nonce %s.",
transactionNonce, accountNonce);
LOG.debug(errorMessage);
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW, errorMessage);
}
if (accountNonce != transactionNonce) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE,
final String errorMessage =
String.format(
"private transaction nonce %s does not match sender account nonce %s.",
transactionNonce, accountNonce));
"Private Transaction nonce %s, does not match sender account nonce %s.",
transactionNonce, accountNonce);
LOG.debug(errorMessage);
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE, errorMessage);
}
return ValidationResult.valid();
}
public ValidationResult<TransactionValidator.TransactionInvalidReason>
private ValidationResult<TransactionValidator.TransactionInvalidReason>
validateTransactionSignature(final PrivateTransaction transaction) {
if (chainId.isPresent()
&& (transaction.getChainId().isPresent() && !transaction.getChainId().equals(chainId))) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.WRONG_CHAIN_ID,
String.format(
"transaction was meant for chain id %s and not this chain id %s",
"Transaction was meant for chain id %s, not this chain id %s",
transaction.getChainId().get(), chainId.get()));
}
if (!chainId.isPresent() && transaction.getChainId().isPresent()) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED,
"replay protected signatures is not supported");
"Replay protection (chainId) is not supported");
}
// org.bouncycastle.math.ec.ECCurve.AbstractFp.decompressPoint throws an
@ -91,7 +100,7 @@ public class PrivateTransactionValidator {
} catch (final IllegalArgumentException e) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INVALID_SIGNATURE,
"sender could not be extracted from transaction signature");
"Sender could not be extracted from transaction signature");
}
return ValidationResult.valid();

Loading…
Cancel
Save