diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rom/Rom.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rom/Rom.java index 2115b1ea3a..5c48637426 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rom/Rom.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rom/Rom.java @@ -62,7 +62,7 @@ public int lineCount() { for (RomChunk chunk : this.romLex.chunks) { traceRowSize += chunkRowSize(chunk); } - return traceRowSize; + return traceRowSize + 32 * this.romLex.emptyContractsCount.stream().mapToInt(x -> x).sum(); } public int chunkRowSize(RomChunk chunk) { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romLex/RomLex.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romLex/RomLex.java index 45f1b28fac..4d5ff7b613 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romLex/RomLex.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/romLex/RomLex.java @@ -22,8 +22,10 @@ import java.math.BigInteger; import java.nio.MappedByteBuffer; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Comparator; +import java.util.Deque; import java.util.List; import java.util.Optional; @@ -50,6 +52,7 @@ public class RomLex implements Module { public int codeIdentifierBeforeLexOrder = 0; public final StackedSet chunks = new StackedSet<>(); + public final Deque emptyContractsCount = new ArrayDeque<>(); public final List sortedChunks = new ArrayList<>(); private Bytes byteCode = Bytes.EMPTY; private Address address = Address.ZERO; @@ -90,11 +93,13 @@ public RomLex(Hub hub) { @Override public void enterTransaction() { this.chunks.enter(); + this.emptyContractsCount.push(0); } @Override public void popTransaction() { this.chunks.pop(); + this.emptyContractsCount.pop(); } public int getCFIById(int value) { @@ -136,7 +141,7 @@ public void traceStartTx(WorldView worldView, Transaction tx) { tx.getTo() .map(worldView::get) .map(AccountState::getCode) - .ifPresent( + .ifPresentOrElse( code -> { codeIdentifierBeforeLexOrder += 1; int depNumber = hub.conflation().deploymentInfo().number(tx.getTo().get()); @@ -151,7 +156,8 @@ public void traceStartTx(WorldView worldView, Transaction tx) { false, codeIdentifierBeforeLexOrder, code)); - }); + }, + () -> this.emptyContractsCount.push(this.emptyContractsCount.pop() + 1)); } @Override @@ -208,7 +214,7 @@ public void tracePreOpcode(MessageFrame frame) { final int depNumber = hub.conflation().deploymentInfo().number(frame.getContractAddress()); Optional.ofNullable(frame.getWorldUpdater().get(calledAddress)) .map(AccountState::getCode) - .ifPresent( + .ifPresentOrElse( byteCode -> { codeIdentifierBeforeLexOrder += 1; this.chunks.add( @@ -220,7 +226,8 @@ public void tracePreOpcode(MessageFrame frame) { false, codeIdentifierBeforeLexOrder, byteCode)); - }); + }, + () -> this.emptyContractsCount.push(this.emptyContractsCount.pop() + 1)); } case EXTCODECOPY -> { @@ -234,7 +241,7 @@ public void tracePreOpcode(MessageFrame frame) { final int depNumber = hub.conflation().deploymentInfo().number(frame.getContractAddress()); Optional.ofNullable(frame.getWorldUpdater().get(calledAddress)) .map(AccountState::getCode) - .ifPresent( + .ifPresentOrElse( byteCode -> { if (!byteCode.isEmpty()) { codeIdentifierBeforeLexOrder += 1; @@ -248,7 +255,8 @@ public void tracePreOpcode(MessageFrame frame) { codeIdentifierBeforeLexOrder, byteCode)); } - }); + }, + () -> this.emptyContractsCount.push(this.emptyContractsCount.pop() + 1)); } } }