use of org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams 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();
}
use of org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams 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;
}
use of org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams in project besu by hyperledger.
the class EthCallTest method internalAutoSelectIsAllowedExeecdBalance.
private void internalAutoSelectIsAllowedExeecdBalance(final JsonCallParameter callParameter, final Optional<Wei> baseFee, final boolean isAllowedExeedingBalance) {
final JsonRpcRequestContext request = ethCallRequest(callParameter, "latest");
BlockHeader blockHeader = mock(BlockHeader.class);
when(blockHeader.getBaseFee()).thenReturn(baseFee);
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
when(blockchainQueries.getBlockchain().getChainHead()).thenReturn(chainHead);
when(blockchainQueries.getBlockchain().getChainHead().getHash()).thenReturn(Hash.ZERO);
when(blockchainQueries.getBlockHeaderByHash(Hash.ZERO)).thenReturn(Optional.of(blockHeader));
method.response(request);
TransactionValidationParams transactionValidationParams = ImmutableTransactionValidationParams.builder().from(TransactionValidationParams.transactionSimulator()).isAllowExceedingBalance(isAllowedExeedingBalance).build();
verify(transactionSimulator).process(any(), eq(transactionValidationParams), any(), any());
}
use of org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams in project besu by hyperledger.
the class TransactionPoolTest method shouldCallValidatorWithExpectedValidationParameters.
@Test
public void shouldCallValidatorWithExpectedValidationParameters() {
final ArgumentCaptor<TransactionValidationParams> txValidationParamCaptor = ArgumentCaptor.forClass(TransactionValidationParams.class);
when(transactionValidator.validate(eq(transaction1), any(Optional.class), any())).thenReturn(valid());
when(transactionValidator.validateForSender(any(), any(), txValidationParamCaptor.capture())).thenReturn(valid());
final TransactionValidationParams expectedValidationParams = TransactionValidationParams.transactionPool();
transactionPool.addLocalTransaction(transaction1);
assertThat(txValidationParamCaptor.getValue()).usingRecursiveComparison().isEqualTo(expectedValidationParams);
}
Aggregations