diff --git a/CHANGELOG.md b/CHANGELOG.md
index 786ddd1e..fdf2d21e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## Next release
+* feat: Report rejected transactions only due to trace limit overflows to an external service.
* feat: Report rejected transactions to an external service for validators used by LineaTransactionPoolValidatorPlugin [#85](https://github.com/Consensys/linea-sequencer/pull/85)
* feat: Report rejected transactions to an external service for LineaTransactionSelector used by LineaTransactionSelectorPlugin [#69](https://github.com/Consensys/linea-sequencer/pull/69)
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/LineaTransactionPoolValidatorFactory.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/LineaTransactionPoolValidatorFactory.java
index dc5759f1..a90d3ec8 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/LineaTransactionPoolValidatorFactory.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/LineaTransactionPoolValidatorFactory.java
@@ -80,11 +80,11 @@ public LineaTransactionPoolValidatorFactory(
public PluginTransactionPoolValidator createTransactionValidator() {
final var validators =
new PluginTransactionPoolValidator[] {
- new AllowedAddressValidator(denied, rejectedTxJsonRpcManager),
- new GasLimitValidator(txPoolValidatorConf, rejectedTxJsonRpcManager),
- new CalldataValidator(txPoolValidatorConf, rejectedTxJsonRpcManager),
+ new AllowedAddressValidator(denied),
+ new GasLimitValidator(txPoolValidatorConf),
+ new CalldataValidator(txPoolValidatorConf),
new ProfitabilityValidator(
- besuConfiguration, blockchainService, profitabilityConf, rejectedTxJsonRpcManager),
+ besuConfiguration, blockchainService, profitabilityConf),
new SimulationValidator(
blockchainService,
transactionSimulationService,
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/AllowedAddressValidator.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/AllowedAddressValidator.java
index a272ea7f..7f278dd8 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/AllowedAddressValidator.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/AllowedAddressValidator.java
@@ -48,15 +48,11 @@ public class AllowedAddressValidator implements PluginTransactionPoolValidator {
Address.fromHexString("0x000000000000000000000000000000000000000a"));
private final Set
denied;
- private final Optional rejectedTxJsonRpcManager;
@Override
public Optional validateTransaction(
final Transaction transaction, final boolean isLocal, final boolean hasPriority) {
- final Optional errMsg =
- validateSender(transaction).or(() -> validateRecipient(transaction));
- errMsg.ifPresent(reason -> reportRejectedTransaction(transaction, reason));
- return errMsg;
+ return validateSender(transaction).or(() -> validateRecipient(transaction));
}
private Optional validateRecipient(final Transaction transaction) {
@@ -90,19 +86,4 @@ private Optional validateSender(final Transaction transaction) {
}
return Optional.empty();
}
-
- private void reportRejectedTransaction(final Transaction transaction, final String reason) {
- rejectedTxJsonRpcManager.ifPresent(
- jsonRpcManager -> {
- final String jsonRpcCall =
- JsonRpcRequestBuilder.generateSaveRejectedTxJsonRpc(
- jsonRpcManager.getNodeType(),
- transaction,
- Instant.now(),
- Optional.empty(), // block number is not available
- reason,
- List.of());
- jsonRpcManager.submitNewJsonRpcCallAsync(jsonRpcCall);
- });
- }
}
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/CalldataValidator.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/CalldataValidator.java
index 7ecaf125..910e0301 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/CalldataValidator.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/CalldataValidator.java
@@ -31,7 +31,6 @@
@RequiredArgsConstructor
public class CalldataValidator implements PluginTransactionPoolValidator {
final LineaTransactionPoolValidatorConfiguration txPoolValidatorConf;
- final Optional rejectedTxJsonRpcManager;
@Override
public Optional validateTransaction(
@@ -41,24 +40,8 @@ public Optional validateTransaction(
"Calldata of transaction is greater than the allowed max of "
+ txPoolValidatorConf.maxTxCalldataSize();
log.debug(errMsg);
- reportRejectedTransaction(transaction, errMsg);
return Optional.of(errMsg);
}
return Optional.empty();
}
-
- private void reportRejectedTransaction(final Transaction transaction, final String reason) {
- rejectedTxJsonRpcManager.ifPresent(
- jsonRpcManager -> {
- final String jsonRpcCall =
- JsonRpcRequestBuilder.generateSaveRejectedTxJsonRpc(
- jsonRpcManager.getNodeType(),
- transaction,
- Instant.now(),
- Optional.empty(), // block number is not available
- reason,
- List.of());
- jsonRpcManager.submitNewJsonRpcCallAsync(jsonRpcCall);
- });
- }
}
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/GasLimitValidator.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/GasLimitValidator.java
index 7e2f9042..63e463d7 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/GasLimitValidator.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/GasLimitValidator.java
@@ -34,7 +34,6 @@
@RequiredArgsConstructor
public class GasLimitValidator implements PluginTransactionPoolValidator {
final LineaTransactionPoolValidatorConfiguration txPoolValidatorConf;
- final Optional rejectedTxJsonRpcManager;
@Override
public Optional validateTransaction(
@@ -44,24 +43,8 @@ public Optional validateTransaction(
"Gas limit of transaction is greater than the allowed max of "
+ txPoolValidatorConf.maxTxGasLimit();
log.debug(errMsg);
- reportRejectedTransaction(transaction, errMsg);
return Optional.of(errMsg);
}
return Optional.empty();
}
-
- private void reportRejectedTransaction(final Transaction transaction, final String reason) {
- rejectedTxJsonRpcManager.ifPresent(
- jsonRpcManager -> {
- final String jsonRpcCall =
- JsonRpcRequestBuilder.generateSaveRejectedTxJsonRpc(
- jsonRpcManager.getNodeType(),
- transaction,
- Instant.now(),
- Optional.empty(), // block number is not available
- reason,
- List.of());
- jsonRpcManager.submitNewJsonRpcCallAsync(jsonRpcCall);
- });
- }
}
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/ProfitabilityValidator.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/ProfitabilityValidator.java
index 8b91452f..cab127ac 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/ProfitabilityValidator.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/ProfitabilityValidator.java
@@ -41,18 +41,15 @@ public class ProfitabilityValidator implements PluginTransactionPoolValidator {
final BlockchainService blockchainService;
final LineaProfitabilityConfiguration profitabilityConf;
final TransactionProfitabilityCalculator profitabilityCalculator;
- final Optional rejectedTxJsonRpcManager;
public ProfitabilityValidator(
final BesuConfiguration besuConfiguration,
final BlockchainService blockchainService,
- final LineaProfitabilityConfiguration profitabilityConf,
- final Optional rejectedTxJsonRpcManager) {
+ final LineaProfitabilityConfiguration profitabilityConf) {
this.besuConfiguration = besuConfiguration;
this.blockchainService = blockchainService;
this.profitabilityConf = profitabilityConf;
this.profitabilityCalculator = new TransactionProfitabilityCalculator(profitabilityConf);
- this.rejectedTxJsonRpcManager = rejectedTxJsonRpcManager;
}
@Override
@@ -68,8 +65,7 @@ public Optional validateTransaction(
.getNextBlockBaseFee()
.orElseThrow(() -> new RuntimeException("We only support a base fee market"));
- final Optional errMsg =
- profitabilityCalculator.isProfitable(
+ return profitabilityCalculator.isProfitable(
"Txpool",
transaction,
profitabilityConf.txPoolMinMargin(),
@@ -79,8 +75,6 @@ public Optional validateTransaction(
besuConfiguration.getMinGasPrice())
? Optional.empty()
: Optional.of("Gas price too low");
- errMsg.ifPresent(s -> reportRejectedTransaction(transaction, s));
- return errMsg;
}
return Optional.empty();
@@ -98,19 +92,4 @@ private Wei calculateUpfrontGasPrice(final Transaction transaction, final Wei ba
baseFee.add(Wei.fromQuantity(transaction.getMaxPriorityFeePerGas().get()))))
.orElseGet(() -> Wei.fromQuantity(transaction.getGasPrice().get()));
}
-
- private void reportRejectedTransaction(final Transaction transaction, final String reason) {
- rejectedTxJsonRpcManager.ifPresent(
- jsonRpcManager -> {
- final String jsonRpcCall =
- JsonRpcRequestBuilder.generateSaveRejectedTxJsonRpc(
- jsonRpcManager.getNodeType(),
- transaction,
- Instant.now(),
- Optional.empty(), // block number is not available
- reason,
- List.of());
- jsonRpcManager.submitNewJsonRpcCallAsync(jsonRpcCall);
- });
- }
}
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/SimulationValidator.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/SimulationValidator.java
index 991e40a7..75204eb6 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/SimulationValidator.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/validators/SimulationValidator.java
@@ -111,7 +111,6 @@ public Optional validateTransaction(
"Invalid transaction"
+ simulationResult.getInvalidReason().map(ir -> ": " + ir).orElse("");
log.debug(errMsg);
- reportRejectedTransaction(transaction, errMsg);
return Optional.of(errMsg);
}
}
diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java
index a396b83f..37ff167c 100644
--- a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java
+++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java
@@ -14,10 +14,16 @@
*/
package net.consensys.linea.sequencer.txselection.selectors;
+import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.BLOCK_MODULE_LINE_COUNT_FULL;
+import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.TX_MODULE_LINE_COUNT_OVERFLOW;
+import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.TX_MODULE_LINE_COUNT_OVERFLOW_CACHED;
+
import java.time.Instant;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.config.LineaProfitabilityConfiguration;
@@ -41,6 +47,7 @@ public class LineaTransactionSelector implements PluginTransactionSelector {
private TraceLineLimitTransactionSelector traceLineLimitTransactionSelector;
private final List selectors;
private final Optional rejectedTxJsonRpcManager;
+ private final Set rejectedTransactionReasonsMap = new HashSet<>();
public LineaTransactionSelector(
final BlockchainService blockchainService,
@@ -51,6 +58,14 @@ public LineaTransactionSelector(
final Map limitsMap,
final Optional rejectedTxJsonRpcManager) {
this.rejectedTxJsonRpcManager = rejectedTxJsonRpcManager;
+
+ // only report rejected transaction selection result from TraceLineLimitTransactionSelector
+ if (rejectedTxJsonRpcManager.isPresent()) {
+ rejectedTransactionReasonsMap.add(TX_MODULE_LINE_COUNT_OVERFLOW.toString());
+ rejectedTransactionReasonsMap.add(TX_MODULE_LINE_COUNT_OVERFLOW_CACHED.toString());
+ rejectedTransactionReasonsMap.add(BLOCK_MODULE_LINE_COUNT_FULL.toString());
+ }
+
selectors =
createTransactionSelectors(
blockchainService,
@@ -163,7 +178,8 @@ public void onTransactionNotSelected(
rejectedTxJsonRpcManager.ifPresent(
jsonRpcManager -> {
- if (transactionSelectionResult.discard()) {
+ if (transactionSelectionResult.discard()
+ && rejectedTransactionReasonsMap.contains(transactionSelectionResult.toString())) {
jsonRpcManager.submitNewJsonRpcCallAsync(
JsonRpcRequestBuilder.generateSaveRejectedTxJsonRpc(
jsonRpcManager.getNodeType(),