Dedicated log marker for invalid txs removed from the txpool (#6826)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
pull/6846/head
Fabio Di Fabio 8 months ago committed by GitHub
parent ad49e21bf0
commit 1679525ae2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 3
      besu/src/main/resources/log4j2.xml
  3. 22
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java
  4. 22
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java

@ -27,8 +27,10 @@
- Extend error handling of plugin RPC methods [#6759](https://github.com/hyperledger/besu/pull/6759)
- Added engine_newPayloadV4 and engine_getPayloadV4 methods [#6783](https://github.com/hyperledger/besu/pull/6783)
- Reduce storage size of receipts [#6602](https://github.com/hyperledger/besu/pull/6602)
- Dedicated log marker for invalid txs removed from the txpool [#6826](https://github.com/hyperledger/besu/pull/6826)
- Prevent startup with BONSAI and privacy enabled [#6809](https://github.com/hyperledger/besu/pull/6809)
### Bug fixes
- Fix txpool dump/restore race condition [#6665](https://github.com/hyperledger/besu/pull/6665)
- Make block transaction selection max time aware of PoA transitions [#6676](https://github.com/hyperledger/besu/pull/6676)

@ -48,6 +48,9 @@
<Logger name="io.vertx.core.dns.DnsException">
<RegexFilter regex="DNS query error occurred:.*" onMatch="DENY" onMismatch="NEUTRAL" />
</Logger>
<Logger name="org.hyperledger.besu.ethereum.eth.transactions">
<MarkerFilter marker="INVALID_TX_REMOVED" onMatch="DENY" onMismatch="NEUTRAL" />
</Logger>
<Root level="${sys:root.log.level}">
<AppenderRef ref="Router" />
</Root>

@ -37,6 +37,7 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;
import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
import java.util.ArrayDeque;
import java.util.ArrayList;
@ -53,10 +54,13 @@ import java.util.stream.Collectors;
import kotlin.ranges.LongRange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
public class LayeredPendingTransactions implements PendingTransactions {
private static final Logger LOG = LoggerFactory.getLogger(LayeredPendingTransactions.class);
private static final Logger LOG_FOR_REPLAY = LoggerFactory.getLogger("LOG_FOR_REPLAY");
private static final Marker INVALID_TX_REMOVED = MarkerFactory.getMarker("INVALID_TX_REMOVED");
private final TransactionPoolConfiguration poolConfig;
private final AbstractPrioritizedTransactions prioritizedTransactions;
@ -234,7 +238,8 @@ public class LayeredPendingTransactions implements PendingTransactions {
.log();
}
private void logTransactionForReplayDelete(final PendingTransaction pendingTransaction) {
private void logDiscardedTransaction(
final PendingTransaction pendingTransaction, final TransactionSelectionResult result) {
// csv fields: sequence, addedAt, sender, nonce, type, hash, rlp
LOG_FOR_REPLAY
.atTrace()
@ -252,6 +257,19 @@ public class LayeredPendingTransactions implements PendingTransactions {
return rlp.encoded().toHexString();
})
.log();
LOG.atInfo()
.addMarker(INVALID_TX_REMOVED)
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
.addKeyValue("reason", result)
.addKeyValue(
"txrlp",
() -> {
final BytesValueRLPOutput rlp = new BytesValueRLPOutput();
pendingTransaction.getTransaction().writeTo(rlp);
return rlp.encoded().toHexString();
})
.log();
}
private TransactionAddedResult nonceChecks(
@ -333,7 +351,7 @@ public class LayeredPendingTransactions implements PendingTransactions {
if (res.discard()) {
invalidTransactions.add(candidatePendingTx);
logTransactionForReplayDelete(candidatePendingTx);
logDiscardedTransaction(candidatePendingTx, res);
}
if (res.stop()) {

@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionAddedResult;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolReplacementHandler;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;
import org.hyperledger.besu.metrics.BesuMetricCategory;
@ -61,6 +62,8 @@ import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
/**
* Holds the current set of pending transactions with the ability to iterate them based on priority
@ -71,6 +74,7 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractPendingTransactionsSorter implements PendingTransactions {
private static final Logger LOG =
LoggerFactory.getLogger(AbstractPendingTransactionsSorter.class);
private static final Marker INVALID_TX_REMOVED = MarkerFactory.getMarker("INVALID_TX_REMOVED");
protected final Clock clock;
protected final TransactionPoolConfiguration poolConfig;
@ -247,6 +251,7 @@ public abstract class AbstractPendingTransactionsSorter implements PendingTransa
if (result.discard()) {
transactionsToRemove.add(transactionToProcess.getTransaction());
logDiscardedTransaction(transactionToProcess, result);
}
if (result.stop()) {
@ -259,6 +264,23 @@ public abstract class AbstractPendingTransactionsSorter implements PendingTransa
}
}
private void logDiscardedTransaction(
final PendingTransaction pendingTransaction, final TransactionSelectionResult result) {
LOG.atInfo()
.addMarker(INVALID_TX_REMOVED)
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
.addKeyValue("reason", result)
.addKeyValue(
"txrlp",
() -> {
final BytesValueRLPOutput rlp = new BytesValueRLPOutput();
pendingTransaction.getTransaction().writeTo(rlp);
return rlp.encoded().toHexString();
})
.log();
}
private AccountTransactionOrder createSenderTransactionOrder(final Address address) {
return new AccountTransactionOrder(
transactionsBySender.get(address).streamPendingTransactions());

Loading…
Cancel
Save