Skip to content

Commit

Permalink
fix: to singular batches method
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod committed Jan 30, 2024
1 parent 8cfc013 commit a31db02
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hildr-node/src/main/java/io/optimism/derive/stages/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ public Batch next() {
while (true) {
if (this.batches.firstEntry() != null) {
Batch batch = this.batches.firstEntry().getValue();
BigInteger timestamp = this.config.chainConfig().l2Genesis().timestamp();
BigInteger l1GenesisTimestamp =
this.config.chainConfig().l2Genesis().timestamp();
switch (batchStatus(batch)) {
case Accept:
derivedBatch = batch;
this.batches.remove(batch.timestamp(timestamp));
this.batches.remove(batch.timestamp(l1GenesisTimestamp));
break loop;
case Drop:
LOGGER.warn("dropping invalid batch");
this.batches.remove(batch.timestamp(timestamp));
this.batches.remove(batch.timestamp(l1GenesisTimestamp));
continue;
case Future, Undecided:
break loop;
Expand Down Expand Up @@ -500,7 +501,7 @@ private BatchStatus spanBatchStatus(final Batch batchWrapper) {
* @return the list that inner batch data was singular batch
*/
public List<Batch> getSingularBatches(final IBatch batch, final State state) {
Function<SingularBatch, Batch> f = singularBatch -> new Batch(batch, state.getCurrentEpochNum());
Function<SingularBatch, Batch> f = singularBatch -> new Batch(singularBatch, state.getCurrentEpochNum());
if (batch instanceof SingularBatch typedBatch) {
return List.of(f.apply(typedBatch));
} else if (batch instanceof RawSpanBatch typedBatch) {
Expand All @@ -521,11 +522,11 @@ private List<SingularBatch> toSingularBatches(final SpanBatch batch, final State
continue;
}
SingularBatch singularBatch = new SingularBatch();
singularBatch.setEpochNum(singularBatch.epochNum());
singularBatch.setTimestamp(singularBatch.timestamp());
singularBatch.setTransactions(singularBatch.transactions());
singularBatch.setEpochNum(element.epochNum());
singularBatch.setTimestamp(element.timestamp());
singularBatch.setTransactions(element.transactions());

Epoch l1Origins = state.epoch(singularBatch.epochNum());
Epoch l1Origins = state.epoch(element.epochNum());
if (l1Origins == null) {
throw new RuntimeException("cannot find origin for epochNum: %d".formatted(element.epochNum()));
}
Expand Down

0 comments on commit a31db02

Please sign in to comment.