Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

If nonce is invalid, do not delete during mining #1422

Merged
merged 4 commits into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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.TransactionValidator.TransactionInvalidReason;
import tech.pegasys.pantheon.ethereum.vm.BlockHashLookup;

import java.util.List;
Expand All @@ -43,10 +44,10 @@
* <p>The output from this class's exeuction will be:
*
* <ul>
* <li>A list of transactions to include in the block being constructed.
* <li>A list of receipts for inclusion in the block.
* <li>The root hash of the world state at the completion of transaction execution.
* <li>The amount of gas consumed when executing all transactions.
* <li>A list of transactions to include in the block being constructed.
* <li>A list of receipts for inclusion in the block.
* <li>The root hash of the world state at the completion of transaction execution.
* <li>The amount of gas consumed when executing all transactions.
* </ul>
*
* Once "used" this class must be discarded and another created. This class contains state which is
Expand All @@ -59,6 +60,7 @@ public class BlockTransactionSelector {
private static final double MIN_BLOCK_OCCUPANCY_RATIO = 0.8;

public static class TransactionSelectionResults {

private final List<Transaction> transactions = Lists.newArrayList();
private final List<TransactionReceipt> receipts = Lists.newArrayList();
private long cumulativeGasUsed = 0;
Expand Down Expand Up @@ -172,8 +174,12 @@ private TransactionSelectionResult evaluateTransaction(final Transaction transac
worldStateUpdater.commit();
updateTransactionResultTracking(transaction, result);
} else {
// Remove invalid transactions from the transaction pool but continue looking for valid ones
// as the block may not yet be full.
// If the transaction has an incorrect nonce, leave it in the pool and continue
if (result.getValidationResult().getInvalidReason()
.equals(TransactionInvalidReason.INCORRECT_NONCE)) {
return TransactionSelectionResult.CONTINUE;
}
// If the transaction was invalid for any other reason, delete it, and continue.
return TransactionSelectionResult.DELETE_TRANSACTION_AND_CONTINUE;
}
return TransactionSelectionResult.CONTINUE;
Expand Down
Loading