updated eth_sendRawTransaction for EIP1559 transactions (#2424)

Updated eth_sendRawTransaction to return an error when maxPriorityFeePerGas exceeds maxFeePerGas

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
pull/2433/head
matkt 3 years ago committed by GitHub
parent 1ca3a4d33e
commit 7120606683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 2
      besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
  3. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java
  4. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  5. 8
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java
  6. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java
  7. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  8. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java
  9. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionValidationParams.java
  10. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java
  11. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java
  12. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java
  13. 51
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java
  14. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  15. 37
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java

@ -9,6 +9,8 @@
### Bug Fixes
- Updated `eth_sendRawTransaction` to return an error when maxPriorityFeePerGas exceeds maxFeePerGas [\#2424](https://github.com/hyperledger/besu/pull/2424)
### Early Access Features
## 21.1.7

@ -128,7 +128,7 @@ public class BesuEventsImplTest {
when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
when(mockProtocolSchedule.getByBlockNumber(anyLong())).thenReturn(mockProtocolSpec);
when(mockProtocolSpec.getTransactionValidator()).thenReturn(mockTransactionValidator);
when(mockTransactionValidator.validate(any(), any(Optional.class)))
when(mockTransactionValidator.validate(any(), any(Optional.class), any()))
.thenReturn(ValidationResult.valid());
when(mockTransactionValidator.validateForSender(any(), any(), any()))
.thenReturn(ValidationResult.valid());

@ -49,6 +49,8 @@ public class JsonRpcErrorConverter {
return JsonRpcError.GAS_PRICE_TOO_LOW;
case TX_FEECAP_EXCEEDED:
return JsonRpcError.TX_FEECAP_EXCEEDED;
case MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS:
return JsonRpcError.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS;
case OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST:
return JsonRpcError.OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST;
case TRANSACTION_ALREADY_KNOWN:

@ -65,6 +65,8 @@ public enum JsonRpcError {
REVERT_ERROR(-32000, "Execution reverted"),
GAS_PRICE_MUST_BE_ZERO(-3200, "gasPrice must be set to zero on a GoQuorum compatible network"),
TRANSACTION_NOT_FOUND(-32000, "Transaction not found"),
MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS(
32000, "Max priority fee per gas exceeds max fee per gas"),
// Miner failures
COINBASE_NOT_SET(-32010, "Coinbase not set. Unable to start mining without a coinbase"),

@ -252,10 +252,13 @@ public class BlockTransactionSelector {
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());
transactionValidator.validate(
transaction, blockHeader.getBaseFee(), transactionValidationParams);
if (!validationResult.isValid()) {
return validationResult;
}
@ -264,8 +267,7 @@ public class BlockTransactionSelector {
final EvmAccount sender = publicWorldStateUpdater.getOrCreate(senderAddress);
validationResult =
transactionValidator.validateForSender(
transaction, sender, TransactionValidationParams.processingBlock());
transactionValidator.validateForSender(transaction, sender, transactionValidationParams);
return validationResult;
}

@ -221,8 +221,11 @@ public class GoQuorumBlockProcessor extends MainnetBlockProcessor {
final WorldUpdater publicWorldStateUpdater) {
final MainnetTransactionValidator transactionValidator =
transactionProcessor.getTransactionValidator();
final TransactionValidationParams transactionValidationParams =
TransactionValidationParams.processingBlock();
ValidationResult<TransactionInvalidReason> validationResult =
transactionValidator.validate(transaction, blockHeader.getBaseFee());
transactionValidator.validate(
transaction, blockHeader.getBaseFee(), transactionValidationParams);
if (!validationResult.isValid()) {
LOG.warn(
"Invalid transaction: {}. Block {} Transaction {}",
@ -236,8 +239,7 @@ public class GoQuorumBlockProcessor extends MainnetBlockProcessor {
final EvmAccount sender = publicWorldStateUpdater.getOrCreate(senderAddress);
validationResult =
transactionValidator.validateForSender(
transaction, sender, TransactionValidationParams.processingBlock());
transactionValidator.validateForSender(transaction, sender, transactionValidationParams);
if (!validationResult.isValid()) {
LOG.warn(
"Invalid transaction: {}. Block {} Transaction {}",

@ -253,7 +253,8 @@ public class MainnetTransactionProcessor {
try {
LOG.trace("Starting execution of {}", transaction);
ValidationResult<TransactionInvalidReason> validationResult =
transactionValidator.validate(transaction, blockHeader.getBaseFee());
transactionValidator.validate(
transaction, blockHeader.getBaseFee(), transactionValidationParams);
// Make sure the transaction is intrinsically valid before trying to
// compare against a sender account (because the transaction may not
// be signed correctly to extract the sender).

@ -97,12 +97,15 @@ public class MainnetTransactionValidator {
*
* @param transaction the transaction to validate
* @param baseFee optional baseFee
* @param transactionValidationParams Validation parameters that will be used
* @return An empty @{link Optional} if the transaction is considered valid; otherwise an @{code
* Optional} containing a {@link TransactionInvalidReason} that identifies why the transaction
* is invalid.
*/
public ValidationResult<TransactionInvalidReason> validate(
final Transaction transaction, final Optional<Long> baseFee) {
final Transaction transaction,
final Optional<Long> baseFee,
final TransactionValidationParams transactionValidationParams) {
final ValidationResult<TransactionInvalidReason> signatureResult =
validateTransactionSignature(transaction);
if (!signatureResult.isValid()) {
@ -126,7 +129,8 @@ public class MainnetTransactionValidator {
if (baseFee.isPresent()) {
final Wei price = transactionPriceCalculator.orElseThrow().price(transaction, baseFee);
if (price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) {
if (!transactionValidationParams.isAllowMaxFeerGasBelowBaseFee()
&& price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) {
return ValidationResult.invalid(
TransactionInvalidReason.INVALID_TRANSACTION_FORMAT,
"gasPrice is less than the current BaseFee");
@ -141,7 +145,7 @@ public class MainnetTransactionValidator {
.compareTo(transaction.getMaxFeePerGas().get().getAsBigInteger())
> 0) {
return ValidationResult.invalid(
TransactionInvalidReason.INVALID_TRANSACTION_FORMAT,
TransactionInvalidReason.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS,
"max priority fee per gas cannot be greater than max fee per gas");
}
}

@ -21,19 +21,19 @@ import org.immutables.value.Value;
public interface TransactionValidationParams {
TransactionValidationParams processingBlockParams =
ImmutableTransactionValidationParams.of(false, false, true, false);
ImmutableTransactionValidationParams.of(false, false, false, true, false);
TransactionValidationParams transactionPoolParams =
ImmutableTransactionValidationParams.of(true, false, false, true);
ImmutableTransactionValidationParams.of(true, false, true, false, true);
TransactionValidationParams miningParams =
ImmutableTransactionValidationParams.of(false, false, true, true);
ImmutableTransactionValidationParams.of(false, false, false, true, true);
TransactionValidationParams blockReplayParams =
ImmutableTransactionValidationParams.of(false, false, false, false);
ImmutableTransactionValidationParams.of(false, false, false, false, false);
TransactionValidationParams transactionSimulatorParams =
ImmutableTransactionValidationParams.of(false, false, false, false);
ImmutableTransactionValidationParams.of(false, false, false, false, false);
@Value.Default
default boolean isAllowFutureNonce() {
@ -45,6 +45,11 @@ public interface TransactionValidationParams {
return false;
}
@Value.Default
default boolean isAllowMaxFeerGasBelowBaseFee() {
return false;
}
@Value.Default
default boolean checkOnchainPermissions() {
return false;

@ -33,6 +33,7 @@ public enum TransactionInvalidReason {
TRANSACTION_PRICE_TOO_LOW,
TRANSACTION_ALREADY_KNOWN,
TRANSACTION_REPLACEMENT_UNDERPRICED,
MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS,
// Private Transaction Invalid Reasons
PRIVATE_TRANSACTION_FAILED,
PRIVATE_NONCE_TOO_LOW,

@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.testutil.JsonTestParameters;
@ -109,7 +110,9 @@ public class TransactionTest {
// Test transaction deserialization (will throw an exception if it fails).
final Transaction transaction = Transaction.readFrom(RLP.input(rlp));
if (!transactionValidator(milestone).validate(transaction, Optional.empty()).isValid()) {
if (!transactionValidator(milestone)
.validate(transaction, Optional.empty(), TransactionValidationParams.processingBlock())
.isValid()) {
throw new RuntimeException(String.format("Transaction is invalid %s", transaction));
}

@ -95,7 +95,7 @@ public class MainnetTransactionProcessorTest {
private ArgumentCaptor<TransactionValidationParams> transactionValidationParamCaptor() {
final ArgumentCaptor<TransactionValidationParams> txValidationParamCaptor =
ArgumentCaptor.forClass(TransactionValidationParams.class);
when(transactionValidator.validate(any(), any())).thenReturn(ValidationResult.valid());
when(transactionValidator.validate(any(), any(), any())).thenReturn(ValidationResult.valid());
// returning invalid transaction to halt method execution
when(transactionValidator.validateForSender(any(), any(), txValidationParamCaptor.capture()))
.thenReturn(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE));

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.GAS_PRICE_MUST_BE_ZERO;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.INVALID_TRANSACTION_FORMAT;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.UPFRONT_COST_EXCEEDS_BALANCE;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@ -62,6 +62,9 @@ public class MainnetTransactionValidatorTest {
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
private static final KeyPair senderKeys = SIGNATURE_ALGORITHM.get().generateKeyPair();
private static final TransactionValidationParams transactionValidationParams =
TransactionValidationParams.processingBlockParams;
@Mock private GasCalculator gasCalculator;
@Mock private TransactionPriceCalculator transactionPriceCalculator;
@ -86,7 +89,7 @@ public class MainnetTransactionValidatorTest {
when(gasCalculator.transactionIntrinsicGasCostAndAccessedState(transaction))
.thenReturn(new GasAndAccessedState(Gas.of(50)));
assertThat(validator.validate(transaction, Optional.empty()))
assertThat(validator.validate(transaction, Optional.empty(), transactionValidationParams))
.isEqualTo(
ValidationResult.invalid(TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT));
}
@ -96,7 +99,7 @@ public class MainnetTransactionValidatorTest {
final MainnetTransactionValidator validator =
new MainnetTransactionValidator(
gasCalculator, false, Optional.empty(), defaultGoQuorumCompatibilityMode);
assertThat(validator.validate(basicTransaction, Optional.empty()))
assertThat(validator.validate(basicTransaction, Optional.empty(), transactionValidationParams))
.isEqualTo(
ValidationResult.invalid(
TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED));
@ -110,7 +113,7 @@ public class MainnetTransactionValidatorTest {
false,
Optional.of(BigInteger.valueOf(2)),
defaultGoQuorumCompatibilityMode);
assertThat(validator.validate(basicTransaction, Optional.empty()))
assertThat(validator.validate(basicTransaction, Optional.empty(), transactionValidationParams))
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.WRONG_CHAIN_ID));
}
@ -260,8 +263,9 @@ public class MainnetTransactionValidatorTest {
.signAndBuild(new SECP256K1().generateKeyPair());
final ValidationResult<TransactionInvalidReason> validationResult =
validator.validate(transaction, Optional.of(1L));
assertThat(validationResult).isEqualTo(ValidationResult.invalid(INVALID_TRANSACTION_FORMAT));
validator.validate(transaction, Optional.of(1L), transactionValidationParams);
assertThat(validationResult)
.isEqualTo(ValidationResult.invalid(MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS));
assertThat(validationResult.getErrorMessage())
.isEqualTo("max priority fee per gas cannot be greater than max fee per gas");
}
@ -347,13 +351,14 @@ public class MainnetTransactionValidatorTest {
when(transactionPriceCalculator.price(eq(transaction), any())).thenReturn(Wei.of(160000L));
assertThat(frontierValidator.validate(transaction, Optional.empty()))
assertThat(
frontierValidator.validate(transaction, Optional.empty(), transactionValidationParams))
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
when(gasCalculator.transactionIntrinsicGasCostAndAccessedState(transaction))
.thenReturn(new GasAndAccessedState(Gas.of(0)));
assertThat(eip1559Validator.validate(transaction, Optional.of(1L)))
assertThat(eip1559Validator.validate(transaction, Optional.of(1L), transactionValidationParams))
.isEqualTo(ValidationResult.valid());
}
@ -376,7 +381,7 @@ public class MainnetTransactionValidatorTest {
.createTransaction(senderKeys);
final Optional<Long> basefee = Optional.of(150000L);
when(transactionPriceCalculator.price(transaction, basefee)).thenReturn(Wei.of(1));
assertThat(validator.validate(transaction, basefee))
assertThat(validator.validate(transaction, basefee, transactionValidationParams))
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
}
@ -402,11 +407,12 @@ public class MainnetTransactionValidatorTest {
.thenReturn(new GasAndAccessedState(Gas.of(50)));
when(transactionPriceCalculator.price(transaction, basefee)).thenReturn(Wei.of(150001L));
assertThat(validator.validate(transaction, basefee)).isEqualTo(ValidationResult.valid());
assertThat(validator.validate(transaction, basefee, transactionValidationParams))
.isEqualTo(ValidationResult.valid());
}
@Test
public void shouldValidate1559TransactionWithPriceLowerThanBaseFee() {
public void shouldValidate1559TransactionWithPriceLowerThanBaseFeeForTransactionPool() {
final MainnetTransactionValidator validator =
new MainnetTransactionValidator(
gasCalculator,
@ -425,9 +431,9 @@ public class MainnetTransactionValidatorTest {
when(gasCalculator.transactionIntrinsicGasCostAndAccessedState(transaction))
.thenReturn(new GasAndAccessedState(Gas.of(50)));
// validate without basefee is an adding to transaction pool case
// rather than a transaction processing case
assertThat(validator.validate(transaction, Optional.empty()))
assertThat(
validator.validate(
transaction, Optional.of(1L), TransactionValidationParams.transactionPool()))
.isEqualTo(ValidationResult.valid());
}
@ -441,8 +447,15 @@ public class MainnetTransactionValidatorTest {
.chainId(Optional.empty())
.createTransaction(senderKeys);
assertThat(validator.validate(transaction, Optional.empty()).isValid()).isFalse();
assertThat(validator.validate(transaction, Optional.empty()).getInvalidReason())
assertThat(
validator
.validate(transaction, Optional.empty(), transactionValidationParams)
.isValid())
.isFalse();
assertThat(
validator
.validate(transaction, Optional.empty(), transactionValidationParams)
.getInvalidReason())
.isEqualTo(GAS_PRICE_MUST_BE_ZERO);
}
@ -459,7 +472,11 @@ public class MainnetTransactionValidatorTest {
when(gasCalculator.transactionIntrinsicGasCostAndAccessedState(transaction))
.thenReturn(new GasAndAccessedState(Gas.of(50)));
assertThat(validator.validate(transaction, Optional.empty()).isValid()).isTrue();
assertThat(
validator
.validate(transaction, Optional.empty(), transactionValidationParams)
.isValid())
.isTrue();
}
private Account accountWithNonce(final long nonce) {

@ -244,7 +244,11 @@ public class TransactionPool implements BlockAddedObserver {
}
final ValidationResult<TransactionInvalidReason> basicValidationResult =
getTransactionValidator().validate(transaction, Optional.empty());
getTransactionValidator()
.validate(
transaction,
chainHeadBlockHeader.getBaseFee(),
TransactionValidationParams.transactionPool());
if (!basicValidationResult.isValid()) {
return basicValidationResult;
}

@ -307,7 +307,7 @@ public class TransactionPoolTest {
.gasPrice(Wei.of(1))
.createTransaction(KEY_PAIR1);
when(transactionValidator.validate(eq(transaction), any(Optional.class)))
when(transactionValidator.validate(eq(transaction), any(Optional.class), any()))
.thenReturn(ValidationResult.valid());
final ValidationResult<TransactionInvalidReason> result =
@ -319,7 +319,7 @@ public class TransactionPoolTest {
@Test
public void shouldNotAddRemoteTransactionsThatAreInvalidAccordingToInvariantChecks() {
givenTransactionIsValid(transaction2);
when(transactionValidator.validate(eq(transaction1), any(Optional.class)))
when(transactionValidator.validate(eq(transaction1), any(Optional.class), any()))
.thenReturn(ValidationResult.invalid(NONCE_TOO_LOW));
transactionPool.addRemoteTransactions(asList(transaction1, transaction2));
@ -332,7 +332,8 @@ public class TransactionPoolTest {
@Test
public void shouldNotAddRemoteTransactionsThatAreInvalidAccordingToStateDependentChecks() {
givenTransactionIsValid(transaction2);
when(transactionValidator.validate(eq(transaction1), any(Optional.class))).thenReturn(valid());
when(transactionValidator.validate(eq(transaction1), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(transaction1, null, true))
.thenReturn(ValidationResult.invalid(NONCE_TOO_LOW));
@ -350,7 +351,7 @@ public class TransactionPoolTest {
final Transaction transaction2 = builder.nonce(2).createTransaction(KEY_PAIR1);
final Transaction transaction3 = builder.nonce(3).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -379,7 +380,7 @@ public class TransactionPoolTest {
final Transaction transaction2 = builder.nonce(2).createTransaction(KEY_PAIR1);
final Transaction transaction3 = builder.nonce(3).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -435,7 +436,7 @@ public class TransactionPoolTest {
final Transaction transaction2 =
builder.nonce(1).gasPrice(Wei.of(5)).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -460,7 +461,7 @@ public class TransactionPoolTest {
final Transaction transaction2 =
builder.nonce(1).gasPrice(Wei.of(5)).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -519,7 +520,7 @@ public class TransactionPoolTest {
when(peerPendingTransactionTracker.isPeerSupported(peer, EthProtocol.ETH65)).thenReturn(false);
when(peerPendingTransactionTracker.isPeerSupported(validPeer, EthProtocol.ETH65))
.thenReturn(true);
when(transactionValidator.validate(any(), any(Optional.class))).thenReturn(valid());
when(transactionValidator.validate(any(), any(Optional.class), any())).thenReturn(valid());
transactionPool.addTransactionHash(transaction1.getHash());
transactionPool.handleConnect(peer);
verify(peerPendingTransactionTracker, never()).addToPeerSendQueue(peer, transaction1.getHash());
@ -562,7 +563,7 @@ public class TransactionPoolTest {
final Transaction transaction2 = builder.nonce(2).createTransaction(KEY_PAIR1);
final Transaction transaction3 = builder.nonce(3).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -589,7 +590,7 @@ public class TransactionPoolTest {
final Transaction transaction2 = builder.nonce(2).createTransaction(KEY_PAIR1);
final Transaction transaction3 = builder.nonce(3).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction1), nullable(Account.class), any(TransactionValidationParams.class)))
@ -632,7 +633,7 @@ public class TransactionPoolTest {
final TransactionTestFixture builder = new TransactionTestFixture();
final Transaction transactionLocal = builder.nonce(1).createTransaction(KEY_PAIR1);
final Transaction transactionRemote = builder.nonce(2).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
any(Transaction.class),
@ -655,7 +656,8 @@ public class TransactionPoolTest {
public void shouldCallValidatorWithExpectedValidationParameters() {
final ArgumentCaptor<TransactionValidationParams> txValidationParamCaptor =
ArgumentCaptor.forClass(TransactionValidationParams.class);
when(transactionValidator.validate(eq(transaction1), any(Optional.class))).thenReturn(valid());
when(transactionValidator.validate(eq(transaction1), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(any(), any(), txValidationParamCaptor.capture()))
.thenReturn(valid());
@ -689,7 +691,7 @@ public class TransactionPoolTest {
metricsSystem,
Optional.empty(),
ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ZERO).build());
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
any(Transaction.class),
@ -727,7 +729,7 @@ public class TransactionPoolTest {
metricsSystem,
Optional.empty(),
ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ONE).build());
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
any(Transaction.class),
@ -770,7 +772,7 @@ public class TransactionPoolTest {
metricsSystem,
Optional.of(new EIP1559(100)),
ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ONE).build());
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
any(Transaction.class),
@ -819,7 +821,7 @@ public class TransactionPoolTest {
final Transaction transactionLocal =
builder.nonce(1).gasPrice(twoEthers.add(Wei.of(1))).createTransaction(KEY_PAIR1);
when(transactionValidator.validate(any(Transaction.class), any(Optional.class)))
when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
any(Transaction.class),
@ -920,7 +922,8 @@ public class TransactionPoolTest {
}
private void givenTransactionIsValid(final Transaction transaction) {
when(transactionValidator.validate(eq(transaction), any(Optional.class))).thenReturn(valid());
when(transactionValidator.validate(eq(transaction), any(Optional.class), any()))
.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transaction), nullable(Account.class), any(TransactionValidationParams.class)))
.thenReturn(valid());

Loading…
Cancel
Save