Skip to content

Commit

Permalink
Fix ZkTracer commit and rollback of non bundle transactions (#150)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored Feb 19, 2025
1 parent f76a350 commit 61e88ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TransactionTraceLimitOverflowTest extends LineaPluginTestBase {

private static final BigInteger GAS_LIMIT = DefaultGasProvider.GAS_LIMIT;
private static final BigInteger VALUE = BigInteger.ZERO;
private static final BigInteger GAS_PRICE = BigInteger.TEN.pow(9);
private static final BigInteger GAS_PRICE = BigInteger.TEN.pow(11);

@Override
public List<String> getTestCliOptions() {
Expand Down Expand Up @@ -68,7 +68,7 @@ public void transactionOverModuleLineCountRemoved() throws Exception {
GAS_PRICE.multiply(BigInteger.TEN).add(BigInteger.ONE));
final byte[] signedTxContractInteraction =
TransactionEncoder.signMessage(
txModuleLineCountTooBig, Credentials.create(Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY));
txModuleLineCountTooBig, Credentials.create(Accounts.GENESIS_ACCOUNT_ONE_PRIVATE_KEY));
final EthSendTransaction signedTxContractInteractionResp =
web3j.ethSendRawTransaction(Numeric.toHexString(signedTxContractInteraction)).send();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.consensys.linea.jsonrpc.JsonRpcRequestBuilder;
import net.consensys.linea.metrics.HistogramMetrics;
import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedConfiguration;
import net.consensys.linea.rpc.methods.LineaSendBundle;
import net.consensys.linea.rpc.services.BundlePoolService;
import net.consensys.linea.zktracer.ZkTracer;
import org.hyperledger.besu.plugin.data.TransactionProcessingResult;
Expand Down Expand Up @@ -183,6 +184,12 @@ public TransactionSelectionResult evaluateTransactionPostProcessing(
public void onTransactionSelected(
final TransactionEvaluationContext evaluationContext,
final TransactionProcessingResult processingResult) {

// if pending tx is not from a bundle, then we need to commit now
if (!(evaluationContext.getPendingTransaction() instanceof LineaSendBundle.PendingBundleTx)) {
getOperationTracer().commitTransactionBundle();
}

selectors.forEach(
selector -> selector.onTransactionSelected(evaluationContext, processingResult));
}
Expand All @@ -197,6 +204,12 @@ public void onTransactionSelected(
public void onTransactionNotSelected(
final TransactionEvaluationContext evaluationContext,
final TransactionSelectionResult transactionSelectionResult) {

// if pending tx is not from a bundle, then we need to rollback now
if (!(evaluationContext.getPendingTransaction() instanceof LineaSendBundle.PendingBundleTx)) {
getOperationTracer().popTransactionBundle();
}

selectors.forEach(
selector ->
selector.onTransactionNotSelected(evaluationContext, transactionSelectionResult));
Expand Down

0 comments on commit 61e88ee

Please # to comment.