Skip to content

Commit

Permalink
fix: check that spilling and limits file contain all counted modules (#…
Browse files Browse the repository at this point in the history
…592)

Fixes #511

Signed-off-by: franklin.delehelle@consensys.net
  • Loading branch information
delehef authored and letypequividelespoubelles committed Feb 21, 2024
1 parent b34b1fe commit ae5de88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.zktracer.ZkTracer;
import net.consensys.linea.zktracer.module.Module;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.PendingTransaction;
import org.hyperledger.besu.datatypes.Transaction;
Expand Down Expand Up @@ -62,6 +63,12 @@ public TraceLineLimitTransactionSelector(
final int overLimitCacheSize) {
this.moduleLimits = moduleLimits;
zkTracer = new ZkTracerWithLog();
for (Module m : zkTracer.getHub().getModulesToCount()) {
if (!moduleLimits.containsKey(m.moduleKey())) {
throw new IllegalStateException(
"Limit for module %s not defined in %s".formatted(m.moduleKey(), limitFilePath));
}
}
zkTracer.traceStartConflation(1L);
this.limitFilePath = limitFilePath;
this.overLimitCacheSize = overLimitCacheSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public ZkTracer() {
Toml.parse(getClass().getClassLoader().getResourceAsStream("spillings.toml"))
.getTable("spillings");
table.toMap().keySet().forEach(k -> spillings.put(k, Math.toIntExact(table.getLong(k))));

for (Module m : this.hub.getModulesToCount()) {
if (!this.spillings.containsKey(m.moduleKey())) {
throw new IllegalStateException(
"Spilling for module " + m.moduleKey() + " not defined in spillings.toml");
}
}
} catch (final Exception e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit ae5de88

Please sign in to comment.