Skip to content

Commit

Permalink
fix some address collisions in TX_SKIP section
Browse files Browse the repository at this point in the history
Signed-off-by: F Bojarski <ceciestunepoubelle@protonmail.ch>
  • Loading branch information
letypequividelespoubelles committed Jan 23, 2025
1 parent c362f36 commit 8d60ede
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,26 @@ public AccountSnapshot setWarmthTo(boolean newWarmth) {
return this;
}

/**
* Raises the nonce by 1. <b>WARNING:</b> 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) {
return this.setDeploymentNumber(hub.transients.conflation().deploymentInfo());
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
}
}
}

Expand Down

0 comments on commit 8d60ede

Please sign in to comment.