Skip to content

Commit

Permalink
fix:clean code 1
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <[email protected]>
  • Loading branch information
GrapeBaBa committed Sep 10, 2024
1 parent 6ce2663 commit 0c12598
Show file tree
Hide file tree
Showing 92 changed files with 202 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/optimism/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import ch.qos.logback.classic.Level;
import io.micrometer.tracing.Tracer;
import io.optimism.cli.typeconverter.SyncModeConverter;
import io.optimism.common.HildrServiceExecutionException;
import io.optimism.config.Config;
import io.optimism.exceptions.HildrServiceExecutionException;
import io.optimism.runner.Runner;
import io.optimism.telemetry.InnerMetrics;
import io.optimism.telemetry.Logging;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/optimism/cli/LogLevelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LogLevelConverter implements CommandLine.ITypeConverter<ch.qos.logb
public LogLevelConverter() {}

@Override
public Level convert(String value) throws Exception {
public Level convert(String value) {
return StringUtils.isEmpty(value) ? Level.DEBUG : Level.valueOf(value);
}
}
5 changes: 3 additions & 2 deletions src/main/java/io/optimism/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.optimism.common.BlockInfo;
import io.optimism.type.Epoch;
import io.optimism.exceptions.ConfigLoadException;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/optimism/derive/State.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.optimism.derive;

import io.optimism.common.BlockInfo;
import io.optimism.config.Config;
import io.optimism.driver.HeadInfo;
import io.optimism.driver.L1AttributesDepositedTxNotFoundException;
import io.optimism.l1.L1Info;
import io.optimism.type.Epoch;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import java.math.BigInteger;
import java.util.Map.Entry;
import java.util.TreeMap;
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/optimism/derive/stages/Attributes.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package io.optimism.derive.stages;

import io.optimism.common.BlockInfo;
import io.optimism.common.BlockNotIncludedException;
import io.optimism.config.Config;
import io.optimism.config.Config.SystemAccounts;
import io.optimism.derive.ForkUpgradeTransactions;
import io.optimism.derive.PurgeableIterator;
import io.optimism.derive.State;
import io.optimism.engine.ExecutionPayload.PayloadAttributes;
import io.optimism.exceptions.BlockNotIncludedException;
import io.optimism.exceptions.L1InfoNotFoundException;
import io.optimism.l1.L1Info;
import io.optimism.type.Epoch;
import io.optimism.types.Batch;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import io.optimism.types.SingularBatch;
import io.optimism.utilities.gas.GasCalculator;
import java.math.BigInteger;
import java.nio.ByteBuffer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.optimism.derive.stages;

