Skip to content

Commit

Permalink
fix: get the right warmth of the COINBASE address at TX_FINL
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB committed Feb 4, 2025
1 parent 7640374 commit 37dbe7b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ public void tracePostExecution(MessageFrame frame, Operation.OperationResult ope

if (frame.getDepth() == 0 && (isExceptional() || opCode().isHalt())) {
this.state.setProcessingPhase(TX_FINL);
coinbaseWarmthAtTransactionEnd = frame.isAddressWarm(coinbaseAddress);
coinbaseWarmthAtTransactionEnd =
isExceptional() || opCode() == REVERT
? txStack.current().coinbaseWarmthAfterTxInit(this)
: frame.isAddressWarm(coinbaseAddress);
}

if (frame.getDepth() == 0 && (isExceptional() || opCode() == REVERT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.google.common.base.Preconditions.checkState;
import static net.consensys.linea.zktracer.module.hub.HubProcessingPhase.TX_EXEC;
import static net.consensys.linea.zktracer.types.AddressUtils.isPrecompile;

import lombok.Getter;
import net.consensys.linea.zktracer.module.hub.AccountSnapshot;
Expand Down Expand Up @@ -79,8 +80,6 @@ public TxInitializationSection(Hub hub, WorldView world) {
final Account senderAccount = world.get(senderAddress);
final DeploymentInfo deploymentInfo = hub.transients().conflation().deploymentInfo();

Address failureAddress = Address.fromHexString("0x6295ee1b4f6dd65047762f924ecd367c17eabf8f");

final boolean isDeployment = tx.isDeployment();
final Wei transactionGasPrice = Wei.of(tx.getEffectiveGasPrice());
final Wei gasCost = transactionGasPrice.multiply(tx.getBesuTransaction().getGasLimit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static net.consensys.linea.zktracer.module.constants.GlobalConstants.*;
import static net.consensys.linea.zktracer.types.AddressUtils.effectiveToAddress;
import static net.consensys.linea.zktracer.types.AddressUtils.isPrecompile;

import java.math.BigInteger;
import java.util.HashMap;
Expand Down Expand Up @@ -175,7 +176,11 @@ public void setPreFinalisationValues(
}

public void completeLineaTransaction(
Hub hub, WorldView world, final boolean statusCode, final List<Log> logs, final Set<Address> selfDestructs) {
Hub hub,
WorldView world,
final boolean statusCode,
final List<Log> logs,
final Set<Address> selfDestructs) {
this.statusCode = statusCode;
hubStampTransactionEnd = hub.stamp();
this.logs = logs;
Expand Down Expand Up @@ -326,4 +331,23 @@ public void captureUpdatedInitialRecipientAddressDeploymentInfoAtTransactionStar
public Bytes getTransactionCallData() {
return besuTransaction.getData().orElse(Bytes.EMPTY);
}

public boolean coinbaseWarmthAfterTxInit(Hub hub) {
final Address coinbaseAddress = hub.coinbaseAddress;
final boolean coinbaseIsInAccessList =
this.getBesuTransaction()
.getAccessList()
.map(
accessList ->
accessList.stream().anyMatch(entry -> entry.address().equals(coinbaseAddress)))
.orElse(false);
final boolean coinbaseIsPrecompile = isPrecompile(coinbaseAddress);
final boolean coinbaseIsSender = this.getSender().equals(coinbaseAddress);
final boolean coinbaseIsRecipient = this.getEffectiveRecipient().equals(coinbaseAddress);

return coinbaseIsInAccessList
|| coinbaseIsPrecompile
|| coinbaseIsSender
|| coinbaseIsRecipient;
}
}

0 comments on commit 37dbe7b

Please sign in to comment.