Skip to content

Commit

Permalink
Merge branch 'main' into verify-artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarla authored Jan 14, 2025
2 parents 33e7456 + b797f2e commit 303ec86
Show file tree
Hide file tree
Showing 107 changed files with 2,664 additions and 1,374 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes
- `--host-whitelist` has been deprecated since 2020 and this option is removed. Use the equivalent `--host-allowlist` instead.
- Changed tracer API to include the mining beneficiary in BlockAwareOperationTracer::traceStartBlock [#8096](https://github.com/hyperledger/besu/pull/8096)

### Upcoming Breaking Changes
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
Expand All @@ -19,7 +20,7 @@
- Retrieve all transaction receipts for a block in one request [#6646](https://github.com/hyperledger/besu/pull/6646)
- Implement EIP-7840: Add blob schedule to config files [#8042](https://github.com/hyperledger/besu/pull/8042)
- Allow gasPrice (legacy) and 1559 gasPrice params to be specified simultaneously for `eth_call`, `eth_createAccessList`, and `eth_estimateGas` [#8059](https://github.com/hyperledger/besu/pull/8059)

- Add support for EIP-7702 transaction in the txpool [#8018](https://github.com/hyperledger/besu/pull/8018) [#7984](https://github.com/hyperledger/besu/pull/7984)

### Bug fixes
- Fix serialization of state overrides when `movePrecompileToAddress` is present [#8204](https://github.com/hyperledger/besu/pull/8024)
Expand Down
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
6 changes: 2 additions & 4 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1816,10 +1816,8 @@ public BesuControllerBuilder setupControllerBuilder() {
if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) {
final DiffBasedSubStorageConfiguration subStorageConfiguration =
getDataStorageConfiguration().getDiffBasedSubStorageConfiguration();
if (subStorageConfiguration.getLimitTrieLogsEnabled()) {
besuControllerBuilder.isParallelTxProcessingEnabled(
subStorageConfiguration.getUnstable().isParallelTxProcessingEnabled());
}
besuControllerBuilder.isParallelTxProcessingEnabled(
subStorageConfiguration.getUnstable().isParallelTxProcessingEnabled());
}
return besuControllerBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.services;

import org.hyperledger.besu.datatypes.AccountOverrideMap;
import org.hyperledger.besu.datatypes.StateOverrideMap;
import org.hyperledger.besu.datatypes.Transaction;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
Expand Down Expand Up @@ -69,16 +69,16 @@ public BlockSimulatorServiceImpl(
* @param blockNumber the block number
* @param transactions the transactions to include in the block
* @param blockOverrides the blockSimulationOverride of the block
* @param accountOverrides state overrides of the block
* @param stateOverrides state overrides of the block
* @return the block context
*/
@Override
public PluginBlockSimulationResult simulate(
final long blockNumber,
final List<? extends Transaction> transactions,
final BlockOverrides blockOverrides,
final AccountOverrideMap accountOverrides) {
return processSimulation(blockNumber, transactions, blockOverrides, accountOverrides, false);
final StateOverrideMap stateOverrides) {
return processSimulation(blockNumber, transactions, blockOverrides, stateOverrides, false);
}

/**
Expand All @@ -88,7 +88,7 @@ public PluginBlockSimulationResult simulate(
* @param blockNumber the block number
* @param transactions the transactions to include in the block
* @param blockOverrides block overrides for the block
* @param accountOverrides state overrides of the block
* @param stateOverrides state overrides of the block
* @return the PluginBlockSimulationResult
*/
@Unstable
Expand All @@ -97,21 +97,21 @@ public PluginBlockSimulationResult simulateAndPersistWorldState(
final long blockNumber,
final List<? extends Transaction> transactions,
final BlockOverrides blockOverrides,
final AccountOverrideMap accountOverrides) {
return processSimulation(blockNumber, transactions, blockOverrides, accountOverrides, true);
final StateOverrideMap stateOverrides) {
return processSimulation(blockNumber, transactions, blockOverrides, stateOverrides, true);
}

private PluginBlockSimulationResult processSimulation(
final long blockNumber,
final List<? extends Transaction> transactions,
final BlockOverrides blockOverrides,
final AccountOverrideMap accountOverrides,
final StateOverrideMap stateOverrides,
final boolean persistWorldState) {
BlockHeader header = getBlockHeader(blockNumber);
List<CallParameter> callParameters =
transactions.stream().map(CallParameter::fromTransaction).toList();
BlockStateCall blockStateCall =
new BlockStateCall(callParameters, blockOverrides, accountOverrides, true);
new BlockStateCall(callParameters, blockOverrides, stateOverrides, true);
try (final MutableWorldState ws = getWorldState(header, persistWorldState)) {
List<BlockSimulationResult> results =
blockSimulator.process(header, List.of(blockStateCall), ws);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
Expand Down Expand Up @@ -152,16 +153,13 @@ public void trace(
.toList();
Tracer.processTracing(
blockchainQueries,
blocks.get(0).getHash(),
blocks.getFirst().getHash(),
traceableState -> {
final WorldUpdater worldStateUpdater = traceableState.updater();
final ChainUpdater chainUpdater = new ChainUpdater(traceableState, worldStateUpdater);
beforeTracing.accept(worldStateUpdater);
final List<TransactionProcessingResult> results = new ArrayList<>();
blocks.forEach(
block -> {
results.addAll(trace(blockchain, block, chainUpdater, tracer));
});
blocks.forEach(block -> results.addAll(trace(blockchain, block, chainUpdater, tracer)));
afterTracing.accept(chainUpdater.getNextUpdater());
return Optional.of(results);
});
Expand Down Expand Up @@ -191,7 +189,9 @@ private List<TransactionProcessingResult> trace(
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(block.getHeader());
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final BlockHeader header = block.getHeader();
tracer.traceStartBlock(block.getHeader(), block.getBody());
final Address miningBeneficiary =
protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(block.getHeader());
tracer.traceStartBlock(block.getHeader(), block.getBody(), miningBeneficiary);

block
.getBody()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.services;

import org.hyperledger.besu.datatypes.AccountOverrideMap;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StateOverrideMap;
import org.hyperledger.besu.datatypes.Transaction;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
Expand Down Expand Up @@ -54,7 +54,7 @@ public void init(final Blockchain blockchain, final TransactionSimulator transac
@Override
public Optional<TransactionSimulationResult> simulate(
final Transaction transaction,
final Optional<AccountOverrideMap> maybeAccountOverrides,
final Optional<StateOverrideMap> maybeStateOverrides,
final Optional<Hash> maybeBlockHash,
final OperationTracer operationTracer,
final boolean isAllowExceedingBalance) {
Expand Down Expand Up @@ -89,7 +89,7 @@ public Optional<TransactionSimulationResult> simulate(
return transactionSimulator
.processOnPending(
callParameter,
maybeAccountOverrides,
maybeStateOverrides,
isAllowExceedingBalance
? TransactionValidationParams.transactionSimulatorAllowExceedingBalance()
: TransactionValidationParams.transactionSimulator(),
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
Expand Up @@ -114,7 +114,9 @@ void shouldRetrieveStateUpdatePostTracingForOneBlock() {

final Block tracedBlock = blockchain.getBlockByNumber(blockNumber).get();

verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
verify(opTracer)
.traceStartBlock(
tracedBlock.getHeader(), tracedBlock.getBody(), tracedBlock.getHeader().getCoinbase());

tracedBlock
.getBody()
Expand Down Expand Up @@ -163,7 +165,11 @@ void shouldRetrieveStateUpdatePostTracingForAllBlocks() {
.map(Optional::get)
.forEach(
tracedBlock -> {
verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
verify(opTracer)
.traceStartBlock(
tracedBlock.getHeader(),
tracedBlock.getBody(),
tracedBlock.getHeader().getCoinbase());
tracedBlock
.getBody()
.getTransactions()
Expand Down Expand Up @@ -312,7 +318,8 @@ public void traceEndTransaction(
}

@Override
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
public void traceStartBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {
if (!traceStartBlockCalled.add(blockHeader.getBlockHash())) {
fail("traceStartBlock already called for block " + blockHeader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void readGenesisFromObjectNode() {
final var configNode = mapper.createObjectNode();
configNode.put("londonBlock", 1);
final var allocNode = mapper.createObjectNode();
allocNode.put(Address.BLS12_G2MUL.toUnprefixedHexString(), generateAllocation(Wei.ONE));
allocNode.put(Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
final var rootNode = mapper.createObjectNode();
rootNode.put("chainId", 12);
rootNode.put(CONFIG_FIELD, configNode);
Expand All @@ -52,15 +52,16 @@ public void readGenesisFromObjectNode() {
assertThat(genesisReader.getRoot().has(ALLOCATION_FIELD)).isFalse();
assertThat(genesisReader.getConfig().get("londonblock").asInt()).isEqualTo(1);
assertThat(genesisReader.streamAllocations())
.containsExactly(new GenesisAccount(Address.BLS12_G2MUL, 0, Wei.ONE, null, Map.of(), null));
.containsExactly(
new GenesisAccount(Address.BLS12_G2MULTIEXP, 0, Wei.ONE, null, Map.of(), null));
}

@Test
public void readGenesisFromObjectDoesNotModifyObjectNodeArg() {
final var configNode = mapper.createObjectNode();
configNode.put("londonBlock", 1);
final var allocNode = mapper.createObjectNode();
allocNode.put(Address.BLS12_G2MUL.toUnprefixedHexString(), generateAllocation(Wei.ONE));
allocNode.put(Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
final var rootNode = mapper.createObjectNode();
rootNode.put("chainId", 12);
rootNode.put(CONFIG_FIELD, configNode);
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
Expand Up @@ -72,29 +72,23 @@ public class Address extends DelegatingBytes {
/** The constant BLS12_G1ADD. */
public static final Address BLS12_G1ADD = Address.precompiled(0xB);

/** The constant BLS12_G1MUL. */
public static final Address BLS12_G1MUL = Address.precompiled(0xC);

/** The constant BLS12_G1MULTIEXP. */
public static final Address BLS12_G1MULTIEXP = Address.precompiled(0xD);
public static final Address BLS12_G1MULTIEXP = Address.precompiled(0xC);

/** The constant BLS12_G2ADD. */
public static final Address BLS12_G2ADD = Address.precompiled(0xE);

/** The constant BLS12_G2MUL. */
public static final Address BLS12_G2MUL = Address.precompiled(0xF);
public static final Address BLS12_G2ADD = Address.precompiled(0xD);

/** The constant BLS12_G2MULTIEXP. */
public static final Address BLS12_G2MULTIEXP = Address.precompiled(0x10);
public static final Address BLS12_G2MULTIEXP = Address.precompiled(0xE);

/** The constant BLS12_PAIRING. */
public static final Address BLS12_PAIRING = Address.precompiled(0x11);
public static final Address BLS12_PAIRING = Address.precompiled(0xF);

/** The constant BLS12_MAP_FP_TO_G1. */
public static final Address BLS12_MAP_FP_TO_G1 = Address.precompiled(0x12);
public static final Address BLS12_MAP_FP_TO_G1 = Address.precompiled(0x10);

/** The constant BLS12_MAP_FP2_TO_G2. */
public static final Address BLS12_MAP_FP2_TO_G2 = Address.precompiled(0x13);
public static final Address BLS12_MAP_FP2_TO_G2 = Address.precompiled(0x11);

/** The constant ZERO. */
public static final Address ZERO = Address.fromHexString("0x0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@

/** Account Override parameter class */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(builder = AccountOverride.Builder.class)
public class AccountOverride {
private static final Logger LOG = LoggerFactory.getLogger(AccountOverride.class);
@JsonDeserialize(builder = StateOverride.Builder.class)
public class StateOverride {
private static final Logger LOG = LoggerFactory.getLogger(StateOverride.class);

private final Optional<Wei> balance;
private final Optional<Long> nonce;
private final Optional<String> code;
private final Optional<Map<String, String>> stateDiff;

private AccountOverride(
private StateOverride(
final Optional<Wei> balance,
final Optional<Long> nonce,
final Optional<String> code,
Expand Down Expand Up @@ -144,8 +144,8 @@ public Builder withStateDiff(final Map<String, String> stateDiff) {
*
* @return account override
*/
public AccountOverride build() {
return new AccountOverride(balance, nonce, code, stateDiff);
public StateOverride build() {
return new StateOverride(balance, nonce, code, stateDiff);
}
}

Expand All @@ -172,11 +172,11 @@ public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
final AccountOverride accountOverride = (AccountOverride) o;
return balance.equals(accountOverride.balance)
&& nonce.equals(accountOverride.nonce)
&& code.equals(accountOverride.code)
&& stateDiff.equals(accountOverride.stateDiff);
final StateOverride stateOverride = (StateOverride) o;
return balance.equals(stateOverride.balance)
&& nonce.equals(stateOverride.nonce)
&& code.equals(stateOverride.code)
&& stateDiff.equals(stateOverride.stateDiff);
}

@Override
Expand All @@ -186,7 +186,7 @@ public int hashCode() {

@Override
public String toString() {
return "AccountOverride{"
return "StateOverride{"
+ "balance="
+ balance
+ ", nonce="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

/** Map of account overrides, indexed by address */
@JsonIgnoreProperties(ignoreUnknown = true)
public class AccountOverrideMap extends HashMap<Address, AccountOverride> {
public class StateOverrideMap extends HashMap<Address, StateOverride> {

/** Default constructor */
public AccountOverrideMap() {}
public StateOverrideMap() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonCallParameterUtil.validateAndGetCallParams;

import org.hyperledger.besu.datatypes.AccountOverrideMap;
import org.hyperledger.besu.datatypes.StateOverrideMap;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
Expand Down Expand Up @@ -76,7 +76,7 @@ protected abstract Object simulate(
protected Object pendingResult(final JsonRpcRequestContext requestContext) {
final JsonCallParameter jsonCallParameter = validateAndGetCallParams(requestContext);
final var validationParams = getTransactionValidationParams(jsonCallParameter);
final var maybeStateOverrides = getAddressAccountOverrideMap(requestContext);
final var maybeStateOverrides = getAddressStateOverrideMap(requestContext);
final var pendingBlockHeader = transactionSimulator.simulatePendingBlockHeader();
final TransactionSimulationFunction simulationFunction =
(cp, op) ->
Expand All @@ -103,7 +103,7 @@ private Object resultByBlockHeader(
final JsonCallParameter jsonCallParameter,
final BlockHeader blockHeader) {
final var validationParams = getTransactionValidationParams(jsonCallParameter);
final var maybeStateOverrides = getAddressAccountOverrideMap(requestContext);
final var maybeStateOverrides = getAddressStateOverrideMap(requestContext);
final TransactionSimulationFunction simulationFunction =
(cp, op) ->
transactionSimulator.process(
Expand Down Expand Up @@ -214,10 +214,10 @@ protected static TransactionValidationParams getTransactionValidationParams(
}

@VisibleForTesting
protected Optional<AccountOverrideMap> getAddressAccountOverrideMap(
protected Optional<StateOverrideMap> getAddressStateOverrideMap(
final JsonRpcRequestContext request) {
try {
return request.getOptionalParameter(2, AccountOverrideMap.class);
return request.getOptionalParameter(2, StateOverrideMap.class);
} catch (JsonRpcParameter.JsonRpcParameterException e) {
throw new InvalidJsonRpcRequestException(
"Invalid account overrides parameter (index 2)", RpcErrorType.INVALID_CALL_PARAMS, e);
Expand Down
Loading

0 comments on commit 303ec86

Please sign in to comment.