diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java index a1b8330ed..8bfffef4a 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/AccountSnapshot.java @@ -234,15 +234,13 @@ public AccountSnapshot setWarmthTo(boolean newWarmth) { return this; } - /** - * Raises the nonce by 1. WARNING: this modifies the underlying {@link AccountSnapshot}. Be - * sure to work with a {@link AccountSnapshot#deepCopy} if necessary. - * - * @return {@code this} with nonce++ - */ public AccountSnapshot raiseNonceByOne() { - this.nonce(nonce + 1); - return this; + return this.nonce(nonce + 1); + } + + public AccountSnapshot decrementNonceByOne() { + checkState(nonce > 0); + return this.nonce(nonce - 1); } public AccountSnapshot setDeploymentNumber(Hub hub) { @@ -250,8 +248,12 @@ public AccountSnapshot setDeploymentNumber(Hub hub) { } public AccountSnapshot setDeploymentNumber(DeploymentInfo deploymentInfo) { - this.deploymentNumber(deploymentInfo.deploymentNumber(address)); - return this; + return this.deploymentNumber(deploymentInfo.deploymentNumber(address)); + } + + public AccountSnapshot decrementDeploymentNumberByOne() { + checkState(deploymentNumber > 0); + return this.deploymentNumber(deploymentNumber - 1); } public AccountSnapshot setDeploymentInfo(Hub hub) { diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TxSkipSection.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TxSkipSection.java index ae27c4aaf..a2707dc66 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TxSkipSection.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/section/TxSkipSection.java @@ -112,14 +112,14 @@ public void resolveAtEndTransaction( // may have to be modified in case of address collision senderNew = canonical(hub, world, sender.address(), isPrecompile(sender.address())); recipientNew = canonical(hub, world, recipient.address(), isPrecompile(recipient.address())); - coinbaseNew = canonical(hub, world, coinbase.address(), isPrecompile(recipient.address())); + coinbaseNew = canonical(hub, world, coinbase.address(), isPrecompile(coinbase.address())); final Wei value = (Wei) txMetadata.getBesuTransaction().getValue(); if (senderAddressCollision()) { - BigInteger gasUsed = BigInteger.valueOf(txMetadata.getGasUsed()); - BigInteger gasPrice = BigInteger.valueOf(txMetadata.getEffectiveGasPrice()); - BigInteger gasCost = gasUsed.multiply(gasPrice); + final BigInteger gasUsed = BigInteger.valueOf(txMetadata.getGasUsed()); + final BigInteger gasPrice = BigInteger.valueOf(txMetadata.getEffectiveGasPrice()); + final BigInteger gasCost = gasUsed.multiply(gasPrice); senderNew = sender .deepCopy() @@ -135,6 +135,9 @@ public void resolveAtEndTransaction( if (recipientIsCoinbase()) { recipientNew = coinbaseNew.deepCopy().decrementBalanceBy(txMetadata.getCoinbaseReward()); recipient = recipientNew.deepCopy().decrementBalanceBy(value); + if (txMetadata.isDeployment()){ + recipient.decrementNonceByOne().decrementDeploymentNumberByOne(); + } } }