Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
089f81c
feat: constraints update
OlivierBBB Nov 7, 2025
bd40fca
constraints update
OlivierBBB Nov 7, 2025
4718cd1
first commit
OlivierBBB Nov 12, 2025
0bd9eef
various ...
OlivierBBB Nov 13, 2025
56978e9
stuff ...
OlivierBBB Nov 14, 2025
1bcb4a3
clean up
OlivierBBB Nov 14, 2025
5be004c
fix: 99% up to par + @EqualsAndHash(callSuper = true)
OlivierBBB Nov 14, 2025
de62eed
fix: ModexpTests
OlivierBBB Nov 14, 2025
613c290
feat: fix ZkCounter event detection
OlivierBBB Nov 14, 2025
7898299
spotless
OlivierBBB Nov 15, 2025
09ba3c8
spotless ... again ?
OlivierBBB Nov 15, 2025
799e5ae
feat: Osaka MODEXP pricing OOB call
OlivierBBB Nov 16, 2025
b9351dc
stuff
OlivierBBB Nov 16, 2025
448e1bc
spotless
OlivierBBB Nov 16, 2025
516f1ef
setting TOT in MODEXP's MMU instructions (DATA and ZERO)
OlivierBBB Nov 16, 2025
c7374ee
small stuff
OlivierBBB Nov 17, 2025
e7f461e
bug: use OsakaBlakeModexpOperation for Osaka rather than LondonBla
OlivierBBB Nov 17, 2025
e1591ee
feat: most tests are passing
OlivierBBB Nov 17, 2025
a951f32
feat: constraints update
OlivierBBB Nov 17, 2025
cbf716f
merge arith-dev
OlivierBBB Nov 17, 2025
14d43b2
constraints update
OlivierBBB Nov 17, 2025
84ec172
feat: byteMultiplier of leadLog in MODEXP made fork dependent
OlivierBBB Nov 18, 2025
e0ee516
feat: ugly test fixes
OlivierBBB Nov 18, 2025
5d496ea
feat: fork dependent MODEXP_PRICING byte multiplier m * (ebs - 32)
OlivierBBB Nov 18, 2025
cc7cca1
feat: fork dependent xbsNonzero for MODEXP_XBS
OlivierBBB Nov 18, 2025
604d294
ras: constraints commit update
OlivierBBB Nov 18, 2025
f97e56c
feat: add fork field to ZkCounter class
OlivierBBB Nov 18, 2025
5fbf41e
spotless
OlivierBBB Nov 18, 2025
3c7db9d
fix: use fork appropriate gasLimit in LowGasStipendPrecompileCallTests
OlivierBBB Nov 18, 2025
1f0bb09
Merge branch 'arith-dev' into EIP-7823-and-7883---Osaka-MODEXP-changes
OlivierBBB Nov 19, 2025
cc31318
fix: disable parallelism (enabled by mistake)
OlivierBBB Nov 19, 2025
af5ecfb
wip: fix of huge gas consumption in 'preCallProgramGasMap'
OlivierBBB Nov 19, 2025
fc8217f
added meaningful input for call to POINT_EVALUATION precompile in Six…
lorenzogentile404 Nov 19, 2025
54c8057
fix: initialize KZG
OlivierBBB Nov 19, 2025
18ea99c
constraints update
OlivierBBB Nov 19, 2025
cfa8e8e
ras: TracerTestBase now on OSAKA
OlivierBBB Nov 19, 2025
8ce1623
review comments
OlivierBBB Nov 20, 2025
71c5055
update constraints
letypequividelespoubelles Nov 20, 2025
2fedec6
Merge branch 'arith-dev' into EIP-7823-and-7883---Osaka-MODEXP-changes
letypequividelespoubelles Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private LineCountingTracer createLineCountingTracer(long fromBlock, long toBlock
final Fork fork = getForkFromBesuBlockchainService(besuContext, fromBlock, toBlock);

return tracerSharedConfiguration.isLimitless()
? new ZkCounter(l1L2BridgeSharedConfiguration)
? new ZkCounter(l1L2BridgeSharedConfiguration, fork)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will require a PR in the monorepo as well to change the ZkCounter interface, everywhere ZkCounter is called https://github.com/Consensys/linea-monorepo/blob/5aed83a5f904a1b19906dac4aa0d45656074dfd3/besu-plugins/linea-sequencer/sequencer/src/main/java/net/consensys/linea/rpc/methods/LineaEstimateGas.java#L437 - might also be the case for Besu-shomei plugin

: new ZkTracer(
fork,
l1L2BridgeSharedConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private LineCountingTracer createLineCountingTracer(long blockNumber) {
final Fork fork = getForkFromBesuBlockchainService(besuContext, blockNumber);

return tracerSharedConfiguration.isLimitless()
? new ZkCounter(l1L2BridgeSharedConfiguration)
? new ZkCounter(l1L2BridgeSharedConfiguration, fork)
: new ZkTracer(
fork,
l1L2BridgeSharedConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
package net.consensys.linea.zktracer;

import static net.consensys.linea.zktracer.Fork.*;
import static net.consensys.linea.zktracer.Trace.*;
import static net.consensys.linea.zktracer.Trace.BLOCKHASH_MAX_HISTORY;
import static net.consensys.linea.zktracer.Trace.Ecdata.TOTAL_SIZE_ECPAIRING_DATA_MIN;
import static net.consensys.linea.zktracer.TraceCancun.Oob.CT_MAX_CALL;
import static net.consensys.linea.zktracer.TraceCancun.Oob.CT_MAX_CREATE;
import static net.consensys.linea.zktracer.module.ModuleName.*;
import static net.consensys.linea.zktracer.module.ModuleName.GAS;
import static net.consensys.linea.zktracer.module.add.AddOperation.NB_ROWS_ADD;
import static net.consensys.linea.zktracer.module.blake2fmodexpdata.BlakeModexpDataOperation.NB_ROWS_BLAKEMODEPX_BLAKE;
import static net.consensys.linea.zktracer.module.blake2fmodexpdata.BlakeModexpDataOperation.NB_ROWS_BLAKEMODEXP_MODEXP;
import static net.consensys.linea.zktracer.module.blake2fmodexpdata.BlakeModexpDataOperation.*;
import static net.consensys.linea.zktracer.module.blockdata.module.CancunBlockData.NB_ROWS_BLOCK_DATA;
import static net.consensys.linea.zktracer.module.blockhash.BlockhashOperation.NB_ROWS_BLOCKHASH;
import static net.consensys.linea.zktracer.module.gas.GasOperation.NB_ROWS_GAS;
Expand All @@ -48,7 +46,7 @@
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.BlakeSubsection.NB_ROWS_HUB_PRC_BLAKE;
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.EllipticCurvePrecompileSubsection.NB_ROWS_HUB_PRC_ELLIPTIC_CURVE;
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.IdentitySubsection.NB_ROWS_HUB_PRC_IDENTITY;
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.ModexpSubsection.NB_ROWS_HUB_PRC_MODEXP;
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.LondonModexpSubsection.NB_ROWS_HUB_PRC_MODEXP;
import static net.consensys.linea.zktracer.module.hub.section.call.precompileSubsection.ShaTwoOrRipemdSubSection.NB_ROWS_HUB_PRC_SHARIP;
import static net.consensys.linea.zktracer.module.hub.section.copy.CallDataCopySection.NB_ROWS_HUB_CALL_DATA_COPY;
import static net.consensys.linea.zktracer.module.hub.section.copy.CodeCopySection.NB_ROWS_HUB_CODE_COPY;
Expand Down Expand Up @@ -108,7 +106,9 @@
import net.consensys.linea.zktracer.module.hub.fragment.imc.exp.ExplogExpCall;
import net.consensys.linea.zktracer.module.hub.fragment.imc.exp.ModexpLogExpCall;
import net.consensys.linea.zktracer.module.hub.fragment.scenario.PrecompileScenarioFragment;
import net.consensys.linea.zktracer.module.hub.precompiles.ModexpMetadata;
import net.consensys.linea.zktracer.module.hub.precompiles.modexpMetadata.LondonModexpMetadata;
import net.consensys.linea.zktracer.module.hub.precompiles.modexpMetadata.ModexpMetadata;
import net.consensys.linea.zktracer.module.hub.precompiles.modexpMetadata.OsakaModexpMetadata;
import net.consensys.linea.zktracer.module.limits.BlockTransactions;
import net.consensys.linea.zktracer.module.limits.Keccak;
import net.consensys.linea.zktracer.module.limits.L1BlockSize;
Expand Down Expand Up @@ -137,49 +137,43 @@
@Slf4j
public class ZkCounter implements LineCountingTracer {

public static final Fork FORK_TO_USE_FOR_ZK_COUNTER = OSAKA;
public final Fork fork;

private final OpCodes opCodes = OpCodes.load(FORK_TO_USE_FOR_ZK_COUNTER);
private static final Trace trace = getTraceFromFork(FORK_TO_USE_FOR_ZK_COUNTER);
private final OpCodes opCodes;
private final Trace trace;

// traced modules
final Add add = new Add();
final Bin bin = new Bin();
final CountingOnlyModule blakemodexp =
new CountingOnlyModule(BLAKE_MODEXP_DATA, trace.blake2fmodexpdata().spillage());
final CountingOnlyModule blockData =
new CountingOnlyModule(BLOCK_DATA, trace.blockdata().spillage());
final CountingOnlyModule blockHash =
new CountingOnlyModule(BLOCK_HASH, trace.blockhash().spillage());
final CountingOnlyModule blakemodexp;
final CountingOnlyModule blockData;
final CountingOnlyModule blockHash;
final BlsData blsdata;
final EcData ecdata;
final Euc euc = new Euc();
final Exp exp = new Exp();
final Ext ext = new Ext();
final CountingOnlyModule gas = new CountingOnlyModule(GAS, trace.gas().spillage());
final CountingOnlyModule hub = new CountingOnlyModule(HUB, trace.hub().spillage());
final CountingOnlyModule logData = new CountingOnlyModule(LOG_DATA, trace.logdata().spillage());
final CountingOnlyModule logInfo = new CountingOnlyModule(LOG_INFO, trace.loginfo().spillage());
final CountingOnlyModule mmio = new CountingOnlyModule(MMIO, trace.mmio().spillage());
final CountingOnlyModule mmu = new CountingOnlyModule(MMU, trace.mmu().spillage());
final CountingOnlyModule gas;
final CountingOnlyModule hub;
final CountingOnlyModule logData;
final CountingOnlyModule logInfo;
final CountingOnlyModule mmio;
final CountingOnlyModule mmu;
final Mod mod = new Mod();
final Mul mul = new Mul();
final CountingOnlyModule mxp = new CountingOnlyModule(MXP, trace.mxp().spillage());
final CountingOnlyModule oob = new CountingOnlyModule(OOB, trace.oob().spillage());
final CountingOnlyModule rlpAddr = new CountingOnlyModule(RLP_ADDR, trace.rlpaddr().spillage());
final CountingOnlyModule rlpTxn = new CountingOnlyModule(RLP_TXN, trace.rlptxn().spillage());
final CountingOnlyModule rlpTxnRcpt =
new CountingOnlyModule(RLP_TXN_RCPT, trace.rlptxrcpt().spillage());
final CountingOnlyModule rlpUtils =
new CountingOnlyModule(RLP_UTILS, trace.rlputils().spillage());
final CountingOnlyModule rom = new CountingOnlyModule(ROM, trace.rom().spillage());
final CountingOnlyModule romlex = new CountingOnlyModule(ROM_LEX, trace.romlex().spillage());
final CountingOnlyModule shakiradata =
new CountingOnlyModule(SHAKIRA_DATA, trace.shakiradata().spillage());
final CountingOnlyModule mxp;
final CountingOnlyModule oob;
final CountingOnlyModule rlpAddr;
final CountingOnlyModule rlpTxn;
final CountingOnlyModule rlpTxnRcpt;
final CountingOnlyModule rlpUtils;
final CountingOnlyModule rom;
final CountingOnlyModule romlex;
final CountingOnlyModule shakiradata;
final Shf shf = new Shf();
final IncrementingModule stp = new IncrementingModule(STP);
final CountingOnlyModule trm = new CountingOnlyModule(TRM, trace.trm().spillage());
final CountingOnlyModule txnData = new CountingOnlyModule(TXN_DATA, trace.txndata().spillage());
final CountingOnlyModule trm;
final CountingOnlyModule txnData;
final Wcp wcp = new Wcp();

// precompiles limits:
Expand Down Expand Up @@ -326,7 +320,31 @@ public List<Module> checkedModules() {
l2l1Logs);
}

public ZkCounter(LineaL1L2BridgeSharedConfiguration bridgeConfiguration) {
public ZkCounter(LineaL1L2BridgeSharedConfiguration bridgeConfiguration, Fork fork) {
this.fork = fork;
this.opCodes = OpCodes.load(fork);
this.trace = getTraceFromFork(fork);
this.blakemodexp =
new CountingOnlyModule(BLAKE_MODEXP_DATA, trace.blake2fmodexpdata().spillage());
this.blockData = new CountingOnlyModule(BLOCK_DATA, trace.blockdata().spillage());
this.blockHash = new CountingOnlyModule(BLOCK_HASH, trace.blockhash().spillage());
this.gas = new CountingOnlyModule(GAS, trace.gas().spillage());
this.hub = new CountingOnlyModule(HUB, trace.hub().spillage());
this.logData = new CountingOnlyModule(LOG_DATA, trace.logdata().spillage());
this.logInfo = new CountingOnlyModule(LOG_INFO, trace.loginfo().spillage());
this.mmio = new CountingOnlyModule(MMIO, trace.mmio().spillage());
this.mmu = new CountingOnlyModule(MMU, trace.mmu().spillage());
this.mxp = new CountingOnlyModule(MXP, trace.mxp().spillage());
this.oob = new CountingOnlyModule(OOB, trace.oob().spillage());
this.rlpAddr = new CountingOnlyModule(RLP_ADDR, trace.rlpaddr().spillage());
this.rlpTxn = new CountingOnlyModule(RLP_TXN, trace.rlptxn().spillage());
this.rlpTxnRcpt = new CountingOnlyModule(RLP_TXN_RCPT, trace.rlptxrcpt().spillage());
this.rlpUtils = new CountingOnlyModule(RLP_UTILS, trace.rlputils().spillage());
this.rom = new CountingOnlyModule(ROM, trace.rom().spillage());
this.romlex = new CountingOnlyModule(ROM_LEX, trace.romlex().spillage());
this.shakiradata = new CountingOnlyModule(SHAKIRA_DATA, trace.shakiradata().spillage());
this.trm = new CountingOnlyModule(TRM, trace.trm().spillage());
this.txnData = new CountingOnlyModule(TXN_DATA, trace.txndata().spillage());
keccak = new Keccak(ecRecoverEffectiveCall, blockTransactions);
ecdata =
new EcData(
Expand Down Expand Up @@ -725,12 +743,15 @@ public void tracePrecompileCall(MessageFrame frame, long gasRequirement, Bytes o
case PRC_MODEXP -> {
hub.updateTally(NB_ROWS_HUB_PRC_MODEXP);
final MemoryRange memoryRange = new MemoryRange(0, 0, callData.size(), callData);
final ModexpMetadata modexpMetadata = new ModexpMetadata(memoryRange);
final ModexpMetadata modexpMetadata =
forkPredatesOsaka(fork)
? new LondonModexpMetadata(memoryRange)
: new OsakaModexpMetadata(memoryRange);
if (modexpMetadata.unprovableModexp()) {
modexpEffectiveCall.detectEvent();
return;
}
blakemodexp.updateTally(NB_ROWS_BLAKEMODEXP_MODEXP);
blakemodexp.updateTally(modexpMetadata.getNumberOfRowsForModexp());
modexpEffectiveCall.updateTally(prcSuccess);
modexpLargeCall.updateTally(modexpMetadata.largeModexp());
if (modexpMetadata.loadRawLeadingWord()) {
Expand All @@ -754,7 +775,7 @@ public void tracePrecompileCall(MessageFrame frame, long gasRequirement, Bytes o
blakeEffectiveCall.updateTally(true);
hub.updateTally(NB_ROWS_HUB_PRC_BLAKE);
oob.updateTally(oobLineCountForPrc(PRC_BLAKE2F));
blakemodexp.updateTally(NB_ROWS_BLAKEMODEPX_BLAKE);
blakemodexp.updateTally(numberOfRowsBlake());
// TODO: still unchecked module for now: blakeRounds.updateTally();
}
case PRC_BLS_G1_ADD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package net.consensys.linea.zktracer.module.blake2fmodexpdata;

import static com.google.common.base.Preconditions.checkState;
import static net.consensys.linea.zktracer.module.ModuleName.BLAKE_MODEXP_DATA;

import java.util.List;
Expand All @@ -28,7 +29,6 @@
import net.consensys.linea.zktracer.container.module.OperationListModule;
import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList;
import net.consensys.linea.zktracer.module.ModuleName;
import net.consensys.linea.zktracer.module.hub.precompiles.ModexpMetadata;
import net.consensys.linea.zktracer.module.limits.precompiles.BlakeRounds;
import net.consensys.linea.zktracer.module.wcp.Wcp;

Expand All @@ -52,21 +52,26 @@ public ModuleName moduleKey() {
return BLAKE_MODEXP_DATA;
}

public void callModexp(final ModexpMetadata modexpMetaData, final int operationID) {
operations.add(new BlakeModexpDataOperation(modexpMetaData, operationID));
public void callModexp(BlakeModexpDataOperation modexpOperation) {

checkState(modexpOperation.isModexpOperation(), "Operation must be a MODEXP operation");
operations.add(modexpOperation);

modexpEffectiveCall.updateTally(1);
modexpLargeCall.updateTally(modexpMetaData.largeModexp());
callWcpForIdCheck(operationID);
modexpLargeCall.updateTally(modexpOperation.modexpMetaData.get().largeModexp());
callWcpForIdCheck(modexpOperation.id());
}

public void callBlake(final BlakeComponents blakeComponents, final int operationID) {
operations.add(new BlakeModexpDataOperation(blakeComponents, operationID));
public void callBlake(BlakeModexpDataOperation blakeOperation) {
checkState(blakeOperation.isBlakeOperation(), "Operation must be a BLAKE2f operation");
operations.add(blakeOperation);

blakeEffectiveCall.updateTally(1);
blakeRounds.addPrecompileLimit(blakeComponents.r());
callWcpForIdCheck(operationID);
blakeRounds.addPrecompileLimit(blakeOperation.blake2fComponents.get().r());
callWcpForIdCheck(blakeOperation.id());
}

private void callWcpForIdCheck(final int operationID) {
private void callWcpForIdCheck(final long operationID) {
wcp.callLT(previousID, operationID);
previousID = operationID;
}
Expand Down
Loading
Loading