Skip to content

Commit

Permalink
Merge branch 'main' into eip-7840
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu committed Dec 19, 2024
2 parents 5cdc356 + a03c98b commit c029879
Show file tree
Hide file tree
Showing 114 changed files with 2,526 additions and 1,036 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
- `--host-whitelist` has been deprecated since 2020 and this option is removed. Use the equivalent `--host-allowlist` instead.

### Upcoming Breaking Changes
- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
- k8s (KUBERNETES) Nat method is now deprecated and will be removed in a future release
- `--host-whitelist` has been deprecated in favor of `--host-allowlist` since 2020 and will be removed in a future release
- k8s (KUBERNETES) Nat method is now deprecated and will be removed in a future release. Use docker or none instead.
- Sunsetting features - for more context on the reasoning behind the deprecation of these features, including alternative options, read [this blog post](https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu)
- Tessera privacy
- Smart-contract-based (onchain) permissioning
Expand All @@ -23,6 +21,7 @@

### Bug fixes
- Fix serialization of state overrides when `movePrecompileToAddress` is present [#8204](https://github.com/hyperledger/besu/pull/8024)
- Revise the approach for setting level_compaction_dynamic_level_bytes RocksDB configuration option [#8037](https://github.com/hyperledger/besu/pull/8037)

## 24.12.2 Hotfix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.hyperledger.besu.tests.acceptance.dsl.transaction.clique.CliqueTransactions.LATEST;

import org.hyperledger.besu.config.CliqueConfigOptions;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.condition.blockchain.ExpectBlockNotCreated;
Expand Down Expand Up @@ -89,9 +89,9 @@ public Condition awaitSignerSetChange(final Node node) {

private int cliqueBlockPeriod(final BesuNode node) {
final String config = node.getGenesisConfigProvider().create(emptyList()).get();
final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(config);
final GenesisConfig genesisConfig = GenesisConfig.fromConfig(config);
final CliqueConfigOptions cliqueConfigOptions =
genesisConfigFile.getConfigOptions().getCliqueConfigOptions();
genesisConfig.getConfigOptions().getCliqueConfigOptions();
return cliqueConfigOptions.getBlockPeriodSeconds();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.controller.BesuControllerBuilder;
import org.hyperledger.besu.crypto.KeyPairUtil;
Expand Down Expand Up @@ -155,8 +155,8 @@ public void startNode(final BesuNode node) {
networkConfigBuilder.setBootNodes(bootnodes);
node.getConfiguration()
.getGenesisConfig()
.map(GenesisConfigFile::fromConfig)
.ifPresent(networkConfigBuilder::setGenesisConfigFile);
.map(GenesisConfig::fromConfig)
.ifPresent(networkConfigBuilder::setGenesisConfig);
final EthNetworkConfig ethNetworkConfig = networkConfigBuilder.build();
final BesuControllerBuilder builder = component.besuControllerBuilder();
builder.isRevertReasonEnabled(node.isRevertReasonEnabled());
Expand All @@ -166,9 +166,7 @@ public void startNode(final BesuNode node) {
builder.nodeKey(new NodeKey(new KeyPairSecurityModule(KeyPairUtil.loadKeyPair(dataDir))));
builder.privacyParameters(node.getPrivacyParameters());

node.getGenesisConfig()
.map(GenesisConfigFile::fromConfig)
.ifPresent(builder::genesisConfigFile);
node.getGenesisConfig().map(GenesisConfig::fromConfig).ifPresent(builder::genesisConfig);

final BesuController besuController = component.besuController();

Expand Down
29 changes: 20 additions & 9 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.config.CheckpointConfigOptions;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.MergeConfiguration;
import org.hyperledger.besu.controller.BesuController;
Expand Down Expand Up @@ -152,6 +152,7 @@
import org.hyperledger.besu.plugin.data.EnodeURL;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.BesuEvents;
import org.hyperledger.besu.plugin.services.BlockSimulationService;
import org.hyperledger.besu.plugin.services.BlockchainService;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.PermissioningService;
Expand All @@ -178,6 +179,7 @@
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockSimulatorServiceImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.P2PServiceImpl;
Expand Down Expand Up @@ -332,8 +334,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
new PreSynchronizationTaskRunner();

private final Set<Integer> allocatedPorts = new HashSet<>();
private final Supplier<GenesisConfigFile> genesisConfigFileSupplier =
Suppliers.memoize(this::readGenesisConfigFile);
private final Supplier<GenesisConfig> genesisConfigSupplier =
Suppliers.memoize(this::readGenesisConfig);
private final Supplier<GenesisConfigOptions> genesisConfigOptionsSupplier =
Suppliers.memoize(this::readGenesisConfigOptions);
private final Supplier<MiningConfiguration> miningParametersSupplier =
Expand Down Expand Up @@ -1288,6 +1290,15 @@ private void startPlugins(final Runner runner) {
besuPluginContext.addService(
MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));

besuPluginContext.addService(
BlockSimulationService.class,
new BlockSimulatorServiceImpl(
besuController.getProtocolContext().getWorldStateArchive(),
miningParametersSupplier.get(),
besuController.getTransactionSimulator(),
besuController.getProtocolSchedule(),
besuController.getProtocolContext().getBlockchain()));

besuController.getAdditionalPluginServices().appendPluginServices(besuPluginContext);
besuPluginContext.startPlugins();
}
Expand Down Expand Up @@ -1587,21 +1598,21 @@ private void validateChainDataPruningParams() {
}
}

private GenesisConfigFile readGenesisConfigFile() {
GenesisConfigFile effectiveGenesisFile;
private GenesisConfig readGenesisConfig() {
GenesisConfig effectiveGenesisFile;
effectiveGenesisFile =
network.equals(EPHEMERY)
? EphemeryGenesisUpdater.updateGenesis(genesisConfigOverrides)
: genesisFile != null
? GenesisConfigFile.fromSource(genesisConfigSource(genesisFile))
: GenesisConfigFile.fromResource(
? GenesisConfig.fromSource(genesisConfigSource(genesisFile))
: GenesisConfig.fromResource(
Optional.ofNullable(network).orElse(MAINNET).getGenesisFile());
return effectiveGenesisFile.withOverrides(genesisConfigOverrides);
}

private GenesisConfigOptions readGenesisConfigOptions() {
try {
return genesisConfigFileSupplier.get().getConfigOptions();
return genesisConfigSupplier.get().getConfigOptions();
} catch (final Exception e) {
throw new ParameterException(
this.commandLine, "Unable to load genesis file. " + e.getCause());
Expand Down Expand Up @@ -2337,7 +2348,7 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) {
builder.setDnsDiscoveryUrl(null);
}

builder.setGenesisConfigFile(genesisConfigFileSupplier.get());
builder.setGenesisConfig(genesisConfigSupplier.get());

if (networkId != null) {
builder.setNetworkId(networkId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.cli.config;

import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.plugin.data.EnodeURL;
Expand All @@ -33,29 +33,29 @@
/**
* The Eth network config.
*
* @param genesisConfigFile Genesis Config File
* @param genesisConfig Genesis Config File
* @param networkId Network Id
* @param bootNodes Boot Nodes
* @param dnsDiscoveryUrl DNS Discovery URL
*/
public record EthNetworkConfig(
GenesisConfigFile genesisConfigFile,
GenesisConfig genesisConfig,
BigInteger networkId,
List<EnodeURL> bootNodes,
String dnsDiscoveryUrl) {

/**
* Validate parameters on new record creation
*
* @param genesisConfigFile the genesis config
* @param genesisConfig the genesis config
* @param networkId the network id
* @param bootNodes the boot nodes
* @param dnsDiscoveryUrl the dns discovery url
*/
@SuppressWarnings(
"MethodInputParametersMustBeFinal") // needed since record constructors are not yet supported
public EthNetworkConfig {
Objects.requireNonNull(genesisConfigFile);
Objects.requireNonNull(genesisConfig);
Objects.requireNonNull(bootNodes);
}

Expand All @@ -67,8 +67,8 @@ public record EthNetworkConfig(
*/
public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) {
final URL genesisSource = jsonConfigSource(networkName.getGenesisFile());
final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromSource(genesisSource);
final GenesisConfigOptions genesisConfigOptions = genesisConfigFile.getConfigOptions();
final GenesisConfig genesisConfig = GenesisConfig.fromSource(genesisSource);
final GenesisConfigOptions genesisConfigOptions = genesisConfig.getConfigOptions();
final Optional<List<String>> rawBootNodes =
genesisConfigOptions.getDiscoveryOptions().getBootNodes();
final List<EnodeURL> bootNodes =
Expand All @@ -79,7 +79,7 @@ public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) {
.orElse(Collections.emptyList());

return new EthNetworkConfig(
genesisConfigFile,
genesisConfig,
networkName.getNetworkId(),
bootNodes,
genesisConfigOptions.getDiscoveryOptions().getDiscoveryDnsUrl().orElse(null));
Expand Down Expand Up @@ -108,7 +108,7 @@ public static String jsonConfig(final NetworkName network) {
public static class Builder {

private String dnsDiscoveryUrl;
private GenesisConfigFile genesisConfigFile;
private GenesisConfig genesisConfig;
private BigInteger networkId;
private List<EnodeURL> bootNodes;

Expand All @@ -118,7 +118,7 @@ public static class Builder {
* @param ethNetworkConfig the eth network config
*/
public Builder(final EthNetworkConfig ethNetworkConfig) {
this.genesisConfigFile = ethNetworkConfig.genesisConfigFile;
this.genesisConfig = ethNetworkConfig.genesisConfig;
this.networkId = ethNetworkConfig.networkId;
this.bootNodes = ethNetworkConfig.bootNodes;
this.dnsDiscoveryUrl = ethNetworkConfig.dnsDiscoveryUrl;
Expand All @@ -127,11 +127,11 @@ public Builder(final EthNetworkConfig ethNetworkConfig) {
/**
* Sets genesis config file.
*
* @param genesisConfigFile the genesis config
* @param genesisConfig the genesis config
* @return this builder
*/
public Builder setGenesisConfigFile(final GenesisConfigFile genesisConfigFile) {
this.genesisConfigFile = genesisConfigFile;
public Builder setGenesisConfig(final GenesisConfig genesisConfig) {
this.genesisConfig = genesisConfig;
return this;
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public Builder setDnsDiscoveryUrl(final String dnsDiscoveryUrl) {
* @return the eth network config
*/
public EthNetworkConfig build() {
return new EthNetworkConfig(genesisConfigFile, networkId, bootNodes, dnsDiscoveryUrl);
return new EthNetworkConfig(genesisConfig, networkId, bootNodes, dnsDiscoveryUrl);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.JsonGenesisConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
Expand Down Expand Up @@ -286,7 +286,7 @@ private void parseConfig() throws IOException {

/** Sets the selected signature algorithm instance in SignatureAlgorithmFactory. */
private void processEcCurve() {
GenesisConfigOptions options = GenesisConfigFile.fromConfig(genesisConfig).getConfigOptions();
GenesisConfigOptions options = GenesisConfig.fromConfig(genesisConfig).getConfigOptions();
Optional<String> ecCurve = options.getEcCurve();

if (ecCurve.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package org.hyperledger.besu.controller;

import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfig;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.PowAlgorithm;
import org.hyperledger.besu.config.QbftConfigOptions;
Expand Down Expand Up @@ -334,24 +334,24 @@ public Builder() {}
*/
public BesuControllerBuilder fromEthNetworkConfig(
final EthNetworkConfig ethNetworkConfig, final SyncMode syncMode) {
return fromGenesisFile(ethNetworkConfig.genesisConfigFile(), syncMode)
return fromGenesisFile(ethNetworkConfig.genesisConfig(), syncMode)
.networkId(ethNetworkConfig.networkId());
}

/**
* From genesis config besu controller builder.
*
* @param genesisConfigFile the genesis config file
* @param genesisConfig the genesis config file
* @param syncMode the sync mode
* @return the besu controller builder
*/
public BesuControllerBuilder fromGenesisFile(
final GenesisConfigFile genesisConfigFile, final SyncMode syncMode) {
final GenesisConfig genesisConfig, final SyncMode syncMode) {
final BesuControllerBuilder builder;
final var configOptions = genesisConfigFile.getConfigOptions();
final var configOptions = genesisConfig.getConfigOptions();

if (configOptions.isConsensusMigration()) {
return createConsensusScheduleBesuControllerBuilder(genesisConfigFile);
return createConsensusScheduleBesuControllerBuilder(genesisConfig);
}

if (configOptions.getPowAlgorithm() != PowAlgorithm.UNSUPPORTED) {
Expand All @@ -373,22 +373,22 @@ public BesuControllerBuilder fromGenesisFile(
if (configOptions.getTerminalTotalDifficulty().isPresent()) {
// Enable start with vanilla MergeBesuControllerBuilder for PoS checkpoint block
if (syncMode == SyncMode.CHECKPOINT && isCheckpointPoSBlock(configOptions)) {
return new MergeBesuControllerBuilder().genesisConfigFile(genesisConfigFile);
return new MergeBesuControllerBuilder().genesisConfig(genesisConfig);
} else {
// TODO this should be changed to vanilla MergeBesuControllerBuilder and the Transition*
// series of classes removed after we successfully transition to PoS
// https://github.com/hyperledger/besu/issues/2897
return new TransitionBesuControllerBuilder(builder, new MergeBesuControllerBuilder())
.genesisConfigFile(genesisConfigFile);
.genesisConfig(genesisConfig);
}

} else return builder.genesisConfigFile(genesisConfigFile);
} else return builder.genesisConfig(genesisConfig);
}

private BesuControllerBuilder createConsensusScheduleBesuControllerBuilder(
final GenesisConfigFile genesisConfigFile) {
final GenesisConfig genesisConfig) {
final Map<Long, BesuControllerBuilder> besuControllerBuilderSchedule = new HashMap<>();
final var configOptions = genesisConfigFile.getConfigOptions();
final var configOptions = genesisConfig.getConfigOptions();

final BesuControllerBuilder originalControllerBuilder;
if (configOptions.isIbft2()) {
Expand All @@ -407,7 +407,7 @@ private BesuControllerBuilder createConsensusScheduleBesuControllerBuilder(
besuControllerBuilderSchedule.put(qbftBlock, new QbftBesuControllerBuilder());

return new ConsensusScheduleBesuControllerBuilder(besuControllerBuilderSchedule)
.genesisConfigFile(genesisConfigFile);
.genesisConfig(genesisConfig);
}

private Long readQbftStartBlockConfig(final QbftConfigOptions qbftConfigOptions) {
Expand Down
Loading

0 comments on commit c029879

Please sign in to comment.