import io.optimism.derive.PurgeableIterator;
import io.optimism.types.Frame;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand All @@ -17,9 +18,9 @@
* @since 0.1.0
*/
public class BatcherTransactions implements PurgeableIterator<BatcherTransactions.BatcherTransaction> {
private Deque<BatcherTransaction> txs;
private final Deque<BatcherTransaction> txs;

private MessagePassingQueue<BatcherTransactionMessage> txMessagesQueue;
private final MessagePassingQueue<BatcherTransactionMessage> txMessagesQueue;

/**
* Instantiates a new Batcher transactions.
Expand Down Expand Up @@ -48,7 +49,7 @@ public BatcherTransaction next() {

@Override
public void purge() {

// Drain the queue of all messages
while (this.txMessagesQueue.poll() != null) {}

this.txs.clear();
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/io/optimism/derive/stages/Batches.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package io.optimism.derive.stages;

import com.google.common.collect.Lists;
import io.optimism.common.BlockInfo;
import io.optimism.config.Config;
import io.optimism.derive.PurgeableIterator;
import io.optimism.derive.State;
import io.optimism.derive.stages.Channels.Channel;
import io.optimism.exceptions.DecompressException;
import io.optimism.l1.L1Info;
import io.optimism.type.Epoch;
import io.optimism.types.Batch;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import io.optimism.types.IBatch;
import io.optimism.types.SingularBatch;
import io.optimism.types.SpanBatch;
import io.optimism.types.SpanBatchElement;
import io.optimism.types.enums.BatchType;
import io.optimism.utilities.compression.Compressors;
import java.io.IOException;
import java.math.BigInteger;
Expand Down Expand Up @@ -46,7 +53,7 @@ public class Batches<I extends PurgeableIterator<Channel>> implements PurgeableI

private final Config config;

private SpscAtomicArrayQueue<Batch> nextSingularBatches;
private final SpscAtomicArrayQueue<Batch> nextSingularBatches;

/**
* Instantiates a new Batches.
Expand Down Expand Up @@ -118,7 +125,7 @@ public Batch next() {
Batch batch = null;
if (derivedBatch != null) {
List<Batch> singularBatches = this.getSingularBatches(derivedBatch.batch(), this.state.get());
if (singularBatches.size() != 0) {
if (!singularBatches.isEmpty()) {
this.nextSingularBatches.addAll(singularBatches);
return this.nextSingularBatches.poll();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/optimism/derive/stages/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.optimism.derive.State;
import io.optimism.derive.stages.BatcherTransactions.BatcherTransaction;
import io.optimism.derive.stages.Channels.Channel;
import io.optimism.types.Frame;
import java.math.BigInteger;
import java.util.Comparator;
import java.util.List;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/optimism/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AbstractExecutionThreadService;
import io.optimism.common.BlockInfo;
import io.optimism.common.HildrServiceExecutionException;
import io.optimism.config.Config;
import io.optimism.derive.Pipeline;
import io.optimism.engine.Engine;
import io.optimism.engine.EngineApi;
import io.optimism.engine.ExecutionPayload;
import io.optimism.engine.ExecutionPayload.PayloadAttributes;
import io.optimism.exceptions.HildrServiceExecutionException;
import io.optimism.l1.BlockUpdate;
import io.optimism.l1.ChainWatcher;
import io.optimism.network.OpStackNetwork;
Expand All @@ -24,14 +23,15 @@
import io.optimism.rpc.internal.result.SyncStatusResult;
import io.optimism.telemetry.InnerMetrics;
import io.optimism.telemetry.TracerTaskWrapper;
import io.optimism.type.BlockId;
import io.optimism.type.DepositTransaction;
import io.optimism.type.Epoch;
import io.optimism.type.Genesis;
import io.optimism.type.L1BlockInfo;
import io.optimism.type.L2BlockRef;
import io.optimism.type.RollupConfigResult;
import io.optimism.type.SystemConfig;
import io.optimism.types.BlockId;
import io.optimism.types.BlockInfo;
import io.optimism.types.DepositTransaction;
import io.optimism.types.Epoch;
import io.optimism.types.Genesis;
import io.optimism.types.L1BlockInfo;
import io.optimism.types.L2BlockRef;
import io.optimism.types.RollupConfigResult;
import io.optimism.types.SystemConfig;
import io.optimism.utilities.encoding.TxDecoder;
import java.math.BigInteger;
import java.time.Duration;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/optimism/driver/EngineDriver.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.optimism.driver;

import io.optimism.common.BlockInfo;
import io.optimism.config.Config;
import io.optimism.engine.Engine;
import io.optimism.engine.EngineApi;
Expand All @@ -15,11 +14,12 @@
import io.optimism.engine.OpEthPayloadStatus;
import io.optimism.network.ExecutionPayloadEnvelop;
import io.optimism.telemetry.TracerTaskWrapper;
import io.optimism.type.Epoch;
import io.optimism.type.L2BlockRef;
import io.optimism.type.PayloadInfo;
import io.optimism.type.enums.BlockInsertion;
import io.optimism.type.enums.SyncStatus;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import io.optimism.types.L2BlockRef;
import io.optimism.types.PayloadInfo;
import io.optimism.types.enums.BlockInsertion;
import io.optimism.types.enums.SyncStatus;
import java.math.BigInteger;
import java.util.List;
import java.util.concurrent.ExecutionException;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/optimism/driver/HeadInfo.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.optimism.driver;

import io.optimism.common.AttributesDepositedCall;
import io.optimism.common.BlockInfo;
import io.optimism.type.Epoch;
import io.optimism.types.AttributesDepositedCall;
import io.optimism.types.BlockInfo;
import io.optimism.types.Epoch;
import java.math.BigInteger;
import org.web3j.protocol.core.methods.response.EthBlock;
import org.web3j.protocol.core.methods.response.EthBlock.TransactionObject;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/optimism/driver/ISequencer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.optimism.driver;

import io.optimism.network.ExecutionPayloadEnvelop;
import io.optimism.type.L2BlockRef;
import io.optimism.types.L2BlockRef;

/**
* The sequencer Interface.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/optimism/driver/Sequencer.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.optimism.driver;

import io.optimism.common.CriticalException;
import io.optimism.common.ResetException;
import io.optimism.common.SequencerException;
import io.optimism.common.TemporaryException;
import io.optimism.config.Config;
import io.optimism.exceptions.CriticalException;
import io.optimism.exceptions.ResetException;
import io.optimism.exceptions.SequencerException;
import io.optimism.exceptions.TemporaryException;
import io.optimism.network.ExecutionPayloadEnvelop;
import io.optimism.type.L2BlockRef;
import io.optimism.type.enums.BlockInsertion;
import io.optimism.types.L2BlockRef;
import io.optimism.types.enums.BlockInsertion;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/optimism/engine/ExecutionPayload.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.optimism.engine;

import io.optimism.common.BlockInfo;
import io.optimism.config.Config;
import io.optimism.network.ExecutionPayloadSSZ;
import io.optimism.rpc.response.OpEthBlock;
import io.optimism.type.DepositTransaction;
import io.optimism.type.Epoch;
import io.optimism.type.L1BlockInfo;
import io.optimism.type.L2BlockRef;
import io.optimism.type.enums.TxType;
import io.optimism.types.BlockInfo;
import io.optimism.types.DepositTransaction;
import io.optimism.types.Epoch;
import io.optimism.types.L1BlockInfo;
import io.optimism.types.L2BlockRef;
import io.optimism.types.enums.TxType;
import io.optimism.utilities.encoding.TxDecoder;
import io.optimism.utilities.encoding.TxEncoder;
import java.math.BigInteger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* The type BlockNotIncludedException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.config;
package io.optimism.exceptions;

/**
* The type ConfigLoadException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* The sequencer critical exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.derive.stages;
package io.optimism.exceptions;

/**
* The type DecompressException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.runner;
package io.optimism.exceptions;

/**
* The type DriverInitException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* The type HildrServiceExecutionException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.derive.stages;
package io.optimism.exceptions;

/**
* The type InvalidFrameSizeException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.config;
package io.optimism.exceptions;

/**
* The type InvalidSyncModeException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.derive.stages;
package io.optimism.exceptions;

/**
* The type L1InfoNotFoundException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* The sequencer reset exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* the sequencer exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.runner;
package io.optimism.exceptions;

/**
* The type SyncUrlMissingException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.common;
package io.optimism.exceptions;

/**
* The sequencer temporary exception.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.runner;
package io.optimism.exceptions;

/**
* The type TransactionNotFoundException.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.optimism.runner;
package io.optimism.exceptions;

/**
* The type TrustedPeerAddedException.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/optimism/l1/BeaconBlobFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import ethereum.ckzg4844.CKZG4844JNI;
import io.optimism.rpc.HttpClientProvider;
import io.optimism.rpc.response.BeaconApiResponse;
import io.optimism.type.BlobSidecar;
import io.optimism.type.SpecConfig;
import io.optimism.types.BlobSidecar;
import io.optimism.types.SpecConfig;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/optimism/l1/ChainWatcher.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.optimism.l1;

import io.optimism.common.BlockInfo;
import io.optimism.config.Config;
import io.optimism.types.BlockInfo;
import java.math.BigInteger;
import org.jctools.queues.MessagePassingQueue;
import org.jctools.queues.MpscGrowableArrayQueue;
Expand Down
Loading

0 comments on commit 0c12598

Please sign in to comment.