Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: some more skip tests #1734

Open
wants to merge 4 commits into
base: arith-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bug


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()){
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bug fix

recipient.decrementNonceByOne().decrementDeploymentNumberByOne();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package net.consensys.linea.zktracer.module.hub;

import static net.consensys.linea.testing.ToyExecutionEnvironmentV2.DEFAULT_COINBASE_ADDRESS;
import static net.consensys.linea.zktracer.types.AddressUtils.getCreateRawAddress;

import java.util.List;

Expand Down Expand Up @@ -320,4 +321,114 @@ void senderIsCoinbaseIsReceiver() {
.build()
.run();
}

@Test
void skipMessageCallCoinbaseIsPrecompile(){
final KeyPair senderKeyPair = new SECP256K1().generateKeyPair();
final Address senderAddress =
Address.extract(Hash.hash(senderKeyPair.getPublicKey().getEncodedBytes()));
final ToyAccount senderAccount =
ToyAccount.builder().balance(Wei.fromEth(0xffff)).nonce(128).address(senderAddress).build();

final Address receiverAddress = Address.fromHexString("0xffffffffffffffffffffffffffffffffffffff");

final ToyAccount receiverAccount =
ToyAccount.builder().balance(Wei.fromEth(0xffffee)).nonce(18).address(receiverAddress).build();

final Transaction tx =
ToyTransaction.builder()
.sender(senderAccount)
.to(receiverAccount)
.keyPair(senderKeyPair)
.value(Wei.of(123))
.build();

ToyExecutionEnvironmentV2.builder()
.accounts(List.of(senderAccount, receiverAccount))
.transaction(tx)
.zkTracerValidator(zkTracer -> {})
.coinbase(Address.BLAKE2B_F_COMPRESSION)
.build()
.run();
}

@Test
void skippedDepSenderIsCoinbase(){
final KeyPair senderKeyPair = new SECP256K1().generateKeyPair();
final Address senderAddress =
Address.extract(Hash.hash(senderKeyPair.getPublicKey().getEncodedBytes()));
final ToyAccount senderAccount =
ToyAccount.builder().balance(Wei.fromEth(0xffff)).nonce(128).address(senderAddress).build();

final Transaction tx =
ToyTransaction.builder()
.sender(senderAccount)
.keyPair(senderKeyPair)
.value(Wei.of(123))
.gasLimit(100000L)
.build();

ToyExecutionEnvironmentV2.builder()
.accounts(List.of(senderAccount))
.transaction(tx)
.zkTracerValidator(zkTracer -> {})
.coinbase(senderAddress)
.build()
.run();
}

@Test
void skippedDepDeploymentAddressIsCoinbase(){
final KeyPair senderKeyPair = new SECP256K1().generateKeyPair();
final Address senderAddress =
Address.extract(Hash.hash(senderKeyPair.getPublicKey().getEncodedBytes()));
final int nonce = 632;
final ToyAccount senderAccount =
ToyAccount.builder().balance(Wei.fromEth(0xffff)).nonce(nonce).address(senderAddress).build();

final Address depAddress = Address.extract(getCreateRawAddress(senderAddress, nonce));

final Transaction tx =
ToyTransaction.builder()
.sender(senderAccount)
.keyPair(senderKeyPair)
.value(Wei.of(123))
.gasLimit(100000L)
.nonce((long) nonce)
.build();

ToyExecutionEnvironmentV2.builder()
.accounts(List.of(senderAccount))
.transaction(tx)
.zkTracerValidator(zkTracer -> {})
.coinbase(depAddress)
.build()
.run();

}

@Test
void skippedDepCoinbaseIsPrecompile(){
final KeyPair senderKeyPair = new SECP256K1().generateKeyPair();
final Address senderAddress =
Address.extract(Hash.hash(senderKeyPair.getPublicKey().getEncodedBytes()));
final ToyAccount senderAccount =
ToyAccount.builder().balance(Wei.fromEth(0xffff)).nonce(128).address(senderAddress).build();

final Transaction tx =
ToyTransaction.builder()
.sender(senderAccount)
.keyPair(senderKeyPair)
.value(Wei.of(123))
.gasLimit(100000L)
.build();

ToyExecutionEnvironmentV2.builder()
.accounts(List.of(senderAccount))
.transaction(tx)
.zkTracerValidator(zkTracer -> {})
.coinbase(Address.RIPEMD160)
.build()
.run();
}
}
Loading