Skip to content

Commit

Permalink
Merge branch 'main' into 7582-avoid-unnecessary-rlp-encoding-during-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Matilda-Clerke authored Jan 29, 2025
2 parents 03ee34a + 4b8d935 commit 772b40f
Show file tree
Hide file tree
Showing 184 changed files with 2,342 additions and 991 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/verify_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_artifact_paths(version):
# besu/internal/config
f"{artifacts_base_path}/internal/config/{version}/config-{version}.module",
f"{artifacts_base_path}/internal/config/{version}/config-{version}.pom",
f"{artifacts_base_path}/internal/config/{version}/config-{version}.jar"
f"{artifacts_base_path}/internal/config/{version}/config-{version}.jar",
# bom
f"{artifacts_base_path}/bom/{version}/bom-{version}.module",
f"{artifacts_base_path}/bom/{version}/bom-{version}.pom",
Expand All @@ -42,11 +42,11 @@ def check_url(url):

def main():
parser = argparse.ArgumentParser(description='Check besu artifacts')
parser.add_argument('--besu_{version}', action="store", dest='besu_{version}', default="")
parser.add_argument('--besu_version', action="store", dest='besu_version', default="")
args = parser.parse_args()
print(args.besu_{version})
print(args.besu_version)

artifacts = create_artifact_paths(args.besu_{version})
artifacts = create_artifact_paths(args.besu_version)
print(artifacts)
for url in artifacts:
check_url(url)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog

