Skip to content

Commit

Permalink
Refactor genesis config file and options (hyperledger#7012)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 authored May 2, 2024
1 parent 60b6b7d commit 690a2ea
Show file tree
Hide file tree
Showing 51 changed files with 513 additions and 618 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import java.io.File;
import java.nio.file.Path;
import java.time.Clock;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -213,14 +212,16 @@ public void startNode(final BesuNode node) {
final EthNetworkConfig.Builder networkConfigBuilder =
new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(network))
.setBootNodes(bootnodes);
node.getConfiguration().getGenesisConfig().ifPresent(networkConfigBuilder::setGenesisConfig);
node.getConfiguration()
.getGenesisConfig()
.map(GenesisConfigFile::fromConfig)
.ifPresent(networkConfigBuilder::setGenesisConfigFile);
final EthNetworkConfig ethNetworkConfig = networkConfigBuilder.build();
final SynchronizerConfiguration synchronizerConfiguration =
new SynchronizerConfiguration.Builder().build();
final BesuControllerBuilder builder =
new BesuController.Builder()
.fromEthNetworkConfig(
ethNetworkConfig, Collections.emptyMap(), synchronizerConfiguration.getSyncMode());
.fromEthNetworkConfig(ethNetworkConfig, synchronizerConfiguration.getSyncMode());

final KeyValueStorageProvider storageProvider =
new KeyValueStorageProviderBuilder()
Expand Down
10 changes: 5 additions & 5 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,15 @@ public Runner build() {
.setAdvertisedHost(p2pAdvertisedHost);
if (discovery) {
final List<EnodeURL> bootstrap;
if (ethNetworkConfig.getBootNodes() == null) {
bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).getBootNodes();
if (ethNetworkConfig.bootNodes() == null) {
bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).bootNodes();
} else {
bootstrap = ethNetworkConfig.getBootNodes();
bootstrap = ethNetworkConfig.bootNodes();
}
discoveryConfiguration.setBootnodes(bootstrap);
LOG.info("Resolved {} bootnodes.", bootstrap.size());
LOG.debug("Bootnodes = {}", bootstrap);
discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.getDnsDiscoveryUrl());
discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.dnsDiscoveryUrl());
discoveryConfiguration.setDiscoveryV5Enabled(
networkingConfiguration.getDiscovery().isDiscoveryV5Enabled());
discoveryConfiguration.setFilterOnEnrForkId(
Expand Down Expand Up @@ -1209,7 +1209,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
new JsonRpcMethodsFactory()
.methods(
BesuInfo.nodeName(identityString),
ethNetworkConfig.getNetworkId(),
ethNetworkConfig.networkId(),
besuController.getGenesisConfigOptions(),
network,
blockchainQueries,
Expand Down
Loading

0 comments on commit 690a2ea

Please sign in to comment.