Skip to content

Commit

Permalink
feat: update to delivery-25.1-develop-1be83c5 (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavePearce authored Jan 15, 2025
1 parent 291b7b6 commit 4483ce5
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void tracePreExecution(MessageFrame frame) {
// Sanity check block within last 256 blocks.
if (blockNumber < currentBlockNumber && (currentBlockNumber - blockNumber) <= 256) {
// Use enclosing frame to determine hash
Hash blockHash = frame.getBlockHashLookup().apply(blockNumber);
Hash blockHash = frame.getBlockHashLookup().apply(frame, blockNumber);
// Record it was seen
this.reaper.touchBlockHash(blockNumber, blockHash);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.util.Map;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.operation.BlockHashOperation.BlockHashLookup;
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
import org.hyperledger.besu.evm.frame.MessageFrame;

/**
* Contain the minimal set of information to replay a conflation as a unit test without requiring
Expand Down Expand Up @@ -64,7 +65,7 @@ private static class BlockHashMap implements BlockHashLookup {
private final Map<Long, Hash> blockHashCache = new HashMap<>();

@Override
public Hash apply(Long blockNumber) {
public Hash apply(MessageFrame frame, Long blockNumber) {
// Sanity check we found the hash
if (!this.blockHashCache.containsKey(blockNumber)) {
// Missing for some reason
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ public void traceEndConflation(WorldView state) {
this.tracers.forEach(tracer -> tracer.traceEndConflation(state));
}

public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
this.tracers.forEach(tracer -> tracer.traceStartBlock(blockHeader, blockBody));
}

public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
this.tracers.forEach(tracer -> tracer.traceStartBlock(processableBlockHeader));
public void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
this.tracers.forEach(
tracer -> tracer.traceStartBlock(processableBlockHeader, miningBeneficiary));
}

public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,16 @@ public void traceEndConflation(final WorldView state) {
}

@Override
public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
public void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
try {
this.hub.traceStartBlock(processableBlockHeader);
this.hub.traceStartBlock(processableBlockHeader, miningBeneficiary);
this.debugMode.ifPresent(DebugMode::traceEndConflation);
} catch (final Exception e) {
this.tracingExceptions.add(e);
}
}

@Override
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
try {
this.hub.traceStartBlock(blockHeader);
this.debugMode.ifPresent(x -> x.traceStartBlock(blockHeader, blockBody));
} catch (final Exception e) {
this.tracingExceptions.add(e);
}
}

@Override
public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import net.consensys.linea.zktracer.ColumnHeader;
import net.consensys.linea.zktracer.types.TransactionProcessingMetadata;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.worldstate.WorldView;
import org.hyperledger.besu.plugin.data.BlockBody;
Expand All @@ -33,7 +34,8 @@ default void traceStartConflation(final long blockCount) {}

default void traceEndConflation(final WorldView state) {}

default void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {}
default void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {}

default void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.consensys.linea.zktracer.module.wcp.Wcp;
import net.consensys.linea.zktracer.opcode.OpCode;
import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.operation.Operation;
import org.hyperledger.besu.evm.worldstate.WorldView;
Expand Down Expand Up @@ -67,7 +68,8 @@ public String moduleKey() {
}

@Override
public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
public void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
relBlock += 1;
absBlock = processableBlockHeader.getNumber();
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,14 @@ public void traceEndConflation(final WorldView world) {
}

@Override
public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
public void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
this.coinbaseAddress = miningBeneficiary;
state.firstAndLastStorageSlotOccurrences.add(new HashMap<>());
this.transients().block().update(processableBlockHeader);
this.transients().block().update(processableBlockHeader, miningBeneficiary);
txStack.resetBlock();
for (Module m : modules) {
m.traceStartBlock(processableBlockHeader);
m.traceStartBlock(processableBlockHeader, miningBeneficiary);
}
}

Expand All @@ -499,7 +501,6 @@ public void traceStartTransaction(final WorldView world, final Transaction tx) {

if (!transactionProcessingMetadata.requiresEvmExecution()) {
state.setProcessingPhase(TX_SKIP);
Address coinbaseAddress = Address.fromHexString("8f81e2e3f8b46467523463835f965ffe476e1c9e");
new TxSkipSection(this, world, transactionProcessingMetadata, transients);
} else {
if (transactionProcessingMetadata.requiresPrewarming()) {
Expand Down Expand Up @@ -552,7 +553,6 @@ public void traceContextEnter(MessageFrame frame) {

// root and transaction call data context's
if (frame.getDepth() == 0) {
coinbaseAddress = frame.getMiningBeneficiary();
if (state.getProcessingPhase() == TX_SKIP) {
checkState(currentTraceSection() instanceof TxSkipSection);
((TxSkipSection) currentTraceSection()).coinbaseSnapshots(this, frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public class Block {
*
* @param processableBlockHeader the processable block header
*/
public void update(final ProcessableBlockHeader processableBlockHeader) {
public void update(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
this.blockNumber++;
this.coinbaseAddress = processableBlockHeader.getCoinbase();
this.coinbaseAddress = miningBeneficiary;
this.baseFee = Wei.fromQuantity(processableBlockHeader.getBaseFee().orElseThrow());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.consensys.linea.zktracer.module.hub.Hub;
import net.consensys.linea.zktracer.module.wcp.Wcp;
import net.consensys.linea.zktracer.types.TransactionProcessingMetadata;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.plugin.data.BlockBody;
import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.data.ProcessableBlockHeader;
Expand Down Expand Up @@ -57,7 +58,8 @@ public void traceStartConflation(final long blockCount) {
}

@Override
public final void traceStartBlock(final ProcessableBlockHeader blockHeader) {
public final void traceStartBlock(
final ProcessableBlockHeader blockHeader, final Address miningBeneficiary) {
blocks.add(new BlockSnapshot(blockHeader));
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
releaseVersion=0.8.0-rc8
besuVersion=24.12-delivery41
besuVersion=25.1-delivery42
besuArtifactGroup=io.consensys.linea-besu
distributionIdentifier=linea-tracer
distributionBaseUrl=https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/
Expand Down
2 changes: 2 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This file is generated by updateDaemonJvm
toolchainVersion=21
2 changes: 1 addition & 1 deletion linea-constraints
Submodule linea-constraints updated 1 files
+471 −0 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static void executeTest(final BlockchainReferenceTestCaseSpec spec) {
try {
final Block block = candidateBlock.getBlock();

zkTracer.traceStartBlock(block.getHeader());
zkTracer.traceStartBlock(block.getHeader(), block.getHeader().getCoinbase());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.evm.operation.BlockHashOperation;
import org.hyperledger.besu.ethereum.vm.BlockchainBasedBlockHashLookup;
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

@Slf4j
Expand Down Expand Up @@ -96,8 +96,8 @@ public BlockProcessingResult processBlock(

final WorldUpdater worldStateUpdater = worldState.updater();

final BlockHashOperation.BlockHashLookup blockHashLookup =
new CachingBlockHashLookup(blockHeader, blockchain);
final BlockHashLookup blockHashLookup =
new BlockchainBasedBlockHashLookup(blockHeader, blockchain);
final Address miningBeneficiary =
miningBeneficiaryCalculator.calculateBeneficiary(blockHeader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.ethereum.vm.BlockchainBasedBlockHashLookup;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
Expand Down Expand Up @@ -178,7 +178,7 @@ public static void executeTest(final GeneralStateTestCaseEipSpec spec) {

final ZkTracer zkTracer = new ZkTracer();
zkTracer.traceStartConflation(1);
zkTracer.traceStartBlock(blockHeader, blockBody);
zkTracer.traceStartBlock(blockHeader, blockHeader.getCoinbase());

final TransactionProcessingResult result =
processor.processTransaction(
Expand All @@ -187,7 +187,7 @@ public static void executeTest(final GeneralStateTestCaseEipSpec spec) {
transaction,
blockHeader.getCoinbase(),
zkTracer,
new CachingBlockHashLookup(blockHeader, blockchain),
new BlockchainBasedBlockHashLookup(blockHeader, blockchain),
false,
TransactionValidationParams.processingBlock(),
blobGasPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import net.consensys.linea.corset.CorsetValidator;
import net.consensys.linea.zktracer.ZkTracer;
import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.clique.CliqueBlockHeaderFunctions;
import org.hyperledger.besu.consensus.clique.CliqueForksSchedulesFactory;
Expand Down Expand Up @@ -57,14 +57,15 @@
public class ExecutionEnvironment {
public static final String CORSET_VALIDATION_RESULT = "Corset validation result: ";

static GenesisConfigFile GENESIS_CONFIG =
GenesisConfigFile.fromSource(GenesisConfigFile.class.getResource("/linea.json"));
static GenesisConfig GENESIS_CONFIG =
GenesisConfig.fromSource(GenesisConfig.class.getResource("/linea.json"));

static final BlockHeaderBuilder DEFAULT_BLOCK_HEADER_BUILDER =
BlockHeaderBuilder.createDefault()
.number(ToyExecutionEnvironmentV2.DEFAULT_BLOCK_NUMBER)
.timestamp(123456789)
.parentHash(Hash.EMPTY_TRIE_HASH)
.baseFee(ToyExecutionEnvironmentV2.DEFAULT_BASE_FEE)
.nonce(0)
.blockHeaderFunctions(new CliqueBlockHeaderFunctions());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.ethereum.vm.BlockchainBasedBlockHashLookup;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
Expand Down Expand Up @@ -93,7 +93,7 @@ public static void executeTest(
.blobGasPricePerGas(blockHeader.getExcessBlobGas().orElse(BlobGas.ZERO));

tracer.traceStartConflation(1);
tracer.traceStartBlock(blockHeader, blockBody);
tracer.traceStartBlock(blockHeader, blockHeader.getCoinbase());
TransactionProcessingResult result = null;
for (Transaction transaction : blockBody.getTransactions()) {
// Several of the GeneralStateTests check if the transaction could potentially
Expand All @@ -111,7 +111,7 @@ public static void executeTest(
transaction,
blockHeader.getCoinbase(),
tracer,
new CachingBlockHashLookup(blockHeader, blockchain),
new BlockchainBasedBlockHashLookup(blockHeader, blockchain),
false,
TransactionValidationParams.processingBlock(),
blobGasPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.internal.Words;
import org.hyperledger.besu.evm.operation.BlockHashOperation;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

Expand Down Expand Up @@ -187,7 +187,7 @@ private static void executeFrom(
final boolean txResultChecking,
final boolean useCoinbaseAddressFromBlockHeader,
final TransactionProcessingResultValidator resultValidator) {
BlockHashOperation.BlockHashLookup blockHashLookup = conflation.toBlockHashLookup();
BlockHashLookup blockHashLookup = conflation.toBlockHashLookup();
// Initialise world state from conflation
MutableWorldState world = initWorld(conflation);
// Construct the transaction processor
Expand All @@ -203,7 +203,11 @@ private static void executeFrom(
new BlockBody(
blockSnapshot.txs().stream().map(TransactionSnapshot::toTransaction).toList(),
new ArrayList<>());
tracer.traceStartBlock(header, body);
final Address miningBeneficiary =
useCoinbaseAddressFromBlockHeader
? header.getCoinbase()
: CliqueHelpers.getProposerOfBlock(header);
tracer.traceStartBlock(header, miningBeneficiary);

for (TransactionSnapshot txs : blockSnapshot.txs()) {
final Transaction tx = txs.toTransaction();
Expand All @@ -214,9 +218,7 @@ private static void executeFrom(
updater,
header,
tx,
useCoinbaseAddressFromBlockHeader
? header.getCoinbase()
: CliqueHelpers.getProposerOfBlock(header),
miningBeneficiary,
buildOperationTracer(tx, txs.getOutcome(), tracer, txResultChecking),
blockHashLookup,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class ToyExecutionEnvironmentV2 {

@Builder.Default private final List<ToyAccount> accounts = Collections.emptyList();
@Builder.Default private final Address coinbase = DEFAULT_COINBASE_ADDRESS;
@Builder.Default public static final Wei DEFAULT_BASE_FEE = Wei.of(7);

@Singular private final List<Transaction> transactions;

Expand Down Expand Up @@ -98,6 +99,7 @@ public GeneralStateTestCaseEipSpec buildGeneralStateTestCaseSpec(ProtocolSpec pr
.coinbase(coinbase)
.timestamp(DEFAULT_TIME_STAMP)
.parentHash(DEFAULT_HASH)
.baseFee(DEFAULT_BASE_FEE)
.buildBlockHeader();

List<Supplier<Transaction>> txSuppliers = new ArrayList<>();
Expand Down

0 comments on commit 4483ce5

Please sign in to comment.