## Unreleased
### Breaking Changes
### Upcoming Breaking Changes
### Additions and Improvements
- Adds timestamps to enable Prague hardfork on Sepolia and Holesky test networks. [#8163](https://github.com/hyperledger/besu/pull/8163)
- Extend simulate transaction on pending block plugin API [#8174](https://github.com/hyperledger/besu/pull/8174)

### Bug fixes


## 25.1.0

### Breaking Changes
- `--host-whitelist` has been deprecated since 2020 and this option is removed. Use the equivalent `--host-allowlist` instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void startNode(final BesuNode node) {
.vertx(Vertx.vertx())
.besuController(besuController)
.ethNetworkConfig(ethNetworkConfig)
.discovery(node.isDiscoveryEnabled())
.discoveryEnabled(node.isDiscoveryEnabled())
.p2pAdvertisedHost(node.getHostName())
.p2pListenPort(0)
.networkingConfiguration(node.getNetworkingConfiguration())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void tearDown() {
public void shouldTransferAllEthOfAuthorizerToSponsor() throws IOException {

// 7702 transaction
final CodeDelegation authorization =
final CodeDelegation codeDelegation =
org.hyperledger.besu.ethereum.core.CodeDelegation.builder()
.chainId(BigInteger.valueOf(20211))
.address(SEND_ALL_ETH_CONTRACT_ADDRESS)
Expand All @@ -108,7 +108,7 @@ public void shouldTransferAllEthOfAuthorizerToSponsor() throws IOException {
.value(Wei.ZERO)
.payload(Bytes32.leftPad(Bytes.fromHexString(transactionSponsor.getAddress())))
.accessList(List.of())
.codeDelegations(List.of(authorization))
.codeDelegations(List.of(codeDelegation))
.signAndBuild(
secp256k1.createKeyPair(
secp256k1.createPrivateKey(
Expand Down Expand Up @@ -143,7 +143,7 @@ public void shouldCheckNonceAfterNonceIncreaseOfSender() throws IOException {
final long GAS_LIMIT = 1_000_000L;
cluster.verify(authorizer.balanceEquals(Amount.ether(90_000)));

final CodeDelegation authorization =
final CodeDelegation codeDelegation =
org.hyperledger.besu.ethereum.core.CodeDelegation.builder()
.chainId(BigInteger.valueOf(20211))
.nonce(
Expand All @@ -166,7 +166,7 @@ public void shouldCheckNonceAfterNonceIncreaseOfSender() throws IOException {
.value(Wei.ZERO)
.payload(Bytes32.leftPad(Bytes.fromHexString(otherAccount.getAddress())))
.accessList(List.of())
.codeDelegations(List.of(authorization))
.codeDelegations(List.of(codeDelegation))
.signAndBuild(
secp256k1.createKeyPair(
secp256k1.createPrivateKey(AUTHORIZER_PRIVATE_KEY.toUnsignedBigInteger())));
Expand Down
12 changes: 6 additions & 6 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public class RunnerBuilder {
private NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create();
private final Collection<Bytes> bannedNodeIds = new ArrayList<>();
private boolean p2pEnabled = true;
private boolean discovery;
private boolean discoveryEnabled;
private String p2pAdvertisedHost;
private String p2pListenInterface = NetworkUtility.INADDR_ANY;
private int p2pListenPort;
Expand Down Expand Up @@ -237,11 +237,11 @@ public RunnerBuilder p2pEnabled(final boolean p2pEnabled) {
/**
* Enable Discovery.
*
* @param discovery the discovery
* @param discoveryEnabled the discoveryEnabled
* @return the runner builder
*/
public RunnerBuilder discovery(final boolean discovery) {
this.discovery = discovery;
public RunnerBuilder discoveryEnabled(final boolean discoveryEnabled) {
this.discoveryEnabled = discoveryEnabled;
return this;
}

Expand Down Expand Up @@ -618,7 +618,7 @@ public Runner build() {
.setBindHost(p2pListenInterface)
.setBindPort(p2pListenPort)
.setAdvertisedHost(p2pAdvertisedHost);
if (discovery) {
if (discoveryEnabled) {
final List<EnodeURL> bootstrap;
if (ethNetworkConfig.bootNodes() == null) {
bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).bootNodes();
Expand All @@ -636,7 +636,7 @@ public Runner build() {
discoveryConfiguration.setFilterOnEnrForkId(
networkingConfiguration.getDiscovery().isFilterOnEnrForkIdEnabled());
} else {
discoveryConfiguration.setActive(false);
discoveryConfiguration.setEnabled(false);
}

final NodeKey nodeKey = besuController.getNodeKey();
Expand Down
26 changes: 11 additions & 15 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.SocketException;
import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.GroupPrincipal;
Expand Down Expand Up @@ -1433,7 +1431,7 @@ private void configureNativeLibs() {

private void validateOptions() {
issueOptionWarnings();
validateP2PInterface(p2PDiscoveryOptions.p2pInterface);
validateP2POptions();
validateMiningParams();
validateNatParams();
validateNetStatsParams();
Expand Down Expand Up @@ -1488,20 +1486,18 @@ private void validateMiningParams() {
commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger);
}

private void validateP2POptions() {
p2PDiscoveryOptions.validate(commandLine, getNetworkInterfaceChecker());
}

/**
* Validates P2P interface IP address/host name. Visible for testing.
* Returns a network interface checker that can be used to validate P2P options.
*
* @param p2pInterface IP Address/host name
* @return A {@link P2PDiscoveryOptions.NetworkInterfaceChecker} that checks if a network
* interface is available.
*/
protected void validateP2PInterface(final String p2pInterface) {
final String failMessage = "The provided --p2p-interface is not available: " + p2pInterface;
try {
if (!NetworkUtility.isNetworkInterfaceAvailable(p2pInterface)) {
throw new ParameterException(commandLine, failMessage);
}
} catch (final UnknownHostException | SocketException e) {
throw new ParameterException(commandLine, failMessage, e);
}
protected P2PDiscoveryOptions.NetworkInterfaceChecker getNetworkInterfaceChecker() {
return NetworkUtility::isNetworkInterfaceAvailable;
}

private void validateGraphQlOptions() {
Expand Down Expand Up @@ -2242,7 +2238,7 @@ private Runner synchronize(
.natMethod(natMethod)
.natManagerServiceName(unstableNatOptions.getNatManagerServiceName())
.natMethodFallbackEnabled(unstableNatOptions.getNatMethodFallbackEnabled())
.discovery(peerDiscoveryEnabled)
.discoveryEnabled(peerDiscoveryEnabled)
.ethNetworkConfig(ethNetworkConfig)
.permissioningConfiguration(permissioningConfiguration)
.p2pAdvertisedHost(p2pAdvertisedHost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,38 @@
import org.hyperledger.besu.util.number.Percentage;

import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import com.google.common.net.InetAddresses;
import org.apache.commons.net.util.SubnetUtils;
import org.apache.tuweni.bytes.Bytes;
import picocli.CommandLine;

/** Command line options for configuring P2P discovery on the node. */
public class P2PDiscoveryOptions implements CLIOptions<P2PDiscoveryConfiguration> {

/** Functional interface for checking if a network interface is available. */
@FunctionalInterface
public interface NetworkInterfaceChecker {

/**
* Checks if the provided network interface is available.
*
* @param p2pInterface The network interface to check.
* @return True if the network interface is available, false otherwise.
* @throws UnknownHostException If the host is unknown.
* @throws SocketException If there is an error with the socket.
*/
boolean isNetworkInterfaceAvailable(final String p2pInterface)
throws UnknownHostException, SocketException;
}

/** Default constructor */
public P2PDiscoveryOptions() {}

Expand Down Expand Up @@ -217,6 +236,37 @@ public P2PDiscoveryConfiguration toDomainObject() {
discoveryDnsUrl);
}

/**
* Validates the provided P2P discovery options.
*
* @param commandLine The command line object used for parsing and error reporting.
* @param networkInterfaceChecker The checker used to validate the network interface.
*/
public void validate(
final CommandLine commandLine, final NetworkInterfaceChecker networkInterfaceChecker) {
validateP2PHost(commandLine);
validateP2PInterface(commandLine, networkInterfaceChecker);
}

private void validateP2PInterface(
final CommandLine commandLine, final NetworkInterfaceChecker networkInterfaceChecker) {
final String failMessage = "The provided --p2p-interface is not available: " + p2pInterface;
try {
if (!networkInterfaceChecker.isNetworkInterfaceAvailable(p2pInterface)) {
throw new CommandLine.ParameterException(commandLine, failMessage);
}
} catch (final UnknownHostException | SocketException e) {
throw new CommandLine.ParameterException(commandLine, failMessage, e);
}
}

private void validateP2PHost(final CommandLine commandLine) {
final String failMessage = "The provided --p2p-host is invalid: " + p2pHost;
if (!InetAddresses.isInetAddress(p2pHost)) {
throw new CommandLine.ParameterException(commandLine, failMessage);
}
}

@Override
public List<String> getCLIOptions() {
return CommandLineUtils.getCLIOptions(this, new P2PDiscoveryOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public BesuController build() {
worldStateHealerSupplier::get);

if (maybeStoredGenesisBlockHash.isEmpty()) {
genesisState.writeStateTo(worldStateArchive.getMutable());
genesisState.writeStateTo(worldStateArchive.getWorldState());
}

transactionSimulator =
Expand Down Expand Up @@ -717,7 +717,8 @@ public BesuController build() {
syncState,
transactionPoolConfiguration,
besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()),
miningConfiguration);
miningConfiguration,
syncConfig.isPeerTaskSystemEnabled());

final List<PeerValidator> peerValidators =
createPeerValidators(protocolSchedule, peerTaskExecutor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.hyperledger.besu.ethereum.transaction.BlockStateCall;
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.plugin.Unstable;
import org.hyperledger.besu.plugin.data.BlockOverrides;
Expand Down Expand Up @@ -135,8 +136,13 @@ private BlockHeader getBlockHeader(final long blockNumber) {
}

private MutableWorldState getWorldState(final BlockHeader header, final boolean isPersisting) {
final WorldStateQueryParams worldStateQueryParams =
WorldStateQueryParams.newBuilder()
.withBlockHeader(header)
.withShouldWorldStateUpdateHead(isPersisting)
.build();
return worldStateArchive
.getMutable(header, isPersisting)
.getWorldState(worldStateQueryParams)
.orElseThrow(
() ->
new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.services;

import static org.hyperledger.besu.ethereum.trie.diffbased.common.provider.WorldStateQueryParams.withBlockHeaderAndUpdateNodeHead;

import org.hyperledger.besu.consensus.merge.MergeContext;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
Expand All @@ -25,7 +27,7 @@
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.diffbased.common.provider.DiffBasedWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.plugin.data.BlockBody;
Expand Down Expand Up @@ -109,7 +111,9 @@ public boolean setHeadUnsafe(final BlockHeader blockHeader, final BlockBody bloc

final MutableBlockchain blockchain = protocolContext.getBlockchain();

if (worldStateArchive.flatMap(archive -> archive.getMutable(coreHeader, true)).isPresent()) {
if (worldStateArchive
.flatMap(archive -> archive.getWorldState(withBlockHeaderAndUpdateNodeHead(coreHeader)))
.isPresent()) {
if (coreHeader.getParentHash().equals(blockchain.getChainHeadHash())) {
LOG.atDebug()
.setMessage(
Expand Down Expand Up @@ -142,7 +146,7 @@ public void disableWorldStateTrie() {
// TODO maybe find a best way in the future to delete and disable trie
worldStateArchive.ifPresent(
archive -> {
archive.getDefaultWorldStateConfig().setTrieDisabled(true);
archive.getWorldStateSharedSpec().setTrieDisabled(true);
final DiffBasedWorldStateKeyValueStorage worldStateStorage =
archive.getWorldStateKeyValueStorage();
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
Expand Down
Loading

0 comments on commit 772b40f

Please sign in to comment.