Skip to content

Commit 9b0e56a

Browse files
set finalization section only onbce
Signed-off-by: F Bojarski <[email protected]>
1 parent b28fff1 commit 9b0e56a

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/Hub.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,12 @@ public void traceContextExit(MessageFrame frame) {
645645
txStack
646646
.current()
647647
.setPreFinalisationValues(
648-
leftOverGas, gasRefund, txStack.getAccumulativeGasUsedInBlockBeforeTxStart());
648+
leftOverGas,
649+
gasRefund,
650+
txStack.getAccumulativeGasUsedInBlockBeforeTxStart(),
651+
coinbaseWarmthAtTxEnd());
649652

650-
if (state.processingPhase() != TX_SKIP
651-
&& frame.getState() == MessageFrame.State.COMPLETED_SUCCESS) {
653+
if (state.processingPhase() != TX_SKIP) {
652654
state.processingPhase(TX_FINL);
653655
new TxFinalizationSection(this);
654656
}
@@ -712,15 +714,6 @@ public void tracePostExecution(MessageFrame frame, Operation.OperationResult ope
712714
if (isExceptional() || !opCode().isCallOrCreate()) {
713715
this.unlatchStack(frame, currentSection);
714716
}
715-
716-
if (frame.getDepth() == 0 && (isExceptional() || opCode().isHalt())) {
717-
state.processingPhase(TX_FINL);
718-
setCoinbaseWarmthAtTxEnd();
719-
}
720-
721-
if (frame.getDepth() == 0 && (isExceptional() || opCode() == REVERT)) {
722-
new TxFinalizationSection(this);
723-
}
724717
}
725718

726719
public boolean isUnexceptional() {
@@ -1066,7 +1059,11 @@ protected TxnData setTxnData() {
10661059
throw new IllegalStateException("must be implemented");
10671060
}
10681061

1069-
protected void setInitializationSection(WorldView world) {}
1062+
protected void setInitializationSection(WorldView world) {
1063+
throw new IllegalStateException("must be implemented");
1064+
}
10701065

1071-
protected void setCoinbaseWarmthAtTxEnd() {}
1066+
protected boolean coinbaseWarmthAtTxEnd() {
1067+
throw new IllegalStateException("must be implemented");
1068+
}
10721069
}

arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/LondonHub.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ protected void setInitializationSection(WorldView world) {
4747
}
4848

4949
@Override
50-
protected void setCoinbaseWarmthAtTxEnd() {
51-
final boolean coinbaseWarmthAtTransactionEnd =
52-
isExceptional() || opCode() == REVERT
53-
? txStack.current().isCoinbasePreWarmed()
54-
: isAddressWarm(messageFrame(), coinbaseAddress());
55-
this.txStack.current().coinbaseWarmAtTransactionEnd(coinbaseWarmthAtTransactionEnd);
50+
protected boolean coinbaseWarmthAtTxEnd() {
51+
return isExceptional() || opCode() == REVERT
52+
? txStack.current().isCoinbasePreWarmed()
53+
: isAddressWarm(messageFrame(), coinbaseAddress());
5654
}
5755
}

arithmetization/src/main/java/net/consensys/linea/zktracer/module/hub/ShanghaiHub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ protected void setInitializationSection(WorldView world) {
4444
}
4545

4646
@Override
47-
protected void setCoinbaseWarmthAtTxEnd() {
47+
protected boolean coinbaseWarmthAtTxEnd() {
4848
// since EIP-3651 (Shanghai), the coinbase address is warm at the beginning of the transaction,
4949
// so obviously at the end.
50-
this.txStack.current().coinbaseWarmAtTransactionEnd(true);
50+
return true;
5151
}
5252
}

arithmetization/src/main/java/net/consensys/linea/zktracer/types/TransactionProcessingMetadata.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public TransactionProcessingMetadata(
164164
public void setPreFinalisationValues(
165165
final long leftOverGas,
166166
final long refundCounterMax,
167-
final long accumulatedGasUsedInBlockAtStartTx) {
167+
final long accumulatedGasUsedInBlockAtStartTx,
168+
final boolean coinbaseWarmAtTransactionEnd) {
168169

169170
this.refundCounterMax = refundCounterMax;
170171
setLeftoverGas(leftOverGas);
@@ -173,6 +174,7 @@ public void setPreFinalisationValues(
173174
gasRefunded = computeRefunded();
174175
totalGasUsed = computeTotalGasUsed();
175176
accumulatedGasUsedInBlock = accumulatedGasUsedInBlockAtStartTx + totalGasUsed;
177+
this.coinbaseWarmAtTransactionEnd = coinbaseWarmAtTransactionEnd;
176178
}
177179

178180
public void completeLineaTransaction(

0 commit comments

Comments
 (0)