Skip to content

Commit

Permalink
Fixing issues related to tracing all blocks in the reference tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Oct 2, 2024
1 parent 3a1bfb0 commit 922b784
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
Expand Down Expand Up @@ -59,6 +60,8 @@ public class ZkTracer implements ConflationAwareOperationTracer {

private static final Map<String, Integer> spillings;

public final BigInteger chainId;

static {
try {
// Load spillings configured in src/main/resources/spillings.toml.
Expand All @@ -79,11 +82,17 @@ public class ZkTracer implements ConflationAwareOperationTracer {
@Getter private final List<Exception> tracingExceptions = new FiniteList<>(50);

public ZkTracer() {
this(LineaL1L2BridgeSharedConfiguration.EMPTY);
this(LineaL1L2BridgeSharedConfiguration.EMPTY, Bytes.fromHexString("c0ffee").toBigInteger());
}

public ZkTracer(BigInteger chainId) {
this(LineaL1L2BridgeSharedConfiguration.EMPTY, chainId);
}

public ZkTracer(final LineaL1L2BridgeSharedConfiguration bridgeConfiguration) {
public ZkTracer(
final LineaL1L2BridgeSharedConfiguration bridgeConfiguration, BigInteger chainId) {
this.hub = new Hub(bridgeConfiguration.contract(), bridgeConfiguration.topic());
this.chainId = chainId;
for (Module m : this.hub.getModulesToCount()) {
if (!spillings.containsKey(m.moduleKey())) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,19 @@ public static void executeTest(final BlockchainReferenceTestCaseSpec spec) {
final MutableBlockchain blockchain = spec.getBlockchain();
final ProtocolContext context = spec.getProtocolContext();

final ZkTracer zkTracer = new ZkTracer(schedule.getChainId().get());
zkTracer.traceStartConflation(spec.getCandidateBlocks().length);

for (var candidateBlock : spec.getCandidateBlocks()) {
if (!candidateBlock.isExecutable()) {
return;
}

final ZkTracer zkTracer = new ZkTracer();

try {
final Block block = candidateBlock.getBlock();

zkTracer.traceStartBlock(block.getHeader());

final ProtocolSpec protocolSpec = schedule.getByBlockHeader(block.getHeader());

final MainnetBlockImporter blockImporter =
Expand All @@ -205,13 +208,18 @@ public static void executeTest(final BlockchainReferenceTestCaseSpec spec) {
importResult.isImported(),
candidateBlock.isValid());
assertThat(importResult.isImported()).isEqualTo(candidateBlock.isValid());

zkTracer.traceEndBlock(block.getHeader(), block.getBody());
} catch (final RLPException e) {
log.info("caugh RLP exception, checking it's invalid {}", candidateBlock.isValid());
log.info("caught RLP exception, checking it's invalid {}", candidateBlock.isValid());
assertThat(candidateBlock.isValid()).isFalse();
}
ExecutionEnvironment.checkTracer(zkTracer, CORSET_VALIDATOR, Optional.of(log));
}

zkTracer.traceEndConflation(worldState);

ExecutionEnvironment.checkTracer(zkTracer, CORSET_VALIDATOR, Optional.of(log));

assertThat(blockchain.getChainHeadHash()).isEqualTo(spec.getLastBlockHash());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public BlockProcessingResult processBlock(
calculateExcessBlobGasForParent(protocolSpec, parentHeader)))
.orElse(Wei.ZERO);

zkTracer.traceStartConflation(1);
zkTracer.traceStartBlock(blockHeader, blockBody);
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
worldStateUpdater,
Expand Down

0 comments on commit 922b784

Please # to comment.