Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix log of line counts in case of block limit reached + minor changes #555

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -31,8 +31,8 @@
@Slf4j
public class LineaTransactionSelector implements PluginTransactionSelector {

private static TraceLineLimitTransactionSelector traceLineLimitTransactionSelector;
List<PluginTransactionSelector> selectors;
private TraceLineLimitTransactionSelector traceLineLimitTransactionSelector;
private List<PluginTransactionSelector> selectors;

public LineaTransactionSelector(
LineaTransactionSelectorConfiguration lineaConfiguration,
Expand All @@ -47,7 +47,7 @@ public LineaTransactionSelector(
* @param limitsMapSupplier The supplier for the limits map.
* @return A list of selectors.
*/
private static List<PluginTransactionSelector> createTransactionSelectors(
private List<PluginTransactionSelector> createTransactionSelectors(
final LineaTransactionSelectorConfiguration lineaConfiguration,
final Supplier<Map<String, Integer>> limitsMapSupplier) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public TransactionSelectionResult evaluateTransactionPostProcessing(

if (margin < minMargin) {
log(
log.atInfo(),
log.atDebug(),
transaction,
margin,
effectiveGasPrice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class TraceLineLimitTransactionSelector implements PluginTransactionSelec
private final ZkTracer zkTracer;
private final String limitFilePath;
private final Map<String, Integer> moduleLimits;
private Map<String, Integer> prevCumulatedLineCount = Map.of();
private Map<String, Integer> consolidatedCumulatedLineCount = Map.of();
private Map<String, Integer> currCumulatedLineCount;

public TraceLineLimitTransactionSelector(
Expand Down Expand Up @@ -81,7 +81,7 @@ public void onTransactionNotSelected(
public void onTransactionSelected(
final TransactionEvaluationContext<? extends PendingTransaction> evaluationContext,
final TransactionProcessingResult processingResult) {
prevCumulatedLineCount = currCumulatedLineCount;
consolidatedCumulatedLineCount = currCumulatedLineCount;
}

/**
Expand Down Expand Up @@ -120,7 +120,7 @@ public TransactionSelectionResult evaluateTransactionPostProcessing(

final int cumulatedModuleLineCount = currCumulatedLineCount.get(module);
final int txModuleLineCount =
cumulatedModuleLineCount - prevCumulatedLineCount.getOrDefault(module, 0);
cumulatedModuleLineCount - consolidatedCumulatedLineCount.getOrDefault(module, 0);

if (txModuleLineCount > moduleLineCountLimit) {
log.warn(
Expand Down Expand Up @@ -158,7 +158,7 @@ private String logTxLineCount() {
// tx line count / cumulated line count / line count limit
e.getKey()
+ "="
+ (e.getValue() - prevCumulatedLineCount.getOrDefault(e.getKey(), 0))
+ (e.getValue() - consolidatedCumulatedLineCount.getOrDefault(e.getKey(), 0))
+ "/"
+ e.getValue()
+ "/"
Expand All @@ -177,12 +177,10 @@ public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBo
.addKeyValue(
"traceCounts",
() ->
currCumulatedLineCount == null
? "null"
: currCumulatedLineCount.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(e -> '"' + e.getKey() + "\":" + e.getValue())
.collect(Collectors.joining(",")))
consolidatedCumulatedLineCount.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(e -> '"' + e.getKey() + "\":" + e.getValue())
.collect(Collectors.joining(",")))
.log();
}
}
Expand Down
Loading