Skip to content

Commit

Permalink
Use coinbase address from block header for multi block tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravahuja committed Oct 3, 2024
1 parent d9e42ed commit 1914bba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.testing;
package net.consensys.linea.zktracer;

import java.util.List;

import net.consensys.linea.testing.BytecodeCompiler;
import net.consensys.linea.testing.MultiBlockExecutionEnvironment;
import net.consensys.linea.testing.ToyAccount;
import net.consensys.linea.testing.ToyTransaction;
import net.consensys.linea.zktracer.opcode.OpCode;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.crypto.KeyPair;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.testing;
package net.consensys.linea.zktracer;

import java.util.List;

import net.consensys.linea.testing.BytecodeCompiler;
import net.consensys.linea.testing.ToyAccount;
import net.consensys.linea.testing.ToyExecutionEnvironmentV2;
import net.consensys.linea.testing.ToyTransaction;
import net.consensys.linea.zktracer.opcode.OpCode;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SECP256K1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public MultiBlockExecutionEnvironmentBuilder addBlock(List<Transaction> transact

public void run() {
ReplayExecutionEnvironment.builder()
.useCoinbaseAddressFromBlockHeader(true)
.build()
.replay(ToyExecutionEnvironmentV2.CHAIN_ID, this.buildConflationSnapshot());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public class ReplayExecutionEnvironment {
*/
private final boolean txResultChecking;

@Builder.Default
private final boolean useCoinbaseAddressFromBlockHeader = false;

private final ZkTracer zkTracer = new ZkTracer();

public void checkTracer(String inputFilePath) {
Expand Down Expand Up @@ -155,18 +158,22 @@ private void executeFrom(final BigInteger chainId, final ConflationSnapshot conf
tracer = ConflationAwareOperationTracer.sequence(tracer, capturer);
}
// Execute the conflation
executeFrom(chainId, conflation, tracer, this.txResultChecking);
executeFrom(chainId, conflation, tracer, this.txResultChecking, this.useCoinbaseAddressFromBlockHeader);
//
if (debugBlockCapturer) {
writeCaptureToFile(conflation, capturer);
}
}



private static void executeFrom(
final BigInteger chainId,
final ConflationSnapshot conflation,
final ConflationAwareOperationTracer tracer,
final boolean txResultChecking) {
final boolean txResultChecking,
final boolean useCoinbaseAddressFromBlockHeader
) {
BlockHashOperation.BlockHashLookup blockHashLookup = conflation.toBlockHashLookup();
// Initialise world state from conflation
MutableWorldState world = initWorld(conflation);
Expand Down Expand Up @@ -194,7 +201,7 @@ private static void executeFrom(
updater,
header,
tx,
CliqueHelpers.getProposerOfBlock(header),
useCoinbaseAddressFromBlockHeader ? header.getCoinbase() : CliqueHelpers.getProposerOfBlock(header),
buildOperationTracer(tx, txs.getOutcome(), tracer, txResultChecking),
blockHashLookup,
false,
Expand Down

0 comments on commit 1914bba

Please sign in to comment.