Skip to content

Commit

Permalink
feat: enable creation of traces output directory on GenerateConflated…
Browse files Browse the repository at this point in the history
…TracesV2 RPC endpoint and set it up as a CLI option (#830)


Resolves: #829 
Signed-off-by: Tsvetan Dimitrov <[email protected]>
  • Loading branch information
powerslider authored Jul 9, 2024
1 parent 9ed01f5 commit 419f654
Show file tree
Hide file tree
Showing 35 changed files with 107 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea;
package net.consensys.linea.plugins;

import lombok.extern.slf4j.Slf4j;
import org.hyperledger.besu.plugin.BesuContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea;
package net.consensys.linea.plugins;

import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.config.LineaTracerCliOptions;
import net.consensys.linea.config.LineaTracerConfiguration;
import net.consensys.linea.plugins.config.LineaTracerCliOptions;
import net.consensys.linea.plugins.config.LineaTracerConfiguration;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.config;
package net.consensys.linea.plugins.config;

import com.google.common.base.MoreObjects;
import net.consensys.linea.config.converters.AddressConverter;
import net.consensys.linea.config.converters.BytesConverter;
import net.consensys.linea.plugins.config.converters.AddressConverter;
import net.consensys.linea.plugins.config.converters.BytesConverter;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.datatypes.Address;
import picocli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.config;
package net.consensys.linea.plugins.config;

import lombok.Builder;
import org.apache.tuweni.bytes.Bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.config;
package net.consensys.linea.plugins.config;

import com.google.common.base.MoreObjects;
import picocli.CommandLine;
Expand All @@ -21,6 +21,8 @@ public class LineaTracerCliOptions {

public static final String MODULE_LIMIT_FILE_PATH = "--plugin-linea-module-limit-file-path";
public static final String DEFAULT_MODULE_LIMIT_FILE_PATH = "moduleLimitFile.toml";
public static final String CONFLATED_TRACE_GENERATION_TRACES_OUTPUT_PATH =
"--plugin-linea-conflated-trace-generation-traces-output-path";

@CommandLine.Option(
names = {MODULE_LIMIT_FILE_PATH},
Expand All @@ -30,6 +32,13 @@ public class LineaTracerCliOptions {
"Path to the toml file containing the module limits (default: ${DEFAULT-VALUE})")
private String moduleLimitFilePath = DEFAULT_MODULE_LIMIT_FILE_PATH;

@CommandLine.Option(
names = {CONFLATED_TRACE_GENERATION_TRACES_OUTPUT_PATH},
hidden = true,
paramLabel = "<PATH>",
description = "Path to where traces will be written")
private String tracesOutputPath = null;

private LineaTracerCliOptions() {}

/**
Expand All @@ -50,6 +59,7 @@ public static LineaTracerCliOptions create() {
public static LineaTracerCliOptions fromConfig(final LineaTracerConfiguration config) {
final LineaTracerCliOptions options = create();
options.moduleLimitFilePath = config.moduleLimitsFilePath();
options.tracesOutputPath = config.tracesOutputPath();
return options;
}

Expand All @@ -59,13 +69,17 @@ public static LineaTracerCliOptions fromConfig(final LineaTracerConfiguration co
* @return the Linea factory configuration
*/
public LineaTracerConfiguration toDomainObject() {
return LineaTracerConfiguration.builder().moduleLimitsFilePath(moduleLimitFilePath).build();
return LineaTracerConfiguration.builder()
.tracesOutputPath(tracesOutputPath)
.moduleLimitsFilePath(moduleLimitFilePath)
.build();
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add(MODULE_LIMIT_FILE_PATH, moduleLimitFilePath)
.add(CONFLATED_TRACE_GENERATION_TRACES_OUTPUT_PATH, tracesOutputPath)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.config;
package net.consensys.linea.plugins.config;

import lombok.Builder;

/** The Linea tracer configuration. */
@Builder(toBuilder = true)
public record LineaTracerConfiguration(String moduleLimitsFilePath) {}
public record LineaTracerConfiguration(String moduleLimitsFilePath, String tracesOutputPath) {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.config.converters;
package net.consensys.linea.plugins.config.converters;

import org.hyperledger.besu.datatypes.Address;
import picocli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.config.converters;
package net.consensys.linea.plugins.config.converters;

import org.apache.tuweni.bytes.Bytes;
import picocli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.config.converters;
package net.consensys.linea.plugins.config.converters;

import java.math.BigInteger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -21,10 +21,10 @@
import java.util.Optional;

import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.continoustracing.exception.InvalidBlockTraceException;
import net.consensys.linea.continoustracing.exception.TraceOutputException;
import net.consensys.linea.continoustracing.exception.TraceVerificationException;
import net.consensys.linea.corset.CorsetValidator;
import net.consensys.linea.plugins.exception.InvalidBlockTraceException;
import net.consensys.linea.plugins.exception.TraceOutputException;
import net.consensys.linea.plugins.exception.TraceVerificationException;
import net.consensys.linea.zktracer.ZkTracer;
import org.apache.commons.io.FileUtils;
import org.hyperledger.besu.datatypes.Hash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -22,10 +22,10 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.continoustracing.exception.InvalidBlockTraceException;
import net.consensys.linea.continoustracing.exception.InvalidTraceHandlerException;
import net.consensys.linea.continoustracing.exception.TraceVerificationException;
import net.consensys.linea.corset.CorsetValidator;
import net.consensys.linea.plugins.exception.InvalidBlockTraceException;
import net.consensys.linea.plugins.exception.InvalidTraceHandlerException;
import net.consensys.linea.plugins.exception.TraceVerificationException;
import net.consensys.linea.zktracer.ZkTracer;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.plugin.data.AddedBlockContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import com.google.common.base.MoreObjects;
import picocli.CommandLine;
Expand All @@ -24,7 +24,7 @@ public class ContinuousTracingCliOptions {
"--plugin-linea-continuous-tracing-zk-evm-bin";

public static final String CONTINUOUS_TRACING_TRACES_DIR =
"--plugin-linea-continuous-tracing-traces-dir";
"--plugin-linea-continuous-tracing-traces-output-path";

@CommandLine.Option(
names = {CONTINUOUS_TRACING_ENABLED},
Expand All @@ -45,7 +45,7 @@ public class ContinuousTracingCliOptions {
hidden = true,
paramLabel = "<PATH>",
description = "Path to where traces will be written")
private String tracesDir = null;
private String tracesOutputPath = null;

private ContinuousTracingCliOptions() {}

Expand All @@ -54,15 +54,15 @@ public static ContinuousTracingCliOptions create() {
}

public ContinuousTracingConfiguration toDomainObject() {
return new ContinuousTracingConfiguration(continuousTracingEnabled, zkEvmBin, tracesDir);
return new ContinuousTracingConfiguration(continuousTracingEnabled, zkEvmBin, tracesOutputPath);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add(CONTINUOUS_TRACING_ENABLED, continuousTracingEnabled)
.add(CONTINUOUS_TRACING_ZK_EVM_BIN, zkEvmBin)
.add(CONTINUOUS_TRACING_TRACES_DIR, tracesDir)
.add(CONTINUOUS_TRACING_TRACES_DIR, tracesOutputPath)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

public record ContinuousTracingConfiguration(
boolean continuousTracing, String zkEvmBin, String tracesDir) {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import static com.slack.api.model.block.Blocks.asBlocks;
import static com.slack.api.model.block.Blocks.divider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing;
package net.consensys.linea.plugins.continoustracing;

import java.io.IOException;

import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.continoustracing.exception.InvalidTraceHandlerException;
import net.consensys.linea.corset.CorsetValidator;
import net.consensys.linea.plugins.exception.InvalidTraceHandlerException;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.plugin.data.BlockHeader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing.exception;
package net.consensys.linea.plugins.exception;

import org.hyperledger.besu.datatypes.Hash;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing.exception;
package net.consensys.linea.plugins.exception;

public class InvalidTraceHandlerException extends Throwable {
public InvalidTraceHandlerException(Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing.exception;
package net.consensys.linea.plugins.exception;

public class TraceOutputException extends RuntimeException {
public TraceOutputException(final String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.continoustracing.exception;
package net.consensys.linea.plugins.exception;

import org.hyperledger.besu.datatypes.Hash;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.capture;
package net.consensys.linea.plugins.rpc.capture;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.capture;
package net.consensys.linea.plugins.rpc.capture;

import java.util.Optional;

import com.google.auto.service.AutoService;
import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.AbstractLineaRequiredPlugin;
import net.consensys.linea.plugins.AbstractLineaRequiredPlugin;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.capture;
package net.consensys.linea.plugins.rpc.capture;

import java.security.InvalidParameterException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.capture;
package net.consensys.linea.plugins.rpc.capture;

import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.counters;
package net.consensys.linea.plugins.rpc.counters;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.counters;
package net.consensys.linea.plugins.rpc.counters;

import com.google.auto.service.AutoService;
import net.consensys.linea.AbstractLineaSharedOptionsPlugin;
import net.consensys.linea.plugins.AbstractLineaSharedOptionsPlugin;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.counters;
package net.consensys.linea.plugins.rpc.counters;

import java.security.InvalidParameterException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.rpc.counters;
package net.consensys.linea.plugins.rpc.counters;

import java.security.InvalidParameterException;
import java.util.Map;
Expand Down
Loading

0 comments on commit 419f654

Please sign in to comment.