diff --git a/arithmetization/src/main/java/net/consensys/linea/rpc/linea/LineaEndpointServicePlugin.java b/arithmetization/src/main/java/net/consensys/linea/rpc/linea/LineaEndpointServicePlugin.java index f5cc8adb..0aab37ab 100644 --- a/arithmetization/src/main/java/net/consensys/linea/rpc/linea/LineaEndpointServicePlugin.java +++ b/arithmetization/src/main/java/net/consensys/linea/rpc/linea/LineaEndpointServicePlugin.java @@ -15,7 +15,7 @@ package net.consensys.linea.rpc.linea; -import static net.consensys.linea.sequencer.modulelimit.LimitModuleHelper.createLimitModules; +import static net.consensys.linea.sequencer.modulelimit.ModuleLineCountValidator.createLimitModules; import com.google.auto.service.AutoService; import lombok.extern.slf4j.Slf4j; diff --git a/arithmetization/src/main/java/net/consensys/linea/sequencer/TracerAggregator.java b/arithmetization/src/main/java/net/consensys/linea/sequencer/TracerAggregator.java index 05410fa5..e9733312 100644 --- a/arithmetization/src/main/java/net/consensys/linea/sequencer/TracerAggregator.java +++ b/arithmetization/src/main/java/net/consensys/linea/sequencer/TracerAggregator.java @@ -53,23 +53,6 @@ public void register(OperationTracer tracer) { tracers.add(tracer); } - /** - * Retrieves a registered tracer by its class type. - * - * @param clazz the class of the tracer to retrieve - * @param the type of the tracer - * @return the registered tracer of the specified type - * @throws IllegalArgumentException if no tracer of the specified class is registered - */ - public T getTracer(Class clazz) { - for (OperationTracer tracer : tracers) { - if (clazz.isInstance(tracer)) { - return clazz.cast(tracer); - } - } - throw new IllegalArgumentException("No tracer found for class: " + clazz.getName()); - } - /** * Creates a {@link TracerAggregator} instance and registers the provided tracers. * diff --git a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/LimitModuleHelper.java b/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/LimitModuleHelper.java deleted file mode 100644 index 385db6b1..00000000 --- a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/LimitModuleHelper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Consensys Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package net.consensys.linea.sequencer.modulelimit; - -import java.io.File; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.stream.Collectors; - -import com.google.common.io.Resources; -import lombok.extern.slf4j.Slf4j; -import net.consensys.linea.config.LineaTracerConfiguration; -import org.apache.tuweni.toml.Toml; -import org.apache.tuweni.toml.TomlParseResult; -import org.apache.tuweni.toml.TomlTable; - -@Slf4j -public class LimitModuleHelper { - public static Map createLimitModules( - LineaTracerConfiguration lineaTracerConfiguration) { - try { - URL url = new File(lineaTracerConfiguration.moduleLimitsFilePath()).toURI().toURL(); - final String tomlString = Resources.toString(url, StandardCharsets.UTF_8); - TomlParseResult result = Toml.parse(tomlString); - final TomlTable table = result.getTable("traces-limits"); - final Map limitsMap = - table.toMap().entrySet().stream() - .collect( - Collectors.toUnmodifiableMap( - Map.Entry::getKey, e -> Math.toIntExact((Long) e.getValue()))); - - return limitsMap; - } catch (final Exception e) { - final String errorMsg = - "Problem reading the toml file containing the limits for the modules: " - + lineaTracerConfiguration.moduleLimitsFilePath(); - log.error(errorMsg); - throw new RuntimeException(errorMsg, e); - } - } -} diff --git a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLimitsValidationResult.java b/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLimitsValidationResult.java index 1439eb00..e5ca09fb 100644 --- a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLimitsValidationResult.java +++ b/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLimitsValidationResult.java @@ -29,7 +29,7 @@ private ModuleLimitsValidationResult( this.moduleName = moduleName; } - public static ModuleLimitsValidationResult ok() { + public static ModuleLimitsValidationResult valid() { return new ModuleLimitsValidationResult( ModuleLineCountValidator.ModuleLineCountResult.VALID, null); } diff --git a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLineCountValidator.java b/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLineCountValidator.java index e6055e83..0600f318 100644 --- a/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLineCountValidator.java +++ b/arithmetization/src/main/java/net/consensys/linea/sequencer/modulelimit/ModuleLineCountValidator.java @@ -14,11 +14,20 @@ */ package net.consensys.linea.sequencer.modulelimit; +import java.io.File; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; +import com.google.common.io.Resources; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import net.consensys.linea.config.LineaTracerConfiguration; +import org.apache.tuweni.toml.Toml; +import org.apache.tuweni.toml.TomlParseResult; +import org.apache.tuweni.toml.TomlTable; /** * Accumulates and verifies line counts for modules based on provided limits. It supports verifying @@ -70,7 +79,7 @@ public ModuleLimitsValidationResult validate(Map currentAccumul return ModuleLimitsValidationResult.blockModuleLineCountFull(moduleName); } } - return ModuleLimitsValidationResult.ok(); + return ModuleLimitsValidationResult.valid(); } /** @@ -90,4 +99,27 @@ public enum ModuleLineCountResult { BLOCK_MODULE_LINE_COUNT_FULL, MODULE_NOT_DEFINED } + + public static Map createLimitModules( + LineaTracerConfiguration lineaTracerConfiguration) { + try { + URL url = new File(lineaTracerConfiguration.moduleLimitsFilePath()).toURI().toURL(); + final String tomlString = Resources.toString(url, StandardCharsets.UTF_8); + TomlParseResult result = Toml.parse(tomlString); + final TomlTable table = result.getTable("traces-limits"); + final Map limitsMap = + table.toMap().entrySet().stream() + .collect( + Collectors.toUnmodifiableMap( + Map.Entry::getKey, e -> Math.toIntExact((Long) e.getValue()))); + + return limitsMap; + } catch (final Exception e) { + final String errorMsg = + "Problem reading the toml file containing the limits for the modules: " + + lineaTracerConfiguration.moduleLimitsFilePath(); + log.error(errorMsg); + throw new RuntimeException(errorMsg, e); + } + } } diff --git a/arithmetization/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java b/arithmetization/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java index 65377ccf..edcfeb09 100644 --- a/arithmetization/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java +++ b/arithmetization/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java @@ -15,7 +15,7 @@ package net.consensys.linea.sequencer.txselection; -import static net.consensys.linea.sequencer.modulelimit.LimitModuleHelper.createLimitModules; +import static net.consensys.linea.sequencer.modulelimit.ModuleLineCountValidator.createLimitModules; import java.util.Optional;