From db1a18a609eed8a131f60dec9438aec1a30f86f5 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Tue, 11 Jun 2024 19:21:14 +0200 Subject: [PATCH] Upgrade to Java 21 Signed-off-by: Fabio Di Fabio --- .github/workflows/gradle.yml | 28 +-- .github/workflows/release.yml | 6 +- .../linea/blockcapture/BlockCapturer.java | 1 + .../linea/blockcapture/reapers/Reaper.java | 2 + .../LineaProfitabilityConfiguration.java | 1 + .../CountersEndpointServicePlugin.java | 1 + .../TracesEndpointServicePlugin.java | 1 + .../linea/zktracer/bytestheta/BaseBytes.java | 1 + .../container/stacked/list/StackedList.java | 3 + .../module/ec_data/EcDataOperation.java | 1 + .../ext/calculator/AbstractExtCalculator.java | 5 +- .../linea/zktracer/module/hub/Bytecode.java | 1 + .../linea/zktracer/module/hub/Exceptions.java | 1 + .../linea/zktracer/module/hub/Hub.java | 58 ++--- .../module/hub/PlatformController.java | 3 + .../linea/zktracer/module/hub/TxTrace.java | 1 + .../module/hub/defer/DeferRegistry.java | 2 + .../module/hub/fragment/StackFragment.java | 9 +- .../module/hub/section/TraceSection.java | 1 + .../linea/zktracer/module/limits/L2Block.java | 1 + .../limits/precompiles/Rip160Blocks.java | 4 +- .../limits/precompiles/Sha256Blocks.java | 4 +- .../zktracer/module/logInfo/LogInfo.java | 4 +- .../module/mmu/Type1PreComputation.java | 5 +- .../module/mmu/Type3PreComputation.java | 7 +- .../module/mmu/Type4PreComputation.java | 19 +- .../module/mmu/Type5PreComputation.java | 10 +- .../linea/zktracer/module/mul/Mul.java | 1 + .../linea/zktracer/module/mxp/MxpData.java | 27 +-- .../zktracer/module/rlp/addr/RlpAddr.java | 70 ++++--- .../linea/zktracer/module/rlp/txn/RlpTxn.java | 5 +- .../zktracer/module/rlp/txrcpt/RlpTxrcpt.java | 55 ++--- .../linea/zktracer/module/stp/StpChunk.java | 162 +++++++------- .../module/txn_data/BlockSnapshot.java | 3 + .../module/txn_data/TransactionSnapshot.java | 18 +- .../zktracer/module/txn_data/TxnData.java | 108 +++++----- .../zktracer/opcode/gas/GasConstants.java | 1 + .../opcode/gas/projector/GasProjector.java | 198 +++++++++--------- .../zktracer/runtime/callstack/CallFrame.java | 15 ++ .../zktracer/runtime/callstack/CallStack.java | 3 + .../zktracer/runtime/stack/StackContext.java | 1 + .../runtime/stack/StackOperation.java | 4 + .../linea/zktracer/module/mxp/MxpTest.java | 60 +++--- .../module/rlp_txrcpt/RandomTxrcptTests.java | 53 ++--- .../module/rlptxn/TestRandomTxns.java | 126 +++++------ .../linea/zktracer/module/stp/StpTest.java | 40 ++-- buildSrc/build.gradle | 10 +- gradle/java.gradle | 10 +- gradle/lint.gradle | 4 +- gradle/tests.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 51 files changed, 637 insertions(+), 521 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 02d20dc1..7302feb1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -22,11 +22,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'adopt' + java-version: 21 + distribution: temurin - name: Build without tests run: ./gradlew build -x test -x spotlessCheck @@ -51,11 +51,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'adopt' + java-version: 21 + distribution: temurin - name: Run acceptance tests run: ./gradlew :acceptance-tests:acceptanceTests @@ -81,11 +81,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'adopt' + java-version: 21 + distribution: temurin - name: Run libcompress JNI tests run: ./gradlew :native:compress:test @@ -105,11 +105,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'adopt' + java-version: 21 + distribution: temurin - name: Run unit tests run: ./gradlew :arithmetization:test @@ -130,7 +130,7 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - distribution: adopt - java-version: 17 + distribution: temurin + java-version: 21 - name: spotless run: ./gradlew --no-daemon --parallel clean spotlessCheck diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53659ab7..fee3c70d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,11 +12,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' - distribution: 'adopt' + java-version: 21 + distribution: temurin cache: 'gradle' - name: Grant execute permission for gradlew diff --git a/arithmetization/src/main/java/net/consensys/linea/blockcapture/BlockCapturer.java b/arithmetization/src/main/java/net/consensys/linea/blockcapture/BlockCapturer.java index 24ea5ea5..fb40ef8f 100644 --- a/arithmetization/src/main/java/net/consensys/linea/blockcapture/BlockCapturer.java +++ b/arithmetization/src/main/java/net/consensys/linea/blockcapture/BlockCapturer.java @@ -39,6 +39,7 @@ public class BlockCapturer implements ConflationAwareOperationTracer { * The {@link Reaper} will collect all the data that will need to be mimicked to replay the block. */ private final Reaper reaper = new Reaper(); + /** * This keeps a pointer to the initial state (i.e. ) to be used at the end of tracing to store the * minimal required information to replay the conflation. diff --git a/arithmetization/src/main/java/net/consensys/linea/blockcapture/reapers/Reaper.java b/arithmetization/src/main/java/net/consensys/linea/blockcapture/reapers/Reaper.java index fe458d56..2836ba54 100644 --- a/arithmetization/src/main/java/net/consensys/linea/blockcapture/reapers/Reaper.java +++ b/arithmetization/src/main/java/net/consensys/linea/blockcapture/reapers/Reaper.java @@ -41,8 +41,10 @@ public class Reaper { /** Collect the reads from the state */ private final StorageReaper storage = new StorageReaper(); + /** Collect the addresses read from the state */ private final AddressReaper addresses = new AddressReaper(); + /** Collect the blocks within a conflation */ private final List blocks = new ArrayList<>(); diff --git a/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java b/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java index dfc4d517..d4d29fb3 100644 --- a/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java +++ b/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java @@ -28,6 +28,7 @@ public class LineaProfitabilityConfiguration { /** It is safe to keep this as long, since it will store value <= max_int * 1000 */ private long fixedCostWei; + /** It is safe to keep this as long, since it will store value <= max_int * 1000 */ private long variableCostWei; diff --git a/arithmetization/src/main/java/net/consensys/linea/rpc/counters/CountersEndpointServicePlugin.java b/arithmetization/src/main/java/net/consensys/linea/rpc/counters/CountersEndpointServicePlugin.java index 8c46578d..4f902866 100644 --- a/arithmetization/src/main/java/net/consensys/linea/rpc/counters/CountersEndpointServicePlugin.java +++ b/arithmetization/src/main/java/net/consensys/linea/rpc/counters/CountersEndpointServicePlugin.java @@ -32,6 +32,7 @@ public class CountersEndpointServicePlugin extends AbstractLineaSharedOptionsPlugin { private BesuContext besuContext; private RpcEndpointService rpcEndpointService; + /** * Register the RPC service. * diff --git a/arithmetization/src/main/java/net/consensys/linea/rpc/tracegeneration/TracesEndpointServicePlugin.java b/arithmetization/src/main/java/net/consensys/linea/rpc/tracegeneration/TracesEndpointServicePlugin.java index b4bb0384..419a1743 100644 --- a/arithmetization/src/main/java/net/consensys/linea/rpc/tracegeneration/TracesEndpointServicePlugin.java +++ b/arithmetization/src/main/java/net/consensys/linea/rpc/tracegeneration/TracesEndpointServicePlugin.java @@ -33,6 +33,7 @@ public class TracesEndpointServicePlugin extends AbstractLineaSharedOptionsPlugin { private BesuContext besuContext; private RpcEndpointService rpcEndpointService; + /** * Register the RPC service. * diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/bytestheta/BaseBytes.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/bytestheta/BaseBytes.java index 8d8e4c76..2bebea57 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/bytestheta/BaseBytes.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/bytestheta/BaseBytes.java @@ -29,6 +29,7 @@ public class BaseBytes implements HighLowBytes { /** The size in bytes of the high and low sections of the 256-bit block. */ private static final int LOW_HIGH_SIZE = 16; + /** * The mutable `Bytes32` object that stores the 256-bit block of data. Equals and hashCode must * only be computed on the numeric value wrapped by this class, so that sets of operations diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/list/StackedList.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/list/StackedList.java index 4028202d..cc7f44b7 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/list/StackedList.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/list/StackedList.java @@ -35,6 +35,7 @@ public class StackedList implements List, StackedContainer { private final LinkedList> lists = new LinkedList<>(); + /** The cached number of elements in this container */ private int totalSize; @@ -239,8 +240,10 @@ public List subList(int fromIndex, int toIndex) { private static class StackedListIterator implements Iterator, ListIterator { private final StackedList sl; + /** Position of the iterator in the list of lists */ private int head = 0; + /** Position of the iterator within the current list, i.e. this.sl.lists[head] */ private int offset = -1; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ec_data/EcDataOperation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ec_data/EcDataOperation.java index 80eb5b1e..b4d76b99 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ec_data/EcDataOperation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ec_data/EcDataOperation.java @@ -55,6 +55,7 @@ public class EcDataOperation extends ModuleOperation { private final int ecType; private final int nRows; + /** -1 if no switch off (i.e. preliminary checks passed) */ private int hurdleSwitchOffRow; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/calculator/AbstractExtCalculator.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/calculator/AbstractExtCalculator.java index 25dded5d..fa889d34 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/calculator/AbstractExtCalculator.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/ext/calculator/AbstractExtCalculator.java @@ -160,8 +160,9 @@ public static AbstractExtCalculator create(OpCode opCode) { return switch (opCode) { case MULMOD -> new MulModCalculator(); case ADDMOD -> new AddModCalculator(); - default -> throw new RuntimeException( - "Incompatible instruction for extended modular arithmetic module"); + default -> + throw new RuntimeException( + "Incompatible instruction for extended modular arithmetic module"); }; } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Bytecode.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Bytecode.java index 341d73dd..a8f2f5d6 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Bytecode.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Bytecode.java @@ -28,6 +28,7 @@ public final class Bytecode { /** The bytecode. */ private final Bytes bytecode; + /** The bytecode hash; is null by default and computed & memoized on the fly when required. */ private Hash hash; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Exceptions.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Exceptions.java index 7e3472a3..98a6be9e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Exceptions.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Exceptions.java @@ -140,6 +140,7 @@ public void reset() { public boolean stackException() { return this.stackUnderflow() || this.stackOverflow(); } + /** * @return true if no stack exception has been raised */ 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 8e29850d..71457289 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 @@ -957,26 +957,29 @@ void traceOperation(MessageFrame frame) { switch (this.opCodeData().instructionFamily()) { case ADD, - MOD, - MUL, - SHF, - BIN, - WCP, - EXT, - BATCH, - MACHINE_STATE, - PUSH_POP, - DUP, - SWAP, - HALT, - INVALID -> this.addTraceSection(new StackOnlySection(this)); + MOD, + MUL, + SHF, + BIN, + WCP, + EXT, + BATCH, + MACHINE_STATE, + PUSH_POP, + DUP, + SWAP, + HALT, + INVALID -> + this.addTraceSection(new StackOnlySection(this)); case KEC -> { this.addTraceSection( new KeccakSection(this, this.currentFrame(), new MiscFragment(this, frame))); } - case CONTEXT, LOG -> this.addTraceSection( - new ContextLogSection( - this, new ContextFragment(this.callStack, this.currentFrame(), updateReturnData))); + case CONTEXT, LOG -> + this.addTraceSection( + new ContextLogSection( + this, + new ContextFragment(this.callStack, this.currentFrame(), updateReturnData))); case ACCOUNT -> { TraceSection accountSection = new AccountSection(this); if (this.opCodeData().stackSettings().flag1()) { @@ -1034,17 +1037,18 @@ void traceOperation(MessageFrame frame) { } this.addTraceSection(copySection); } - case TRANSACTION -> this.addTraceSection( - new TransactionSection( - this, - TransactionFragment.prepare( - this.conflation.number(), - frame.getMiningBeneficiary(), - this.tx.transaction(), - true, - frame.getGasPrice(), - frame.getBlockValues().getBaseFee().orElse(Wei.ZERO), - this.tx.initialGas()))); + case TRANSACTION -> + this.addTraceSection( + new TransactionSection( + this, + TransactionFragment.prepare( + this.conflation.number(), + frame.getMiningBeneficiary(), + this.tx.transaction(), + true, + frame.getGasPrice(), + frame.getBlockValues().getBaseFee().orElse(Wei.ZERO), + this.tx.initialGas()))); case STACK_RAM -> { switch (this.currentFrame().opCode()) { case CALLDATALOAD -> { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/PlatformController.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/PlatformController.java index cf8e9c0c..04fb17e7 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/PlatformController.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/PlatformController.java @@ -26,10 +26,13 @@ @Accessors(fluent = true) public class PlatformController { private final Hub hub; + /** What other modules should be triggered for the current operation */ @Getter private final Signals signals; + /** The exceptions raised during the execution of the current operation */ @Getter private final Exceptions exceptions; + /** The aborting conditions raised during the execution of the current operation */ @Getter private final AbortingConditions aborts; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/TxTrace.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/TxTrace.java index 2745fc4c..8227246a 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/TxTrace.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/TxTrace.java @@ -29,6 +29,7 @@ public class TxTrace { /** The {@link TraceSection} of which this transaction trace is made of */ @Getter private final List trace = new ArrayList<>(); + /** A cache for the line count of this transaction */ private int cachedLineCount = 0; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/defer/DeferRegistry.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/defer/DeferRegistry.java index c27851da..85ace9f7 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/defer/DeferRegistry.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/defer/DeferRegistry.java @@ -32,8 +32,10 @@ public class DeferRegistry { /** A list of actions deferred until the end of the current transaction */ private final List txDefers = new ArrayList<>(); + /** A list of actions deferred until the end of the current opcode execution */ private final List postExecDefers = new ArrayList<>(); + /** A list of actions deferred until the end of the current opcode execution */ private final List> contextReentry = new ArrayList<>(); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/StackFragment.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/StackFragment.java index 3310cacb..9dc8d6ee 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/StackFragment.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/fragment/StackFragment.java @@ -69,10 +69,11 @@ private StackFragment( switch (this.opCode) { case SHA3 -> exceptions.none() && gp.messageSize() > 0; case RETURN -> exceptions.none() && gp.messageSize() > 0 && isDeploying; - case CREATE2 -> exceptions.none() - && contextExceptions.none() - && aborts.none() - && gp.messageSize() > 0; + case CREATE2 -> + exceptions.none() + && contextExceptions.none() + && aborts.none() + && gp.messageSize() > 0; default -> false; }; this.hashInfoSize = this.hashInfoFlag ? gp.messageSize() : 0; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TraceSection.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TraceSection.java index b8d40c41..b574d70c 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TraceSection.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TraceSection.java @@ -59,6 +59,7 @@ public Trace trace(Trace trace) { /** Count the stack lines */ @Getter private int stackRowsCounter; + /** Count the non-stack lines */ private int nonStackRowsCounter; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/L2Block.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/L2Block.java index 2b384aee..32f0112f 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/L2Block.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/L2Block.java @@ -47,6 +47,7 @@ public class L2Block implements Module { /** The byte size of the RLP-encoded transaction of the conflation */ @Getter private final Deque sizesRlpEncodedTxs = new ArrayDeque<>(); + /** The byte size of the L2->L1 logs messages of the conflation */ @Getter private final Deque> l2l1LogSizes = new ArrayDeque<>(); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Rip160Blocks.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Rip160Blocks.java index aa4b5c32..bb452921 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Rip160Blocks.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Rip160Blocks.java @@ -66,8 +66,8 @@ public void tracePreOpcode(MessageFrame frame) { long dataByteLength = 0; switch (opCode) { case CALL, CALLCODE -> dataByteLength = Words.clampedToLong(frame.getStackItem(4)); - case DELEGATECALL, STATICCALL -> dataByteLength = - Words.clampedToLong(frame.getStackItem(3)); + case DELEGATECALL, STATICCALL -> + dataByteLength = Words.clampedToLong(frame.getStackItem(3)); } if (dataByteLength == 0) { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Sha256Blocks.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Sha256Blocks.java index 4fba3b50..a4c11580 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Sha256Blocks.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/limits/precompiles/Sha256Blocks.java @@ -66,8 +66,8 @@ public void tracePreOpcode(MessageFrame frame) { long dataByteLength = 0; switch (opCode) { case CALL, CALLCODE -> dataByteLength = Words.clampedToLong(frame.getStackItem(4)); - case DELEGATECALL, STATICCALL -> dataByteLength = - Words.clampedToLong(frame.getStackItem(3)); + case DELEGATECALL, STATICCALL -> + dataByteLength = Words.clampedToLong(frame.getStackItem(3)); } if (dataByteLength == 0) { return; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/logInfo/LogInfo.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/logInfo/LogInfo.java index 3750abc5..b7c7b709 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/logInfo/LogInfo.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/logInfo/LogInfo.java @@ -219,8 +219,8 @@ public void traceLog( .dataLo(topic4.slice(16, 16).toUnsignedBigInteger()) .validateRow(); } - default -> throw new IllegalArgumentException( - "ct = " + ct + " greater than ctMax =" + ctMax); + default -> + throw new IllegalArgumentException("ct = " + ct + " greater than ctMax =" + ctMax); } } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type1PreComputation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type1PreComputation.java index 1b2281c9..155c0c41 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type1PreComputation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type1PreComputation.java @@ -84,8 +84,9 @@ public MicroData dispatch( microData.microOp(MmuTrace.FullStackToRam); } } - default -> throw new IllegalArgumentException( - "Opcode %s is not supported for type 1 pre-computation".formatted(opCode)); + default -> + throw new IllegalArgumentException( + "Opcode %s is not supported for type 1 pre-computation".formatted(opCode)); } return microData; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type3PreComputation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type3PreComputation.java index 02084ee0..43b05e0e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type3PreComputation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type3PreComputation.java @@ -97,9 +97,10 @@ public MicroData preProcess(final MicroData microData, final CallStack callStack microData.exoIsRom(true); microData.exoIsHash(true); } - default -> throw new UnsupportedOperationException( - "OpCode.%s is not supported for MMU type 3 pre-processing." - .formatted(microData.opCode())); + default -> + throw new UnsupportedOperationException( + "OpCode.%s is not supported for MMU type 3 pre-processing." + .formatted(microData.opCode())); } return microData; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type4PreComputation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type4PreComputation.java index 8f4a359e..33ea3e0d 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type4PreComputation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type4PreComputation.java @@ -416,9 +416,10 @@ void setContext(final boolean isMicro, MicroData microData, final CallStack call microData.sourceContext(0); } - default -> throw new UnsupportedOperationException( - "OpCode.%s is not supported for MMU type 4 pre-processing and/or processing" - .formatted(microData.opCode())); + default -> + throw new UnsupportedOperationException( + "OpCode.%s is not supported for MMU type 4 pre-processing and/or processing" + .formatted(microData.opCode())); } } @@ -475,8 +476,9 @@ private int calculateReferenceSize(final MicroData microData, final CallStack ca } case CALLDATACOPY -> callStack.caller().callDataRange().length(); case RETURNDATACOPY -> topCallFrame.returnDataRange().length(); - default -> throw new IllegalArgumentException( - "OpCode.%s not supported for type 4 reference size calculation.".formatted(opCode)); + default -> + throw new IllegalArgumentException( + "OpCode.%s not supported for type 4 reference size calculation.".formatted(opCode)); } return 0; @@ -553,9 +555,10 @@ private int calculateReferenceOffset(final MicroData microData, final CallStack case CODECOPY, EXTCODECOPY -> 0; case CALLDATACOPY -> callStack.caller().callDataRange().absolute().toInt(); case RETURNDATACOPY -> callStack.current().returnDataRange().absolute().toInt(); - default -> throw new IllegalArgumentException( - "OpCode.%s not supported for type 4 reference offset calculation" - .formatted(microData.opCode())); + default -> + throw new IllegalArgumentException( + "OpCode.%s not supported for type 4 reference offset calculation" + .formatted(microData.opCode())); }; } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type5PreComputation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type5PreComputation.java index faf83037..09ab7f6c 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type5PreComputation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mmu/Type5PreComputation.java @@ -146,8 +146,9 @@ private void updateOffsetType5(MicroData microData, final CallStack callStack) { case 2 -> microData.sourceLimbOffset(acc3.add(1)); case 1 -> microData.sourceLimbOffset(acc3.add(2)); case 0 -> microData.sourceLimbOffset(EWord.ZERO); - default -> throw new IllegalStateException( - "Unexpected value: %s".formatted(microData.remainingReads())); + default -> + throw new IllegalStateException( + "Unexpected value: %s".formatted(microData.remainingReads())); } } else { if (!microData.isLastRead()) { @@ -210,8 +211,9 @@ private void updateMicroOpType5(MicroData microData, final CallStack callStack) } } } - default -> throw new IllegalStateException( - "Unexpected value: %s".formatted(microData.remainingReads())); + default -> + throw new IllegalStateException( + "Unexpected value: %s".formatted(microData.remainingReads())); } } 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 1efcb203..b3d31e15 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 @@ -32,6 +32,7 @@ @RequiredArgsConstructor public class Mul implements Module { private final Hub hub; + /** A set of the operations to trace */ private final StackedSet operations = new StackedSet<>(); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/MxpData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/MxpData.java index 6674a0ed..19475f80 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/MxpData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/mxp/MxpData.java @@ -189,15 +189,17 @@ protected void setRoob() { roob = switch (typeMxp) { case TYPE_2, TYPE_3 -> offset1.toBigInteger().compareTo(TWO_POW_128) >= 0; - case TYPE_4 -> size1.toBigInteger().compareTo(TWO_POW_128) >= 0 - || (offset1.toBigInteger().compareTo(TWO_POW_128) >= 0 - && !size1.toBigInteger().equals(BigInteger.ZERO)); - case TYPE_5 -> size1.toBigInteger().compareTo(TWO_POW_128) >= 0 - || (offset1.toBigInteger().compareTo(TWO_POW_128) >= 0 - && !size1.toBigInteger().equals(BigInteger.ZERO)) - || (size2.toBigInteger().compareTo(TWO_POW_128) >= 0 - || (offset2.toBigInteger().compareTo(TWO_POW_128) >= 0 - && !size2.toBigInteger().equals(BigInteger.ZERO))); + case TYPE_4 -> + size1.toBigInteger().compareTo(TWO_POW_128) >= 0 + || (offset1.toBigInteger().compareTo(TWO_POW_128) >= 0 + && !size1.toBigInteger().equals(BigInteger.ZERO)); + case TYPE_5 -> + size1.toBigInteger().compareTo(TWO_POW_128) >= 0 + || (offset1.toBigInteger().compareTo(TWO_POW_128) >= 0 + && !size1.toBigInteger().equals(BigInteger.ZERO)) + || (size2.toBigInteger().compareTo(TWO_POW_128) >= 0 + || (offset2.toBigInteger().compareTo(TWO_POW_128) >= 0 + && !size2.toBigInteger().equals(BigInteger.ZERO))); default -> false; }; } @@ -432,9 +434,10 @@ private void setWordsNew(final MessageFrame frame) { case TYPE_1 -> wordsNew = frame.calculateMemoryExpansion(Words.clampedToLong(offset1), 0); case TYPE_2 -> wordsNew = frame.calculateMemoryExpansion(Words.clampedToLong(offset1), 32); case TYPE_3 -> wordsNew = frame.calculateMemoryExpansion(Words.clampedToLong(offset1), 1); - case TYPE_4 -> wordsNew = - frame.calculateMemoryExpansion( - Words.clampedToLong(offset1), Words.clampedToLong(size1)); + case TYPE_4 -> + wordsNew = + frame.calculateMemoryExpansion( + Words.clampedToLong(offset1), Words.clampedToLong(size1)); case TYPE_5 -> { long wordsNew1 = frame.calculateMemoryExpansion( diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/addr/RlpAddr.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/addr/RlpAddr.java index f17c7c16..205fee20 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/addr/RlpAddr.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/addr/RlpAddr.java @@ -145,9 +145,8 @@ private void traceCreate2(int stamp, RlpAddrChunk chunk, Trace trace) { case 2 -> trace.limb(chunk.salt().orElseThrow().slice(0, LLARGE)).nBytes(BYTES_LLARGE); case 3 -> trace.limb(chunk.salt().orElseThrow().slice(LLARGE, LLARGE)).nBytes(BYTES_LLARGE); case 4 -> trace.limb(chunk.keccak().orElseThrow().slice(0, LLARGE)).nBytes(BYTES_LLARGE); - case 5 -> trace - .limb(chunk.keccak().orElseThrow().slice(LLARGE, LLARGE)) - .nBytes(BYTES_LLARGE); + case 5 -> + trace.limb(chunk.keccak().orElseThrow().slice(LLARGE, LLARGE)).nBytes(BYTES_LLARGE); } // Columns unused for Recipe2 @@ -230,36 +229,41 @@ private void traceCreate(int stamp, RlpAddrChunk chunk, Trace trace) { switch (ct) { case 0, 1, 2, 3 -> trace.lc(false).limb(Bytes.EMPTY).nBytes(Bytes.EMPTY).index(Bytes.EMPTY); - case 4 -> trace - .lc(true) - .limb( - rightPadTo( - bigIntegerToBytes( - BigInteger.valueOf(LIST_SHORT) - .add(BigInteger.valueOf(21)) - .add(BigInteger.valueOf(size_rlp_nonce))), - LLARGE)) - .nBytes(Bytes.of(1)) - .index(Bytes.EMPTY); - case 5 -> trace - .lc(true) - .limb( - rightPadTo( - Bytes.concatenate( - bigIntegerToBytes(BigInteger.valueOf(148)), chunk.address().slice(0, 4)), - LLARGE)) - .nBytes(Bytes.of(5)) - .index(Bytes.of(1)); - case 6 -> trace - .lc(true) - .limb(chunk.address().slice(4, LLARGE)) - .nBytes(Bytes.of(16)) - .index(Bytes.of(2)); - case 7 -> trace - .lc(true) - .limb(rightPadTo(rlpNonce, LLARGE)) - .nBytes(Bytes.of(size_rlp_nonce)) - .index(Bytes.of(3)); + case 4 -> + trace + .lc(true) + .limb( + rightPadTo( + bigIntegerToBytes( + BigInteger.valueOf(LIST_SHORT) + .add(BigInteger.valueOf(21)) + .add(BigInteger.valueOf(size_rlp_nonce))), + LLARGE)) + .nBytes(Bytes.of(1)) + .index(Bytes.EMPTY); + case 5 -> + trace + .lc(true) + .limb( + rightPadTo( + Bytes.concatenate( + bigIntegerToBytes(BigInteger.valueOf(148)), + chunk.address().slice(0, 4)), + LLARGE)) + .nBytes(Bytes.of(5)) + .index(Bytes.of(1)); + case 6 -> + trace + .lc(true) + .limb(chunk.address().slice(4, LLARGE)) + .nBytes(Bytes.of(16)) + .index(Bytes.of(2)); + case 7 -> + trace + .lc(true) + .limb(rightPadTo(rlpNonce, LLARGE)) + .nBytes(Bytes.of(size_rlp_nonce)) + .index(Bytes.of(3)); } // Column not used fo recipe 1: diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txn/RlpTxn.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txn/RlpTxn.java index 258ad861..30d4120e 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txn/RlpTxn.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txn/RlpTxn.java @@ -194,8 +194,8 @@ public void traceChunk(RlpTxnChunk chunk, int absTxNum, int codeFragmentIndex, T // the innerRlp method already concatenate with the first byte "transaction type" traceValue.rlpLxByteSize = innerRlpSize(besuRlpLx.size() - 1); } - default -> throw new IllegalStateException( - "Transaction Type not supported: " + traceValue.txType); + default -> + throw new IllegalStateException("Transaction Type not supported: " + traceValue.txType); } // Phase 0 : Global RLP prefix @@ -1054,6 +1054,7 @@ private void traceVoidList( traceValue.phaseEnd = phaseEnd; traceRow(traceValue, trace); } + // Define the Tracer private void traceRow(RlpTxnColumnsValue traceValue, Trace builder) { // Decrements RLP_BYTESIZE diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txrcpt/RlpTxrcpt.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txrcpt/RlpTxrcpt.java index 4a715761..93227160 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txrcpt/RlpTxrcpt.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/rlp/txrcpt/RlpTxrcpt.java @@ -386,33 +386,33 @@ private void phase5(RlpTxrcptColumns traceValue, List logList, Trace trace) traceRow(traceValue, trace); } case 1 -> // Case with data is made of one byte - rlpInt( - 3, - phase, - logList.get(i).getData().toUnsignedBigInteger().longValueExact(), - true, - true, - true, - false, - true, - true, - indexLocalEndTopic, - traceValue, - trace); + rlpInt( + 3, + phase, + logList.get(i).getData().toUnsignedBigInteger().longValueExact(), + true, + true, + true, + false, + true, + true, + indexLocalEndTopic, + traceValue, + trace); default -> // Default case, data is made of >= 2 bytes - rlpByteString( - phase, - logList.get(i).getData().size(), - false, - true, - true, - true, - false, - true, - indexLocalEndTopic, - traceValue, - trace); + rlpByteString( + phase, + logList.get(i).getData().size(), + false, + true, + true, + true, + false, + true, + indexLocalEndTopic, + traceValue, + trace); } // Tracing the Data @@ -581,8 +581,9 @@ private void rlpInt( traceValue.input1 = Bytes.minimalBytes(1); traceValue.input3 = inputBytes; } - default -> throw new IllegalArgumentException( - "should be called only to write Input1 or Input3, not Input" + inputToWrite); + default -> + throw new IllegalArgumentException( + "should be called only to write Input1 or Input3, not Input" + inputToWrite); } if (writeInput2) { traceValue.input2 = Bytes.minimalBytes(valueInput2); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/StpChunk.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/StpChunk.java index ac1ac179..ef2785ba 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/StpChunk.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/stp/StpChunk.java @@ -153,30 +153,33 @@ private void traceCreate(Trace trace, int stamp) { .arg1Hi(Bytes.EMPTY); switch (ct) { - case 0 -> trace - .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) - .arg2Lo(Bytes.EMPTY) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) - .resLo(Bytes.EMPTY) // we REQUIRE that the currently available gas is nonnegative - .wcpFlag(true) - .modFlag(false) - .validateRow(); - case 1 -> trace - .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) - .arg2Lo(Bytes.ofUnsignedLong(this.gasPrelim())) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) - .resLo(Bytes.of(this.oogx() ? 1 : 0)) - .wcpFlag(true) - .modFlag(false) - .validateRow(); - case 2 -> trace - .arg1Lo(Bytes.ofUnsignedLong(getGDiff())) - .arg2Lo(Bytes.of(64)) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.DIV.byteValue())) - .resLo(Bytes.ofUnsignedLong(getGDiffOver64())) - .wcpFlag(false) - .modFlag(true) - .validateRow(); + case 0 -> + trace + .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) + .arg2Lo(Bytes.EMPTY) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) + .resLo(Bytes.EMPTY) // we REQUIRE that the currently available gas is nonnegative + .wcpFlag(true) + .modFlag(false) + .validateRow(); + case 1 -> + trace + .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) + .arg2Lo(Bytes.ofUnsignedLong(this.gasPrelim())) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) + .resLo(Bytes.of(this.oogx() ? 1 : 0)) + .wcpFlag(true) + .modFlag(false) + .validateRow(); + case 2 -> + trace + .arg1Lo(Bytes.ofUnsignedLong(getGDiff())) + .arg2Lo(Bytes.of(64)) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.DIV.byteValue())) + .resLo(Bytes.ofUnsignedLong(getGDiffOver64())) + .wcpFlag(false) + .modFlag(true) + .validateRow(); default -> throw new IllegalArgumentException("counter too big, should be <=" + ctMax); } } @@ -223,60 +226,65 @@ private void traceCall(Trace trace, int stamp) { .gasStipend(Bytes.ofUnsignedLong(gasStipend)); switch (ct) { - case 0 -> trace - .arg1Hi(Bytes.EMPTY) - .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) - .arg2Lo(Bytes.EMPTY) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) - .resLo(Bytes.EMPTY) // we REQUIRE that the currently available gas is nonnegative - .wcpFlag(true) - .modFlag(false) - .validateRow(); - case 1 -> trace - .arg1Hi(this.value().slice(0, 16)) - .arg1Lo(this.value().slice(16, 16)) - .arg2Lo(Bytes.EMPTY) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.ISZERO.byteValue())) - .resLo(Bytes.of(this.value().isZero() ? 1 : 0)) - .wcpFlag(callCanTransferValue(this.opCode())) - .modFlag(false) - .validateRow(); - case 2 -> trace - .arg1Hi(Bytes.EMPTY) - .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) - .arg2Lo(Bytes.ofUnsignedLong(this.gasPrelim())) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) - .resLo(Bytes.of(this.oogx() ? 1 : 0)) - .wcpFlag(true) - .modFlag(false) - .validateRow(); + case 0 -> + trace + .arg1Hi(Bytes.EMPTY) + .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) + .arg2Lo(Bytes.EMPTY) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) + .resLo(Bytes.EMPTY) // we REQUIRE that the currently available gas is nonnegative + .wcpFlag(true) + .modFlag(false) + .validateRow(); + case 1 -> + trace + .arg1Hi(this.value().slice(0, 16)) + .arg1Lo(this.value().slice(16, 16)) + .arg2Lo(Bytes.EMPTY) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.ISZERO.byteValue())) + .resLo(Bytes.of(this.value().isZero() ? 1 : 0)) + .wcpFlag(callCanTransferValue(this.opCode())) + .modFlag(false) + .validateRow(); + case 2 -> + trace + .arg1Hi(Bytes.EMPTY) + .arg1Lo(Bytes.ofUnsignedLong(this.gasActual())) + .arg2Lo(Bytes.ofUnsignedLong(this.gasPrelim())) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) + .resLo(Bytes.of(this.oogx() ? 1 : 0)) + .wcpFlag(true) + .modFlag(false) + .validateRow(); // the following rows are only filled in if no out of gas exception - case 3 -> trace - .arg1Hi(Bytes.EMPTY) - .arg1Lo(Bytes.ofUnsignedLong(getGDiff())) - .arg2Lo(Bytes.of(64)) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.DIV.byteValue())) - .resLo(Bytes.ofUnsignedLong(getGDiffOver64())) - .wcpFlag(false) - .modFlag(true) - .validateRow(); - case 4 -> trace - .arg1Hi(this.gas().orElseThrow().slice(0, 16)) - .arg1Lo(this.gas().orElseThrow().slice(16, 16)) - .arg2Lo(Bytes.ofUnsignedLong(getGDiff() - getGDiffOver64())) - .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) - .resLo( - Bytes.of( - this.gas() - .orElseThrow() - .toUnsignedBigInteger() - .compareTo(BigInteger.valueOf(get63of64GDiff())) - < 0 - ? 1 - : 0)) - .wcpFlag(true) - .modFlag(false) - .validateRow(); + case 3 -> + trace + .arg1Hi(Bytes.EMPTY) + .arg1Lo(Bytes.ofUnsignedLong(getGDiff())) + .arg2Lo(Bytes.of(64)) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.DIV.byteValue())) + .resLo(Bytes.ofUnsignedLong(getGDiffOver64())) + .wcpFlag(false) + .modFlag(true) + .validateRow(); + case 4 -> + trace + .arg1Hi(this.gas().orElseThrow().slice(0, 16)) + .arg1Lo(this.gas().orElseThrow().slice(16, 16)) + .arg2Lo(Bytes.ofUnsignedLong(getGDiff() - getGDiffOver64())) + .exogenousModuleInstruction(UnsignedByte.of(OpCode.LT.byteValue())) + .resLo( + Bytes.of( + this.gas() + .orElseThrow() + .toUnsignedBigInteger() + .compareTo(BigInteger.valueOf(get63of64GDiff())) + < 0 + ? 1 + : 0)) + .wcpFlag(true) + .modFlag(false) + .validateRow(); default -> throw new IllegalArgumentException("counter too big, should be <=" + ctMax); } } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/BlockSnapshot.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/BlockSnapshot.java index 09f0e442..44d9dd2b 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/BlockSnapshot.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/BlockSnapshot.java @@ -31,10 +31,13 @@ public class BlockSnapshot { /** Sequential ID of this block within a conflation */ @Getter int id; + /** A list of {@link TransactionSnapshot} contained in this block */ @Getter private final StackedList txs = new StackedList<>(); + /** The base fee of this block */ @Getter private final Optional baseFee; + /** The coinbase of this block */ @Getter private final Address coinbaseAddress; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TransactionSnapshot.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TransactionSnapshot.java index 23a51d39..5c2df5f9 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TransactionSnapshot.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TransactionSnapshot.java @@ -49,26 +49,37 @@ public final class TransactionSnapshot extends ModuleOperation { /** Value moved by the transaction */ private final BigInteger value; + /** Sender address */ private final Address from; + /** Receiver or contract deployment address */ private final Address to; + /** Sender nonce */ private final long nonce; + /** Number of addresses to pre-warm */ private final int prewarmedAddressesCount; + /** Number of storage slots to pre-warm */ private final int prewarmedStorageKeysCount; + /** Whether this transaction is a smart contract deployment */ private final boolean isDeployment; + /** Whether this transaction triggers the EVM */ private final boolean requiresEvmExecution; + /** The transaction {@link TransactionType} */ private final TransactionType type; + /** CodeFragmentIndex, given by the {@link net.consensys.linea.zktracer.module.romLex.RomLex} */ private final int codeIdBeforeLex; + /** The sender balance when it sent the transaction */ private final BigInteger initialSenderBalance; + /** The payload of the transaction, calldata or initcode */ private final Bytes payload; @@ -167,9 +178,10 @@ public long dataCost() { private static BigInteger computeEffectiveGasPrice(Optional baseFee, Transaction tx) { return switch (tx.getType()) { case FRONTIER, ACCESS_LIST -> tx.getGasPrice().get().getAsBigInteger(); - case EIP1559 -> TransactionPriceCalculator.eip1559() - .price((org.hyperledger.besu.ethereum.core.Transaction) tx, baseFee) - .getAsBigInteger(); + case EIP1559 -> + TransactionPriceCalculator.eip1559() + .price((org.hyperledger.besu.ethereum.core.Transaction) tx, baseFee) + .getAsBigInteger(); default -> throw new RuntimeException("transaction type not supported"); }; } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TxnData.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TxnData.java index 69a831c5..ae60eb11 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TxnData.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/TxnData.java @@ -236,18 +236,20 @@ private List setWcpInst(TransactionSnapshot tx) { ); List suffix = switch (tx.type()) { - case FRONTIER, ACCESS_LIST -> List.of( - 0, // ct = 4 - 0, // ct = 5 - 0, // ct = 6 - 0 // ct = 7 - ); - case EIP1559 -> List.of( - LT, // ct = 4 - LT, // ct = 5 - LT, // ct = 6 - 0 // ct = 7 - ); + case FRONTIER, ACCESS_LIST -> + List.of( + 0, // ct = 4 + 0, // ct = 5 + 0, // ct = 6 + 0 // ct = 7 + ); + case EIP1559 -> + List.of( + LT, // ct = 4 + LT, // ct = 5 + LT, // ct = 6 + 0 // ct = 7 + ); default -> throw new RuntimeException("transaction type not supported"); }; return Stream.concat(common.stream(), suffix.stream()).toList(); @@ -296,30 +298,33 @@ private List setWcpArgumentTwo(BlockSnapshot block, TransactionSnapshot List suffixTwos = switch (tx.type()) { - case FRONTIER, ACCESS_LIST -> List.of( - Bytes16.ZERO, // ct = 4 - Bytes16.ZERO, // ct = 5 - Bytes16.ZERO, // ct = 6 - Bytes16.ZERO // ct =7 - ); - case EIP1559 -> List.of( - Bytes16.leftPad( - bigIntegerToBytes(block.getBaseFee().orElseThrow().getAsBigInteger())), // ct = 4 - Bytes16.leftPad( - bigIntegerToBytes( - tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger())), // ct = 5 - Bytes16.leftPad( - bigIntegerToBytes( - block - .getBaseFee() - .orElseThrow() - .getAsBigInteger() - .add( - tx.maxPriorityFeePerGas() - .orElseThrow() - .getAsBigInteger()))), // ct = 6 - Bytes16.ZERO // ct = 7 - ); + case FRONTIER, ACCESS_LIST -> + List.of( + Bytes16.ZERO, // ct = 4 + Bytes16.ZERO, // ct = 5 + Bytes16.ZERO, // ct = 6 + Bytes16.ZERO // ct =7 + ); + case EIP1559 -> + List.of( + Bytes16.leftPad( + bigIntegerToBytes( + block.getBaseFee().orElseThrow().getAsBigInteger())), // ct = 4 + Bytes16.leftPad( + bigIntegerToBytes( + tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger())), // ct = 5 + Bytes16.leftPad( + bigIntegerToBytes( + block + .getBaseFee() + .orElseThrow() + .getAsBigInteger() + .add( + tx.maxPriorityFeePerGas() + .orElseThrow() + .getAsBigInteger()))), // ct = 6 + Bytes16.ZERO // ct = 7 + ); default -> throw new IllegalStateException("transaction type not supported:" + tx.type()); }; @@ -370,20 +375,23 @@ private static List computePhaseDependentSuffix(TransactionSnapshot tx) List phaseDependentSuffix; switch (tx.type()) { - case FRONTIER -> phaseDependentSuffix = - List.of( - TYPE_0_RLP_TXN_PHASE_NUMBER_6 // ct = 6 - ); - case ACCESS_LIST -> phaseDependentSuffix = - List.of( - TYPE_1_RLP_TXN_PHASE_NUMBER_6, // ct = 6 - TYPE_1_RLP_TXN_PHASE_NUMBER_7 // ct = 7 - ); - case EIP1559 -> phaseDependentSuffix = - List.of( - TYPE_2_RLP_TXN_PHASE_NUMBER_6, // ct = 6 - TYPE_2_RLP_TXN_PHASE_NUMBER_7 // ct = 7 - ); + case FRONTIER -> + phaseDependentSuffix = + List.of( + TYPE_0_RLP_TXN_PHASE_NUMBER_6 // ct = 6 + ); + case ACCESS_LIST -> + phaseDependentSuffix = + List.of( + TYPE_1_RLP_TXN_PHASE_NUMBER_6, // ct = 6 + TYPE_1_RLP_TXN_PHASE_NUMBER_7 // ct = 7 + ); + case EIP1559 -> + phaseDependentSuffix = + List.of( + TYPE_2_RLP_TXN_PHASE_NUMBER_6, // ct = 6 + TYPE_2_RLP_TXN_PHASE_NUMBER_7 // ct = 7 + ); default -> throw new IllegalStateException("transaction type not supported:" + tx.type()); } return phaseDependentSuffix; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/GasConstants.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/GasConstants.java index e01648d1..3d70bd30 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/GasConstants.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/GasConstants.java @@ -80,6 +80,7 @@ public int cost() { private static class Constants { /** Base price for a LOGx call. */ private static final int LOG = 375; + /** Additional price per topic for a LOGx call. */ private static final int LOG_TOPIC = 375; } diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/GasProjector.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/GasProjector.java index c5c8c152..2b691445 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/GasProjector.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/opcode/gas/projector/GasProjector.java @@ -29,109 +29,111 @@ public GasProjection of(MessageFrame frame, OpCode opCode) { return switch (opCode) { case STOP -> new Zero(); case ADD, - SUB, - NOT, - LT, - GT, - SLT, - SGT, - EQ, - ISZERO, - AND, - OR, - XOR, - BYTE, - SHL, - SHR, - SAR, - CALLDATALOAD, - PUSH1, - PUSH2, - PUSH3, - PUSH4, - PUSH5, - PUSH6, - PUSH7, - PUSH8, - PUSH9, - PUSH10, - PUSH11, - PUSH12, - PUSH13, - PUSH14, - PUSH15, - PUSH16, - PUSH17, - PUSH18, - PUSH19, - PUSH20, - PUSH21, - PUSH22, - PUSH23, - PUSH24, - PUSH25, - PUSH26, - PUSH27, - PUSH28, - PUSH29, - PUSH30, - PUSH31, - PUSH32, - DUP1, - DUP2, - DUP3, - DUP4, - DUP5, - DUP6, - DUP7, - DUP8, - DUP9, - DUP10, - DUP11, - DUP12, - DUP13, - DUP14, - DUP15, - DUP16, - SWAP1, - SWAP2, - SWAP3, - SWAP4, - SWAP5, - SWAP6, - SWAP7, - SWAP8, - SWAP9, - SWAP10, - SWAP11, - SWAP12, - SWAP13, - SWAP14, - SWAP15, - SWAP16 -> new VeryLow(); + SUB, + NOT, + LT, + GT, + SLT, + SGT, + EQ, + ISZERO, + AND, + OR, + XOR, + BYTE, + SHL, + SHR, + SAR, + CALLDATALOAD, + PUSH1, + PUSH2, + PUSH3, + PUSH4, + PUSH5, + PUSH6, + PUSH7, + PUSH8, + PUSH9, + PUSH10, + PUSH11, + PUSH12, + PUSH13, + PUSH14, + PUSH15, + PUSH16, + PUSH17, + PUSH18, + PUSH19, + PUSH20, + PUSH21, + PUSH22, + PUSH23, + PUSH24, + PUSH25, + PUSH26, + PUSH27, + PUSH28, + PUSH29, + PUSH30, + PUSH31, + PUSH32, + DUP1, + DUP2, + DUP3, + DUP4, + DUP5, + DUP6, + DUP7, + DUP8, + DUP9, + DUP10, + DUP11, + DUP12, + DUP13, + DUP14, + DUP15, + DUP16, + SWAP1, + SWAP2, + SWAP3, + SWAP4, + SWAP5, + SWAP6, + SWAP7, + SWAP8, + SWAP9, + SWAP10, + SWAP11, + SWAP12, + SWAP13, + SWAP14, + SWAP15, + SWAP16 -> + new VeryLow(); case MUL, DIV, SDIV, MOD, SMOD, SIGNEXTEND, SELFBALANCE -> new Low(); case ADDMOD, MULMOD, JUMP -> new Mid(); case EXP -> new Exp(frame); case SHA3 -> new Sha3(frame); case ADDRESS, - ORIGIN, - CALLER, - CALLVALUE, - CALLDATASIZE, - CODESIZE, - GASPRICE, - COINBASE, - TIMESTAMP, - NUMBER, - DIFFICULTY, - GASLIMIT, - CHAINID, - RETURNDATASIZE, - POP, - PC, - MSIZE, - GAS, - BASEFEE -> new Base(); + ORIGIN, + CALLER, + CALLVALUE, + CALLDATASIZE, + CODESIZE, + GASPRICE, + COINBASE, + TIMESTAMP, + NUMBER, + DIFFICULTY, + GASLIMIT, + CHAINID, + RETURNDATASIZE, + POP, + PC, + MSIZE, + GAS, + BASEFEE -> + new Base(); case BALANCE, EXTCODESIZE, EXTCODEHASH -> new AccountAccess(frame); case CALLDATACOPY, CODECOPY, RETURNDATACOPY -> new DataCopy(frame, opCode); case EXTCODECOPY -> new ExtCodeCopy(frame); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallFrame.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallFrame.java index 1284f15e..e7227820 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallFrame.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallFrame.java @@ -41,16 +41,22 @@ @Accessors(fluent = true) public class CallFrame { public static final CallFrame EMPTY = new CallFrame(Address.ZERO); + /** the position of this {@link CallFrame} in the {@link CallStack}. */ @Getter private int id; + /** the context number of the frame, i.e. the hub stamp at its creation */ @Getter private final int contextNumber; + /** the depth of this CallFrame within its call hierarchy. */ @Getter private int depth; + /** */ @Getter private int accountDeploymentNumber; + /** */ @Getter private int codeDeploymentNumber; + /** */ @Getter private boolean underDeployment; @@ -58,15 +64,19 @@ public class CallFrame { /** the position of this {@link CallFrame} parent in the {@link CallStack}. */ @Getter private int parentFrame; + /** all the {@link CallFrame} that have been called by this frame. */ @Getter private final List childFrames = new ArrayList<>(); /** the {@link Address} of the account executing this {@link CallFrame}. */ @Getter private final Address address; + /** A memoized {@link EWord} conversion of `address` */ private EWord eAddress = null; + /** the {@link Address} of the code executed in this {@link CallFrame}. */ @Getter private Address codeAddress = Address.ZERO; + /** A memoized {@link EWord} conversion of `codeAddress` */ private EWord eCodeAddress = null; @@ -83,17 +93,22 @@ public class CallFrame { /** the ether amount given to this frame. */ @Getter private Wei value = Wei.fromHexString("0xbadf00d"); // Marker for debugging + /** the gas given to this frame. */ @Getter private long gasEndowment; /** the call data given to this frame. */ @Getter private Bytes callData = Bytes.EMPTY; + /** the call data span in the parent memory. */ @Getter private final MemorySpan callDataPointer; + /** the data returned by the latest callee. */ @Getter @Setter private Bytes returnData = Bytes.EMPTY; + /** returnData position within the latest callee memory space. */ @Getter @Setter private MemorySpan returnDataPointer = new MemorySpan(0, 0); + /** where this frame is expected to write its returnData within its parent's memory space. */ @Getter private final MemorySpan returnDataTarget; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallStack.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallStack.java index 62870d54..dd2e6c93 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallStack.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/callstack/CallStack.java @@ -40,10 +40,13 @@ public final class CallStack { /** the maximal depth of the call stack (as defined by Ethereum) */ static final int MAX_CALLSTACK_SIZE = 1024; + /** a never-pruned-tree of the {@link CallFrame} executed by the {@link Hub} */ private final List frames = new ArrayList<>(); + /** the current depth of the call stack. */ @Getter private int depth; + /** a "pointer" to the current {@link CallFrame} in frames. */ private int current; diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackContext.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackContext.java index 1acc8bb4..cb64731d 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackContext.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackContext.java @@ -32,6 +32,7 @@ public final class StackContext { /** The opcode that triggered the stack operations. */ OpCode opCode; + /** One or two lines to be traced, representing the stack operations performed by the opcode. */ @Getter final List lines = new ArrayList<>(4); diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackOperation.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackOperation.java index b9350360..83e4bf50 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackOperation.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/runtime/stack/StackOperation.java @@ -27,15 +27,19 @@ */ public final class StackOperation { private static final Bytes MARKER = Bytes.fromHexString("0xDEADBEEF"); + /** * The relative height of the element with regard to the stack height just before executing the * linked EVM instruction. */ private final int height; + /** The value having been popped from/pushed on the stack. */ private Bytes value; + /** whether this action is a push or a pop. */ private final Action action; + /** * The stamp of this operation relative to the stack stamp before executing the linked EVM * instruction. diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/MxpTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/MxpTest.java index 03d30ac0..fabd391e 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/MxpTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/mxp/MxpTest.java @@ -475,34 +475,38 @@ private void triggerNonTrivialButMxpxOrRoob( case MLOAD -> appendOpCodeCall(List.of(offset1), opCode, program); case MSTORE, MSTORE8 -> appendOpCodeCall(List.of(value, offset1), opCode, program); case LOG0, - SHA3, - RETURN, - REVERT -> // RETURN and REVERT are selected only when isHalting is true - appendOpCodeCall(List.of(size1, offset1), opCode, program); - case LOG1 -> appendOpCodeCall( - Stream.concat(getRandomUpTo32BytesBigIntegers(1).stream(), Stream.of(size1, offset1)) - .collect(Collectors.toList()), - opCode, - program); - case LOG2 -> appendOpCodeCall( - Stream.concat(getRandomUpTo32BytesBigIntegers(2).stream(), Stream.of(size1, offset1)) - .collect(Collectors.toList()), - opCode, - program); - case LOG3 -> appendOpCodeCall( - Stream.concat(getRandomUpTo32BytesBigIntegers(3).stream(), Stream.of(size1, offset1)) - .collect(Collectors.toList()), - opCode, - program); - case LOG4 -> appendOpCodeCall( - Stream.concat(getRandomUpTo32BytesBigIntegers(4).stream(), Stream.of(size1, offset1)) - .collect(Collectors.toList()), - opCode, - program); - case CODECOPY, CALLDATACOPY -> appendOpCodeCall( - List.of(size1, offset2, offset1), opCode, program); - case EXTCODECOPY -> appendOpCodeCall( - List.of(size1, offset2, offset1, EWord.of(address)), opCode, program); + SHA3, + RETURN, + REVERT -> // RETURN and REVERT are selected only when isHalting is true + appendOpCodeCall(List.of(size1, offset1), opCode, program); + case LOG1 -> + appendOpCodeCall( + Stream.concat(getRandomUpTo32BytesBigIntegers(1).stream(), Stream.of(size1, offset1)) + .collect(Collectors.toList()), + opCode, + program); + case LOG2 -> + appendOpCodeCall( + Stream.concat(getRandomUpTo32BytesBigIntegers(2).stream(), Stream.of(size1, offset1)) + .collect(Collectors.toList()), + opCode, + program); + case LOG3 -> + appendOpCodeCall( + Stream.concat(getRandomUpTo32BytesBigIntegers(3).stream(), Stream.of(size1, offset1)) + .collect(Collectors.toList()), + opCode, + program); + case LOG4 -> + appendOpCodeCall( + Stream.concat(getRandomUpTo32BytesBigIntegers(4).stream(), Stream.of(size1, offset1)) + .collect(Collectors.toList()), + opCode, + program); + case CODECOPY, CALLDATACOPY -> + appendOpCodeCall(List.of(size1, offset2, offset1), opCode, program); + case EXTCODECOPY -> + appendOpCodeCall(List.of(size1, offset2, offset1, EWord.of(address)), opCode, program); case CREATE, CREATE2 -> { if (opCode == OpCode.CREATE) { // CREATE diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlp_txrcpt/RandomTxrcptTests.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlp_txrcpt/RandomTxrcptTests.java index 50bd555d..441aab49 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlp_txrcpt/RandomTxrcptTests.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlp_txrcpt/RandomTxrcptTests.java @@ -105,32 +105,35 @@ private Transaction randTransaction(ToyAccount senderAccount, KeyPair keyPair) { int txType = rnd.nextInt(0, 3); final List accessList = new ArrayList<>(); return switch (txType) { - case 0 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.FRONTIER) - .gasLimit(10_000_000L) - .value(Wei.of(BigInteger.valueOf(2_500))) - .payload(Bytes.EMPTY) - .build(); - case 1 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.ACCESS_LIST) - .gasLimit(10_000_000L) - .value(Wei.of(BigInteger.valueOf(2_500))) - .payload(Bytes.EMPTY) - .accessList(accessList) - .build(); + case 0 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.FRONTIER) + .gasLimit(10_000_000L) + .value(Wei.of(BigInteger.valueOf(2_500))) + .payload(Bytes.EMPTY) + .build(); + case 1 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.ACCESS_LIST) + .gasLimit(10_000_000L) + .value(Wei.of(BigInteger.valueOf(2_500))) + .payload(Bytes.EMPTY) + .accessList(accessList) + .build(); - case 2 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.EIP1559) - .gasLimit(10_000_000L) - .value(Wei.of(BigInteger.valueOf(2_500))) - .payload(Bytes.EMPTY) - .build(); + case 2 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.EIP1559) + .gasLimit(10_000_000L) + .value(Wei.of(BigInteger.valueOf(2_500))) + .payload(Bytes.EMPTY) + .build(); default -> throw new IllegalStateException("Unexpected value: " + txType); }; } diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlptxn/TestRandomTxns.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlptxn/TestRandomTxns.java index 3e6f5329..069bda52 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlptxn/TestRandomTxns.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/rlptxn/TestRandomTxns.java @@ -72,66 +72,72 @@ final Transaction randTx(ToyAccount senderAccount, KeyPair keyPair, ToyAccount r int txType = rnd.nextInt(0, 6); return switch (txType) { - case 0 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.FRONTIER) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randBigInt(true))) - .payload(randData(false)) - .build(); - - case 1 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.FRONTIER) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randBigInt(true))) - .to(receiverAccount) - .payload(randData(false)) - .build(); - - case 2 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.ACCESS_LIST) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randLong())) - .payload(randData(false)) - .accessList(randAccessList()) - .build(); - - case 3 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.ACCESS_LIST) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randLong())) - .to(receiverAccount) - .payload(randData(false)) - .accessList(randAccessList()) - .build(); - - case 4 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.EIP1559) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randLong())) - .payload(randData(false)) - .accessList(randAccessList()) - .build(); - - case 5 -> ToyTransaction.builder() - .sender(senderAccount) - .keyPair(keyPair) - .transactionType(TransactionType.EIP1559) - .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) - .value(Wei.of(randLong())) - .to(receiverAccount) - .payload(randData(false)) - .accessList(randAccessList()) - .build(); + case 0 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.FRONTIER) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randBigInt(true))) + .payload(randData(false)) + .build(); + + case 1 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.FRONTIER) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randBigInt(true))) + .to(receiverAccount) + .payload(randData(false)) + .build(); + + case 2 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.ACCESS_LIST) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randLong())) + .payload(randData(false)) + .accessList(randAccessList()) + .build(); + + case 3 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.ACCESS_LIST) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randLong())) + .to(receiverAccount) + .payload(randData(false)) + .accessList(randAccessList()) + .build(); + + case 4 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.EIP1559) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randLong())) + .payload(randData(false)) + .accessList(randAccessList()) + .build(); + + case 5 -> + ToyTransaction.builder() + .sender(senderAccount) + .keyPair(keyPair) + .transactionType(TransactionType.EIP1559) + .gasLimit(rnd.nextLong(21000, 0xfffffffffffffL)) + .value(Wei.of(randLong())) + .to(receiverAccount) + .payload(randData(false)) + .accessList(randAccessList()) + .build(); default -> throw new IllegalStateException("Unexpected value: " + txType); }; diff --git a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/stp/StpTest.java b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/stp/StpTest.java index b03a29ba..430dd35f 100644 --- a/arithmetization/src/test/java/net/consensys/linea/zktracer/module/stp/StpTest.java +++ b/arithmetization/src/test/java/net/consensys/linea/zktracer/module/stp/StpTest.java @@ -168,25 +168,27 @@ final Transaction txCall( private Bytes codeCall(OpCode opcode, Address calleeAddress, BigInteger value, long gasCall) { return switch (opcode) { - case CALL, CALLCODE -> BytecodeCompiler.newProgram() - .push(Bytes.minimalBytes(6)) // retLength - .push(Bytes.minimalBytes(5)) // terOffset - .push(Bytes.minimalBytes(4)) // argsLength - .push(Bytes.minimalBytes(3)) // argsOffset - .push(bigIntegerToBytes(value)) // value - .push(calleeAddress) // address - .push(longToBytes(gasCall)) // gas - .op(opcode) - .compile(); - case DELEGATECALL, STATICCALL -> BytecodeCompiler.newProgram() - .push(Bytes.minimalBytes(5)) // retLength - .push(Bytes.minimalBytes(4)) // terOffset - .push(Bytes.minimalBytes(3)) // argsLength - .push(Bytes.minimalBytes(2)) // argsOffset - .push(calleeAddress) // address - .push(longToBytes(gasCall)) // gas - .op(opcode) - .compile(); + case CALL, CALLCODE -> + BytecodeCompiler.newProgram() + .push(Bytes.minimalBytes(6)) // retLength + .push(Bytes.minimalBytes(5)) // terOffset + .push(Bytes.minimalBytes(4)) // argsLength + .push(Bytes.minimalBytes(3)) // argsOffset + .push(bigIntegerToBytes(value)) // value + .push(calleeAddress) // address + .push(longToBytes(gasCall)) // gas + .op(opcode) + .compile(); + case DELEGATECALL, STATICCALL -> + BytecodeCompiler.newProgram() + .push(Bytes.minimalBytes(5)) // retLength + .push(Bytes.minimalBytes(4)) // terOffset + .push(Bytes.minimalBytes(3)) // argsLength + .push(Bytes.minimalBytes(2)) // argsOffset + .push(calleeAddress) // address + .push(longToBytes(gasCall)) // gas + .op(opcode) + .compile(); default -> throw new IllegalStateException("Unexpected value: " + opcode); }; diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index fe5b0080..0d3ae500 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -22,11 +22,11 @@ repositories { } dependencies { - implementation 'io.freefair.gradle:lombok-plugin:8.1.0' - implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.20.0' - implementation 'com.github.ben-manes:gradle-versions-plugin:0.11.1' + implementation 'io.freefair.gradle:lombok-plugin:8.6' + implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0' + implementation 'com.github.ben-manes:gradle-versions-plugin:0.51.0' implementation 'com.github.hierynomus.license:com.github.hierynomus.license.gradle.plugin:0.16.1' - implementation 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.1.2' - implementation 'de.undercouch.download:de.undercouch.download.gradle.plugin:5.4.0' + implementation 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.1.5' + implementation 'de.undercouch.download:de.undercouch.download.gradle.plugin:5.6.0' } diff --git a/gradle/java.gradle b/gradle/java.gradle index 41beb9a0..01c62843 100644 --- a/gradle/java.gradle +++ b/gradle/java.gradle @@ -15,13 +15,13 @@ apply plugin: 'java-library' -if (!JavaVersion.current().java11Compatible) { - throw new GradleException("Java 17 or later is required.\n" + - " Detected version ${JavaVersion.current()}") +if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) { + throw new GradleException("Java 21 or later is required to build Besu.\n" + + " Detected version ${JavaVersion.current()}") } -sourceCompatibility = 17 -targetCompatibility = 17 +sourceCompatibility = 21 +targetCompatibility = 21 tasks.withType(JavaCompile) { options.compilerArgs += [ diff --git a/gradle/lint.gradle b/gradle/lint.gradle index 9b6a11b0..417d7e3a 100644 --- a/gradle/lint.gradle +++ b/gradle/lint.gradle @@ -15,13 +15,13 @@ apply plugin: 'com.diffplug.spotless' spotless { - version "6.16.0" + version "6.25.0" java { // This path needs to be relative to each project target 'src/**/*.java' targetExclude '**/src/test/java/**ReferenceTest**', '**/src/main/generated/**', '**/src/test/generated/**', '**/src/jmh/generated/**' removeUnusedImports() - googleJavaFormat('1.15.0') + googleJavaFormat('1.22.0') importOrder '\\#', 'java', 'javax', '' trimTrailingWhitespace() endWithNewline() diff --git a/gradle/tests.gradle b/gradle/tests.gradle index 0e973c9c..8a26ee37 100644 --- a/gradle/tests.gradle +++ b/gradle/tests.gradle @@ -17,7 +17,7 @@ import java.time.LocalTime apply plugin: 'jacoco' jacoco { - toolVersion = '0.8.8' + toolVersion = '0.8.12' } /* diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME