diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationListModule.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationListModule.java index 579a3a2fa5..371ee090c7 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationListModule.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationListModule.java @@ -16,7 +16,7 @@ package net.consensys.linea.zktracer.container.module; import net.consensys.linea.zktracer.container.ModuleOperation; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import org.hyperledger.besu.evm.worldstate.WorldView; /** @@ -24,7 +24,7 @@ * where we can keep trace of duplicates. */ public interface OperationListModule extends Module { - StackedList operations(); + ModuleOperationStackedList operations(); @Override default void enterTransaction() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationSetModule.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationSetModule.java index 2897f62ac6..1d27194ba0 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationSetModule.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/module/OperationSetModule.java @@ -16,7 +16,7 @@ package net.consensys.linea.zktracer.container.module; import net.consensys.linea.zktracer.container.ModuleOperation; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import org.hyperledger.besu.evm.worldstate.WorldView; /** @@ -25,7 +25,7 @@ */ public interface OperationSetModule extends Module { - StackedSet operations(); + ModuleOperationStackedSet operations(); @Override default void enterTransaction() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedList.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedList.java similarity index 96% rename from arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedList.java rename to arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedList.java index 4eb9d9848e..74f4c61975 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedList.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedList.java @@ -35,19 +35,19 @@ * @param the type of elements stored in the set */ @Accessors(fluent = true) -public class StackedList { +public class ModuleOperationStackedList { private final List operationsCommitedToTheConflation; @Getter private final List operationsInTransaction; private final CountOnlyOperation lineCounter = new CountOnlyOperation(); private boolean conflationFinished = false; - public StackedList() { + public ModuleOperationStackedList() { operationsCommitedToTheConflation = new ArrayList<>(); operationsInTransaction = new ArrayList<>(); } /** Prefer this constructor as we preallocate more needed memory */ - public StackedList( + public ModuleOperationStackedList( final int expectedConflationNumberOperations, final int expectedTransactionNumberOperations) { operationsCommitedToTheConflation = new ArrayList<>(expectedConflationNumberOperations); operationsInTransaction = new ArrayList<>(expectedTransactionNumberOperations); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedSet.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedSet.java new file mode 100644 index 0000000000..d8eabe6ac5 --- /dev/null +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/ModuleOperationStackedSet.java @@ -0,0 +1,138 @@ +/* + * Copyright Consensys Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package net.consensys.linea.zktracer.container.stacked; + +import java.util.Collection; +import java.util.Set; + +import com.google.common.base.Preconditions; +import lombok.Getter; +import lombok.experimental.Accessors; +import net.consensys.linea.zktracer.container.ModuleOperation; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implements a system of pseudo-stacked squashed sets where {@link + * ModuleOperationStackedSet#operationsCommitedToTheConflation()} represents the set of all + * operations since the beginning of the conflation and {@link + * ModuleOperationStackedSet#operationsInTransaction()} represents the operations added by the last + * transaction. We can pop only the operations added by last transaction. The line counting is done + * by a separate {@link CountOnlyOperation}. + * + * @param the type of elements stored in the set + */ +@Accessors(fluent = true) +public class ModuleOperationStackedSet extends StackedSet { + private static final Logger log = LoggerFactory.getLogger(ModuleOperationStackedSet.class); + private final CountOnlyOperation lineCounter = new CountOnlyOperation(); + @Getter private boolean conflationFinished = false; + + public ModuleOperationStackedSet() { + super(); + } + + /** Prefer this constructor as we preallocate more needed memory */ + public ModuleOperationStackedSet( + final int expectedConflationNumberOperations, final int expectedTransactionNumberOperations) { + super(expectedConflationNumberOperations, expectedTransactionNumberOperations); + } + + /** + * Upon entering a new transaction, the set of operations generated by the previous transaction + * {@link ModuleOperationStackedSet#operationsInTransaction()} (which is empty if no such + * transaction exists) is added to the set of committed operations {@link + * ModuleOperationStackedSet#operationsCommitedToTheConflation()}. {@link + * ModuleOperationStackedSet#operationsInTransaction()} is further reset to be empty. + */ + public void enter() { + super.enter(); + lineCounter.enter(); + } + + public void pop() { + super.pop(); + lineCounter.pop(); + } + + public int size() { + return operationsInTransaction().size() + operationsCommitedToTheConflation().size(); + } + + public int lineCount() { + return lineCounter.lineCount(); + } + + public Set getAll() { + Preconditions.checkState(conflationFinished, "Conflation not finished"); + return operationsCommitedToTheConflation(); + } + + public boolean isEmpty() { + return size() == 0; + } + + public boolean contains(Object o) { + return operationsInTransaction().contains(o) || operationsCommitedToTheConflation().contains(o); + } + + public boolean add(E e) { + if (!operationsCommitedToTheConflation().contains(e)) { + final boolean isNew = operationsInTransaction().add(e); + if (isNew) { + lineCounter.add(e.lineCount()); + } + return isNew; + } else { + log.trace( + "Operation of type {} was already in operationsCommitedToTheConflation hashset, reference is ", + e.getClass().getName(), + e); + } + return false; + } + + public boolean containsAll(@NotNull Collection c) { + for (var x : c) { + if (!contains(x)) { + return false; + } + } + return true; + } + + public boolean addAll(@NotNull Collection c) { + boolean r = false; + for (var x : c) { + r |= add(x); + } + return r; + } + + public void clear() { + operationsCommitedToTheConflation().clear(); + operationsInTransaction().clear(); + lineCounter.clear(); + } + + public void finishConflation() { + conflationFinished = true; + operationsCommitedToTheConflation().addAll(operationsInTransaction()); + operationsInTransaction().clear(); + lineCounter.enter(); // this is not mandatory but it is more consistent + } +} diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/NoLineCountStackedSet.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/NoLineCountStackedSet.java deleted file mode 100644 index 51eea10a76..0000000000 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/NoLineCountStackedSet.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright ConsenSys Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package net.consensys.linea.zktracer.container.stacked; - -import java.util.HashSet; -import java.util.Set; - -import lombok.Getter; -import lombok.experimental.Accessors; - -@Accessors(fluent = true) -@Getter -public class NoLineCountStackedSet { - private final Set operationsCommitedToTheConflation; - private final Set operationsInTransaction; - - public NoLineCountStackedSet() { - operationsCommitedToTheConflation = new HashSet<>(); - operationsInTransaction = new HashSet<>(); - } - - /** Prefer this constructor as we preallocate more needed memory */ - public NoLineCountStackedSet( - final int expectedConflationNumberOperations, final int expectedTransactionNumberOperations) { - operationsCommitedToTheConflation = new HashSet<>(expectedConflationNumberOperations); - operationsInTransaction = new HashSet<>(expectedTransactionNumberOperations); - } - - /** - * Upon entering a new transaction, the set of operations generated by the previous transaction - * {@link StackedSet#operationsInTransaction()} (which is empty if no such transaction exists) is - * added to the set of committed operations {@link - * StackedSet#operationsCommitedToTheConflation()}. {@link StackedSet#operationsInTransaction()} - * is further reset to be empty. - */ - public void enter() { - operationsCommitedToTheConflation().addAll(operationsInTransaction()); - operationsInTransaction().clear(); - } - - public void pop() { - operationsInTransaction().clear(); - } - - public boolean add(E e) { - if (!operationsCommitedToTheConflation().contains(e)) { - return operationsInTransaction().add(e); - } - return false; - } -} diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedSet.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedSet.java index 1b303815d3..87d695f7bf 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedSet.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/StackedSet.java @@ -1,5 +1,5 @@ /* - * Copyright Consensys Software Inc. + * Copyright ConsenSys Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -15,123 +15,50 @@ package net.consensys.linea.zktracer.container.stacked; -import java.util.Collection; +import java.util.HashSet; import java.util.Set; -import com.google.common.base.Preconditions; import lombok.Getter; import lombok.experimental.Accessors; -import net.consensys.linea.zktracer.container.ModuleOperation; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** - * Implements a system of pseudo-stacked squashed sets where {@link - * StackedSet#operationsCommitedToTheConflation()} represents the set of all operations since the - * beginning of the conflation and {@link StackedSet#operationsInTransaction()} represents the - * operations added by the last transaction. We can pop only the operations added by last - * transaction. The line counting is done by a separate {@link CountOnlyOperation}. - * - * @param the type of elements stored in the set - */ @Accessors(fluent = true) -public class StackedSet extends NoLineCountStackedSet { - private static final Logger log = LoggerFactory.getLogger(StackedSet.class); - private final CountOnlyOperation lineCounter = new CountOnlyOperation(); - @Getter private boolean conflationFinished = false; +@Getter +public class StackedSet { + private final Set operationsCommitedToTheConflation; + private final Set operationsInTransaction; public StackedSet() { - super(); + operationsCommitedToTheConflation = new HashSet<>(); + operationsInTransaction = new HashSet<>(); } /** Prefer this constructor as we preallocate more needed memory */ public StackedSet( final int expectedConflationNumberOperations, final int expectedTransactionNumberOperations) { - super(expectedConflationNumberOperations, expectedTransactionNumberOperations); + operationsCommitedToTheConflation = new HashSet<>(expectedConflationNumberOperations); + operationsInTransaction = new HashSet<>(expectedTransactionNumberOperations); } /** * Upon entering a new transaction, the set of operations generated by the previous transaction - * {@link StackedSet#operationsInTransaction()} (which is empty if no such transaction exists) is - * added to the set of committed operations {@link - * StackedSet#operationsCommitedToTheConflation()}. {@link StackedSet#operationsInTransaction()} - * is further reset to be empty. + * {@link ModuleOperationStackedSet#operationsInTransaction()} (which is empty if no such + * transaction exists) is added to the set of committed operations {@link + * ModuleOperationStackedSet#operationsCommitedToTheConflation()}. {@link + * ModuleOperationStackedSet#operationsInTransaction()} is further reset to be empty. */ public void enter() { - super.enter(); - lineCounter.enter(); + operationsCommitedToTheConflation().addAll(operationsInTransaction()); + operationsInTransaction().clear(); } public void pop() { - super.pop(); - lineCounter.pop(); - } - - public int size() { - return operationsInTransaction().size() + operationsCommitedToTheConflation().size(); - } - - public int lineCount() { - return lineCounter.lineCount(); - } - - public Set getAll() { - Preconditions.checkState(conflationFinished, "Conflation not finished"); - return operationsCommitedToTheConflation(); - } - - public boolean isEmpty() { - return size() == 0; - } - - public boolean contains(Object o) { - return operationsInTransaction().contains(o) || operationsCommitedToTheConflation().contains(o); + operationsInTransaction().clear(); } public boolean add(E e) { if (!operationsCommitedToTheConflation().contains(e)) { - final boolean isNew = operationsInTransaction().add(e); - if (isNew) { - lineCounter.add(e.lineCount()); - } - return isNew; - } else { - log.trace( - "Operation of type {} was already in operationsCommitedToTheConflation hashset, reference is ", - e.getClass().getName(), - e); + return operationsInTransaction().add(e); } return false; } - - public boolean containsAll(@NotNull Collection c) { - for (var x : c) { - if (!contains(x)) { - return false; - } - } - return true; - } - - public boolean addAll(@NotNull Collection c) { - boolean r = false; - for (var x : c) { - r |= add(x); - } - return r; - } - - public void clear() { - operationsCommitedToTheConflation().clear(); - operationsInTransaction().clear(); - lineCounter.clear(); - } - - public void finishConflation() { - conflationFinished = true; - operationsCommitedToTheConflation().addAll(operationsInTransaction()); - operationsInTransaction().clear(); - lineCounter.enter(); // this is not mandatory but it is more consistent - } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/add/Add.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/add/Add.java index 091368cb16..25a947aa78 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/add/Add.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/add/Add.java @@ -25,7 +25,7 @@ import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.Module; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.evm.frame.MessageFrame; @@ -36,7 +36,8 @@ @Accessors(fluent = true) public class Add implements OperationSetModule { - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/bin/Bin.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/bin/Bin.java index 0b9af84d7f..98e332f303 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/bin/Bin.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/bin/Bin.java @@ -25,7 +25,7 @@ import net.consensys.linea.zktracer.bytestheta.BaseBytes; import net.consensys.linea.zktracer.container.module.Module; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.evm.frame.MessageFrame; @@ -36,7 +36,8 @@ @RequiredArgsConstructor public class Bin implements OperationSetModule { - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blake2fmodexpdata/BlakeModexpData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blake2fmodexpdata/BlakeModexpData.java index 3e83f5afd9..c8a8c85ca1 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blake2fmodexpdata/BlakeModexpData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blake2fmodexpdata/BlakeModexpData.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.hub.precompiles.ModexpMetadata; import net.consensys.linea.zktracer.module.limits.precompiles.BlakeEffectiveCall; import net.consensys.linea.zktracer.module.limits.precompiles.BlakeRounds; @@ -39,7 +39,8 @@ public class BlakeModexpData implements OperationListModule operations = new StackedList<>(); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); private long previousID = 0; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockdata/Blockdata.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockdata/Blockdata.java index 651c6b7f67..b8d612e5d7 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockdata/Blockdata.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockdata/Blockdata.java @@ -27,6 +27,7 @@ import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.Module; import net.consensys.linea.zktracer.module.rlptxn.RlpTxn; +import net.consensys.linea.zktracer.module.rlptxn.RlpTxnOperation; import net.consensys.linea.zktracer.module.txndata.TxnData; import net.consensys.linea.zktracer.module.wcp.Wcp; import org.hyperledger.besu.evm.worldstate.WorldView; @@ -92,13 +93,30 @@ public List columnsHeaders() { @Override public void commit(List buffers) { - final long firstBlockNumber = operations.getFirst().absoluteBlockNumber(); - final long chainId = getChainIdFromTransaction(rlpTxn.operations().getLast().tx()); final Trace trace = new Trace(buffers); + + final long firstBlockNumber = operations.getFirst().absoluteBlockNumber(); + final long chainId = getChainIdFromConflation(); int relblock = 0; - for (BlockdataOperation blockData : this.operations) { - relblock += 1; - blockData.trace(trace, relblock, firstBlockNumber, chainId); + for (BlockdataOperation blockData : operations) { + blockData.trace(trace, ++relblock, firstBlockNumber, chainId); + } + } + + private long getChainIdFromConflation() { + // TODO: this doesn't work if all transaction of the batch are WO ChainId + long chainId = -1; + for (RlpTxnOperation tx : rlpTxn.operations().getAll()) { + try { + chainId = getChainIdFromTransaction(tx.tx()); + break; + } catch (Exception e) { + continue; + } + } + if (chainId == -1) { + throw new RuntimeException("No chainId found in the batch"); } + return chainId; } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockhash/Blockhash.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockhash/Blockhash.java index f5cb2011b0..528575e63a 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockhash/Blockhash.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/blockhash/Blockhash.java @@ -28,7 +28,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.wcp.Wcp; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes; @@ -41,7 +41,8 @@ @Accessors(fluent = true) public class Blockhash implements OperationSetModule { private final Wcp wcp; - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); List sortedOperations; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcData.java index 7bc89aab93..0d804612c2 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ecdata/EcData.java @@ -24,7 +24,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.ext.Ext; import net.consensys.linea.zktracer.module.hub.fragment.scenario.PrecompileScenarioFragment; import net.consensys.linea.zktracer.module.limits.precompiles.EcAddEffectiveCall; @@ -44,7 +44,8 @@ public class EcData implements OperationListModule { public static final Set
EC_PRECOMPILES = Set.of(Address.ECREC, Address.ALTBN128_ADD, Address.ALTBN128_MUL, Address.ALTBN128_PAIRING); - private final StackedList operations = new StackedList<>(); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); private final Wcp wcp; private final Ext ext; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/Euc.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/Euc.java index 6b9e24b998..09396c99d1 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/Euc.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/Euc.java @@ -26,7 +26,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.wcp.Wcp; import org.apache.tuweni.bytes.Bytes; @@ -34,7 +34,10 @@ @Accessors(fluent = true) public class Euc implements OperationSetModule { private final Wcp wcp; - @Getter private final StackedSet operations = new StackedSet<>(); + + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/Exp.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/Exp.java index 4bd6199721..61e9a317dc 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/Exp.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/Exp.java @@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.module.hub.fragment.imc.exp.ExpCall; import net.consensys.linea.zktracer.module.wcp.Wcp; @@ -36,7 +36,9 @@ public class Exp implements OperationSetModule { private final Hub hub; private final Wcp wcp; - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/Ext.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/Ext.java index 8f710c25e5..bbf6402c2e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/Ext.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/Ext.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.opcode.OpCode; import net.consensys.linea.zktracer.opcode.OpCodeData; @@ -36,7 +36,9 @@ public class Ext implements OperationSetModule { private final Hub hub; - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/gas/Gas.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/gas/Gas.java index 29e03bea04..7f9205369e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/gas/Gas.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/gas/Gas.java @@ -21,12 +21,13 @@ import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.Module; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import org.hyperledger.besu.evm.frame.MessageFrame; public class Gas implements Module { /** A list of the operations to trace */ - private final StackedList operations = new StackedList<>(); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); // TODO: why a stackedList of GasOperation? It should be a StateLess module no ? diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/transients/Conflation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/transients/Conflation.java index 85ee51f639..8d86728165 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/transients/Conflation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/transients/Conflation.java @@ -19,7 +19,7 @@ import lombok.Getter; import lombok.experimental.Accessors; -import net.consensys.linea.zktracer.container.stacked.NoLineCountStackedSet; +import net.consensys.linea.zktracer.container.stacked.StackedSet; import net.consensys.linea.zktracer.runtime.LogData; /** Stores data relative to the conflation. */ @@ -28,10 +28,10 @@ public class Conflation { private final DeploymentInfo deploymentInfo = new DeploymentInfo(); private final List logs = new ArrayList<>(100); - private final NoLineCountStackedSet stackHeightChecksForStackUnderflows = - new NoLineCountStackedSet<>(256, 32); - private final NoLineCountStackedSet stackHeightChecksForStackOverflows = - new NoLineCountStackedSet<>(256, 32); + private final StackedSet stackHeightChecksForStackUnderflows = + new StackedSet<>(256, 32); + private final StackedSet stackHeightChecksForStackOverflows = + new StackedSet<>(256, 32); public int log(LogData logData) { this.logs.add(logData); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Mmu.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Mmu.java index 66939467d2..c39bbbb5e4 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Mmu.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Mmu.java @@ -24,7 +24,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.euc.Euc; import net.consensys.linea.zktracer.module.hub.fragment.imc.mmu.MmuCall; import net.consensys.linea.zktracer.module.mmu.values.HubToMmuValues; @@ -33,7 +33,10 @@ @RequiredArgsConstructor @Accessors(fluent = true) public class Mmu implements OperationListModule { - @Getter private final StackedList operations = new StackedList<>(); + @Getter + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); + private final Euc euc; private final Wcp wcp; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mod/Mod.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mod/Mod.java index 7669fa09f5..5f51faae4f 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mod/Mod.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mod/Mod.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.opcode.OpCode; import net.consensys.linea.zktracer.opcode.OpCodeData; import net.consensys.linea.zktracer.opcode.OpCodes; @@ -33,7 +33,8 @@ @Getter @Accessors(fluent = true) public class Mod implements OperationSetModule { - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mul/Mul.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mul/Mul.java index 72affedcc4..4fe2edf3e0 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mul/Mul.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mul/Mul.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes32; @@ -34,7 +34,9 @@ public class Mul implements OperationSetModule { private final Hub hub; - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/Mxp.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/Mxp.java index b0e235b814..2d7533cbc8 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/Mxp.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/Mxp.java @@ -24,7 +24,7 @@ import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.Module; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.hub.fragment.imc.MxpCall; /** Implementation of a {@link Module} for memory expansion. */ @@ -33,7 +33,8 @@ @RequiredArgsConstructor public class Mxp implements OperationListModule { - private final StackedList operations = new StackedList<>(); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/oob/Oob.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/oob/Oob.java index 1e271b3044..f10ef5f641 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/oob/Oob.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/oob/Oob.java @@ -26,7 +26,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.add.Add; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.module.hub.fragment.imc.oob.OobCall; @@ -46,7 +46,9 @@ public class Oob implements OperationListModule { private final Mod mod; private final Wcp wcp; - @Getter private final StackedList operations = new StackedList<>(); + @Getter + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); @Override public String moduleKey() { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlpaddr/RlpAddr.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlpaddr/RlpAddr.java index 6ad3e5611c..cee070ce8d 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlpaddr/RlpAddr.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlpaddr/RlpAddr.java @@ -42,7 +42,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.constants.GlobalConstants; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.module.rlputils.ByteCountAndPowerOutput; @@ -61,7 +61,9 @@ @RequiredArgsConstructor @Accessors(fluent = true) public class RlpAddr implements OperationSetModule { - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); private static final Bytes CREATE2_SHIFT = Bytes.minimalBytes(GlobalConstants.CREATE2_SHIFT); private static final Bytes INT_SHORT = Bytes.minimalBytes(RLP_PREFIX_INT_SHORT); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxn/RlpTxn.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxn/RlpTxn.java index 076d58dd0d..1d4a5f4c52 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxn/RlpTxn.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxn/RlpTxn.java @@ -63,7 +63,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.rlputils.ByteCountAndPowerOutput; import net.consensys.linea.zktracer.module.romlex.ContractMetadata; import net.consensys.linea.zktracer.module.romlex.RomLex; @@ -90,8 +90,8 @@ public class RlpTxn implements OperationListModule { private final RomLex romLex; @Getter - private final StackedList operations = - new StackedList<>(LINEA_MAX_NUMBER_OF_TRANSACTIONS_IN_BATCH, 1); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(LINEA_MAX_NUMBER_OF_TRANSACTIONS_IN_BATCH, 1); @Override public String moduleKey() { @@ -593,7 +593,7 @@ private void handlePhaseBeta(RlpTxnColumnsValue traceValue, Transaction tx, Trac checkArgument(bigIntegerToBytes(V).size() <= 8, "V is longer than 8 bytes"); final boolean betaIsZero = V.equals(BigInteger.valueOf(27)) - || V.equals(BigInteger.valueOf(28)); // beta = ChainId = 0 iff (V == 27 or V == 28) + || V.equals(BigInteger.valueOf(28)); // beta = 0 iff (V == 27 or V == 28) // Rlp(w) rlpInt( diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxrcpt/RlpTxnRcpt.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxrcpt/RlpTxnRcpt.java index 88f521913b..f213de4f4e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxrcpt/RlpTxnRcpt.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlptxrcpt/RlpTxnRcpt.java @@ -38,7 +38,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.rlputils.ByteCountAndPowerOutput; import net.consensys.linea.zktracer.types.BitDecOutput; import net.consensys.linea.zktracer.types.TransactionProcessingMetadata; @@ -55,8 +55,8 @@ public class RlpTxnRcpt implements OperationListModule { private static final Bytes BYTES_RLP_LIST_SHORT = Bytes.minimalBytes(RLP_PREFIX_LIST_SHORT); @Getter - private final StackedList operations = - new StackedList<>(LINEA_MAX_NUMBER_OF_TRANSACTIONS_IN_BATCH, 1); + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(LINEA_MAX_NUMBER_OF_TRANSACTIONS_IN_BATCH, 1); private int absLogNum = 0; 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 8ebb076bcc..f84eac73c1 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 @@ -33,7 +33,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.module.hub.defer.ContextExitDefer; import net.consensys.linea.zktracer.module.hub.defer.ImmediateContextEntryDefer; @@ -61,7 +61,10 @@ public class RomLex private final Hub hub; - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); + @Getter private List sortedOperations; private Bytes byteCode = Bytes.EMPTY; private Address address = Address.ZERO; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shakiradata/ShakiraData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shakiradata/ShakiraData.java index c8b51ccade..b81876c80d 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shakiradata/ShakiraData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shakiradata/ShakiraData.java @@ -25,7 +25,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.limits.Keccak; import net.consensys.linea.zktracer.module.limits.precompiles.RipemdBlocks; import net.consensys.linea.zktracer.module.limits.precompiles.Sha256Blocks; @@ -34,7 +34,10 @@ @RequiredArgsConstructor @Accessors(fluent = true) public class ShakiraData implements OperationListModule { - @Getter private final StackedList operations = new StackedList<>(); + @Getter + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); + private final Wcp wcp; private final Sha256Blocks sha256Blocks; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shf/Shf.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shf/Shf.java index 6fe2c1fef6..f8fcb57649 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shf/Shf.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/shf/Shf.java @@ -22,7 +22,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.evm.frame.MessageFrame; @@ -31,7 +31,8 @@ @Accessors(fluent = true) public class Shf implements OperationSetModule { - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); @Override public String moduleKey() { @@ -62,7 +63,7 @@ public void commit(List buffers) { } @Override - public StackedSet operations() { + public ModuleOperationStackedSet operations() { return operations; } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/Stp.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/Stp.java index e20197e651..a03402bba6 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/Stp.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/Stp.java @@ -26,7 +26,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.hub.fragment.imc.StpCall; import net.consensys.linea.zktracer.module.mod.Mod; import net.consensys.linea.zktracer.module.wcp.Wcp; @@ -39,7 +39,9 @@ public class Stp implements OperationSetModule { private final Wcp wcp; private final Mod mod; - @Getter private final StackedSet operations = new StackedSet<>(); + @Getter + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); public void call(StpCall stpCall) { final StpOperation stpOperation = new StpOperation(stpCall); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/trm/Trm.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/trm/Trm.java index 6d0ca7cd3a..eea9a8d5bd 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/trm/Trm.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/trm/Trm.java @@ -24,7 +24,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationSetModule; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.types.EWord; import net.consensys.linea.zktracer.types.TransactionProcessingMetadata; import org.apache.tuweni.bytes.Bytes; @@ -38,7 +38,8 @@ @Getter @Accessors(fluent = true) public class Trm implements OperationSetModule { - private final StackedSet operations = new StackedSet<>(); + private final ModuleOperationStackedSet operations = + new ModuleOperationStackedSet<>(); static final int MAX_CT = LLARGE; static final int PIVOT_BIT_FLIPS_TO_TRUE = 12; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txndata/TxnData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txndata/TxnData.java index 6c5074f8b4..4ab1f76dce 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txndata/TxnData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txndata/TxnData.java @@ -24,7 +24,7 @@ import lombok.experimental.Accessors; import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.OperationListModule; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.euc.Euc; import net.consensys.linea.zktracer.module.wcp.Wcp; import net.consensys.linea.zktracer.types.TransactionProcessingMetadata; @@ -35,7 +35,9 @@ @RequiredArgsConstructor @Accessors(fluent = true) public class TxnData implements OperationListModule { - @Getter private final StackedList operations = new StackedList<>(); + @Getter + private final ModuleOperationStackedList operations = + new ModuleOperationStackedList<>(); private final Wcp wcp; private final Euc euc; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/wcp/Wcp.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/wcp/Wcp.java index 58df5bcbe8..e2996a1910 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/wcp/Wcp.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/wcp/Wcp.java @@ -31,7 +31,7 @@ import net.consensys.linea.zktracer.ColumnHeader; import net.consensys.linea.zktracer.container.module.Module; import net.consensys.linea.zktracer.container.stacked.CountOnlyOperation; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; @@ -41,20 +41,28 @@ @RequiredArgsConstructor public class Wcp implements Module { - private final StackedSet ltOperations = new StackedSet<>(); - private final StackedSet leqOperations = new StackedSet<>(); - private final StackedSet gtOperations = new StackedSet<>(); - private final StackedSet geqOperations = new StackedSet<>(); - private final StackedSet sltOperations = new StackedSet<>(); - private final StackedSet sgtOperations = new StackedSet<>(); - private final StackedSet eqOperations = new StackedSet<>(); - private final StackedSet isZeroOperations = new StackedSet<>(); + private final ModuleOperationStackedSet ltOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet leqOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet gtOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet geqOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet sltOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet sgtOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet eqOperations = + new ModuleOperationStackedSet<>(); + private final ModuleOperationStackedSet isZeroOperations = + new ModuleOperationStackedSet<>(); /** * For perf, we split the WcpOperations into different StackedSet in order to - have smaller * set,thus faster to check for equality - remove the opcode value when checking the equality */ - private final List> operations = + private final List> operations = List.of( ltOperations, leqOperations, @@ -75,7 +83,7 @@ public String moduleKey() { @Override public void enterTransaction() { - for (StackedSet operationsSet : operations) { + for (ModuleOperationStackedSet operationsSet : operations) { operationsSet.enter(); } additionalRows.enter(); @@ -83,7 +91,7 @@ public void enterTransaction() { @Override public void popTransaction() { - for (StackedSet operationsSet : operations) { + for (ModuleOperationStackedSet operationsSet : operations) { operationsSet.pop(); } additionalRows.pop(); @@ -117,7 +125,7 @@ public void commit(List buffers) { final Trace trace = new Trace(buffers); int stamp = 0; - for (StackedSet operationsSet : operations) { + for (ModuleOperationStackedSet operationsSet : operations) { for (WcpOperation operation : operationsSet.getAll()) { operation.trace(trace, ++stamp); } @@ -126,7 +134,7 @@ public void commit(List buffers) { @Override public int lineCount() { - final int count = operations.stream().mapToInt(StackedSet::lineCount).sum(); + final int count = operations.stream().mapToInt(ModuleOperationStackedSet::lineCount).sum(); return ltOperations.conflationFinished() ? count : count + additionalRows.lineCount(); } @@ -198,7 +206,7 @@ public boolean callGEQ(final Bytes arg1, final Bytes arg2) { @Override public void traceEndConflation(final WorldView state) { - for (StackedSet operationsSet : operations) { + for (ModuleOperationStackedSet operationsSet : operations) { operationsSet.finishConflation(); } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/types/TransactionUtils.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/types/TransactionUtils.java index 0a86dcfa7a..e83d92ec94 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/types/TransactionUtils.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/types/TransactionUtils.java @@ -24,10 +24,10 @@ public static long getChainIdFromTransaction(final Transaction tx) { return tx.getChainId().get().longValueExact(); } case FRONTIER -> { - // when ChainId != 0, V = 2 * ChainID + 35 or V = 2 * ChainId + 36; + // If chainId is specified, V = 2 * ChainID + 35 or V = 2 * ChainId + 36; final long V = tx.getV().longValueExact(); if (V == 27 || V == 28) { - return 0; + throw new IllegalArgumentException("ChainId not specified in transaction"); } return (V - 35) / 2; } diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedListTests.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedListTests.java index 1e779c199d..2059c32f1f 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedListTests.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedListTests.java @@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor; import net.consensys.linea.zktracer.container.ModuleOperation; -import net.consensys.linea.zktracer.container.stacked.StackedList; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; import net.consensys.linea.zktracer.module.add.AddOperation; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes; @@ -53,7 +53,8 @@ protected int computeLineCount() { @Test void testAddedToFront() { - final StackedList state = new StackedList<>(); + final ModuleOperationStackedList state = + new ModuleOperationStackedList<>(); state.enter(); state.add(new IntegerModuleOperation(1)); @@ -69,7 +70,7 @@ void testAddedToFront() { @Test public void push() { - StackedList chunks = new StackedList<>(); + ModuleOperationStackedList chunks = new ModuleOperationStackedList<>(); chunks.enter(); chunks.add(ONE_PLUS_ONE); @@ -82,7 +83,7 @@ public void push() { @Test public void multiplePushPop() { - StackedList chunks = new StackedList<>(); + ModuleOperationStackedList chunks = new ModuleOperationStackedList<>(); chunks.enter(); chunks.add(ONE_PLUS_ONE); chunks.add(ONE_PLUS_ONE); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedSetTests.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedSetTests.java index aef6d73c1e..6edd282f47 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedSetTests.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/containers/StackedSetTests.java @@ -17,7 +17,7 @@ import java.math.BigInteger; -import net.consensys.linea.zktracer.container.stacked.StackedSet; +import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.add.AddOperation; import net.consensys.linea.zktracer.opcode.OpCode; import org.apache.tuweni.bytes.Bytes; @@ -40,7 +40,7 @@ public class StackedSetTests { @Test public void push() { - StackedSet chunks = new StackedSet<>(); + ModuleOperationStackedSet chunks = new ModuleOperationStackedSet<>(); chunks.enter(); chunks.add(ONE_PLUS_ONE); @@ -53,7 +53,7 @@ public void push() { @Test public void multiplePushPop() { - StackedSet chunks = new StackedSet<>(); + ModuleOperationStackedSet chunks = new ModuleOperationStackedSet<>(); chunks.enter(); chunks.add(ONE_PLUS_ONE); chunks.add(ONE_PLUS_ONE); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/BasicAdditionTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/BasicAdditionTest.java deleted file mode 100644 index deb812cb5c..0000000000 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/BasicAdditionTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Consensys Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package net.consensys.linea.zktracer.instructionprocessing; - -import net.consensys.linea.testing.BytecodeCompiler; -import net.consensys.linea.testing.BytecodeRunner; -import net.consensys.linea.zktracer.opcode.OpCode; -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; - -public class BasicAdditionTest { - @Test - void basicAdditionTest() { - final Bytes bytecode = - BytecodeCompiler.newProgram().push(1).push(2).op(OpCode.ADD).op(OpCode.POP).compile(); - BytecodeRunner.of(bytecode).run(); - } -} diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/StpTests.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/StpTests.java deleted file mode 100644 index bfba1f1983..0000000000 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/StpTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Consensys Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package net.consensys.linea.zktracer.instructionprocessing; - -import net.consensys.linea.testing.BytecodeCompiler; -import net.consensys.linea.zktracer.opcode.OpCode; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Wei; - -public class StpTests { - - private void forceWarmRecipient( - BytecodeCompiler bytecode, Address recipient, boolean forceWarmth) { - if (forceWarmth) { - bytecode.push(recipient).op(OpCode.BALANCE).op(OpCode.POP); - } - } - - // private void appendCall(BytecodeCompiler bytecode, Address recipient, Wei value) { - // - // bytecode - // .push() // return at capacity - // .push() // return at offset - // .push() // call data size - // .push() // call data offset - // .push() // value - // .push() // address - // .push() // gas - // } - private void appendCallcode(BytecodeCompiler bytecode, Address recipient, Wei value) {} - - private void appendDelegatecall(BytecodeCompiler bytecode, Address recipient) {} - - private void appendStaticcall(BytecodeCompiler bytecode, Address recipient, Wei value) {} -} diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/hub/MessageFrameTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/hub/MessageFrameTest.java index cfeb8c2515..10f23a8fb6 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/hub/MessageFrameTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/hub/MessageFrameTest.java @@ -29,7 +29,7 @@ public class MessageFrameTest { @Test - void TestCreate() { + void testCreate() { // The pc is not updated as expected // We do not execute the init code of the created smart contract // TODO: fix this! @@ -50,7 +50,7 @@ void TestCreate() { } @Test - void TestCall() { + void testCall() { // Interestingly for CALL the pc is updated as expected // We execute the bytecode of the called smart contract BytecodeCompiler program = BytecodeCompiler.newProgram(); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/SeveralKeccaks.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/SeveralKeccaks.java index a0284527f2..615fb2fd11 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/SeveralKeccaks.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/SeveralKeccaks.java @@ -28,7 +28,7 @@ public void testMul() { /** For readability we write __ instead of 00 */ @Test - void TestIsTheBeefDeadYet() { + void testIsTheBeefDeadYet() { BytecodeRunner.of( BytecodeCompiler.newProgram() .push("deadbeef") // 4 bytes diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobCallTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobCallTest.java index 74a387377d..31d691e6e3 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobCallTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobCallTest.java @@ -41,7 +41,7 @@ public class OobCallTest { @Test - void TestCallSendValueGreaterThanBalanceHiNonZero() { + void testCallSendValueGreaterThanBalanceHiNonZero() { final EWord balanceOfCaller = EWord.of(BigInteger.ONE); final EWord amountToSend = EWord.of(BigInteger.ONE, BigInteger.ZERO); @@ -49,7 +49,7 @@ void TestCallSendValueGreaterThanBalanceHiNonZero() { } @Test - void TestCallSendValueGreaterThanBalanceLoNonZero() { + void testCallSendValueGreaterThanBalanceLoNonZero() { final EWord balanceOfCaller = EWord.of(BigInteger.ONE); final EWord amountToSend = EWord.of(BigInteger.ZERO, BigInteger.TWO); @@ -57,7 +57,7 @@ void TestCallSendValueGreaterThanBalanceLoNonZero() { } @Test - void TestCallSendValueGreaterThanBalanceHiLoNonZero() { + void testCallSendValueGreaterThanBalanceHiLoNonZero() { final EWord balanceOfCaller = EWord.of(BigInteger.ONE); final EWord amountToSend = EWord.of(BigInteger.TWO, BigInteger.TWO); @@ -65,7 +65,7 @@ void TestCallSendValueGreaterThanBalanceHiLoNonZero() { } @Test - void TestCallSendValueSmallerThanBalanceLoNonZero() { + void testCallSendValueSmallerThanBalanceLoNonZero() { final EWord balanceOfCaller = EWord.of(BigInteger.TWO); final EWord amountToSend = EWord.of(BigInteger.ZERO, BigInteger.ONE); @@ -91,7 +91,7 @@ void testRecursiveCalls1025() { } @Test - void TestRecursiveCallsWithBytecode() { + void testRecursiveCallsWithBytecode() { final BytecodeRunner bytecodeRunner = BytecodeRunner.of(Bytes.fromHexString("60006000600060006000305af1")); bytecodeRunner.run(Wei.fromEth(400), 0xFFFFFFL); @@ -102,11 +102,11 @@ void TestRecursiveCallsWithBytecode() { } /** - * Same as {@link #TestRecursiveCallsWithBytecode()} but with an ADD opcode at the end triggering + * Same as {@link #testRecursiveCallsWithBytecode()} but with an ADD opcode at the end triggering * SUX */ @Test - void TestRecursiveCallsWithBytecodeFollowedByStackUnderflow() { + void testRecursiveCallsWithBytecodeFollowedByStackUnderflow() { final BytecodeRunner bytecodeRunner = BytecodeRunner.of(Bytes.fromHexString("60006000600060006000305af101")); bytecodeRunner.run(Wei.fromEth(400), 0xFFFFFFL); @@ -116,9 +116,9 @@ void TestRecursiveCallsWithBytecodeFollowedByStackUnderflow() { assertTrue(stackUnderflow(hub.pch().exceptions())); } - /** Same as {@link #TestRecursiveCallsWithBytecode()} but with an ADDRESS opcode at the end */ + /** Same as {@link #testRecursiveCallsWithBytecode()} but with an ADDRESS opcode at the end */ @Test - void TestRecursiveCallsWithBytecodeFollowedByAddress() { + void testRecursiveCallsWithBytecodeFollowedByAddress() { final BytecodeRunner bytecodeRunner = BytecodeRunner.of(Bytes.fromHexString("60006000600060006000305af130")); bytecodeRunner.run(Wei.fromEth(400), (long) 21000 + 10000); @@ -128,9 +128,9 @@ void TestRecursiveCallsWithBytecodeFollowedByAddress() { assertTrue(Exceptions.none(hub.pch().exceptions())); } - /** Same as {@link #TestRecursiveCallsWithBytecode()} but with an STOP opcode at the end */ + /** Same as {@link #testRecursiveCallsWithBytecode()} but with an STOP opcode at the end */ @Test - void TestRecursiveCallsWithBytecodeFollowedByExplicitStop() { + void testRecursiveCallsWithBytecodeFollowedByExplicitStop() { final BytecodeRunner bytecodeRunner = BytecodeRunner.of(Bytes.fromHexString("60006000600060006000305af100")); bytecodeRunner.run(Wei.fromEth(400), 0xFFFFFFL); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobJumpAndJumpiTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobJumpAndJumpiTest.java index 1032dcd932..8f046923c3 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobJumpAndJumpiTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobJumpAndJumpiTest.java @@ -42,7 +42,7 @@ public class OobJumpAndJumpiTest { BigInteger.ONE.shiftLeft(128).subtract(BigInteger.ONE); @Test - void TestJumpSequenceSuccessTrivial() { + void testJumpSequenceSuccessTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJump(EWord.of(35), program); @@ -70,7 +70,7 @@ void TestJumpSequenceSuccessTrivial() { } @Test - void TestJumpSequenceSuccessBackAndForth() { + void testJumpSequenceSuccessBackAndForth() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJump(EWord.of(71), program); @@ -98,7 +98,7 @@ void TestJumpSequenceSuccessBackAndForth() { } @Test - void TestJumpSequenceFailingNoJumpdestTrivial() { + void testJumpSequenceFailingNoJumpdestTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJump(EWord.of(35), program); @@ -125,7 +125,7 @@ void TestJumpSequenceFailingNoJumpdestTrivial() { } @Test - void TestJumpSequenceFailingOobTrivial() { + void testJumpSequenceFailingOobTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJump(EWord.of(35), program); @@ -152,7 +152,7 @@ void TestJumpSequenceFailingOobTrivial() { } @Test - void TestJumpSequenceSuccessRandom() { + void testJumpSequenceSuccessRandom() { final int N_JUMPS = 200; final int MAX_JUMPDESTINATION = 256; final int SPREADING_FACTOR = 256; @@ -198,7 +198,7 @@ void TestJumpSequenceSuccessRandom() { } @Test - void TestJumpSequenceSuccessRandomBackAndForth() { + void testJumpSequenceSuccessRandomBackAndForth() { final int N_JUMPS = 200; final int MAX_JUMPDESTINATION = 256; final int SPREADING_FACTOR = 256; @@ -248,7 +248,7 @@ void TestJumpSequenceSuccessRandomBackAndForth() { } @Test - void TestJumpiSequenceSuccessTrivial() { + void testJumpiSequenceSuccessTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJumpi(EWord.of(68), EWord.of(1), program); @@ -276,7 +276,7 @@ void TestJumpiSequenceSuccessTrivial() { } @Test - void TestJumpiSequenceSuccessBackAndForth() { + void testJumpiSequenceSuccessBackAndForth() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJumpi(EWord.of(137), EWord.of(1), program); @@ -304,7 +304,7 @@ void TestJumpiSequenceSuccessBackAndForth() { } @Test - void TestJumpiSequenceFailingNoJumpdestTrivial() { + void testJumpiSequenceFailingNoJumpdestTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJumpi(EWord.of(68), EWord.of(1), program); @@ -331,7 +331,7 @@ void TestJumpiSequenceFailingNoJumpdestTrivial() { } @Test - void TestJumpiSequenceFailingOobTrivial() { + void testJumpiSequenceFailingOobTrivial() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJumpi(EWord.of(68), EWord.of(1), program); @@ -359,7 +359,7 @@ void TestJumpiSequenceFailingOobTrivial() { } @Test - void TestNoJumpi() { + void testNoJumpi() { BytecodeCompiler program = BytecodeCompiler.newProgram(); appendJumpi(EWord.of(68), EWord.of(0), program); // jumpCondition is 0, that means no JUMPI @@ -378,7 +378,7 @@ void TestNoJumpi() { } @Test - void TestJumpiHiNonZero() { + void testJumpiHiNonZero() { BytecodeCompiler program = BytecodeCompiler.newProgram(); EWord jumpCondition = EWord.of(TWO_POW_128_MINUS_ONE, BigInteger.ZERO); @@ -398,7 +398,7 @@ void TestJumpiHiNonZero() { } @Test - void TestJumpiLoNonZero() { + void testJumpiLoNonZero() { BytecodeCompiler program = BytecodeCompiler.newProgram(); EWord jumpCondition = EWord.of(BigInteger.valueOf(0), TWO_POW_128_MINUS_ONE); @@ -418,7 +418,7 @@ void TestJumpiLoNonZero() { } @Test - void TestJumpiHiLoNonZero() { + void testJumpiHiLoNonZero() { BytecodeCompiler program = BytecodeCompiler.newProgram(); EWord jumpCondition = EWord.of(TWO_POW_128_MINUS_ONE, TWO_POW_128_MINUS_ONE); @@ -438,7 +438,7 @@ void TestJumpiHiLoNonZero() { } @Test - void TestJumpiSequenceSuccessRandom() { + void testJumpiSequenceSuccessRandom() { final int N_JUMPIS = 200; final int MAX_JUMPDESTINATION = 256; final int SPREADING_FACTOR = 256; @@ -489,7 +489,7 @@ void TestJumpiSequenceSuccessRandom() { } @Test - void TestJumpiSequenceSuccessRandomBackAndForth() { + void testJumpiSequenceSuccessRandomBackAndForth() { final int N_JUMPIS = 200; final int MAX_JUMPDESTINATION = 256; final int SPREADING_FACTOR = 256; diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobRdcTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobRdcTest.java index 483065137c..839e256585 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobRdcTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobRdcTest.java @@ -37,7 +37,7 @@ public class OobRdcTest { BigInteger.ONE.shiftLeft(128).subtract(BigInteger.valueOf(100)); @Test - void TestReturnDataCopyMaxPosZero() { + void testReturnDataCopyMaxPosZero() { // maxPos = offset + size = 0 + 0 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.ZERO, BigInteger.ZERO); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -49,7 +49,7 @@ void TestReturnDataCopyMaxPosZero() { } @Test - void TestReturnDataCopyMaxPosRds() { + void testReturnDataCopyMaxPosRds() { // maxPos = offset + size = 12 + 20 = rds = 32 BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(12), BigInteger.valueOf(20)); @@ -62,7 +62,7 @@ void TestReturnDataCopyMaxPosRds() { } @Test - void TestReturnDataCopyMaxPosSmallerThanRds() { + void testReturnDataCopyMaxPosSmallerThanRds() { // maxPos = offset + size = 3 + 4 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(3), BigInteger.valueOf(4)); @@ -75,7 +75,7 @@ void TestReturnDataCopyMaxPosSmallerThanRds() { } @Test - void TestReturnDataCopyMaxPosSmallerThanRdsAndOffsetZero() { + void testReturnDataCopyMaxPosSmallerThanRdsAndOffsetZero() { // maxPos = offset + size = 0 + 4 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(0), BigInteger.valueOf(4)); @@ -88,7 +88,7 @@ void TestReturnDataCopyMaxPosSmallerThanRdsAndOffsetZero() { } @Test - void TestReturnDataCopyMaxPosSmallerThanRdsAndSizeZero() { + void testReturnDataCopyMaxPosSmallerThanRdsAndSizeZero() { // maxPos = offset + size = 3 + 0 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(3), BigInteger.valueOf(0)); @@ -104,7 +104,7 @@ void TestReturnDataCopyMaxPosSmallerThanRdsAndSizeZero() { // offset smaller cases @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeSmall() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeSmall() { // maxPos = offset + size = 10 + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(10), BigInteger.valueOf(23)); @@ -117,7 +117,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeSmall() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigLeft() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigLeft() { // maxPos = offset + size = 10 + TWO_POW_128_LEFT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(10), TWO_POW_128_LEFT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -129,7 +129,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigLeft() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigRight() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigRight() { // maxPos = offset + size = 10 + TWO_POW_128_RIGHT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(10), TWO_POW_128_RIGHT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -142,7 +142,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetSmallerAndSizeBigRight() { // offset just greater cases @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeZero() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeZero() { // maxPos = offset + size = 33 + 0 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(33), BigInteger.valueOf(0)); @@ -155,7 +155,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeZero() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeSmall() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeSmall() { // maxPos = offset + size = 33 + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(33), BigInteger.valueOf(23)); @@ -168,7 +168,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeSmall() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigLeft() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigLeft() { // maxPos = offset + size = 33 + TWO_POW_128_LEFT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(33), TWO_POW_128_LEFT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -180,7 +180,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigLeft() } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigRight() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigRight() { // maxPos = offset + size = 33 + TWO_POW_128_RIGHT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(BigInteger.valueOf(33), TWO_POW_128_RIGHT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -193,7 +193,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetJustGreaterAndSizeBigRight() // offset big left cases @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeZero() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeZero() { // maxPos = offset + size = TWO_POW_128_LEFT + 0 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_LEFT, BigInteger.valueOf(0)); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -205,7 +205,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeZero() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeSmall() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeSmall() { // maxPos = offset + size = TWO_POW_128_LEFT + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_LEFT, BigInteger.valueOf(23)); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -217,7 +217,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeSmall() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigLeft() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigLeft() { // maxPos = offset + size = TWO_POW_128_LEFT + TWO_POW_128_LEFT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_LEFT, TWO_POW_128_LEFT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -229,7 +229,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigLeft() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigRight() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigRight() { // maxPos = offset + size = TWO_POW_128_LEFT + TWO_POW_128_RIGHT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_LEFT, TWO_POW_128_RIGHT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -242,7 +242,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeBigRight() { // offset big right cases @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeZero() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeZero() { // maxPos = offset + size = TWO_POW_128_RIGHT + 0 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_RIGHT, BigInteger.valueOf(0)); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -254,7 +254,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeZero() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeSmall() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeSmall() { // maxPos = offset + size = TWO_POW_128_RIGHT + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_RIGHT, BigInteger.valueOf(23)); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -266,7 +266,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeSmall() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigLeft() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigLeft() { // maxPos = offset + size = TWO_POW_128_Right + TWO_POW_128_LEFT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_RIGHT, TWO_POW_128_LEFT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -278,7 +278,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigLeft() { } @Test - void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigRight() { + void testReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigRight() { // maxPos = offset + size = TWO_POW_128_RIGHT + TWO_POW_128_RIGHT > 32 = rds BytecodeCompiler program = initReturnDataCopyProgram(TWO_POW_128_RIGHT, TWO_POW_128_RIGHT); BytecodeRunner bytecodeRunner = BytecodeRunner.of(program.compile()); @@ -291,7 +291,7 @@ void TestReturnDataCopyMaxPosGreaterThanRdsAndOffsetBigRightAndSizeBigRight() { // Same cases but using identity precompile @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosZero() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosZero() { // maxPos = offset + size = 0 + 0 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile(BigInteger.ZERO, BigInteger.ZERO); @@ -311,7 +311,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosZero() { } @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosRds() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosRds() { // maxPos = offset + size = 12 + 20 = rds = 32 BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile( @@ -333,7 +333,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosRds() { } @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRds() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRds() { // maxPos = offset + size = 3 + 4 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile( @@ -354,7 +354,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRds() { } @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndOffsetZero() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndOffsetZero() { // maxPos = offset + size = 0 + 4 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile( @@ -375,7 +375,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndOffsetZero( } @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndSizeZero() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndSizeZero() { // maxPos = offset + size = 3 + 0 < rds = 32 BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile( @@ -399,7 +399,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosSmallerThanRdsAndSizeZero() // offset smaller cases @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetSmallerAndSizeSmall() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetSmallerAndSizeSmall() { // maxPos = offset + size = 10 + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile( @@ -551,7 +551,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetSmall // offset big left cases @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeZero() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeZero() { // maxPos = offset + size = TWO_POW_128_LEFT + 0 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile(TWO_POW_128_LEFT, BigInteger.valueOf(0)); @@ -571,7 +571,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLe } @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeSmall() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLeftAndSizeSmall() { // maxPos = offset + size = TWO_POW_128_LEFT + 23 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile(TWO_POW_128_LEFT, BigInteger.valueOf(23)); @@ -634,7 +634,7 @@ void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigLe // offset big right cases @Test - void TestReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigRightAndSizeZero() { + void testReturnDataCopyUsingIdentityPrecompileMaxPosGreaterThanRdsAndOffsetBigRightAndSizeZero() { // maxPos = offset + size = TWO_POW_128_RIGHT + 0 > 32 = rds BytecodeCompiler program = initReturnDataCopyProgramUsingIdentityPrecompile(TWO_POW_128_RIGHT, BigInteger.valueOf(0)); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobSha2RipemdIdentityTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobSha2RipemdIdentityTest.java index e686853a9b..5fce76cc19 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobSha2RipemdIdentityTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/oob/OobSha2RipemdIdentityTest.java @@ -48,7 +48,7 @@ static int[] argSizesSource() { @ParameterizedTest @MethodSource("argSizesSource") - void TestSha2(int argSize) throws NoSuchAlgorithmException { + void testSha2(int argSize) throws NoSuchAlgorithmException { String data = generateHexString(argSize); ProgramAndRetInfo programAndRetInfo = initProgramInvokingPrecompile(data, Address.SHA256); BytecodeCompiler program = programAndRetInfo.program(); @@ -72,7 +72,7 @@ void TestSha2(int argSize) throws NoSuchAlgorithmException { @ParameterizedTest @MethodSource("argSizesSource") - void TestIdentity(int argSize) { + void testIdentity(int argSize) { String data = generateHexString(argSize); ProgramAndRetInfo programAndRetInfo = initProgramInvokingPrecompile(data, Address.ID); BytecodeCompiler program = programAndRetInfo.program(); @@ -90,7 +90,7 @@ void TestIdentity(int argSize) { @ParameterizedTest @MethodSource("argSizesSource") - void TestRipmd(int argSize) { + void testRipmd(int argSize) { String data = generateHexString(argSize); ProgramAndRetInfo programAndRetInfo = initProgramInvokingPrecompile(data, Address.RIPEMD160); BytecodeCompiler program = programAndRetInfo.program(); @@ -134,7 +134,7 @@ private static String ripemd160(String hexString) { } @Test - void TestPrcSupportMethods() throws NoSuchAlgorithmException { + void testPrcSupportMethods() throws NoSuchAlgorithmException { String data = generateHexString(32); System.out.println("SHA2-256 of random data: " + sha256(data)); System.out.println("RIPEMD-160 of random data: " + ripemd160(data)); @@ -264,7 +264,7 @@ ProgramAndRetInfo initProgramInvokingPrecompile(String data, Address address) { @ParameterizedTest @MethodSource("argSizesSource") - void TestInitProgramInvokingPrecompileDataInMemorySupportMethod(int argSize) { + void testInitProgramInvokingPrecompileDataInMemorySupportMethod(int argSize) { // This test is to ensure that the data written in memory is the same as the input data String data = generateHexString(argSize); diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/shf/ShfRtTracerTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/shf/ShfRtTracerTest.java index 12878caee6..20951e498c 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/shf/ShfRtTracerTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/shf/ShfRtTracerTest.java @@ -48,7 +48,7 @@ void testFailingBlockchainBlock(final int opCodeValue) { } @Test - void TestShfResultFailure() { + void testShfResultFailure() { BytecodeRunner.of( Bytes.fromHexString( "7faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa7fa0000000000000000000000000000000000000000000000000000000000000001d"))