From d417838b9aa11eba8e79c6e49ff0c5eeb10a29db Mon Sep 17 00:00:00 2001 From: F Bojarski Date: Thu, 13 Nov 2025 22:06:11 +0530 Subject: [PATCH 1/5] clean: no duplicate for exp and cleaning Signed-off-by: F Bojarski --- .../net/consensys/linea/zktracer/module/gas/Gas.java | 4 ++-- .../hub/fragment/common/CommonFragmentValues.java | 2 +- .../zktracer/module/hub/fragment/imc/StpCall.java | 11 +++++------ .../consensys/linea/zktracer/module/exp/ExpTest.java | 9 +++++++++ 4 files changed, 17 insertions(+), 9 deletions(-) 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 55d9f2ae7f..88c5bbd6d1 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 @@ -51,9 +51,9 @@ public ModuleName moduleKey() { return GAS; } - public void call(GasParameters gasParameters, Hub hub, CommonFragmentValues commonValues) { + public void call(Hub hub, CommonFragmentValues commonValues) { this.commonValues = commonValues; - this.gasParameters = gasParameters; + gasParameters = new GasParameters(); hub.defers().scheduleForPostExecution(this); } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java index 73409e4337..7e5ae53b05 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java @@ -124,7 +124,7 @@ public CommonFragmentValues(Hub hub) { if (contextMayChange) { // Trigger the gas module in case contextMayChange is true - hub.gas().call(new GasParameters(), hub, this); + hub.gas().call(hub, this); } if (none(exceptions)) { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/imc/StpCall.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/imc/StpCall.java index f312f58ce1..5880562671 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/imc/StpCall.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/imc/StpCall.java @@ -62,8 +62,8 @@ public class StpCall implements TraceSubFragment { private final OpCodeData opCodeData; public StpCall(Hub hub, MessageFrame frame, long memoryExpansionGas) { - this.opCode = hub.opCode(); - this.opCodeData = hub.opCodeData(); + opCodeData = hub.opCodeData(); + opCode = opCodeData.mnemonic(); checkArgument( opCodeData.isCall() || opCodeData.isCreate(), @@ -74,21 +74,20 @@ public StpCall(Hub hub, MessageFrame frame, long memoryExpansionGas) { this.gasActual = frame.getRemainingGas(); if (this.opCodeData.isCall()) { - this.stpCallForCalls(hub); + this.stpCallForCalls(hub, frame, opCode); } else { this.stpCallForCreates(frame); } } - private void stpCallForCalls(Hub hub) { - final MessageFrame frame = hub.messageFrame(); + private void stpCallForCalls(Hub hub, MessageFrame frame, OpCode opCode) { final Address to = Words.toAddress(frame.getStackItem(1)); final Account toAccount = frame.getWorldUpdater().get(to); this.gas = EWord.of(frame.getStackItem(0)); this.value = opCodeData.callHasValueArgument() ? EWord.of(frame.getStackItem(2)) : ZERO; this.exists = - switch (hub.opCode()) { + switch (opCode) { case CALL -> toAccount != null && !toAccount.isEmpty(); case CALLCODE, DELEGATECALL, STATICCALL -> false; default -> throw new IllegalArgumentException( diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java index f317a130ec..311fd780f8 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java @@ -68,6 +68,15 @@ void testExpLogSingleCase(TestInfo testInfo) { bytecodeRunner.run(chainConfig, testInfo); } + @Test + void testExpLogDuplicate(TestInfo testInfo) { + BytecodeRunner bytecodeRunner = + BytecodeRunner.of(BytecodeCompiler.newProgram(chainConfig) + .push(256).push(256).op(OpCode.EXP).op(OpCode.POP) + .push(256).push(256).op(OpCode.EXP).op(OpCode.POP)); + bytecodeRunner.run(chainConfig, testInfo); + } + @Test void testModexpLogSingleCase(TestInfo testInfo) { BytecodeCompiler program = From ebd5a4a027c45aa75508f104ead1870a937156f9 Mon Sep 17 00:00:00 2001 From: F Bojarski Date: Fri, 14 Nov 2025 11:22:17 +0530 Subject: [PATCH 2/5] ras Signed-off-by: F Bojarski --- .../consensys/linea/zktracer/module/euc/Euc.java | 4 +++- .../linea/zktracer/module/exp/ExpOperation.java | 7 +++---- .../hub/fragment/common/CommonFragmentValues.java | 1 - .../linea/zktracer/module/exp/ExpTest.java | 13 ++++++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) 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 18b5e4f415..1ce1789bbb 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 @@ -102,7 +102,9 @@ public EucOperation callEUC(final Bytes dividend, final Bytes divisor) { final Bytes quotient = bigIntegerToBytes(dividendBI.divide(divisorBI)); final Bytes remainder = bigIntegerToBytes(dividendBI.remainder(divisorBI)); - final EucOperation operation = new EucOperation(dividend, divisor, quotient, remainder); + final EucOperation operation = + new EucOperation( + dividend.trimLeadingZeros(), divisor.trimLeadingZeros(), quotient, remainder); final boolean isNew = operations.add(operation); if (isNew) { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/ExpOperation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/ExpOperation.java index 1aa1d69345..11c5717c64 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/ExpOperation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/exp/ExpOperation.java @@ -18,8 +18,7 @@ import static com.google.common.base.Preconditions.*; import static com.google.common.math.BigIntegerMath.log2; import static java.lang.Math.min; -import static net.consensys.linea.zktracer.Trace.EXP_INST_EXPLOG; -import static net.consensys.linea.zktracer.Trace.EXP_INST_MODEXPLOG; +import static net.consensys.linea.zktracer.Trace.*; import static net.consensys.linea.zktracer.module.hub.precompiles.ModexpMetadata.BASE_MIN_OFFSET; import static net.consensys.linea.zktracer.types.Conversions.bigIntegerToBytes; @@ -62,8 +61,8 @@ public ExpOperation(ExpCall expCall) { "MODEXP call data unexpectedly short"); final EWord rawLead = modexpMetadata.rawLeadingWord(); final int cdsCutoff = - Math.min(modexpMetadata.callData().size() - BASE_MIN_OFFSET - bbsInt, 32); - final int ebsCutoff = Math.min(ebsInt, 32); + Math.min(modexpMetadata.callData().size() - BASE_MIN_OFFSET - bbsInt, WORD_SIZE); + final int ebsCutoff = Math.min(ebsInt, WORD_SIZE); final BigInteger leadLog = BigInteger.valueOf(LeadLogTrimLead.fromArgs(rawLead, cdsCutoff, ebsCutoff).leadLog()); // Fill expCall diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java index 7e5ae53b05..58ca0b1f01 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/common/CommonFragmentValues.java @@ -30,7 +30,6 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; -import net.consensys.linea.zktracer.module.gas.GasParameters; import net.consensys.linea.zktracer.module.hub.Hub; import net.consensys.linea.zktracer.module.hub.HubProcessingPhase; import net.consensys.linea.zktracer.module.hub.TransactionProcessingType; diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java index 311fd780f8..5f6bb3c4bf 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/exp/ExpTest.java @@ -71,9 +71,16 @@ void testExpLogSingleCase(TestInfo testInfo) { @Test void testExpLogDuplicate(TestInfo testInfo) { BytecodeRunner bytecodeRunner = - BytecodeRunner.of(BytecodeCompiler.newProgram(chainConfig) - .push(256).push(256).op(OpCode.EXP).op(OpCode.POP) - .push(256).push(256).op(OpCode.EXP).op(OpCode.POP)); + BytecodeRunner.of( + BytecodeCompiler.newProgram(chainConfig) + .push(256) + .push(256) + .op(OpCode.EXP) + .op(OpCode.POP) + .push(256) + .push(256) + .op(OpCode.EXP) + .op(OpCode.POP)); bytecodeRunner.run(chainConfig, testInfo); } From f7a8e011703209286beb6ad15d17a4706bf3a391 Mon Sep 17 00:00:00 2001 From: F Bojarski Date: Fri, 14 Nov 2025 11:26:41 +0530 Subject: [PATCH 3/5] clean EUC Signed-off-by: F Bojarski --- .../net/consensys/linea/zktracer/ZkCounter.java | 3 +-- .../consensys/linea/zktracer/module/euc/Euc.java | 13 +------------ .../linea/zktracer/module/euc/EucOperation.java | 12 ++++++------ .../consensys/linea/zktracer/module/hub/Hub.java | 3 +-- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/ZkCounter.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/ZkCounter.java index 444e20d57e..0c5545fda6 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/ZkCounter.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/ZkCounter.java @@ -153,7 +153,7 @@ public class ZkCounter implements LineCountingTracer { new CountingOnlyModule(BLOCK_HASH, trace.blockhash().spillage()); final BlsData blsdata; final EcData ecdata; - final Euc euc; + final Euc euc = new Euc(); final Exp exp = new Exp(); final Ext ext = new Ext(); final CountingOnlyModule gas = new CountingOnlyModule(GAS, trace.gas().spillage()); @@ -327,7 +327,6 @@ public List checkedModules() { } public ZkCounter(LineaL1L2BridgeSharedConfiguration bridgeConfiguration) { - euc = new Euc(wcp); keccak = new Keccak(ecRecoverEffectiveCall, blockTransactions); ecdata = new EcData( 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 1ce1789bbb..02b5d5b36b 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 @@ -29,7 +29,6 @@ import net.consensys.linea.zktracer.container.stacked.CountOnlyOperation; import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedSet; import net.consensys.linea.zktracer.module.ModuleName; -import net.consensys.linea.zktracer.module.wcp.Wcp; import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.evm.worldstate.WorldView; @@ -38,7 +37,6 @@ @RequiredArgsConstructor @Accessors(fluent = true) public class Euc implements OperationSetModule { - private final Wcp wcp; @Getter private final ModuleOperationStackedSet operations = @@ -102,15 +100,6 @@ public EucOperation callEUC(final Bytes dividend, final Bytes divisor) { final Bytes quotient = bigIntegerToBytes(dividendBI.divide(divisorBI)); final Bytes remainder = bigIntegerToBytes(dividendBI.remainder(divisorBI)); - final EucOperation operation = - new EucOperation( - dividend.trimLeadingZeros(), divisor.trimLeadingZeros(), quotient, remainder); - - final boolean isNew = operations.add(operation); - if (isNew) { - wcp.callLT(operation.remainder(), operation.divisor()); - } - - return operation; + return new EucOperation(dividend, divisor, quotient, remainder); } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/EucOperation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/EucOperation.java index fe78b39193..79925c1f11 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/EucOperation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/euc/EucOperation.java @@ -38,8 +38,8 @@ public EucOperation( final Bytes divisorTrim = divisor.trimLeadingZeros(); final Bytes quotientTrim = quotient.trimLeadingZeros(); - this.dividend = dividend; - this.divisor = divisorTrim; + this.dividend = dividend.trimLeadingZeros(); + this.divisor = divisorTrim.trimLeadingZeros(); this.quotient = quotientTrim; this.remainder = remainder; } @@ -54,10 +54,10 @@ void trace(Trace.Euc trace) { final Bytes ceil = this.ceiling(); trace - .dividend(this.dividend) - .divisor(this.divisor) - .quotient(this.quotient) - .remainder(this.remainder) + .dividend(dividend) + .divisor(divisor) + .quotient(quotient) + .remainder(remainder) .ceil(ceil) .validateRow(); } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Hub.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Hub.java index 2dddcbe219..b448218655 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Hub.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Hub.java @@ -204,11 +204,10 @@ public int spillage(Trace trace) { // stateless modules private final Wcp wcp = new Wcp(); - private final Add add = new Add(); private final Bin bin = new Bin(); private final Blockhash blockhash; - private final Euc euc = new Euc(wcp); + private final Euc euc = new Euc(); private final Ext ext = new Ext(); private final Gas gas = new Gas(); private final Mul mul = new Mul(); From b9f17e6c9ce7d4569e27bcdb0a5332c2edf061cf Mon Sep 17 00:00:00 2001 From: F Bojarski Date: Fri, 14 Nov 2025 11:28:56 +0530 Subject: [PATCH 4/5] ras Signed-off-by: F Bojarski --- .../java/net/consensys/linea/zktracer/module/euc/Euc.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 02b5d5b36b..29197dd4bc 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 @@ -100,6 +100,8 @@ public EucOperation callEUC(final Bytes dividend, final Bytes divisor) { final Bytes quotient = bigIntegerToBytes(dividendBI.divide(divisorBI)); final Bytes remainder = bigIntegerToBytes(dividendBI.remainder(divisorBI)); - return new EucOperation(dividend, divisor, quotient, remainder); + final EucOperation op = new EucOperation(dividend, divisor, quotient, remainder); + operations.add(op); + return op; } } From 564f95d04fef11d29b52ae04ed92e6938917e2fb Mon Sep 17 00:00:00 2001 From: F Bojarski Date: Fri, 14 Nov 2025 14:52:23 +0530 Subject: [PATCH 5/5] ras update release name Signed-off-by: F Bojarski --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d78e910b92..ea42a61817 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -releaseVersion=beta-v4.0-rc12 +releaseVersion=beta-v5.0-integration-test-wo-modexp-secp256r1 besuVersion=25.11.0-RC1-linea2 shomeiVersion=2.4-develop besuShomeiPluginVersion=v0.7.4