-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: stages interface and base type
- Loading branch information
1 parent
280b82c
commit 8602acb
Showing
39 changed files
with
1,098 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/io/optimism/spec/derive/datasource/BlobProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.optimism.spec.derive.datasource; | ||
|
||
import io.optimism.types.BlobSidecar; | ||
import io.optimism.types.BlockInfo; | ||
|
||
import java.util.List; | ||
|
||
public interface BlobProvider { | ||
|
||
BlobSidecar getBlobs(BlockInfo l1Info, List<String> blobHashes); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/optimism/spec/derive/datasource/ChainProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.optimism.spec.derive.datasource; | ||
|
||
import io.optimism.types.BlockInfo; | ||
import org.web3j.protocol.core.methods.response.EthBlock; | ||
import org.web3j.protocol.core.methods.response.TransactionReceipt; | ||
|
||
import java.math.BigInteger; | ||
|
||
public interface ChainProvider { | ||
|
||
EthBlock.Block headerByHash(String hash); | ||
|
||
BlockInfo blockInfoByNumber(BigInteger num); | ||
|
||
TransactionReceipt receiptsByHash(String hash); | ||
|
||
EthBlock.Block blockInfoNTxsByHash(String hash); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/io/optimism/spec/derive/datasource/DataAvailabilityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.optimism.spec.derive.datasource; | ||
|
||
import io.optimism.spec.derive.stages.DataIter; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public interface DataAvailabilityProvider { | ||
|
||
DataIter openData(BlockInfo l1Ref, String batcherAddr); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/io/optimism/spec/derive/datasource/L2ChainProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.optimism.spec.derive.datasource; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.types.ExecutionPayloadEnvelop; | ||
import io.optimism.types.L2BlockRef; | ||
import io.optimism.types.SystemConfig; | ||
|
||
import java.math.BigInteger; | ||
|
||
public interface L2ChainProvider { | ||
|
||
L2BlockRef l2BlockInfoByNumber(BigInteger num); | ||
|
||
ExecutionPayloadEnvelop payloadByNumber(BigInteger num); | ||
|
||
SystemConfig systemConfigByNumber(BigInteger num, Config.ChainConfig chainConfig); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/optimism/spec/derive/datasource/impl/L1Retrieval.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.optimism.spec.derive.datasource.impl; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.spec.derive.stages.FrameQueueProvider; | ||
import io.optimism.spec.derive.stages.OriginAdvancer; | ||
import io.optimism.spec.derive.stages.OriginProvider; | ||
import io.optimism.spec.derive.stages.ResettableStage; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public class L1Retrieval implements FrameQueueProvider, OriginProvider, OriginAdvancer, ResettableStage { | ||
|
||
@Override | ||
public void advanceOrigin() { | ||
|
||
} | ||
|
||
@Override | ||
public BlockInfo origin() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset(BlockInfo base, Config.SystemConfig config) { | ||
|
||
} | ||
|
||
@Override | ||
public byte[] next() { | ||
return new byte[0]; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/io/optimism/spec/derive/datasource/impl/L1Traversal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.optimism.spec.derive.datasource.impl; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.spec.derive.stages.L1RetrievalProvider; | ||
import io.optimism.spec.derive.stages.OriginAdvancer; | ||
import io.optimism.spec.derive.stages.OriginProvider; | ||
import io.optimism.spec.derive.stages.ResettableStage; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public class L1Traversal implements L1RetrievalProvider, OriginProvider, OriginAdvancer, ResettableStage { | ||
|
||
public L1Traversal() { | ||
|
||
} | ||
|
||
|
||
@Override | ||
public BlockInfo nextL1Block() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String batcherAddr() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public void advanceOrigin() { | ||
|
||
} | ||
|
||
@Override | ||
public BlockInfo origin() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset(BlockInfo base, Config.SystemConfig config) { | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/io/optimism/spec/derive/pipeline/DerivationPipeline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.optimism.spec.derive.pipeline; | ||
|
||
public class DerivationPipeline { | ||
|
||
DerivationPipeline() {} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/optimism/spec/derive/pipeline/PipelineBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.optimism.spec.derive.pipeline; | ||
|
||
public class PipelineBuilder { | ||
|
||
public PipelineBuilder() {} | ||
|
||
public DerivationPipeline build() { | ||
return new DerivationPipeline(); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/optimism/spec/derive/stages/AttributesBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.spec.derive.types.L2BlockRef; | ||
import io.optimism.spec.derive.types.OpPayloadAttributes; | ||
import io.optimism.spec.derive.types.Epoch; | ||
|
||
public interface AttributesBuilder { | ||
|
||
OpPayloadAttributes preparePayloadAttr(L2BlockRef ref, Epoch epoch); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/optimism/spec/derive/stages/AttributesProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.types.L2BlockRef; | ||
import io.optimism.types.SingularBatch; | ||
|
||
public interface AttributesProvider { | ||
/** | ||
* returns the next valid batch upon the given safe head. | ||
* @param parent | ||
* @return | ||
*/ | ||
SingularBatch nextBatch(L2BlockRef parent); | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
boolean isLastInSpan(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/optimism/spec/derive/stages/BatchQueueProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.spec.derive.types.Batch; | ||
|
||
public interface BatchQueueProvider { | ||
|
||
Batch nextBatch(); | ||
|
||
void flush(); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/io/optimism/spec/derive/stages/ChannelBankProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.spec.derive.types.Frame; | ||
|
||
public interface ChannelBankProvider { | ||
|
||
Frame nextFrame(); | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/io/optimism/spec/derive/stages/ChannelReaderProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
public interface ChannelReaderProvider { | ||
|
||
byte[] nextData(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
public interface DataIter { | ||
|
||
byte[] Next(); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/io/optimism/spec/derive/stages/FrameQueueProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
public interface FrameQueueProvider { | ||
byte[] next(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/io/optimism/spec/derive/stages/L1RetrievalProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.types.BlockInfo; | ||
|
||
public interface L1RetrievalProvider { | ||
|
||
BlockInfo nextL1Block(); | ||
|
||
String batcherAddr(); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/io/optimism/spec/derive/stages/NextAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.spec.derive.types.L2BlockRef; | ||
import io.optimism.spec.derive.types.OpAttributesWithParent; | ||
|
||
public interface NextAttributes { | ||
|
||
OpAttributesWithParent nextAttr(L2BlockRef parent); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/io/optimism/spec/derive/stages/OriginAdvancer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
public interface OriginAdvancer { | ||
void advanceOrigin(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/io/optimism/spec/derive/stages/OriginProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.types.BlockInfo; | ||
|
||
public interface OriginProvider { | ||
|
||
BlockInfo origin(); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/io/optimism/spec/derive/stages/ResettableStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.optimism.spec.derive.stages; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public interface ResettableStage { | ||
|
||
void reset(BlockInfo base, Config.SystemConfig config); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/io/optimism/spec/derive/stages/impl/AttributesQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.optimism.spec.derive.stages.impl; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.spec.derive.stages.AttributesBuilder; | ||
import io.optimism.spec.derive.stages.NextAttributes; | ||
import io.optimism.spec.derive.stages.OriginAdvancer; | ||
import io.optimism.spec.derive.stages.OriginProvider; | ||
import io.optimism.spec.derive.stages.ResettableStage; | ||
import io.optimism.spec.derive.types.Epoch; | ||
import io.optimism.spec.derive.types.L2BlockRef; | ||
import io.optimism.spec.derive.types.OpAttributesWithParent; | ||
import io.optimism.spec.derive.types.OpPayloadAttributes; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public class AttributesQueue implements NextAttributes, OriginAdvancer, OriginProvider, ResettableStage, AttributesBuilder { | ||
@Override | ||
public OpPayloadAttributes preparePayloadAttr(L2BlockRef ref, Epoch epoch) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void advanceOrigin() { | ||
|
||
} | ||
|
||
@Override | ||
public BlockInfo origin() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset(BlockInfo base, Config.SystemConfig config) { | ||
|
||
} | ||
|
||
@Override | ||
public OpAttributesWithParent nextAttr(L2BlockRef parent) { | ||
return null; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/io/optimism/spec/derive/stages/impl/BatchQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.optimism.spec.derive.stages.impl; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.spec.derive.stages.AttributesProvider; | ||
import io.optimism.spec.derive.stages.OriginAdvancer; | ||
import io.optimism.spec.derive.stages.OriginProvider; | ||
import io.optimism.spec.derive.stages.ResettableStage; | ||
import io.optimism.types.BlockInfo; | ||
import io.optimism.types.L2BlockRef; | ||
import io.optimism.types.SingularBatch; | ||
|
||
public class BatchQueue implements AttributesProvider, OriginProvider, OriginAdvancer, ResettableStage { | ||
@Override | ||
public SingularBatch nextBatch(L2BlockRef parent) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isLastInSpan() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void advanceOrigin() { | ||
|
||
} | ||
|
||
@Override | ||
public BlockInfo origin() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset(BlockInfo base, Config.SystemConfig config) { | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/io/optimism/spec/derive/stages/impl/BatchStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.optimism.spec.derive.stages.impl; | ||
|
||
import io.optimism.config.Config; | ||
import io.optimism.spec.derive.stages.BatchQueueProvider; | ||
import io.optimism.spec.derive.stages.OriginAdvancer; | ||
import io.optimism.spec.derive.stages.OriginProvider; | ||
import io.optimism.spec.derive.stages.ResettableStage; | ||
import io.optimism.spec.derive.types.Batch; | ||
import io.optimism.types.BlockInfo; | ||
|
||
public class BatchStream implements BatchQueueProvider, OriginProvider, OriginAdvancer, ResettableStage { | ||
@Override | ||
public Batch nextBatch() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
|
||
} | ||
|
||
@Override | ||
public void advanceOrigin() { | ||
|
||
} | ||
|
||
@Override | ||
public BlockInfo origin() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset(BlockInfo base, Config.SystemConfig config) { | ||
|
||
} | ||
} |
Oops, something went wrong.