Skip to content

Commit

Permalink
Merge branch 'move-precompile-to-address' of https://github.com/Gabri…
Browse files Browse the repository at this point in the history
…el-Trintinalia/besu into move-precompile-to-address
  • Loading branch information
Gabriel-Trintinalia committed Jan 14, 2025
2 parents cb7ee63 + ea96f93 commit 81e87b1
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 77 deletions.
2 changes: 1 addition & 1 deletion acceptance-tests/tests/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Configuration level="WARN" monitorInterval="30">
<Properties>
<Property name="root.log.level">INFO</Property>
</Properties>
Expand Down
2 changes: 1 addition & 1 deletion besu/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Configuration level="WARN">
<Properties>
<Property name="root.log.level">${env:LOG_LEVEL:-INFO}</Property>
<Property name="root.log.logger">${env:LOGGER:-Console}</Property>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Configuration level="WARN">
<Properties>
<Property name="root.log.level">DEBUG</Property>
</Properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright contributors to Hyperledger Besu.
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -22,6 +22,7 @@
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getRequestsValidator;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator;
import static org.hyperledger.besu.metrics.BesuMetricCategory.BLOCK_PROCESSING;

import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.datatypes.BlobGas;
Expand Down Expand Up @@ -61,6 +62,7 @@
import org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.exception.StorageException;

import java.security.InvalidParameterException;
Expand All @@ -85,17 +87,24 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
private static final BlockHeaderFunctions headerFunctions = new MainnetBlockHeaderFunctions();
private final MergeMiningCoordinator mergeCoordinator;
private final EthPeers ethPeers;
private long lastExecutionTime = 0L;

public AbstractEngineNewPayload(
final Vertx vertx,
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeCoordinator,
final EthPeers ethPeers,
final EngineCallListener engineCallListener) {
final EngineCallListener engineCallListener,
final MetricsSystem metricsSystem) {
super(vertx, protocolSchedule, protocolContext, engineCallListener);
this.mergeCoordinator = mergeCoordinator;
this.ethPeers = ethPeers;
metricsSystem.createLongGauge(
BLOCK_PROCESSING,
"execution_time_head",
"The execution time of the last block (head)",
this::getLastExecutionTime);
}

@Override
Expand Down Expand Up @@ -347,16 +356,16 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
// execute block and return result response
final long startTimeMs = System.currentTimeMillis();
final BlockProcessingResult executionResult = mergeCoordinator.rememberBlock(block);

