diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/Trace.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/Trace.java index 1700e61bfd..2bb24f0037 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/Trace.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/txn_data/Trace.java @@ -63,6 +63,7 @@ public class Trace { private final MappedByteBuffer codeFragmentIndex; private final MappedByteBuffer coinbaseHi; private final MappedByteBuffer coinbaseLo; + private final MappedByteBuffer copyTxcdAtInitialisation; private final MappedByteBuffer ct; private final MappedByteBuffer cumulativeConsumedGas; private final MappedByteBuffer fromHi; @@ -108,6 +109,7 @@ static List headers(int length) { new ColumnHeader("txnData.CODE_FRAGMENT_INDEX", 32, length), new ColumnHeader("txnData.COINBASE_HI", 32, length), new ColumnHeader("txnData.COINBASE_LO", 32, length), + new ColumnHeader("txnData.COPY_TXCD_AT_INITIALISATION", 1, length), new ColumnHeader("txnData.CT", 1, length), new ColumnHeader("txnData.CUMULATIVE_CONSUMED_GAS", 32, length), new ColumnHeader("txnData.FROM_HI", 32, length), @@ -153,39 +155,40 @@ public Trace(List buffers) { this.codeFragmentIndex = buffers.get(6); this.coinbaseHi = buffers.get(7); this.coinbaseLo = buffers.get(8); - this.ct = buffers.get(9); - this.cumulativeConsumedGas = buffers.get(10); - this.fromHi = buffers.get(11); - this.fromLo = buffers.get(12); - this.gasLimit = buffers.get(13); - this.gasPrice = buffers.get(14); - this.initCodeSize = buffers.get(15); - this.initialBalance = buffers.get(16); - this.initialGas = buffers.get(17); - this.isDep = buffers.get(18); - this.leftoverGas = buffers.get(19); - this.nonce = buffers.get(20); - this.outgoingHi = buffers.get(21); - this.outgoingLo = buffers.get(22); - this.outgoingRlpTxnrcpt = buffers.get(23); - this.phaseRlpTxn = buffers.get(24); - this.phaseRlpTxnrcpt = buffers.get(25); - this.refundAmount = buffers.get(26); - this.refundCounter = buffers.get(27); - this.relTxNum = buffers.get(28); - this.relTxNumMax = buffers.get(29); - this.requiresEvmExecution = buffers.get(30); - this.statusCode = buffers.get(31); - this.toHi = buffers.get(32); - this.toLo = buffers.get(33); - this.type0 = buffers.get(34); - this.type1 = buffers.get(35); - this.type2 = buffers.get(36); - this.value = buffers.get(37); - this.wcpArgOneLo = buffers.get(38); - this.wcpArgTwoLo = buffers.get(39); - this.wcpInst = buffers.get(40); - this.wcpRes = buffers.get(41); + this.copyTxcdAtInitialisation = buffers.get(9); + this.ct = buffers.get(10); + this.cumulativeConsumedGas = buffers.get(11); + this.fromHi = buffers.get(12); + this.fromLo = buffers.get(13); + this.gasLimit = buffers.get(14); + this.gasPrice = buffers.get(15); + this.initCodeSize = buffers.get(16); + this.initialBalance = buffers.get(17); + this.initialGas = buffers.get(18); + this.isDep = buffers.get(19); + this.leftoverGas = buffers.get(20); + this.nonce = buffers.get(21); + this.outgoingHi = buffers.get(22); + this.outgoingLo = buffers.get(23); + this.outgoingRlpTxnrcpt = buffers.get(24); + this.phaseRlpTxn = buffers.get(25); + this.phaseRlpTxnrcpt = buffers.get(26); + this.refundAmount = buffers.get(27); + this.refundCounter = buffers.get(28); + this.relTxNum = buffers.get(29); + this.relTxNumMax = buffers.get(30); + this.requiresEvmExecution = buffers.get(31); + this.statusCode = buffers.get(32); + this.toHi = buffers.get(33); + this.toLo = buffers.get(34); + this.type0 = buffers.get(35); + this.type1 = buffers.get(36); + this.type2 = buffers.get(37); + this.value = buffers.get(38); + this.wcpArgOneLo = buffers.get(39); + this.wcpArgTwoLo = buffers.get(40); + this.wcpInst = buffers.get(41); + this.wcpRes = buffers.get(42); } public int size() { @@ -340,23 +343,35 @@ public Trace coinbaseLo(final Bytes b) { return this; } - public Trace ct(final UnsignedByte b) { + public Trace copyTxcdAtInitialisation(final Boolean b) { if (filled.get(9)) { - throw new IllegalStateException("txnData.CT already set"); + throw new IllegalStateException("txnData.COPY_TXCD_AT_INITIALISATION already set"); } else { filled.set(9); } + copyTxcdAtInitialisation.put((byte) (b ? 1 : 0)); + + return this; + } + + public Trace ct(final UnsignedByte b) { + if (filled.get(10)) { + throw new IllegalStateException("txnData.CT already set"); + } else { + filled.set(10); + } + ct.put(b.toByte()); return this; } public Trace cumulativeConsumedGas(final Bytes b) { - if (filled.get(10)) { + if (filled.get(11)) { throw new IllegalStateException("txnData.CUMULATIVE_CONSUMED_GAS already set"); } else { - filled.set(10); + filled.set(11); } final byte[] bs = b.toArrayUnsafe(); @@ -369,10 +384,10 @@ public Trace cumulativeConsumedGas(final Bytes b) { } public Trace fromHi(final Bytes b) { - if (filled.get(11)) { + if (filled.get(12)) { throw new IllegalStateException("txnData.FROM_HI already set"); } else { - filled.set(11); + filled.set(12); } final byte[] bs = b.toArrayUnsafe(); @@ -385,10 +400,10 @@ public Trace fromHi(final Bytes b) { } public Trace fromLo(final Bytes b) { - if (filled.get(12)) { + if (filled.get(13)) { throw new IllegalStateException("txnData.FROM_LO already set"); } else { - filled.set(12); + filled.set(13); } final byte[] bs = b.toArrayUnsafe(); @@ -401,10 +416,10 @@ public Trace fromLo(final Bytes b) { } public Trace gasLimit(final Bytes b) { - if (filled.get(13)) { + if (filled.get(14)) { throw new IllegalStateException("txnData.GAS_LIMIT already set"); } else { - filled.set(13); + filled.set(14); } final byte[] bs = b.toArrayUnsafe(); @@ -417,10 +432,10 @@ public Trace gasLimit(final Bytes b) { } public Trace gasPrice(final Bytes b) { - if (filled.get(14)) { + if (filled.get(15)) { throw new IllegalStateException("txnData.GAS_PRICE already set"); } else { - filled.set(14); + filled.set(15); } final byte[] bs = b.toArrayUnsafe(); @@ -433,10 +448,10 @@ public Trace gasPrice(final Bytes b) { } public Trace initCodeSize(final Bytes b) { - if (filled.get(17)) { + if (filled.get(18)) { throw new IllegalStateException("txnData.INIT_CODE_SIZE already set"); } else { - filled.set(17); + filled.set(18); } final byte[] bs = b.toArrayUnsafe(); @@ -449,10 +464,10 @@ public Trace initCodeSize(final Bytes b) { } public Trace initialBalance(final Bytes b) { - if (filled.get(15)) { + if (filled.get(16)) { throw new IllegalStateException("txnData.INITIAL_BALANCE already set"); } else { - filled.set(15); + filled.set(16); } final byte[] bs = b.toArrayUnsafe(); @@ -465,10 +480,10 @@ public Trace initialBalance(final Bytes b) { } public Trace initialGas(final Bytes b) { - if (filled.get(16)) { + if (filled.get(17)) { throw new IllegalStateException("txnData.INITIAL_GAS already set"); } else { - filled.set(16); + filled.set(17); } final byte[] bs = b.toArrayUnsafe(); @@ -481,10 +496,10 @@ public Trace initialGas(final Bytes b) { } public Trace isDep(final Boolean b) { - if (filled.get(18)) { + if (filled.get(19)) { throw new IllegalStateException("txnData.IS_DEP already set"); } else { - filled.set(18); + filled.set(19); } isDep.put((byte) (b ? 1 : 0)); @@ -493,10 +508,10 @@ public Trace isDep(final Boolean b) { } public Trace leftoverGas(final Bytes b) { - if (filled.get(19)) { + if (filled.get(20)) { throw new IllegalStateException("txnData.LEFTOVER_GAS already set"); } else { - filled.set(19); + filled.set(20); } final byte[] bs = b.toArrayUnsafe(); @@ -509,10 +524,10 @@ public Trace leftoverGas(final Bytes b) { } public Trace nonce(final Bytes b) { - if (filled.get(20)) { + if (filled.get(21)) { throw new IllegalStateException("txnData.NONCE already set"); } else { - filled.set(20); + filled.set(21); } final byte[] bs = b.toArrayUnsafe(); @@ -525,10 +540,10 @@ public Trace nonce(final Bytes b) { } public Trace outgoingHi(final Bytes b) { - if (filled.get(21)) { + if (filled.get(22)) { throw new IllegalStateException("txnData.OUTGOING_HI already set"); } else { - filled.set(21); + filled.set(22); } final byte[] bs = b.toArrayUnsafe(); @@ -541,10 +556,10 @@ public Trace outgoingHi(final Bytes b) { } public Trace outgoingLo(final Bytes b) { - if (filled.get(22)) { + if (filled.get(23)) { throw new IllegalStateException("txnData.OUTGOING_LO already set"); } else { - filled.set(22); + filled.set(23); } final byte[] bs = b.toArrayUnsafe(); @@ -557,10 +572,10 @@ public Trace outgoingLo(final Bytes b) { } public Trace outgoingRlpTxnrcpt(final Bytes b) { - if (filled.get(23)) { + if (filled.get(24)) { throw new IllegalStateException("txnData.OUTGOING_RLP_TXNRCPT already set"); } else { - filled.set(23); + filled.set(24); } final byte[] bs = b.toArrayUnsafe(); @@ -573,10 +588,10 @@ public Trace outgoingRlpTxnrcpt(final Bytes b) { } public Trace phaseRlpTxn(final UnsignedByte b) { - if (filled.get(24)) { + if (filled.get(25)) { throw new IllegalStateException("txnData.PHASE_RLP_TXN already set"); } else { - filled.set(24); + filled.set(25); } phaseRlpTxn.put(b.toByte()); @@ -585,10 +600,10 @@ public Trace phaseRlpTxn(final UnsignedByte b) { } public Trace phaseRlpTxnrcpt(final UnsignedByte b) { - if (filled.get(25)) { + if (filled.get(26)) { throw new IllegalStateException("txnData.PHASE_RLP_TXNRCPT already set"); } else { - filled.set(25); + filled.set(26); } phaseRlpTxnrcpt.put(b.toByte()); @@ -597,10 +612,10 @@ public Trace phaseRlpTxnrcpt(final UnsignedByte b) { } public Trace refundAmount(final Bytes b) { - if (filled.get(26)) { + if (filled.get(27)) { throw new IllegalStateException("txnData.REFUND_AMOUNT already set"); } else { - filled.set(26); + filled.set(27); } final byte[] bs = b.toArrayUnsafe(); @@ -613,10 +628,10 @@ public Trace refundAmount(final Bytes b) { } public Trace refundCounter(final Bytes b) { - if (filled.get(27)) { + if (filled.get(28)) { throw new IllegalStateException("txnData.REFUND_COUNTER already set"); } else { - filled.set(27); + filled.set(28); } final byte[] bs = b.toArrayUnsafe(); @@ -629,10 +644,10 @@ public Trace refundCounter(final Bytes b) { } public Trace relTxNum(final Bytes b) { - if (filled.get(28)) { + if (filled.get(29)) { throw new IllegalStateException("txnData.REL_TX_NUM already set"); } else { - filled.set(28); + filled.set(29); } final byte[] bs = b.toArrayUnsafe(); @@ -645,10 +660,10 @@ public Trace relTxNum(final Bytes b) { } public Trace relTxNumMax(final Bytes b) { - if (filled.get(29)) { + if (filled.get(30)) { throw new IllegalStateException("txnData.REL_TX_NUM_MAX already set"); } else { - filled.set(29); + filled.set(30); } final byte[] bs = b.toArrayUnsafe(); @@ -661,10 +676,10 @@ public Trace relTxNumMax(final Bytes b) { } public Trace requiresEvmExecution(final Boolean b) { - if (filled.get(30)) { + if (filled.get(31)) { throw new IllegalStateException("txnData.REQUIRES_EVM_EXECUTION already set"); } else { - filled.set(30); + filled.set(31); } requiresEvmExecution.put((byte) (b ? 1 : 0)); @@ -673,10 +688,10 @@ public Trace requiresEvmExecution(final Boolean b) { } public Trace statusCode(final Boolean b) { - if (filled.get(31)) { + if (filled.get(32)) { throw new IllegalStateException("txnData.STATUS_CODE already set"); } else { - filled.set(31); + filled.set(32); } statusCode.put((byte) (b ? 1 : 0)); @@ -685,10 +700,10 @@ public Trace statusCode(final Boolean b) { } public Trace toHi(final Bytes b) { - if (filled.get(32)) { + if (filled.get(33)) { throw new IllegalStateException("txnData.TO_HI already set"); } else { - filled.set(32); + filled.set(33); } final byte[] bs = b.toArrayUnsafe(); @@ -701,10 +716,10 @@ public Trace toHi(final Bytes b) { } public Trace toLo(final Bytes b) { - if (filled.get(33)) { + if (filled.get(34)) { throw new IllegalStateException("txnData.TO_LO already set"); } else { - filled.set(33); + filled.set(34); } final byte[] bs = b.toArrayUnsafe(); @@ -717,10 +732,10 @@ public Trace toLo(final Bytes b) { } public Trace type0(final Boolean b) { - if (filled.get(34)) { + if (filled.get(35)) { throw new IllegalStateException("txnData.TYPE0 already set"); } else { - filled.set(34); + filled.set(35); } type0.put((byte) (b ? 1 : 0)); @@ -729,10 +744,10 @@ public Trace type0(final Boolean b) { } public Trace type1(final Boolean b) { - if (filled.get(35)) { + if (filled.get(36)) { throw new IllegalStateException("txnData.TYPE1 already set"); } else { - filled.set(35); + filled.set(36); } type1.put((byte) (b ? 1 : 0)); @@ -741,10 +756,10 @@ public Trace type1(final Boolean b) { } public Trace type2(final Boolean b) { - if (filled.get(36)) { + if (filled.get(37)) { throw new IllegalStateException("txnData.TYPE2 already set"); } else { - filled.set(36); + filled.set(37); } type2.put((byte) (b ? 1 : 0)); @@ -753,10 +768,10 @@ public Trace type2(final Boolean b) { } public Trace value(final Bytes b) { - if (filled.get(37)) { + if (filled.get(38)) { throw new IllegalStateException("txnData.VALUE already set"); } else { - filled.set(37); + filled.set(38); } final byte[] bs = b.toArrayUnsafe(); @@ -769,10 +784,10 @@ public Trace value(final Bytes b) { } public Trace wcpArgOneLo(final Bytes b) { - if (filled.get(38)) { + if (filled.get(39)) { throw new IllegalStateException("txnData.WCP_ARG_ONE_LO already set"); } else { - filled.set(38); + filled.set(39); } final byte[] bs = b.toArrayUnsafe(); @@ -785,10 +800,10 @@ public Trace wcpArgOneLo(final Bytes b) { } public Trace wcpArgTwoLo(final Bytes b) { - if (filled.get(39)) { + if (filled.get(40)) { throw new IllegalStateException("txnData.WCP_ARG_TWO_LO already set"); } else { - filled.set(39); + filled.set(40); } final byte[] bs = b.toArrayUnsafe(); @@ -801,10 +816,10 @@ public Trace wcpArgTwoLo(final Bytes b) { } public Trace wcpInst(final UnsignedByte b) { - if (filled.get(40)) { + if (filled.get(41)) { throw new IllegalStateException("txnData.WCP_INST already set"); } else { - filled.set(40); + filled.set(41); } wcpInst.put(b.toByte()); @@ -813,10 +828,10 @@ public Trace wcpInst(final UnsignedByte b) { } public Trace wcpRes(final Boolean b) { - if (filled.get(41)) { + if (filled.get(42)) { throw new IllegalStateException("txnData.WCP_RES already set"); } else { - filled.set(41); + filled.set(42); } wcpRes.put((byte) (b ? 1 : 0)); @@ -862,134 +877,138 @@ public Trace validateRow() { } if (!filled.get(9)) { - throw new IllegalStateException("txnData.CT has not been filled"); + throw new IllegalStateException("txnData.COPY_TXCD_AT_INITIALISATION has not been filled"); } if (!filled.get(10)) { - throw new IllegalStateException("txnData.CUMULATIVE_CONSUMED_GAS has not been filled"); + throw new IllegalStateException("txnData.CT has not been filled"); } if (!filled.get(11)) { - throw new IllegalStateException("txnData.FROM_HI has not been filled"); + throw new IllegalStateException("txnData.CUMULATIVE_CONSUMED_GAS has not been filled"); } if (!filled.get(12)) { - throw new IllegalStateException("txnData.FROM_LO has not been filled"); + throw new IllegalStateException("txnData.FROM_HI has not been filled"); } if (!filled.get(13)) { - throw new IllegalStateException("txnData.GAS_LIMIT has not been filled"); + throw new IllegalStateException("txnData.FROM_LO has not been filled"); } if (!filled.get(14)) { + throw new IllegalStateException("txnData.GAS_LIMIT has not been filled"); + } + + if (!filled.get(15)) { throw new IllegalStateException("txnData.GAS_PRICE has not been filled"); } - if (!filled.get(17)) { + if (!filled.get(18)) { throw new IllegalStateException("txnData.INIT_CODE_SIZE has not been filled"); } - if (!filled.get(15)) { + if (!filled.get(16)) { throw new IllegalStateException("txnData.INITIAL_BALANCE has not been filled"); } - if (!filled.get(16)) { + if (!filled.get(17)) { throw new IllegalStateException("txnData.INITIAL_GAS has not been filled"); } - if (!filled.get(18)) { + if (!filled.get(19)) { throw new IllegalStateException("txnData.IS_DEP has not been filled"); } - if (!filled.get(19)) { + if (!filled.get(20)) { throw new IllegalStateException("txnData.LEFTOVER_GAS has not been filled"); } - if (!filled.get(20)) { + if (!filled.get(21)) { throw new IllegalStateException("txnData.NONCE has not been filled"); } - if (!filled.get(21)) { + if (!filled.get(22)) { throw new IllegalStateException("txnData.OUTGOING_HI has not been filled"); } - if (!filled.get(22)) { + if (!filled.get(23)) { throw new IllegalStateException("txnData.OUTGOING_LO has not been filled"); } - if (!filled.get(23)) { + if (!filled.get(24)) { throw new IllegalStateException("txnData.OUTGOING_RLP_TXNRCPT has not been filled"); } - if (!filled.get(24)) { + if (!filled.get(25)) { throw new IllegalStateException("txnData.PHASE_RLP_TXN has not been filled"); } - if (!filled.get(25)) { + if (!filled.get(26)) { throw new IllegalStateException("txnData.PHASE_RLP_TXNRCPT has not been filled"); } - if (!filled.get(26)) { + if (!filled.get(27)) { throw new IllegalStateException("txnData.REFUND_AMOUNT has not been filled"); } - if (!filled.get(27)) { + if (!filled.get(28)) { throw new IllegalStateException("txnData.REFUND_COUNTER has not been filled"); } - if (!filled.get(28)) { + if (!filled.get(29)) { throw new IllegalStateException("txnData.REL_TX_NUM has not been filled"); } - if (!filled.get(29)) { + if (!filled.get(30)) { throw new IllegalStateException("txnData.REL_TX_NUM_MAX has not been filled"); } - if (!filled.get(30)) { + if (!filled.get(31)) { throw new IllegalStateException("txnData.REQUIRES_EVM_EXECUTION has not been filled"); } - if (!filled.get(31)) { + if (!filled.get(32)) { throw new IllegalStateException("txnData.STATUS_CODE has not been filled"); } - if (!filled.get(32)) { + if (!filled.get(33)) { throw new IllegalStateException("txnData.TO_HI has not been filled"); } - if (!filled.get(33)) { + if (!filled.get(34)) { throw new IllegalStateException("txnData.TO_LO has not been filled"); } - if (!filled.get(34)) { + if (!filled.get(35)) { throw new IllegalStateException("txnData.TYPE0 has not been filled"); } - if (!filled.get(35)) { + if (!filled.get(36)) { throw new IllegalStateException("txnData.TYPE1 has not been filled"); } - if (!filled.get(36)) { + if (!filled.get(37)) { throw new IllegalStateException("txnData.TYPE2 has not been filled"); } - if (!filled.get(37)) { + if (!filled.get(38)) { throw new IllegalStateException("txnData.VALUE has not been filled"); } - if (!filled.get(38)) { + if (!filled.get(39)) { throw new IllegalStateException("txnData.WCP_ARG_ONE_LO has not been filled"); } - if (!filled.get(39)) { + if (!filled.get(40)) { throw new IllegalStateException("txnData.WCP_ARG_TWO_LO has not been filled"); } - if (!filled.get(40)) { + if (!filled.get(41)) { throw new IllegalStateException("txnData.WCP_INST has not been filled"); } - if (!filled.get(41)) { + if (!filled.get(42)) { throw new IllegalStateException("txnData.WCP_RES has not been filled"); } @@ -1037,134 +1056,138 @@ public Trace fillAndValidateRow() { } if (!filled.get(9)) { - ct.position(ct.position() + 1); + copyTxcdAtInitialisation.position(copyTxcdAtInitialisation.position() + 1); } if (!filled.get(10)) { - cumulativeConsumedGas.position(cumulativeConsumedGas.position() + 32); + ct.position(ct.position() + 1); } if (!filled.get(11)) { - fromHi.position(fromHi.position() + 32); + cumulativeConsumedGas.position(cumulativeConsumedGas.position() + 32); } if (!filled.get(12)) { - fromLo.position(fromLo.position() + 32); + fromHi.position(fromHi.position() + 32); } if (!filled.get(13)) { - gasLimit.position(gasLimit.position() + 32); + fromLo.position(fromLo.position() + 32); } if (!filled.get(14)) { + gasLimit.position(gasLimit.position() + 32); + } + + if (!filled.get(15)) { gasPrice.position(gasPrice.position() + 32); } - if (!filled.get(17)) { + if (!filled.get(18)) { initCodeSize.position(initCodeSize.position() + 32); } - if (!filled.get(15)) { + if (!filled.get(16)) { initialBalance.position(initialBalance.position() + 32); } - if (!filled.get(16)) { + if (!filled.get(17)) { initialGas.position(initialGas.position() + 32); } - if (!filled.get(18)) { + if (!filled.get(19)) { isDep.position(isDep.position() + 1); } - if (!filled.get(19)) { + if (!filled.get(20)) { leftoverGas.position(leftoverGas.position() + 32); } - if (!filled.get(20)) { + if (!filled.get(21)) { nonce.position(nonce.position() + 32); } - if (!filled.get(21)) { + if (!filled.get(22)) { outgoingHi.position(outgoingHi.position() + 32); } - if (!filled.get(22)) { + if (!filled.get(23)) { outgoingLo.position(outgoingLo.position() + 32); } - if (!filled.get(23)) { + if (!filled.get(24)) { outgoingRlpTxnrcpt.position(outgoingRlpTxnrcpt.position() + 32); } - if (!filled.get(24)) { + if (!filled.get(25)) { phaseRlpTxn.position(phaseRlpTxn.position() + 1); } - if (!filled.get(25)) { + if (!filled.get(26)) { phaseRlpTxnrcpt.position(phaseRlpTxnrcpt.position() + 1); } - if (!filled.get(26)) { + if (!filled.get(27)) { refundAmount.position(refundAmount.position() + 32); } - if (!filled.get(27)) { + if (!filled.get(28)) { refundCounter.position(refundCounter.position() + 32); } - if (!filled.get(28)) { + if (!filled.get(29)) { relTxNum.position(relTxNum.position() + 32); } - if (!filled.get(29)) { + if (!filled.get(30)) { relTxNumMax.position(relTxNumMax.position() + 32); } - if (!filled.get(30)) { + if (!filled.get(31)) { requiresEvmExecution.position(requiresEvmExecution.position() + 1); } - if (!filled.get(31)) { + if (!filled.get(32)) { statusCode.position(statusCode.position() + 1); } - if (!filled.get(32)) { + if (!filled.get(33)) { toHi.position(toHi.position() + 32); } - if (!filled.get(33)) { + if (!filled.get(34)) { toLo.position(toLo.position() + 32); } - if (!filled.get(34)) { + if (!filled.get(35)) { type0.position(type0.position() + 1); } - if (!filled.get(35)) { + if (!filled.get(36)) { type1.position(type1.position() + 1); } - if (!filled.get(36)) { + if (!filled.get(37)) { type2.position(type2.position() + 1); } - if (!filled.get(37)) { + if (!filled.get(38)) { value.position(value.position() + 32); } - if (!filled.get(38)) { + if (!filled.get(39)) { wcpArgOneLo.position(wcpArgOneLo.position() + 32); } - if (!filled.get(39)) { + if (!filled.get(40)) { wcpArgTwoLo.position(wcpArgTwoLo.position() + 32); } - if (!filled.get(40)) { + if (!filled.get(41)) { wcpInst.position(wcpInst.position() + 1); } - if (!filled.get(41)) { + if (!filled.get(42)) { wcpRes.position(wcpRes.position() + 1); } 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 23a51d395e..03d84eab4f 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 @@ -72,6 +72,8 @@ public final class TransactionSnapshot extends ModuleOperation { /** The payload of the transaction, calldata or initcode */ private final Bytes payload; + private final int callDataSize; + private final long gasLimit; private final BigInteger effectiveGasPrice; private final Optional maxFeePerGas; @@ -116,6 +118,7 @@ public TransactionSnapshot( this.effectiveGasPrice = effectiveGasPrice; this.maxFeePerGas = maxFeePerGas; this.maxPriorityFeePerGas = maxPriorityFeePerGas; + this.callDataSize = this.isDeployment ? 0 : this.payload.size(); } public static TransactionSnapshot fromTransaction( 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 69a831c511..5001c72c70 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 @@ -54,6 +54,7 @@ public class TxnData implements Module { private static final int N_ROWS_TX_MAX = Math.max(Math.max(N_ROWS_FRONTIER_TX, N_ROWS_ACCESS_LIST_TX), N_ROWS_EIP_1559_TX); private static final int LT = 16; + private static final int ISZERO = 21; static final int COMMON_RLP_TXN_PHASE_NUMBER_0 = 0; static final int COMMON_RLP_TXN_PHASE_NUMBER_1 = 7; static final int COMMON_RLP_TXN_PHASE_NUMBER_2 = 2; @@ -131,11 +132,15 @@ public void callWcp() { final List wcpArgOneLo = setWcpArgumentOne(this.currentBlock().currentTx()); final List wcpArgTwoLo = setWcpArgumentTwo(this.currentBlock(), this.currentBlock().currentTx()); + // wcp call row from 0 to 3 for (int ct = 0; ct < 4; ct++) { this.wcp.callLT(Bytes32.leftPad(wcpArgOneLo.get(ct)), Bytes32.leftPad(wcpArgTwoLo.get(ct))); } + // wcp call row 4 + this.wcp.callISZERO(Bytes32.leftPad(wcpArgOneLo.get(4))); + // wcp call row 5 to 7 for Type 2 transaction only if (this.currentBlock().currentTx().type() == TransactionType.EIP1559) { - for (int ct = 4; ct < 7; ct++) { + for (int ct = 5; ct < 8; ct++) { this.wcp.callLT(Bytes32.leftPad(wcpArgOneLo.get(ct)), Bytes32.leftPad(wcpArgTwoLo.get(ct))); } } @@ -232,21 +237,20 @@ private List setWcpInst(TransactionSnapshot tx) { LT, // ct = 0 LT, // ct = 1 LT, // ct = 2 - LT // ct = 3 + LT, // ct = 3 + ISZERO // ct = 4 ); 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 + LT // ct = 7 ); default -> throw new RuntimeException("transaction type not supported"); }; @@ -260,10 +264,10 @@ private List setWcpArgumentOne(TransactionSnapshot tx) { output.add(1, Bytes16.leftPad(Bytes.ofUnsignedLong(tx.gasLimit()))); // ct = 1 output.add(2, Bytes16.leftPad(bigIntegerToBytes(tx.getLimitMinusLeftoverGas()))); // ct = 2 output.add(3, Bytes16.leftPad(Bytes.ofUnsignedLong(tx.refundCounter()))); // ct = 3 + output.add(4, Bytes16.leftPad(Bytes.ofUnsignedLong(tx.callDataSize()))); // ct = 4 switch (tx.type()) { case FRONTIER, ACCESS_LIST -> { - output.add(4, Bytes16.ZERO); // ct = 4 output.add(5, Bytes16.ZERO); // ct = 5 output.add(6, Bytes16.ZERO); // ct = 6 output.add(7, Bytes16.ZERO); // ct = 7 @@ -272,10 +276,9 @@ private List setWcpArgumentOne(TransactionSnapshot tx) { case EIP1559 -> { final Bytes16 maxFeePerGas = Bytes16.leftPad(bigIntegerToBytes(tx.maxFeePerGas().orElseThrow().getAsBigInteger())); - output.add(4, maxFeePerGas); // ct = 4 output.add(5, maxFeePerGas); // ct = 5 output.add(6, maxFeePerGas); // ct = 6 - output.add(7, Bytes16.ZERO); // ct = 7 + output.add(7, maxFeePerGas); // ct = 7 } default -> throw new RuntimeException("transaction type not supported"); } @@ -291,23 +294,23 @@ private List setWcpArgumentTwo(BlockSnapshot block, TransactionSnapshot Bytes16.leftPad(bigIntegerToBytes(tx.getMaximalUpfrontCost())), // ct = 0 Bytes16.leftPad(Bytes.ofUnsignedLong(tx.getUpfrontGasCost())), // ct = 1 limitMinusLeftOverGasDividedByTwo, // ct = 2 - limitMinusLeftOverGasDividedByTwo // ct = 3 + limitMinusLeftOverGasDividedByTwo, // ct = 3 + Bytes16.ZERO // ct = 4 ); 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 + bigIntegerToBytes(block.getBaseFee().orElseThrow().getAsBigInteger())), // ct = 5 Bytes16.leftPad( bigIntegerToBytes( - tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger())), // ct = 5 + tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger())), // ct = 6 Bytes16.leftPad( bigIntegerToBytes( block @@ -315,10 +318,7 @@ private List setWcpArgumentTwo(BlockSnapshot block, TransactionSnapshot .orElseThrow() .getAsBigInteger() .add( - tx.maxPriorityFeePerGas() - .orElseThrow() - .getAsBigInteger()))), // ct = 6 - Bytes16.ZERO // ct = 7 + tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger()))) // ct = 7 ); default -> throw new IllegalStateException("transaction type not supported:" + tx.type()); }; @@ -333,8 +333,9 @@ private List setWcpRes(BlockSnapshot block, TransactionSnapshot tx) { false, // ct = 2 tx.getLimitMinusLeftoverGasDividedByTwo().compareTo(BigInteger.valueOf(tx.refundCounter())) >= 0, // ct = 3, - false, // ct = 4 + tx.callDataSize() == 0, // ct = 4 false, // ct = 5 + false, // ct = 6 tx.type() == TransactionType.EIP1559 && tx.maxFeePerGas() .orElseThrow() @@ -345,8 +346,7 @@ private List setWcpRes(BlockSnapshot block, TransactionSnapshot tx) { .orElseThrow() .getAsBigInteger() .add(tx.maxPriorityFeePerGas().orElseThrow().getAsBigInteger())) - < 0, // ct = 6, - false // ct = 7 + < 0 // ct = 7, ); } @@ -454,6 +454,7 @@ private void traceTx( final List phaseNumbers = setPhaseRlpTxnNumbers(tx); final List phaseRlpTxnRcpt = setPhaseRlpTxnRcpt(); final List outgoingRlpTxnRcpt = setOutgoingRlpTxnRcpt(tx); + final boolean copyTxCd = tx.requiresEvmExecution() && tx.callDataSize() != 0; for (int ct = 0; ct < tx.maxCounter(); ct++) { trace .absTxNumMax(Bytes.ofUnsignedInt(absTxNumMax)) @@ -477,12 +478,13 @@ private void traceTx( .basefee(block.getBaseFee().orElseThrow()) .coinbaseHi(coinbase.hi()) .coinbaseLo(coinbase.lo()) - .callDataSize(tx.isDeployment() ? Bytes.EMPTY : Bytes.ofUnsignedInt(tx.payload().size())) + .callDataSize(Bytes.ofUnsignedShort(tx.callDataSize())) .initCodeSize(tx.isDeployment() ? Bytes.ofUnsignedInt(tx.payload().size()) : Bytes.EMPTY) .type0(tx.type() == TransactionType.FRONTIER) .type1(tx.type() == TransactionType.ACCESS_LIST) .type2(tx.type() == TransactionType.EIP1559) .requiresEvmExecution(tx.requiresEvmExecution()) + .copyTxcdAtInitialisation(copyTxCd) .leftoverGas(Bytes.ofUnsignedLong(tx.leftoverGas())) .refundCounter(Bytes.ofUnsignedLong(tx.refundCounter())) .refundAmount(Bytes.ofUnsignedLong(tx.effectiveGasRefund())) diff --git a/zkevm-constraints b/zkevm-constraints index 435746956a..54be331ff8 160000 --- a/zkevm-constraints +++ b/zkevm-constraints @@ -1 +1 @@ -Subproject commit 435746956ad2ec91a50702613fb9261af8c43274 +Subproject commit 54be331ff882673df42bf928dc86415c0b6a471b