Search in sources :

Example 1 with MainnetTransactionValidator

use of org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator in project besu by hyperledger.

the class GoQuorumBlockProcessor method validateTransaction.

private ValidationResult<TransactionInvalidReason> validateTransaction(final BlockHeader blockHeader, final Transaction transaction, final WorldUpdater publicWorldStateUpdater) {
    final MainnetTransactionValidator transactionValidator = transactionProcessor.getTransactionValidator();
    final TransactionValidationParams transactionValidationParams = TransactionValidationParams.processingBlock();
    ValidationResult<TransactionInvalidReason> validationResult = transactionValidator.validate(transaction, blockHeader.getBaseFee(), transactionValidationParams);
    if (!validationResult.isValid()) {
        LOG.warn("Invalid transaction: {}. Block {} Transaction {}", validationResult.getErrorMessage(), blockHeader.getHash().toHexString(), transaction.getHash().toHexString());
        return validationResult;
    }
    final Address senderAddress = transaction.getSender();
    final EvmAccount sender = publicWorldStateUpdater.getOrCreate(senderAddress);
    validationResult = transactionValidator.validateForSender(transaction, sender, transactionValidationParams);
    if (!validationResult.isValid()) {
        LOG.warn("Invalid transaction: {}. Block {} Transaction {}", validationResult.getErrorMessage(), blockHeader.getHash().toHexString(), transaction.getHash().toHexString());
        return validationResult;
    }
    return ValidationResult.valid();
}
Also used : EvmAccount(org.hyperledger.besu.evm.account.EvmAccount) Address(org.hyperledger.besu.datatypes.Address) TransactionInvalidReason(org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason) MainnetTransactionValidator(org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator) TransactionValidationParams(org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams)

Example 2 with MainnetTransactionValidator

use of org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator in project besu by hyperledger.

the class BlockTransactionSelector method validateTransaction.

private ValidationResult<TransactionInvalidReason> validateTransaction(final ProcessableBlockHeader blockHeader, final Transaction transaction, final WorldUpdater publicWorldStateUpdater) {
    final TransactionValidationParams transactionValidationParams = TransactionValidationParams.processingBlock();
    final MainnetTransactionValidator transactionValidator = transactionProcessor.getTransactionValidator();
    ValidationResult<TransactionInvalidReason> validationResult = transactionValidator.validate(transaction, blockHeader.getBaseFee(), transactionValidationParams);
    if (!validationResult.isValid()) {
        return validationResult;
    }
    final Address senderAddress = transaction.getSender();
    final EvmAccount sender = publicWorldStateUpdater.getOrCreate(senderAddress);
    validationResult = transactionValidator.validateForSender(transaction, sender, transactionValidationParams);
    return validationResult;
}
Also used : EvmAccount(org.hyperledger.besu.evm.account.EvmAccount) Address(org.hyperledger.besu.datatypes.Address) TransactionInvalidReason(org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason) MainnetTransactionValidator(org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator) TransactionValidationParams(org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams)

Aggregations

Address (org.hyperledger.besu.datatypes.Address)2 MainnetTransactionValidator (org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator)2 TransactionValidationParams (org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams)2 TransactionInvalidReason (org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason)2 EvmAccount (org.hyperledger.besu.evm.account.EvmAccount)2