From 456f3f4ecb57e343c83fc498baf47711384bdc59 Mon Sep 17 00:00:00 2001 From: Lucas Saldanha Date: Fri, 28 Jun 2019 14:49:54 +1200 Subject: [PATCH] PIE-1717: Add TransactionValidationParam to TxProcessor (#1613) * Updated TransactionValidationParams with checkLocalPermissioning flag * Added TransactionValidationParam to TxProcessor Signed-off-by: Adrian Sutton --- .../BlockTransactionSelector.java | 3 +- .../BlockTransactionSelectorTest.java | 18 +++--- .../vm/TraceTransactionIntegrationTest.java | 3 +- .../mainnet/MainnetBlockProcessor.java | 3 +- .../mainnet/MainnetTransactionProcessor.java | 10 +-- .../mainnet/MainnetTransactionValidator.java | 14 +++-- .../mainnet/TransactionProcessor.java | 14 +++-- .../mainnet/TransactionValidationParams.java | 61 ++++++++++++++++++- .../transaction/TransactionSimulator.java | 3 +- .../MainnetTransactionProcessorTest.java | 30 +-------- .../MainnetTransactionValidatorTest.java | 23 +++++++ .../transaction/TransactionSimulatorTest.java | 4 +- .../vm/GeneralStateReferenceTestTools.java | 3 +- .../eth/transactions/TransactionPool.java | 9 +-- .../eth/transactions/TransactionPoolTest.java | 5 +- .../internal/processor/BlockReplay.java | 5 +- 16 files changed, 130 insertions(+), 78 deletions(-) diff --git a/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelector.java index e228bf8d2b..b3755166a9 100644 --- a/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelector.java @@ -24,6 +24,7 @@ import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions; import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions.TransactionSelectionResult; import tech.pegasys.pantheon.ethereum.mainnet.MainnetBlockProcessor.TransactionReceiptFactory; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor; +import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidationParams; import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import tech.pegasys.pantheon.ethereum.vm.BlockHashLookup; @@ -169,7 +170,7 @@ public class BlockTransactionSelector { miningBeneficiary, blockHashLookup, false, - true); + TransactionValidationParams.mining()); if (!result.isInvalid()) { worldStateUpdater.commit(); diff --git a/ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelectorTest.java index 46f3955ddd..c4b83353a7 100644 --- a/ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelectorTest.java @@ -123,7 +123,7 @@ public class BlockTransactionSelectorTest { pendingTransactions.addRemoteTransaction(transaction); when(transactionProcessor.processTransaction( - any(), any(), any(), eq(transaction), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), eq(transaction), any(), any(), anyBoolean(), any())) .thenReturn(MainnetTransactionProcessor.Result.failed(5, ValidationResult.valid())); // The block should fit 3 transactions only @@ -162,7 +162,7 @@ public class BlockTransactionSelectorTest { } when(transactionProcessor.processTransaction( - any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( MainnetTransactionProcessor.Result.successful( new LogSeries(Lists.newArrayList()), @@ -177,7 +177,7 @@ public class BlockTransactionSelectorTest { any(), any(), anyBoolean(), - anyBoolean())) + any())) .thenReturn( MainnetTransactionProcessor.Result.invalid(ValidationResult.invalid(NONCE_TOO_LOW))); @@ -218,7 +218,7 @@ public class BlockTransactionSelectorTest { } when(transactionProcessor.processTransaction( - any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( MainnetTransactionProcessor.Result.successful( new LogSeries(Lists.newArrayList()), @@ -289,7 +289,7 @@ public class BlockTransactionSelectorTest { final ProcessableBlockHeader blockHeader = createBlockWithGasLimit(300); when(transactionProcessor.processTransaction( - any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( MainnetTransactionProcessor.Result.successful( new LogSeries(Lists.newArrayList()), @@ -346,7 +346,7 @@ public class BlockTransactionSelectorTest { // TransactionProcessor mock assumes all gas in the transaction was used (i.e. gasLimit). when(transactionProcessor.processTransaction( - any(), any(), any(), any(), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( MainnetTransactionProcessor.Result.successful( new LogSeries(Lists.newArrayList()), @@ -442,7 +442,7 @@ public class BlockTransactionSelectorTest { any(), any(), anyBoolean(), - anyBoolean())) + any())) .thenReturn( Result.successful( LogSeries.empty(), 10000, BytesValue.EMPTY, ValidationResult.valid())); @@ -454,7 +454,7 @@ public class BlockTransactionSelectorTest { any(), any(), anyBoolean(), - anyBoolean())) + any())) .thenReturn( Result.invalid( ValidationResult.invalid(TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT))); @@ -483,7 +483,7 @@ public class BlockTransactionSelectorTest { any(), any(), anyBoolean(), - anyBoolean())) + any())) .thenReturn( Result.invalid(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))); diff --git a/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java index 4493faf0ca..a0cecb33d7 100644 --- a/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/tech/pegasys/pantheon/ethereum/vm/TraceTransactionIntegrationTest.java @@ -30,6 +30,7 @@ import tech.pegasys.pantheon.ethereum.debug.TraceOptions; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor.Result; +import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidationParams; import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive; import tech.pegasys.pantheon.util.bytes.Bytes32; @@ -93,7 +94,7 @@ public class TraceTransactionIntegrationTest { genesisBlock.getHeader().getCoinbase(), blockHashLookup, false, - false); + TransactionValidationParams.blockReplay()); assertThat(result.isSuccessful()).isTrue(); final Account createdContract = createTransactionUpdater.getTouchedAccounts().stream() diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetBlockProcessor.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetBlockProcessor.java index 60771f1310..750f38b095 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetBlockProcessor.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetBlockProcessor.java @@ -121,6 +121,7 @@ public class MainnetBlockProcessor implements BlockProcessor { final BlockHashLookup blockHashLookup = new BlockHashLookup(blockHeader, blockchain); final Address miningBeneficiary = miningBeneficiaryCalculator.calculateBeneficiary(blockHeader); + final TransactionProcessor.Result result = transactionProcessor.processTransaction( blockchain, @@ -130,7 +131,7 @@ public class MainnetBlockProcessor implements BlockProcessor { miningBeneficiary, blockHashLookup, true, - true); + TransactionValidationParams.processingBlock()); if (result.isInvalid()) { return Result.failed(); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java index 30cdbc6ca1..f3b07e3c97 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java @@ -147,7 +147,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { final OperationTracer operationTracer, final BlockHashLookup blockHashLookup, final Boolean isPersistingState, - final Boolean checkOnchainPermissions) { + final TransactionValidationParams transactionValidationParams) { LOG.trace("Starting execution of {}", transaction); ValidationResult validationResult = @@ -160,16 +160,10 @@ public class MainnetTransactionProcessor implements TransactionProcessor { return Result.invalid(validationResult); } - final TransactionValidationParams validationParams = - new TransactionValidationParams.Builder() - .allowFutureNonce(false) - .checkOnchainPermissions(checkOnchainPermissions) - .build(); - final Address senderAddress = transaction.getSender(); final MutableAccount sender = worldState.getOrCreate(senderAddress); validationResult = - transactionValidator.validateForSender(transaction, sender, validationParams); + transactionValidator.validateForSender(transaction, sender, transactionValidationParams); if (!validationResult.isValid()) { LOG.warn("Invalid transaction: {}", validationResult.getErrorMessage()); return Result.invalid(validationResult); diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidator.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidator.java index cadd99c9ab..d9f4421745 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidator.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidator.java @@ -114,7 +114,7 @@ public class MainnetTransactionValidator implements TransactionValidator { transaction.getNonce(), senderNonce)); } - if (!isSenderAllowed(transaction, validationParams.checkOnchainPermissions())) { + if (!isSenderAllowed(transaction, validationParams)) { return ValidationResult.invalid( TX_SENDER_NOT_AUTHORIZED, String.format("Sender %s is not on the Account Whitelist", transaction.getSender())); @@ -163,10 +163,14 @@ public class MainnetTransactionValidator implements TransactionValidator { } private boolean isSenderAllowed( - final Transaction transaction, final boolean checkOnchainPermissions) { - return transactionFilter - .map(c -> c.permitted(transaction, checkOnchainPermissions)) - .orElse(true); + final Transaction transaction, final TransactionValidationParams validationParams) { + if (validationParams.checkLocalPermissions() || validationParams.checkOnchainPermissions()) { + return transactionFilter + .map(c -> c.permitted(transaction, validationParams.checkOnchainPermissions())) + .orElse(true); + } else { + return true; + } } @Override diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionProcessor.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionProcessor.java index 7d07ededc6..88556fb29e 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionProcessor.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionProcessor.java @@ -107,9 +107,11 @@ public interface TransactionProcessor { * @param miningBeneficiary The address which is to receive the transaction fee * @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations * @param isPersistingState Whether the state will be modified by this process - * @param checkOnchainPermissions Whether a transaction permissioning check should check onchain - * permissioning rules + * @param transactionValidationParams Validation parameters that will be used by the {@link + * TransactionValidator} * @return the transaction result + * @see TransactionValidator + * @see TransactionValidationParams */ default Result processTransaction( final Blockchain blockchain, @@ -119,7 +121,7 @@ public interface TransactionProcessor { final Address miningBeneficiary, final BlockHashLookup blockHashLookup, final Boolean isPersistingState, - final Boolean checkOnchainPermissions) { + final TransactionValidationParams transactionValidationParams) { return processTransaction( blockchain, worldState, @@ -129,7 +131,7 @@ public interface TransactionProcessor { NO_TRACING, blockHashLookup, isPersistingState, - checkOnchainPermissions); + transactionValidationParams); } /** @@ -163,7 +165,7 @@ public interface TransactionProcessor { operationTracer, blockHashLookup, isPersistingState, - false); + new TransactionValidationParams.Builder().build()); } Result processTransaction( @@ -175,5 +177,5 @@ public interface TransactionProcessor { OperationTracer operationTracer, BlockHashLookup blockHashLookup, Boolean isPersistingState, - Boolean checkOnchainPermissions); + TransactionValidationParams transactionValidationParams); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionValidationParams.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionValidationParams.java index 2376cbc9c6..a550b4a308 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionValidationParams.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/TransactionValidationParams.java @@ -16,11 +16,15 @@ public class TransactionValidationParams { private final boolean allowFutureNonce; private final boolean checkOnchainPermissions; + private final boolean checkLocalPermissions; private TransactionValidationParams( - final boolean allowFutureNonce, final boolean checkOnchainPermissions) { + final boolean allowFutureNonce, + final boolean checkOnchainPermissions, + final boolean checkLocalPermissions) { this.allowFutureNonce = allowFutureNonce; this.checkOnchainPermissions = checkOnchainPermissions; + this.checkLocalPermissions = checkLocalPermissions; } public boolean isAllowFutureNonce() { @@ -31,10 +35,55 @@ public class TransactionValidationParams { return checkOnchainPermissions; } - public static class Builder { + public boolean checkLocalPermissions() { + return checkLocalPermissions; + } + + public static TransactionValidationParams transactionSimulator() { + return new Builder() + .checkLocalPermissions(false) + .checkOnchainPermissions(false) + .allowFutureNonce(false) + .build(); + } + + public static TransactionValidationParams processingBlock() { + return new Builder() + .checkLocalPermissions(false) + .checkOnchainPermissions(true) + .allowFutureNonce(false) + .build(); + } + + public static TransactionValidationParams transactionPool() { + return new Builder() + .checkLocalPermissions(true) + .checkOnchainPermissions(false) + .allowFutureNonce(true) + .build(); + } + + public static TransactionValidationParams mining() { + return new Builder() + .checkLocalPermissions(true) + .checkOnchainPermissions(true) + .allowFutureNonce(false) + .build(); + } + + public static TransactionValidationParams blockReplay() { + return new Builder() + .checkLocalPermissions(false) + .checkOnchainPermissions(false) + .allowFutureNonce(false) + .build(); + } + + static class Builder { private boolean allowFutureNonce = false; private boolean checkOnchainPermissions = false; + private boolean checkLocalPermissions = true; public Builder allowFutureNonce(final boolean allowFutureNonce) { this.allowFutureNonce = allowFutureNonce; @@ -46,8 +95,14 @@ public class TransactionValidationParams { return this; } + public Builder checkLocalPermissions(final boolean checkLocalPermissions) { + this.checkLocalPermissions = checkLocalPermissions; + return this; + } + public TransactionValidationParams build() { - return new TransactionValidationParams(allowFutureNonce, checkOnchainPermissions); + return new TransactionValidationParams( + allowFutureNonce, checkOnchainPermissions, checkLocalPermissions); } } } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulator.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulator.java index 0923660510..87a43de28e 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulator.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulator.java @@ -24,6 +24,7 @@ import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor; +import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidationParams; import tech.pegasys.pantheon.ethereum.vm.BlockHashLookup; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -123,7 +124,7 @@ public class TransactionSimulator { protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(header), new BlockHashLookup(header, blockchain), false, - false); + TransactionValidationParams.transactionSimulator()); return Optional.of(new TransactionSimulatorResult(transaction, result)); } diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessorTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessorTest.java index 8c219cb891..36473ccf38 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessorTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionProcessorTest.java @@ -65,13 +65,12 @@ public class MainnetTransactionProcessorTest { } @Test - public void - shouldCallTransactionValidatorWithExpectedTransactionValidationParamsWhenNotPersistingState() { + public void shouldCallTransactionValidatorWithExpectedTransactionValidationParams() { final ArgumentCaptor txValidationParamCaptor = transactionValidationParamCaptor(); final TransactionValidationParams expectedValidationParams = - new TransactionValidationParams.Builder().checkOnchainPermissions(false).build(); + new TransactionValidationParams.Builder().build(); transactionProcessor.processTransaction( blockchain, @@ -81,30 +80,7 @@ public class MainnetTransactionProcessorTest { Address.fromHexString("1"), blockHashLookup, false, - false); - - assertThat(txValidationParamCaptor.getValue()) - .isEqualToComparingFieldByField(expectedValidationParams); - } - - @Test - public void - shouldCallTransactionValidatorWithExpectedTransactionValidationParamsWhenPersistingState() { - final ArgumentCaptor txValidationParamCaptor = - transactionValidationParamCaptor(); - - final TransactionValidationParams expectedValidationParams = - new TransactionValidationParams.Builder().checkOnchainPermissions(true).build(); - - transactionProcessor.processTransaction( - blockchain, - worldState, - blockHeader, - transaction, - Address.fromHexString("1"), - blockHashLookup, - true, - true); + new TransactionValidationParams.Builder().build()); assertThat(txValidationParamCaptor.getValue()) .isEqualToComparingFieldByField(expectedValidationParams); diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidatorTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidatorTest.java index 62d58f8d8b..d894c47641 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidatorTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetTransactionValidatorTest.java @@ -16,6 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import static tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE; import static tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT; @@ -193,6 +194,28 @@ public class MainnetTransactionValidatorTest { assertThat(stateChangeParamCaptor.getValue()).isTrue(); } + @Test + public void shouldNotCheckAccountPermissionIfBothValidationParamsCheckPermissionsAreFalse() { + final TransactionFilter transactionFilter = mock(TransactionFilter.class); + + final MainnetTransactionValidator validator = + new MainnetTransactionValidator(gasCalculator, false, Optional.empty()); + validator.setTransactionFilter(transactionFilter); + + final TransactionValidationParams validationParams = + new TransactionValidationParams.Builder() + .checkOnchainPermissions(false) + .checkLocalPermissions(false) + .build(); + + validator.validateForSender(basicTransaction, accountWithNonce(0), validationParams); + + assertThat(validator.validateForSender(basicTransaction, accountWithNonce(0), validationParams)) + .isEqualTo(ValidationResult.valid()); + + verifyZeroInteractions(transactionFilter); + } + private Account accountWithNonce(final long nonce) { return account(basicTransaction.getUpfrontCost(), nonce); } diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorTest.java index 2c6d5ef31f..da74019aa4 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorTest.java @@ -345,14 +345,14 @@ public class TransactionSimulatorTest { } when(transactionProcessor.processTransaction( - any(), any(), any(), eq(transaction), any(), any(), anyBoolean(), anyBoolean())) + any(), any(), any(), eq(transaction), any(), any(), anyBoolean(), any())) .thenReturn(result); } private void verifyTransactionWasProcessed(final Transaction expectedTransaction) { verify(transactionProcessor) .processTransaction( - any(), any(), any(), eq(expectedTransaction), any(), any(), anyBoolean(), anyBoolean()); + any(), any(), any(), eq(expectedTransaction), any(), any(), anyBoolean(), any()); } private CallParameter callParameter() { diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java index 85ee8d4736..3f2a2148c1 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java @@ -23,6 +23,7 @@ import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.core.WorldState; import tech.pegasys.pantheon.ethereum.core.WorldUpdater; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor; +import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidationParams; import tech.pegasys.pantheon.ethereum.rlp.RLP; import tech.pegasys.pantheon.ethereum.worldstate.DebuggableMutableWorldState; import tech.pegasys.pantheon.testutil.JsonTestParameters; @@ -117,7 +118,7 @@ public class GeneralStateReferenceTestTools { blockHeader.getCoinbase(), new BlockHashLookup(blockHeader, blockchain), false, - false); + TransactionValidationParams.processingBlock()); final Account coinbase = worldStateUpdater.getOrCreate(spec.blockHeader().getCoinbase()); if (coinbase != null && coinbase.isEmpty() && shouldClearEmptyAccounts(spec.eip())) { worldStateUpdater.deleteAccount(coinbase.getAddress()); diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPool.java index 22b862ffb9..8a6543f886 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPool.java @@ -204,12 +204,6 @@ public class TransactionPool implements BlockAddedObserver { transaction.getGasLimit(), chainHeadBlockHeader.getGasLimit())); } - final TransactionValidationParams validationParams = - new TransactionValidationParams.Builder() - .allowFutureNonce(true) - .checkOnchainPermissions(false) - .build(); - return protocolContext .getWorldStateArchive() .get(chainHeadBlockHeader.getStateRoot()) @@ -217,7 +211,8 @@ public class TransactionPool implements BlockAddedObserver { worldState -> { final Account senderAccount = worldState.get(transaction.getSender()); return getTransactionValidator() - .validateForSender(transaction, senderAccount, validationParams); + .validateForSender( + transaction, senderAccount, TransactionValidationParams.transactionPool()); }) .orElseGet(() -> ValidationResult.invalid(CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE)); } diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolTest.java index 6150ad98d8..9886299ee6 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolTest.java @@ -595,10 +595,7 @@ public class TransactionPoolTest { .thenReturn(valid()); final TransactionValidationParams expectedValidationParams = - new TransactionValidationParams.Builder() - .checkOnchainPermissions(false) - .allowFutureNonce(true) - .build(); + TransactionValidationParams.transactionPool(); transactionPool.addLocalTransaction(transaction1); diff --git a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/processor/BlockReplay.java b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/processor/BlockReplay.java index 1fc92a7eaa..96b2e75340 100644 --- a/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/processor/BlockReplay.java +++ b/ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/processor/BlockReplay.java @@ -22,6 +22,7 @@ import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSpec; import tech.pegasys.pantheon.ethereum.mainnet.TransactionProcessor; +import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidationParams; import tech.pegasys.pantheon.ethereum.vm.BlockHashLookup; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive; @@ -90,7 +91,7 @@ public class BlockReplay { spec.getMiningBeneficiaryCalculator().calculateBeneficiary(header), blockHashLookup, false, - false); + TransactionValidationParams.blockReplay()); } } return Optional.empty(); @@ -112,7 +113,7 @@ public class BlockReplay { spec.getMiningBeneficiaryCalculator().calculateBeneficiary(blockHeader), new BlockHashLookup(blockHeader, blockchain), false, - false); + TransactionValidationParams.blockReplay()); return action.performAction( transaction, blockHeader, blockchain, worldState, transactionProcessor); });