if (executionResult.isSuccessful()) {
lastExecutionTime = System.currentTimeMillis() - startTimeMs;
logImportedBlockInfo(
block,
blobTransactions.stream()
.map(Transaction::getVersionedHashes)
.flatMap(Optional::stream)
.mapToInt(List::size)
.sum(),
(System.currentTimeMillis() - startTimeMs) / 1000.0,
lastExecutionTime / 1000.0,
executionResult.getNbParallelizedTransations());
return respondWith(reqId, blockParam, newBlockHeader.getHash(), VALID);
} else {
Expand Down Expand Up @@ -629,4 +638,8 @@ private void logImportedBlockInfo(
messageArgs.add(ethPeers.peerCount());
LOG.info(String.format(message.toString(), messageArgs.toArray()));
}

private long getLastExecutionTime() {
return this.lastExecutionTime;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright contributors to Hyperledger Besu.
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -27,6 +27,7 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.util.List;
import java.util.Optional;
Expand All @@ -41,8 +42,16 @@ public EngineNewPayloadV1(
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeCoordinator,
final EthPeers ethPeers,
final EngineCallListener engineCallListener) {
super(vertx, protocolSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener);
final EngineCallListener engineCallListener,
final MetricsSystem metricsSystem) {
super(
vertx,
protocolSchedule,
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener,
metricsSystem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright contributors to Hyperledger Besu.
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -28,6 +28,7 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.util.List;
import java.util.Optional;
Expand All @@ -43,8 +44,16 @@ public EngineNewPayloadV2(
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeCoordinator,
final EthPeers ethPeers,
final EngineCallListener engineCallListener) {
super(vertx, protocolSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener);
final EngineCallListener engineCallListener,
final MetricsSystem metricsSystem) {
super(
vertx,
protocolSchedule,
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener,
metricsSystem);
cancunMilestone = protocolSchedule.milestoneFor(CANCUN);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.util.List;
import java.util.Optional;
Expand All @@ -40,9 +41,16 @@ public EngineNewPayloadV3(
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeCoordinator,
final EthPeers ethPeers,
final EngineCallListener engineCallListener) {
final EngineCallListener engineCallListener,
final MetricsSystem metricsSystem) {
super(
vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener);
vertx,
timestampSchedule,
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener,
metricsSystem);
this.cancunMilestone = timestampSchedule.milestoneFor(CANCUN);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.util.List;
import java.util.Optional;
Expand All @@ -40,9 +41,16 @@ public EngineNewPayloadV4(
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeCoordinator,
final EthPeers ethPeers,
final EngineCallListener engineCallListener) {
final EngineCallListener engineCallListener,
final MetricsSystem metricsSystem) {
super(
vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener);
vertx,
timestampSchedule,
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener,
metricsSystem);
pragueMilestone = timestampSchedule.milestoneFor(PRAGUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.plugin.services.MetricsSystem;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -63,6 +64,7 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final String clientVersion;
private final String commit;
private final TransactionPool transactionPool;
private final MetricsSystem metricsSystem;

ExecutionEngineJsonRpcMethods(
final MiningCoordinator miningCoordinator,
Expand All @@ -72,7 +74,8 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
final Vertx consensusEngineServer,
final String clientVersion,
final String commit,
final TransactionPool transactionPool) {
final TransactionPool transactionPool,
final MetricsSystem metricsSystem) {
this.mergeCoordinator =
Optional.ofNullable(miningCoordinator)
.filter(mc -> mc.isCompatibleWithEngineApi())
Expand All @@ -84,6 +87,7 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.clientVersion = clientVersion;
this.commit = commit;
this.transactionPool = transactionPool;
this.metricsSystem = metricsSystem;
}

@Override
Expand Down Expand Up @@ -117,21 +121,24 @@ protected Map<String, JsonRpcMethod> create() {
protocolContext,
mergeCoordinator.get(),
ethPeers,
engineQosTimer),
engineQosTimer,
metricsSystem),
new EngineNewPayloadV2(
consensusEngineServer,
protocolSchedule,
protocolContext,
mergeCoordinator.get(),
ethPeers,
engineQosTimer),
engineQosTimer,
metricsSystem),
new EngineNewPayloadV3(
consensusEngineServer,
protocolSchedule,
protocolContext,
mergeCoordinator.get(),
ethPeers,
engineQosTimer),
engineQosTimer,
metricsSystem),
new EngineForkchoiceUpdatedV1(
consensusEngineServer,
protocolSchedule,
Expand Down Expand Up @@ -193,7 +200,8 @@ protected Map<String, JsonRpcMethod> create() {
protocolContext,
mergeCoordinator.get(),
ethPeers,
engineQosTimer));
engineQosTimer,
metricsSystem));
}

return mapOf(executionEngineApisSupported);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public Map<String, JsonRpcMethod> methods(
consensusEngineServer,
clientVersion,
commit,
transactionPool),
transactionPool,
metricsSystem),
new EthJsonRpcMethods(
blockchainQueries,
synchronizer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH;

import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -43,7 +44,8 @@ public void before() {
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener);
engineCallListener,
new NoOpMetricsSystem());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -64,7 +65,8 @@ public void before() {
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener);
engineCallListener,
new NoOpMetricsSystem());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.hyperledger.besu.ethereum.mainnet.CancunTargetingGasLimitCalculator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;

import java.math.BigInteger;
import java.util.List;
Expand Down Expand Up @@ -95,7 +96,8 @@ public void before() {
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener);
engineCallListener,
new NoOpMetricsSystem());
lenient().when(protocolSpec.getGasCalculator()).thenReturn(new CancunGasCalculator());
lenient()
.when(protocolSpec.getGasLimitCalculator())
Expand All @@ -120,7 +122,8 @@ public void shouldInvalidVersionedHash_whenShortVersionedHash() {
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener);
engineCallListener,
new NoOpMetricsSystem());
final JsonRpcResponse badParam =
methodV3.response(
new JsonRpcRequestContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator;
import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;

import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -78,7 +79,8 @@ public void before() {
protocolContext,
mergeCoordinator,
ethPeers,
engineCallListener);
engineCallListener,
new NoOpMetricsSystem());
lenient().when(protocolSchedule.hardforkFor(any())).thenReturn(Optional.of(pragueHardfork));
lenient().when(protocolSpec.getGasCalculator()).thenReturn(new PragueGasCalculator());
mockAllowedRequestsValidator();
Expand Down
Loading

0 comments on commit 81e87b1

Please sign in to comment.