Skip to content

Commit

Permalink
Merge branch 'main' into zkbesu
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/verify_artifacts.py
  • Loading branch information
fab-10 committed Jan 27, 2025
2 parents 448d1a9 + 846e483 commit 3485e29
Show file tree
Hide file tree
Showing 103 changed files with 1,431 additions and 487 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# 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)
### 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 @@ -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 @@ -63,16 +63,18 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0xfe3366e7L), 1735371L),
new ForkId(Bytes.ofUnsignedInt(0xb96cbd13L), 1677557088L),
new ForkId(Bytes.ofUnsignedInt(0xf7f9bc08L), 1706655072L),
new ForkId(Bytes.ofUnsignedInt(0x88cf81d9L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x88cf81d9L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x88cf81d9L), 1739980128L),
new ForkId(Bytes.ofUnsignedInt(0xbafd09c3L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xbafd09c3L), 0L))
},
new Object[] {
NetworkName.HOLESKY,
List.of(
new ForkId(Bytes.ofUnsignedInt(0xc61a6098L), 1696000704L),
new ForkId(Bytes.ofUnsignedInt(0xfd4f016bL), 1707305664L),
new ForkId(Bytes.ofUnsignedInt(0x9b192ad0L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x9b192ad0L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x9b192ad0L), 1739352768L),
new ForkId(Bytes.ofUnsignedInt(0xf818a0d6L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xf818a0d6L), 0L))
},
new Object[] {
NetworkName.MAINNET,
Expand Down
12 changes: 6 additions & 6 deletions besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void enodeUrlShouldHaveAdvertisedHostWhenDiscoveryDisabled() {
.p2pListenPort(p2pListenPort)
.p2pAdvertisedHost(p2pAdvertisedHost)
.p2pEnabled(true)
.discovery(false)
.discoveryEnabled(false)
.besuController(besuController)
.ethNetworkConfig(mock(EthNetworkConfig.class))
.metricsSystem(mock(ObservableMetricsSystem.class))
Expand Down Expand Up @@ -196,7 +196,7 @@ public void movingAcrossProtocolSpecsUpdatesNodeRecord() {
when(protocolContext.getBlockchain()).thenReturn(inMemoryBlockchain);
final Runner runner =
new RunnerBuilder()
.discovery(true)
.discoveryEnabled(true)
.p2pListenInterface("0.0.0.0")
.p2pListenPort(p2pListenPort)
.p2pAdvertisedHost(p2pAdvertisedHost)
Expand Down Expand Up @@ -255,7 +255,7 @@ public void whenEngineApiAddedListensOnDefaultPort() {

final Runner runner =
new RunnerBuilder()
.discovery(true)
.discoveryEnabled(true)
.p2pListenInterface("0.0.0.0")
.p2pListenPort(30303)
.p2pAdvertisedHost("127.0.0.1")
Expand Down Expand Up @@ -299,7 +299,7 @@ public void whenEngineApiAddedWebSocketReadyOnSamePort() {

final Runner runner =
new RunnerBuilder()
.discovery(true)
.discoveryEnabled(true)
.p2pListenInterface("0.0.0.0")
.p2pListenPort(30303)
.p2pAdvertisedHost("127.0.0.1")
Expand Down Expand Up @@ -342,7 +342,7 @@ public void whenEngineApiAddedEthSubscribeAvailable() {

final Runner runner =
new RunnerBuilder()
.discovery(true)
.discoveryEnabled(true)
.p2pListenInterface("0.0.0.0")
.p2pListenPort(30303)
.p2pAdvertisedHost("127.0.0.1")
Expand Down Expand Up @@ -387,7 +387,7 @@ public void noEngineApiNoServiceForMethods() {

final Runner runner =
new RunnerBuilder()
.discovery(true)
.discoveryEnabled(true)
.p2pListenInterface("0.0.0.0")
.p2pListenPort(30303)
.p2pAdvertisedHost("127.0.0.1")
Expand Down
2 changes: 1 addition & 1 deletion besu/src/test/java/org/hyperledger/besu/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void syncFromGenesis(
final RunnerBuilder runnerBuilder =
new RunnerBuilder()
.vertx(vertx)
.discovery(true)
.discoveryEnabled(true)
.p2pAdvertisedHost(listenHost)
.p2pListenPort(0)
.metricsSystem(noOpMetricsSystem)
Expand Down
Loading

0 comments on commit 3485e29

Please sign in to comment.