From 606d5fbbc37ecf141bae65bd17189bc75c2ef8fe Mon Sep 17 00:00:00 2001 From: jflo Date: Wed, 18 Dec 2024 16:49:48 -0500 Subject: [PATCH] rename GenesisConfigFile because it's not a file at all Signed-off-by: jflo --- .../condition/clique/CliqueConditions.java | 6 +- .../dsl/node/ThreadBesuNodeRunner.java | 10 +-- .../org/hyperledger/besu/cli/BesuCommand.java | 18 ++-- .../besu/cli/config/EthNetworkConfig.java | 28 +++---- .../operator/GenerateBlockchainConfig.java | 4 +- .../besu/controller/BesuController.java | 24 +++--- .../controller/BesuControllerBuilder.java | 15 ++-- ...onsensusScheduleBesuControllerBuilder.java | 8 +- .../TransitionBesuControllerBuilder.java | 8 +- .../besu/util/EphemeryGenesisUpdater.java | 16 ++-- .../besu/FlexGroupPrivacyTest.java | 4 +- .../besu/ForkIdsNetworkConfigTest.java | 17 ++-- .../hyperledger/besu/PrivacyReorgTest.java | 10 +-- .../org/hyperledger/besu/PrivacyTest.java | 4 +- .../java/org/hyperledger/besu/RunnerTest.java | 19 ++--- .../chainimport/JsonBlockImporterTest.java | 18 ++-- .../hyperledger/besu/cli/BesuCommandTest.java | 36 ++++---- .../cli/CascadingDefaultProviderTest.java | 7 +- .../besu/cli/config/EthNetworkConfigTest.java | 8 +- .../besu/components/GenesisConfigModule.java | 10 +-- .../AbstractBftBesuControllerBuilderTest.java | 20 ++--- .../besu/controller/BesuControllerTest.java | 27 +++--- .../CliqueBesuControllerBuilderTest.java | 18 ++-- ...nsusScheduleBesuControllerBuilderTest.java | 8 +- .../IbftBesuControllerBuilderTest.java | 4 +- .../MergeBesuControllerBuilderTest.java | 21 +++-- .../QbftBesuControllerBuilderTest.java | 4 +- .../TransitionControllerBuilderTest.java | 10 +-- .../besu/util/EphemeryGenesisUpdaterTest.java | 24 +++--- ...esisConfigFile.java => GenesisConfig.java} | 32 ++++---- .../besu/config/CliqueConfigOptionsTest.java | 2 +- .../besu/config/GenesisConfigOptionsTest.java | 8 +- ...igFileTest.java => GenesisConfigTest.java} | 72 ++++++++-------- .../besu/config/JsonBftConfigOptionsTest.java | 2 +- .../clique/CliqueProtocolScheduleTest.java | 8 +- .../blockcreation/CliqueBlockCreatorTest.java | 6 +- .../CliqueMinerExecutorTest.java | 4 +- .../blockcreation/BftBlockCreatorTest.java | 5 +- .../merge/MergeProtocolScheduleTest.java | 12 +-- .../blockcreation/MergeCoordinatorTest.java | 4 +- .../MergeGenesisConfigHelper.java | 14 ++-- .../merge/blockcreation/MergeReorgTest.java | 6 +- .../qbft/support/TestContextBuilder.java | 4 +- .../api/jsonrpc/BlockchainImporter.java | 4 +- .../AbstractBlockCreatorTest.java | 8 +- .../AbstractBlockTransactionSelectorTest.java | 13 ++- ...FeeMarketBlockTransactionSelectorTest.java | 8 +- ...FeeMarketBlockTransactionSelectorTest.java | 8 +- .../blockcreation/PoWBlockCreatorTest.java | 38 ++++----- .../vm/TraceTransactionIntegrationTest.java | 5 +- .../operations/OperationBenchmarkHelper.java | 4 +- .../besu/ethereum/chain/GenesisState.java | 82 +++++++++---------- .../mainnet/feemarket/LondonFeeMarket.java | 5 +- .../ethereum/core/BlockchainSetupUtil.java | 16 ++-- .../core/ExecutionContextTestFixture.java | 22 ++--- .../core/ProtocolScheduleFixture.java | 4 +- .../fixed/FixedProtocolScheduleTest.java | 4 +- ...AbstractBlockProcessorIntegrationTest.java | 6 +- .../mainnet/MainnetProtocolScheduleTest.java | 8 +- .../bonsai/AbstractIsolationTests.java | 8 +- .../EthProtocolManagerTestBuilder.java | 15 ++-- .../eth/messages/BlockBodiesMessageTest.java | 4 +- .../eth/messages/BlockHeadersMessageTest.java | 4 +- .../eth/sync/ChainHeadTrackerTest.java | 4 +- .../AbstractTransactionPoolTestBase.java | 4 +- .../ethereum/eth/transactions/TestNode.java | 8 +- .../besu/evmtool/EvmToolCommand.java | 6 +- .../besu/evmtool/GenesisFileModule.java | 14 ++-- ...rtContractPermissioningControllerTest.java | 4 +- ...rtContractPermissioningControllerTest.java | 5 +- .../mainnet/DifficultyCalculatorTests.java | 4 +- 71 files changed, 439 insertions(+), 461 deletions(-) rename config/src/main/java/org/hyperledger/besu/config/{GenesisConfigFile.java => GenesisConfig.java} (89%) rename config/src/test/java/org/hyperledger/besu/config/{GenesisConfigFileTest.java => GenesisConfigTest.java} (89%) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/CliqueConditions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/CliqueConditions.java index 750e587f6e3..4490a2b2a2e 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/CliqueConditions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/clique/CliqueConditions.java @@ -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; @@ -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(); } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index 3f0e0848c70..c18f71c4b09 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -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; @@ -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()); @@ -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(); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 21cb787f52b..5f7047dcae3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -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; @@ -332,8 +332,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { new PreSynchronizationTaskRunner(); private final Set allocatedPorts = new HashSet<>(); - private final Supplier genesisConfigFileSupplier = - Suppliers.memoize(this::readGenesisConfigFile); + private final Supplier genesisConfigSupplier = + Suppliers.memoize(this::readGenesisConfig); private final Supplier genesisConfigOptionsSupplier = Suppliers.memoize(this::readGenesisConfigOptions); private final Supplier miningParametersSupplier = @@ -1587,21 +1587,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()); @@ -2337,7 +2337,7 @@ private EthNetworkConfig updateNetworkConfig(final NetworkName network) { builder.setDnsDiscoveryUrl(null); } - builder.setGenesisConfigFile(genesisConfigFileSupplier.get()); + builder.setGenesisConfig(genesisConfigSupplier.get()); if (networkId != null) { builder.setNetworkId(networkId); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java index dab3a4c227c..0a8d86c795a 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java @@ -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; @@ -33,13 +33,13 @@ /** * 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 bootNodes, String dnsDiscoveryUrl) { @@ -47,7 +47,7 @@ public record EthNetworkConfig( /** * 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 @@ -55,7 +55,7 @@ public record EthNetworkConfig( @SuppressWarnings( "MethodInputParametersMustBeFinal") // needed since record constructors are not yet supported public EthNetworkConfig { - Objects.requireNonNull(genesisConfigFile); + Objects.requireNonNull(genesisConfig); Objects.requireNonNull(bootNodes); } @@ -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> rawBootNodes = genesisConfigOptions.getDiscoveryOptions().getBootNodes(); final List bootNodes = @@ -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)); @@ -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 bootNodes; @@ -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; @@ -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; } @@ -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); } } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java index d71cf652a5f..368f6da3800 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java @@ -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; @@ -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 ecCurve = options.getEcCurve(); if (ecCurve.isEmpty()) { diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java index 25a306d3a29..700b414edce 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java @@ -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; @@ -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) { @@ -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 besuControllerBuilderSchedule = new HashMap<>(); - final var configOptions = genesisConfigFile.getConfigOptions(); + final var configOptions = genesisConfig.getConfigOptions(); final BesuControllerBuilder originalControllerBuilder; if (configOptions.isIbft2()) { @@ -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) { diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 258cf95ca35..9498f7b2d92 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -18,7 +18,7 @@ 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.consensus.merge.MergeContext; import org.hyperledger.besu.consensus.merge.UnverifiedForkchoiceSupplier; @@ -127,7 +127,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides private static final Logger LOG = LoggerFactory.getLogger(BesuControllerBuilder.class); /** The genesis file */ - protected GenesisConfigFile genesisConfigFile; + protected GenesisConfig genesisConfig; /** The genesis config options; */ protected GenesisConfigOptions genesisConfigOptions; @@ -250,8 +250,8 @@ public BesuControllerBuilder storageProvider(final StorageProvider storageProvid * @param genesisConfig the genesis config * @return the besu controller builder */ - public BesuControllerBuilder genesisConfigFile(final GenesisConfigFile genesisConfig) { - this.genesisConfigFile = genesisConfig; + public BesuControllerBuilder genesisConfig(final GenesisConfig genesisConfig) { + this.genesisConfig = genesisConfig; this.genesisConfigOptions = genesisConfig.getConfigOptions(); return this; } @@ -559,7 +559,7 @@ public BesuControllerBuilder isParallelTxProcessingEnabled( * @return the besu controller */ public BesuController build() { - checkNotNull(genesisConfigFile, "Missing genesis config file"); + checkNotNull(genesisConfig, "Missing genesis config file"); checkNotNull(genesisConfigOptions, "Missing genesis config options"); checkNotNull(syncConfig, "Missing sync config"); checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration"); @@ -840,11 +840,10 @@ private GenesisState getGenesisState( return maybeGenesisStateRoot .map( genesisStateRoot -> - GenesisState.fromStorage(genesisStateRoot, genesisConfigFile, protocolSchedule)) + GenesisState.fromStorage(genesisStateRoot, genesisConfig, protocolSchedule)) .orElseGet( () -> - GenesisState.fromConfig( - dataStorageConfiguration, genesisConfigFile, protocolSchedule)); + GenesisState.fromConfig(dataStorageConfiguration, genesisConfig, protocolSchedule)); } private TrieLogPruner createTrieLogPruner( diff --git a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java index 31f84b6ae04..0b7299cedb5 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java @@ -16,7 +16,7 @@ import static org.hyperledger.besu.ethereum.core.BlockHeader.GENESIS_BLOCK_NUMBER; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.consensus.common.CombinedProtocolScheduleFactory; import org.hyperledger.besu.consensus.common.ForkSpec; import org.hyperledger.besu.consensus.common.ForksSchedule; @@ -264,9 +264,9 @@ public BesuControllerBuilder storageProvider(final StorageProvider storageProvid } @Override - public BesuControllerBuilder genesisConfigFile(final GenesisConfigFile genesisConfig) { - besuControllerBuilderSchedule.values().forEach(b -> b.genesisConfigFile(genesisConfig)); - return super.genesisConfigFile(genesisConfig); + public BesuControllerBuilder genesisConfig(final GenesisConfig genesisConfig) { + besuControllerBuilderSchedule.values().forEach(b -> b.genesisConfig(genesisConfig)); + return super.genesisConfig(genesisConfig); } @Override diff --git a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java index 4f078fda286..9d37f594e8a 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.controller; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.consensus.merge.MergeContext; import org.hyperledger.besu.consensus.merge.PostMergeContext; import org.hyperledger.besu.consensus.merge.TransitionBackwardSyncContext; @@ -301,9 +301,9 @@ public BesuControllerBuilder evmConfiguration(final EvmConfiguration evmConfigur } @Override - public BesuControllerBuilder genesisConfigFile(final GenesisConfigFile genesisConfig) { - super.genesisConfigFile(genesisConfig); - return propagateConfig(z -> z.genesisConfigFile(genesisConfig)); + public BesuControllerBuilder genesisConfig(final GenesisConfig genesisConfig) { + super.genesisConfig(genesisConfig); + return propagateConfig(z -> z.genesisConfig(genesisConfig)); } @Override diff --git a/besu/src/main/java/org/hyperledger/besu/util/EphemeryGenesisUpdater.java b/besu/src/main/java/org/hyperledger/besu/util/EphemeryGenesisUpdater.java index 0b970a6809c..c022f84adae 100644 --- a/besu/src/main/java/org/hyperledger/besu/util/EphemeryGenesisUpdater.java +++ b/besu/src/main/java/org/hyperledger/besu/util/EphemeryGenesisUpdater.java @@ -16,7 +16,7 @@ import static org.hyperledger.besu.cli.config.NetworkName.EPHEMERY; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import java.io.IOException; import java.math.BigInteger; @@ -46,16 +46,16 @@ public EphemeryGenesisUpdater() {} * @return the updated GenesisConfigFile * @throws RuntimeException if an error occurs during the update process */ - public static GenesisConfigFile updateGenesis(final Map overrides) + public static GenesisConfig updateGenesis(final Map overrides) throws RuntimeException { - GenesisConfigFile genesisConfigFile; + GenesisConfig genesisConfig; try { if (EPHEMERY.getGenesisFile() == null) { throw new IOException("Genesis file or config options are null"); } - genesisConfigFile = GenesisConfigFile.fromResource(EPHEMERY.getGenesisFile()); - long genesisTimestamp = genesisConfigFile.getTimestamp(); - Optional genesisChainId = genesisConfigFile.getConfigOptions().getChainId(); + genesisConfig = GenesisConfig.fromResource(EPHEMERY.getGenesisFile()); + long genesisTimestamp = genesisConfig.getTimestamp(); + Optional genesisChainId = genesisConfig.getConfigOptions().getChainId(); long currentTimestamp = Instant.now().getEpochSecond(); long periodsSinceGenesis = ChronoUnit.DAYS.between(Instant.ofEpochSecond(genesisTimestamp), Instant.now()) @@ -71,9 +71,9 @@ public static GenesisConfigFile updateGenesis(final Map override if (currentTimestamp > (genesisTimestamp + PERIOD_IN_SECONDS)) { overrides.put("chainId", String.valueOf(updatedChainId)); overrides.put("timestamp", String.valueOf(updatedTimestamp)); - genesisConfigFile = genesisConfigFile.withOverrides(overrides); + genesisConfig = genesisConfig.withOverrides(overrides); } - return genesisConfigFile.withOverrides(overrides); + return genesisConfig.withOverrides(overrides); } catch (IOException e) { throw new RuntimeException("Error updating ephemery genesis: " + e.getMessage(), e); } diff --git a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java index bad87162fd2..5298633ff9b 100644 --- a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.components.MockBesuCommandModule; import org.hyperledger.besu.components.NoOpMetricsSystemModule; import org.hyperledger.besu.components.PrivacyTestModule; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; @@ -146,7 +146,7 @@ BesuController provideBesuController( @Named("dataDir") final Path dataDir) { return new BesuController.Builder() - .fromGenesisFile(GenesisConfigFile.mainnet(), SyncMode.FULL) + .fromGenesisFile(GenesisConfig.mainnet(), SyncMode.FULL) .synchronizerConfiguration(SynchronizerConfiguration.builder().build()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java index 87bab916f23..e4ac7d5b5fc 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.cli.config.NetworkName; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule; import org.hyperledger.besu.consensus.merge.PostMergeContext; @@ -133,10 +133,9 @@ public static Collection parameters() { @ParameterizedTest @MethodSource("parameters") public void testForkId(final NetworkName chainName, final List expectedForkIds) { - final GenesisConfigFile genesisConfigFile = - GenesisConfigFile.fromResource(chainName.getGenesisFile()); - final MilestoneStreamingTransitionProtocolSchedule schedule = createSchedule(genesisConfigFile); - final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, schedule); + final GenesisConfig genesisConfig = GenesisConfig.fromResource(chainName.getGenesisFile()); + final MilestoneStreamingTransitionProtocolSchedule schedule = createSchedule(genesisConfig); + final GenesisState genesisState = GenesisState.fromConfig(genesisConfig, schedule); final Blockchain mockBlockchain = mock(Blockchain.class); final BlockHeader mockBlockHeader = mock(BlockHeader.class); @@ -150,8 +149,8 @@ public void testForkId(final NetworkName chainName, final List expectedF final ForkIdManager forkIdManager = new ForkIdManager( mockBlockchain, - genesisConfigFile.getForkBlockNumbers(), - genesisConfigFile.getForkTimestamps(), + genesisConfig.getForkBlockNumbers(), + genesisConfig.getForkTimestamps(), false); final List actualForkIds = @@ -167,8 +166,8 @@ public void testForkId(final NetworkName chainName, final List expectedF } private static MilestoneStreamingTransitionProtocolSchedule createSchedule( - final GenesisConfigFile genesisConfigFile) { - final GenesisConfigOptions configOptions = genesisConfigFile.getConfigOptions(); + final GenesisConfig genesisConfig) { + final GenesisConfigOptions configOptions = genesisConfig.getConfigOptions(); MilestoneStreamingProtocolSchedule preMergeProtocolSchedule = new MilestoneStreamingProtocolSchedule( (DefaultProtocolSchedule) diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java index beff4b8586b..6ddaa618635 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java @@ -27,7 +27,7 @@ import org.hyperledger.besu.components.MockBesuCommandModule; import org.hyperledger.besu.components.NoOpMetricsSystemModule; import org.hyperledger.besu.components.PrivacyTestModule; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithm; @@ -535,7 +535,7 @@ static class PrivacyReorgTestBesuControllerModule { @SuppressWarnings("CloseableProvides") BesuController provideBesuController( final PrivacyParameters privacyParameters, - final GenesisConfigFile genesisConfigFile, + final GenesisConfig genesisConfig, final PrivacyReorgTestComponent context, final @Named("dataDir") Path dataDir) { @@ -543,7 +543,7 @@ BesuController provideBesuController( // named privacyReorgParams BesuController retval = new BesuController.Builder() - .fromGenesisFile(genesisConfigFile, SyncMode.FULL) + .fromGenesisFile(genesisConfig, SyncMode.FULL) .synchronizerConfiguration(SynchronizerConfiguration.builder().build()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) @@ -568,8 +568,8 @@ BesuController provideBesuController( @Module static class PrivacyReorgTestGenesisConfigModule { @Provides - GenesisConfigFile providePrivacyReorgGenesisConfigFile() { - return GenesisConfigFile.fromResource("/privacy_reorg_genesis.json"); + GenesisConfig providePrivacyReorgGenesisConfig() { + return GenesisConfig.fromResource("/privacy_reorg_genesis.json"); } } } diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java index 3e905d94416..32f2b1f6176 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.components.NoOpMetricsSystemModule; import org.hyperledger.besu.components.PrivacyParametersModule; import org.hyperledger.besu.components.PrivacyTestModule; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; @@ -121,7 +121,7 @@ BesuController provideBesuController( @Named("dataDir") final Path dataDir) { return new BesuController.Builder() - .fromGenesisFile(GenesisConfigFile.mainnet(), SyncMode.FULL) + .fromGenesisFile(GenesisConfig.mainnet(), SyncMode.FULL) .synchronizerConfiguration(SynchronizerConfiguration.builder().build()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java index cf995c25e07..2fc89285668 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java @@ -26,7 +26,7 @@ import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.components.BesuComponent; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.config.MergeConfiguration; import org.hyperledger.besu.controller.BesuController; @@ -181,9 +181,7 @@ public void fastSyncFromGenesisUsingPeerTaskSystem() throws Exception { } private void syncFromGenesis( - final SyncMode mode, - final GenesisConfigFile genesisConfig, - final boolean isPeerTaskSystemEnabled) + final SyncMode mode, final GenesisConfig genesisConfig, final boolean isPeerTaskSystemEnabled) throws Exception { final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead"); final Path dbAhead = dataDirAhead.resolve("database"); @@ -270,7 +268,7 @@ private void syncFromGenesis( final EnodeURL aheadEnode = runnerAhead.getLocalEnode().get(); final EthNetworkConfig behindEthNetworkConfiguration = new EthNetworkConfig( - GenesisConfigFile.fromResource(DEV.getGenesisFile()), + GenesisConfig.fromResource(DEV.getGenesisFile()), DEV.getNetworkId(), Collections.singletonList(aheadEnode), null); @@ -395,11 +393,10 @@ private Request getRequest(final String method, final String baseUrl) { .build(); } - private GenesisConfigFile getFastSyncGenesis() throws IOException { + private GenesisConfig getFastSyncGenesis() throws IOException { final ObjectNode jsonNode = (ObjectNode) - new ObjectMapper() - .readTree(GenesisConfigFile.class.getResource(MAINNET.getGenesisFile())); + new ObjectMapper().readTree(GenesisConfig.class.getResource(MAINNET.getGenesisFile())); final Optional configNode = JsonUtil.getObjectNode(jsonNode, "config"); configNode.ifPresent( (node) -> { @@ -408,7 +405,7 @@ private GenesisConfigFile getFastSyncGenesis() throws IOException { // remove merge terminal difficulty for fast sync in the absence of a CL mock node.remove("terminalTotalDifficulty"); }); - return GenesisConfigFile.fromConfig(jsonNode); + return GenesisConfig.fromConfig(jsonNode); } private StorageProvider createKeyValueStorageProvider( @@ -482,7 +479,7 @@ private static void setupState( } private BesuController getController( - final GenesisConfigFile genesisConfig, + final GenesisConfig genesisConfig, final SynchronizerConfiguration syncConfig, final Path dataDir, final NodeKey nodeKey, @@ -490,7 +487,7 @@ private BesuController getController( final ObservableMetricsSystem metricsSystem, final MiningConfiguration miningConfiguration) { return new MainnetBesuControllerBuilder() - .genesisConfigFile(genesisConfig) + .genesisConfig(genesisConfig) .synchronizerConfiguration(syncConfig) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .dataDirectory(dataDir) diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java index 383ef1a3a1a..1b1c914d411 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.components.BesuCommandModule; import org.hyperledger.besu.components.BesuComponent; import org.hyperledger.besu.components.BesuPluginContextModule; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; @@ -78,14 +78,14 @@ public abstract class JsonBlockImporterTest { @TempDir public Path dataDir; protected String consensusEngine; - protected GenesisConfigFile genesisConfigFile; + protected GenesisConfig genesisConfig; protected boolean isEthash; protected void setup(final String consensusEngine) throws IOException { this.consensusEngine = consensusEngine; final String genesisData = getFileContents("genesis.json"); - this.genesisConfigFile = GenesisConfigFile.fromConfig(genesisData); - this.isEthash = genesisConfigFile.getConfigOptions().isEthHash(); + this.genesisConfig = GenesisConfig.fromConfig(genesisData); + this.isEthash = genesisConfig.getConfigOptions().isEthHash(); } public static class SingletonTests extends JsonBlockImporterTest { @@ -106,7 +106,7 @@ public void importChain_unsupportedConsensusAlgorithm() throws IOException { .isInstanceOf(IllegalArgumentException.class) .hasMessage( "Unable to create block using current consensus engine: " - + genesisConfigFile.getConfigOptions().getConsensusEngine()); + + genesisConfig.getConfigOptions().getConsensusEngine()); } } @@ -419,7 +419,7 @@ public void importChain_specialFields(final String consensusEngine) throws IOExc .isInstanceOf(IllegalArgumentException.class) .hasMessage( "Some fields (coinbase, extraData) are unsupported by the current consensus engine: " - + genesisConfigFile.getConfigOptions().getConsensusEngine()); + + genesisConfig.getConfigOptions().getConsensusEngine()); } } @@ -448,12 +448,12 @@ protected String getFileContents(final String folder, final String filename) thr } protected BesuController createController() throws IOException { - return createController(genesisConfigFile); + return createController(genesisConfig); } - protected BesuController createController(final GenesisConfigFile genesisConfigFile) { + protected BesuController createController(final GenesisConfig genesisConfig) { return new BesuController.Builder() - .fromGenesisFile(genesisConfigFile, SyncMode.FAST) + .fromGenesisFile(genesisConfig, SyncMode.FAST) .synchronizerConfiguration(SynchronizerConfiguration.builder().build()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index eb789478b9a..a8bcde0e27d 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -46,7 +46,7 @@ import org.hyperledger.besu.BesuInfo; import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.NetworkName; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.MergeConfiguration; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Hash; @@ -188,11 +188,10 @@ public void testGenesisOverrideOptions() throws Exception { assertThat(config.networkId()).isEqualTo(BigInteger.valueOf(1)); // assert that shanghaiTime override is applied - final GenesisConfigFile actualGenesisConfigFile = (config.genesisConfigFile()); - assertThat(actualGenesisConfigFile).isNotNull(); - assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime()).isNotEmpty(); - assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime().getAsLong()) - .isEqualTo(123); + final GenesisConfig actualGenesisConfig = (config.genesisConfig()); + assertThat(actualGenesisConfig).isNotNull(); + assertThat(actualGenesisConfig.getConfigOptions().getShanghaiTime()).isNotEmpty(); + assertThat(actualGenesisConfig.getConfigOptions().getShanghaiTime().getAsLong()).isEqualTo(123); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -217,11 +216,10 @@ public void testGenesisOverrideOptionsWithCustomGenesis() throws Exception { assertThat(config.networkId()).isEqualTo(BigInteger.valueOf(3141592)); // then assert that the shanghaiTime is applied - final GenesisConfigFile actualGenesisConfigFile = (config.genesisConfigFile()); - assertThat(actualGenesisConfigFile).isNotNull(); - assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime()).isNotEmpty(); - assertThat(actualGenesisConfigFile.getConfigOptions().getShanghaiTime().getAsLong()) - .isEqualTo(123); + final GenesisConfig actualGenesisConfig = (config.genesisConfig()); + assertThat(actualGenesisConfig).isNotNull(); + assertThat(actualGenesisConfig.getConfigOptions().getShanghaiTime()).isNotEmpty(); + assertThat(actualGenesisConfig.getConfigOptions().getShanghaiTime().getAsLong()).isEqualTo(123); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -262,7 +260,7 @@ public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() { verify(mockRunnerBuilder) .ethNetworkConfig( new EthNetworkConfig( - GenesisConfigFile.fromResource(MAINNET.getGenesisFile()), + GenesisConfig.fromResource(MAINNET.getGenesisFile()), MAINNET.getNetworkId(), MAINNET_BOOTSTRAP_NODES, MAINNET_DISCOVERY_URL)); @@ -470,8 +468,8 @@ public void genesisPathOptionMustBeUsed() throws Exception { verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any()); verify(mockControllerBuilder).build(); - assertThat(networkArg.getValue().genesisConfigFile()) - .isEqualTo(GenesisConfigFile.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))); + assertThat(networkArg.getValue().genesisConfig()) + .isEqualTo(GenesisConfig.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -636,8 +634,8 @@ public void defaultNetworkIdAndBootnodesForCustomNetworkOptions() throws Excepti verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any()); verify(mockControllerBuilder).build(); - assertThat(networkArg.getValue().genesisConfigFile()) - .isEqualTo(GenesisConfigFile.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))); + assertThat(networkArg.getValue().genesisConfig()) + .isEqualTo(GenesisConfig.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))); assertThat(networkArg.getValue().bootNodes()).isEmpty(); assertThat(networkArg.getValue().networkId()).isEqualTo(GENESIS_CONFIG_TEST_CHAINID); @@ -657,8 +655,8 @@ public void defaultNetworkIdForInvalidGenesisMustBeMainnetNetworkId() throws Exc verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any()); verify(mockControllerBuilder).build(); - assertThat(networkArg.getValue().genesisConfigFile()) - .isEqualTo(GenesisConfigFile.fromConfig(encodeJsonGenesis(GENESIS_INVALID_DATA))); + assertThat(networkArg.getValue().genesisConfig()) + .isEqualTo(GenesisConfig.fromConfig(encodeJsonGenesis(GENESIS_INVALID_DATA))); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -672,7 +670,7 @@ public void predefinedNetworkIdsMustBeEqualToChainIds() { // in this network genesis file. final var genesisConfig = - EthNetworkConfig.getNetworkConfig(MAINNET).genesisConfigFile().getConfigOptions(); + EthNetworkConfig.getNetworkConfig(MAINNET).genesisConfig().getConfigOptions(); assertThat(genesisConfig.getChainId().isPresent()).isTrue(); assertThat(genesisConfig.getChainId().get()) .isEqualTo(EthNetworkConfig.getNetworkConfig(MAINNET).networkId()); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java index c1428388149..c2c10ef73c7 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.verify; import org.hyperledger.besu.cli.config.EthNetworkConfig; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; @@ -128,8 +128,7 @@ public void overrideDefaultValuesIfKeyIsPresentInConfigFile(final @TempDir File final EthNetworkConfig networkConfig = new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(MAINNET)) .setNetworkId(BigInteger.valueOf(42)) - .setGenesisConfigFile( - GenesisConfigFile.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))) + .setGenesisConfig(GenesisConfig.fromConfig(encodeJsonGenesis(GENESIS_VALID_JSON))) .setBootNodes(nodes) .setDnsDiscoveryUrl(null) .build(); @@ -166,7 +165,7 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() { verify(mockRunnerBuilder) .ethNetworkConfig( new EthNetworkConfig( - GenesisConfigFile.fromResource(MAINNET.getGenesisFile()), + GenesisConfig.fromResource(MAINNET.getGenesisFile()), MAINNET.getNetworkId(), MAINNET_BOOTSTRAP_NODES, MAINNET_DISCOVERY_URL)); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java index 3af43eb4e5f..768ca09e971 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java @@ -21,7 +21,7 @@ import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_BOOTSTRAP_NODES; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_DISCOVERY_URL; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import java.math.BigInteger; @@ -77,8 +77,8 @@ public void testBuilderWithNetworkId() { EthNetworkConfig config = new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(MAINNET)) .setNetworkId(BigInteger.valueOf(42)) - .setGenesisConfigFile( - GenesisConfigFile.fromConfig( + .setGenesisConfig( + GenesisConfig.fromConfig( """ { "config":{ @@ -87,7 +87,7 @@ public void testBuilderWithNetworkId() { } """)) .build(); - assertThat(config.genesisConfigFile().getConfigOptions().getChainId()) + assertThat(config.genesisConfig().getConfigOptions().getChainId()) .contains(BigInteger.valueOf(1234567)); assertThat(config.dnsDiscoveryUrl()).isNotNull(); assertThat(config.bootNodes()).isNotEmpty(); diff --git a/besu/src/test/java/org/hyperledger/besu/components/GenesisConfigModule.java b/besu/src/test/java/org/hyperledger/besu/components/GenesisConfigModule.java index ae82b8b9288..c43d49cd8ef 100644 --- a/besu/src/test/java/org/hyperledger/besu/components/GenesisConfigModule.java +++ b/besu/src/test/java/org/hyperledger/besu/components/GenesisConfigModule.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.components; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import javax.inject.Named; @@ -26,13 +26,13 @@ public class GenesisConfigModule { @Named("default") @Provides - GenesisConfigFile provideDefaultGenesisConfigFile() { - return GenesisConfigFile.DEFAULT; + GenesisConfig provideDefaultGenesisConfig() { + return GenesisConfig.DEFAULT; } @Named("mainnet") @Provides - GenesisConfigFile provideMainnetGenesisConfigFile() { - return GenesisConfigFile.mainnet(); + GenesisConfig provideMainnetGenesisConfig() { + return GenesisConfig.mainnet(); } } diff --git a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java index 26364087492..b1cf3dd776d 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java @@ -21,7 +21,7 @@ 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.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; @@ -75,7 +75,7 @@ public abstract class AbstractBftBesuControllerBuilderTest { protected BesuControllerBuilder bftBesuControllerBuilder; - @Mock protected GenesisConfigFile genesisConfigFile; + @Mock protected GenesisConfig genesisConfig; @Mock protected GenesisConfigOptions genesisConfigOptions; @Mock private SynchronizerConfiguration synchronizerConfiguration; @Mock private EthProtocolConfiguration ethProtocolConfiguration; @@ -102,11 +102,11 @@ public void setup() throws JsonProcessingException { final WorldStateStorageCoordinator worldStateStorageCoordinator = new WorldStateStorageCoordinator(worldStateKeyValueStorage); - lenient().when(genesisConfigFile.getParentHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); - lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1)); - lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions); + lenient().when(genesisConfig.getParentHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); + lenient().when(genesisConfig.getMixHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getNonce()).thenReturn(Long.toHexString(1)); + lenient().when(genesisConfig.getConfigOptions()).thenReturn(genesisConfigOptions); lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions); lenient() .when(storageProvider.createBlockchainStorage(any(), any(), any())) @@ -139,11 +139,11 @@ public void setup() throws JsonProcessingException { .when(synchronizerConfiguration.getBlockPropagationRange()) .thenReturn(Range.closed(1L, 2L)); - setupBftGenesisConfigFile(); + setupBftGenesisConfig(); bftBesuControllerBuilder = createBftControllerBuilder() - .genesisConfigFile(genesisConfigFile) + .genesisConfig(genesisConfig) .synchronizerConfiguration(synchronizerConfiguration) .ethProtocolConfiguration(ethProtocolConfiguration) .networkId(networkId) @@ -163,7 +163,7 @@ public void setup() throws JsonProcessingException { .apiConfiguration(ImmutableApiConfiguration.builder().build()); } - protected abstract void setupBftGenesisConfigFile() throws JsonProcessingException; + protected abstract void setupBftGenesisConfig() throws JsonProcessingException; protected abstract BesuControllerBuilder createBftControllerBuilder(); diff --git a/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerTest.java b/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerTest.java index 94c68f7cbe2..1f6927ca995 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.QbftConfigOptions; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -39,20 +39,20 @@ @ExtendWith(MockitoExtension.class) public class BesuControllerTest { - @Mock GenesisConfigFile genesisConfigFile; + @Mock GenesisConfig genesisConfig; @Mock GenesisConfigOptions genesisConfigOptions; @Mock QbftConfigOptions qbftConfigOptions; @BeforeEach public void setUp() { - lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions); + lenient().when(genesisConfig.getConfigOptions()).thenReturn(genesisConfigOptions); } @Test public void missingQbftStartBlock() { mockGenesisConfigForMigration("ibft2", OptionalLong.empty()); assertThatThrownBy( - () -> new BesuController.Builder().fromGenesisFile(genesisConfigFile, SyncMode.FULL)) + () -> new BesuController.Builder().fromGenesisFile(genesisConfig, SyncMode.FULL)) .isInstanceOf(IllegalStateException.class) .hasMessage("Missing QBFT startBlock config in genesis file"); } @@ -61,7 +61,7 @@ public void missingQbftStartBlock() { public void invalidQbftStartBlock() { mockGenesisConfigForMigration("ibft2", OptionalLong.of(-1L)); assertThatThrownBy( - () -> new BesuController.Builder().fromGenesisFile(genesisConfigFile, SyncMode.FULL)) + () -> new BesuController.Builder().fromGenesisFile(genesisConfig, SyncMode.FULL)) .isInstanceOf(IllegalStateException.class) .hasMessage("Invalid QBFT startBlock config in genesis file"); } @@ -72,7 +72,7 @@ public void invalidConsensusCombination() { // explicitly not setting isIbft2() for genesisConfigOptions assertThatThrownBy( - () -> new BesuController.Builder().fromGenesisFile(genesisConfigFile, SyncMode.FULL)) + () -> new BesuController.Builder().fromGenesisFile(genesisConfig, SyncMode.FULL)) .isInstanceOf(IllegalStateException.class) .hasMessage( "Invalid genesis migration config. Migration is supported from IBFT (legacy) or IBFT2 to QBFT)"); @@ -84,7 +84,7 @@ public void createConsensusScheduleBesuControllerBuilderWhenMigratingFromIbft2To mockGenesisConfigForMigration("ibft2", OptionalLong.of(qbftStartBlock)); final BesuControllerBuilder besuControllerBuilder = - new BesuController.Builder().fromGenesisFile(genesisConfigFile, SyncMode.FULL); + new BesuController.Builder().fromGenesisFile(genesisConfig, SyncMode.FULL); assertThat(besuControllerBuilder).isInstanceOf(ConsensusScheduleBesuControllerBuilder.class); @@ -118,8 +118,8 @@ private void mockGenesisConfigForMigration( @Test public void postMergeCheckpointSyncUsesMergeControllerBuilder() { - final GenesisConfigFile postMergeGenesisFile = - GenesisConfigFile.fromResource("/valid_post_merge_near_head_checkpoint.json"); + final GenesisConfig postMergeGenesisFile = + GenesisConfig.fromResource("/valid_post_merge_near_head_checkpoint.json"); final BesuControllerBuilder besuControllerBuilder = new BesuController.Builder().fromGenesisFile(postMergeGenesisFile, SyncMode.CHECKPOINT); @@ -130,8 +130,8 @@ public void postMergeCheckpointSyncUsesMergeControllerBuilder() { @Test public void postMergeCheckpointSyncWithTotalDifficultyEqualsTTDUsesTransitionControllerBuilder() throws IOException { - final GenesisConfigFile mergeAtGenesisFile = - GenesisConfigFile.fromResource( + final GenesisConfig mergeAtGenesisFile = + GenesisConfig.fromResource( "/invalid_post_merge_checkpoint_total_difficulty_same_as_TTD.json"); final BesuControllerBuilder besuControllerBuilder = @@ -143,8 +143,7 @@ public void postMergeCheckpointSyncWithTotalDifficultyEqualsTTDUsesTransitionCon @Test public void preMergeCheckpointSyncUsesTransitionControllerBuilder() { final BesuControllerBuilder besuControllerBuilder = - new BesuController.Builder() - .fromGenesisFile(GenesisConfigFile.mainnet(), SyncMode.CHECKPOINT); + new BesuController.Builder().fromGenesisFile(GenesisConfig.mainnet(), SyncMode.CHECKPOINT); assertThat(besuControllerBuilder).isInstanceOf(TransitionBesuControllerBuilder.class); } @@ -152,7 +151,7 @@ public void preMergeCheckpointSyncUsesTransitionControllerBuilder() { @Test public void nonCheckpointSyncUsesTransitionControllerBuild() { final BesuControllerBuilder besuControllerBuilder = - new BesuController.Builder().fromGenesisFile(GenesisConfigFile.mainnet(), SyncMode.SNAP); + new BesuController.Builder().fromGenesisFile(GenesisConfig.mainnet(), SyncMode.SNAP); assertThat(besuControllerBuilder).isInstanceOf(TransitionBesuControllerBuilder.class); } diff --git a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java index f05ea666a0d..b9c919d18f0 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java @@ -22,7 +22,7 @@ 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.ImmutableCliqueConfigOptions; import org.hyperledger.besu.config.TransitionsConfigOptions; @@ -80,7 +80,7 @@ public class CliqueBesuControllerBuilderTest { private BesuControllerBuilder cliqueBesuControllerBuilder; - @Mock private GenesisConfigFile genesisConfigFile; + @Mock private GenesisConfig genesisConfig; @Mock private GenesisConfigOptions genesisConfigOptions; @Mock private SynchronizerConfiguration synchronizerConfiguration; @Mock private EthProtocolConfiguration ethProtocolConfiguration; @@ -108,14 +108,14 @@ public void setup() throws JsonProcessingException { final WorldStateStorageCoordinator worldStateStorageCoordinator = new WorldStateStorageCoordinator(worldStateKeyValueStorage); - lenient().when(genesisConfigFile.getParentHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); - when(genesisConfigFile.getExtraData()) + lenient().when(genesisConfig.getParentHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); + when(genesisConfig.getExtraData()) .thenReturn( "0x0000000000000000000000000000000000000000000000000000000000000000b9b81ee349c3807e46bc71aa2632203c5b4620340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1)); - lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions); + lenient().when(genesisConfig.getMixHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getNonce()).thenReturn(Long.toHexString(1)); + lenient().when(genesisConfig.getConfigOptions()).thenReturn(genesisConfigOptions); lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions); lenient() .when(storageProvider.createBlockchainStorage(any(), any(), any())) @@ -176,7 +176,7 @@ public void setup() throws JsonProcessingException { cliqueBesuControllerBuilder = new CliqueBesuControllerBuilder() - .genesisConfigFile(genesisConfigFile) + .genesisConfig(genesisConfig) .synchronizerConfiguration(synchronizerConfiguration) .ethProtocolConfiguration(ethProtocolConfiguration) .networkId(networkId) diff --git a/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java index 4e38e03c062..4a4ae8530e3 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.consensus.common.ForkSpec; import org.hyperledger.besu.consensus.common.ForksSchedule; @@ -60,7 +60,7 @@ public class ConsensusScheduleBesuControllerBuilderTest { private @Mock BiFunction< NavigableSet>, Optional, ProtocolSchedule> combinedProtocolScheduleFactory; - private @Mock GenesisConfigFile genesisConfigFile; + private @Mock GenesisConfig genesisConfig; private @Mock BesuControllerBuilder besuControllerBuilder1; private @Mock BesuControllerBuilder besuControllerBuilder2; private @Mock BesuControllerBuilder besuControllerBuilder3; @@ -103,8 +103,8 @@ public void mustCreateCombinedProtocolScheduleUsingProtocolSchedulesOrderedByBlo final ConsensusScheduleBesuControllerBuilder consensusScheduleBesuControllerBuilder = new ConsensusScheduleBesuControllerBuilder( besuControllerBuilderSchedule, combinedProtocolScheduleFactory); - when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions); - consensusScheduleBesuControllerBuilder.genesisConfigFile(genesisConfigFile); + when(genesisConfig.getConfigOptions()).thenReturn(genesisConfigOptions); + consensusScheduleBesuControllerBuilder.genesisConfig(genesisConfig); consensusScheduleBesuControllerBuilder.createProtocolSchedule(); final NavigableSet> expectedProtocolSchedulesSpecs = diff --git a/besu/src/test/java/org/hyperledger/besu/controller/IbftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/IbftBesuControllerBuilderTest.java index 055e136c8ca..1a2f45eac8b 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/IbftBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/IbftBesuControllerBuilderTest.java @@ -33,7 +33,7 @@ public class IbftBesuControllerBuilderTest extends AbstractBftBesuControllerBuilderTest { @Override - public void setupBftGenesisConfigFile() throws JsonProcessingException { + public void setupBftGenesisConfig() throws JsonProcessingException { // Ibft prepForBuild setup lenient() @@ -56,7 +56,7 @@ public void setupBftGenesisConfigFile() throws JsonProcessingException { .when(genesisConfigOptions.getTransitions()) .thenReturn(new TransitionsConfigOptions(jsonTransitions)); - when(genesisConfigFile.getExtraData()) + when(genesisConfig.getExtraData()) .thenReturn( "0xf83ea00000000000000000000000000000000000000000000000000000000000000000d594c2ab482b506de561668e07f04547232a72897daf808400000000c0"); } diff --git a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java index 7c4a370beb0..ce2dab822ff 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java @@ -25,7 +25,7 @@ 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.consensus.merge.MergeContext; import org.hyperledger.besu.cryptoservices.NodeKey; @@ -89,7 +89,7 @@ public class MergeBesuControllerBuilderTest { private MergeBesuControllerBuilder besuControllerBuilder; private static final NodeKey nodeKey = NodeKeyUtils.generate(); - @Mock GenesisConfigFile genesisConfigFile; + @Mock GenesisConfig genesisConfig; @Mock GenesisConfigOptions genesisConfigOptions; @Mock SynchronizerConfiguration synchronizerConfiguration; @Mock EthProtocolConfiguration ethProtocolConfiguration; @@ -121,12 +121,12 @@ public void setup() { final WorldStateStorageCoordinator worldStateStorageCoordinator = new WorldStateStorageCoordinator(worldStateKeyValueStorage); - lenient().when(genesisConfigFile.getParentHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); - lenient().when(genesisConfigFile.getExtraData()).thenReturn(Bytes.EMPTY.toHexString()); - lenient().when(genesisConfigFile.getMixHash()).thenReturn(Hash.ZERO.toHexString()); - lenient().when(genesisConfigFile.getNonce()).thenReturn(Long.toHexString(1)); - lenient().when(genesisConfigFile.getConfigOptions()).thenReturn(genesisConfigOptions); + lenient().when(genesisConfig.getParentHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getDifficulty()).thenReturn(Bytes.of(0).toHexString()); + lenient().when(genesisConfig.getExtraData()).thenReturn(Bytes.EMPTY.toHexString()); + lenient().when(genesisConfig.getMixHash()).thenReturn(Hash.ZERO.toHexString()); + lenient().when(genesisConfig.getNonce()).thenReturn(Long.toHexString(1)); + lenient().when(genesisConfig.getConfigOptions()).thenReturn(genesisConfigOptions); lenient().when(genesisConfigOptions.getCheckpointOptions()).thenReturn(checkpointConfigOptions); when(genesisConfigOptions.getTerminalTotalDifficulty()) .thenReturn((Optional.of(UInt256.valueOf(100L)))); @@ -177,7 +177,7 @@ MergeBesuControllerBuilder visitWithMockConfigs(final MergeBesuControllerBuilder return (MergeBesuControllerBuilder) builder .gasLimitCalculator(gasLimitCalculator) - .genesisConfigFile(genesisConfigFile) + .genesisConfig(genesisConfig) .synchronizerConfiguration(synchronizerConfiguration) .ethProtocolConfiguration(ethProtocolConfiguration) .miningParameters(miningConfiguration) @@ -227,8 +227,7 @@ public void assertConfiguredBlock() { @Test public void assertBuiltContextMonitorsTTD() { final GenesisState genesisState = - GenesisState.fromConfig( - genesisConfigFile, this.besuControllerBuilder.createProtocolSchedule()); + GenesisState.fromConfig(genesisConfig, this.besuControllerBuilder.createProtocolSchedule()); final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); final MergeContext mergeContext = spy( diff --git a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java index a448b11f406..c00a9160ca2 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java @@ -47,7 +47,7 @@ public class QbftBesuControllerBuilderTest extends AbstractBftBesuControllerBuilderTest { @Override - public void setupBftGenesisConfigFile() throws JsonProcessingException { + public void setupBftGenesisConfig() throws JsonProcessingException { // qbft prepForBuild setup lenient() @@ -71,7 +71,7 @@ public void setupBftGenesisConfigFile() throws JsonProcessingException { .thenReturn(new TransitionsConfigOptions(jsonTransitions)); lenient() - .when(genesisConfigFile.getExtraData()) + .when(genesisConfig.getExtraData()) .thenReturn( QbftExtraDataCodec.createGenesisExtraDataString(List.of(Address.fromHexString("1")))); } diff --git a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java index da409482e03..dc8eee16eb5 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.consensus.clique.BlockHeaderValidationRulesetFactory; import org.hyperledger.besu.consensus.clique.CliqueContext; import org.hyperledger.besu.consensus.common.EpochManager; @@ -98,9 +98,9 @@ public void setup() { preMergeProtocolSchedule, postMergeProtocolSchedule, mergeContext)); transitionProtocolSchedule.setProtocolContext(protocolContext); cliqueBuilder.nodeKey(NodeKeyUtils.generate()); - cliqueBuilder.genesisConfigFile(GenesisConfigFile.DEFAULT); - powBuilder.genesisConfigFile(GenesisConfigFile.DEFAULT); - postMergeBuilder.genesisConfigFile(GenesisConfigFile.DEFAULT); + cliqueBuilder.genesisConfig(GenesisConfig.DEFAULT); + powBuilder.genesisConfig(GenesisConfig.DEFAULT); + postMergeBuilder.genesisConfig(GenesisConfig.DEFAULT); postMergeBuilder.storageProvider(storageProvider); lenient().when(protocolContext.getBlockchain()).thenReturn(mockBlockchain); lenient() @@ -267,7 +267,7 @@ void assertDetachedRulesForPostMergeBlocks(final BlockHeaderValidator validator) TransitionCoordinator buildTransitionCoordinator( final BesuControllerBuilder preMerge, final MergeBesuControllerBuilder postMerge) { var builder = new TransitionBesuControllerBuilder(preMerge, postMerge); - builder.genesisConfigFile(GenesisConfigFile.mainnet()); + builder.genesisConfig(GenesisConfig.mainnet()); builder.storageProvider(storageProvider); builder.metricsSystem(new NoOpMetricsSystem()); var coordinator = diff --git a/besu/src/test/java/org/hyperledger/besu/util/EphemeryGenesisUpdaterTest.java b/besu/src/test/java/org/hyperledger/besu/util/EphemeryGenesisUpdaterTest.java index fe21c1e6d72..704f26f8e87 100644 --- a/besu/src/test/java/org/hyperledger/besu/util/EphemeryGenesisUpdaterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/util/EphemeryGenesisUpdaterTest.java @@ -16,9 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.hyperledger.besu.config.GenesisConfigFile.fromConfig; +import static org.hyperledger.besu.config.GenesisConfig.fromConfig; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import java.math.BigInteger; import java.util.Map; @@ -44,7 +44,7 @@ public class EphemeryGenesisUpdaterTest { .put("config", (new JsonObject()).put("chainId", GENESIS_CONFIG_TEST_CHAINID)) .put("timestamp", GENESIS_TEST_TIMESTAMP); - private static final GenesisConfigFile INVALID_GENESIS_JSON = fromConfig("{}"); + private static final GenesisConfig INVALID_GENESIS_JSON = fromConfig("{}"); private static final JsonObject INVALID_GENESIS_JSON_WITHOUT_CHAINID = (new JsonObject()).put("timestamp", GENESIS_TEST_TIMESTAMP); @@ -54,16 +54,16 @@ public class EphemeryGenesisUpdaterTest { @Test public void testEphemeryWhenChainIdIsAbsent() { - final GenesisConfigFile config = - GenesisConfigFile.fromConfig(INVALID_GENESIS_JSON_WITHOUT_CHAINID.toString()); + final GenesisConfig config = + GenesisConfig.fromConfig(INVALID_GENESIS_JSON_WITHOUT_CHAINID.toString()); Optional chainId = config.getConfigOptions().getChainId(); assertThat(chainId).isNotPresent(); } @Test public void testShouldDefaultTimestampToZero() { - final GenesisConfigFile config = - GenesisConfigFile.fromConfig(INVALID_GENESIS_JSON_WITHOUT_TIMESTAMP.toString()); + final GenesisConfig config = + GenesisConfig.fromConfig(INVALID_GENESIS_JSON_WITHOUT_TIMESTAMP.toString()); assertThat(config.getTimestamp()).isZero(); } @@ -76,7 +76,7 @@ public void testEphemeryWhenGenesisJsonIsInvalid() { @Test public void testEphemeryWhenGenesisJsonIsValid() { - final GenesisConfigFile config = GenesisConfigFile.fromConfig(VALID_GENESIS_JSON.toString()); + final GenesisConfig config = GenesisConfig.fromConfig(VALID_GENESIS_JSON.toString()); assertThat(String.valueOf(config.getTimestamp())) .isEqualTo(String.valueOf(GENESIS_TEST_TIMESTAMP)); assertThat(config.getConfigOptions().getChainId()) @@ -87,7 +87,7 @@ public void testEphemeryWhenGenesisJsonIsValid() { @Test public void testEphemeryNotYetDueForUpdate() { - final GenesisConfigFile config = GenesisConfigFile.fromConfig(VALID_GENESIS_JSON.toString()); + final GenesisConfig config = GenesisConfig.fromConfig(VALID_GENESIS_JSON.toString()); assertThat(EARLIER_TIMESTAMP).isLessThan(config.getTimestamp() + PERIOD_IN_SECONDS); } @@ -100,7 +100,7 @@ void testOverrideWithUpdatedChainIdAndTimeStamp() { long expectedGenesisTimestamp = GENESIS_TEST_TIMESTAMP + (PERIOD_SINCE_GENESIS * PERIOD_IN_SECONDS); - final GenesisConfigFile config = GenesisConfigFile.fromResource("/ephemery.json"); + final GenesisConfig config = GenesisConfig.fromResource("/ephemery.json"); final Map override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); override.put("chainId", String.valueOf(expectedChainId)); @@ -116,7 +116,7 @@ void testOverrideWithUpdatedChainIdAndTimeStamp() { @Test public void testEphemeryWhenSuccessful() { - final GenesisConfigFile config = GenesisConfigFile.fromConfig(VALID_GENESIS_JSON.toString()); + final GenesisConfig config = GenesisConfig.fromConfig(VALID_GENESIS_JSON.toString()); BigInteger expectedChainId = BigInteger.valueOf(GENESIS_CONFIG_TEST_CHAINID) @@ -127,7 +127,7 @@ public void testEphemeryWhenSuccessful() { final Map override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); override.put("chainId", String.valueOf(expectedChainId)); override.put("timestamp", String.valueOf(expectedGenesisTimestamp)); - final GenesisConfigFile updatedConfig = config.withOverrides(override); + final GenesisConfig updatedConfig = config.withOverrides(override); assertThat(LATER_TIMESTAMP) .isGreaterThan(Long.parseLong(String.valueOf(GENESIS_TEST_TIMESTAMP + PERIOD_IN_SECONDS))); diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfig.java similarity index 89% rename from config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java rename to config/src/main/java/org/hyperledger/besu/config/GenesisConfig.java index 84c81a7f083..47fa2967451 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfig.java @@ -29,11 +29,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode; /** The Genesis config file. */ -public class GenesisConfigFile { +public class GenesisConfig { /** The constant DEFAULT. */ - public static final GenesisConfigFile DEFAULT = - new GenesisConfigFile(new GenesisReader.FromObjectNode(JsonUtil.createEmptyObjectNode())); + public static final GenesisConfig DEFAULT = + new GenesisConfig(new GenesisReader.FromObjectNode(JsonUtil.createEmptyObjectNode())); /** The constant BASEFEE_AT_GENESIS_DEFAULT_VALUE. */ public static final Wei BASEFEE_AT_GENESIS_DEFAULT_VALUE = Wei.of(1_000_000_000L); @@ -42,7 +42,7 @@ public class GenesisConfigFile { private final ObjectNode genesisRoot; private Map overrides; - private GenesisConfigFile(final GenesisReader loader) { + private GenesisConfig(final GenesisReader loader) { this.loader = loader; this.genesisRoot = loader.getRoot(); } @@ -52,8 +52,8 @@ private GenesisConfigFile(final GenesisReader loader) { * * @return the genesis config file */ - public static GenesisConfigFile mainnet() { - return fromSource(GenesisConfigFile.class.getResource("/mainnet.json")); + public static GenesisConfig mainnet() { + return fromSource(GenesisConfig.class.getResource("/mainnet.json")); } /** @@ -62,7 +62,7 @@ public static GenesisConfigFile mainnet() { * @param jsonSource the URL * @return the genesis config file */ - public static GenesisConfigFile fromSource(final URL jsonSource) { + public static GenesisConfig fromSource(final URL jsonSource) { return fromConfig(JsonUtil.objectNodeFromURL(jsonSource, false)); } @@ -72,8 +72,8 @@ public static GenesisConfigFile fromSource(final URL jsonSource) { * @param resourceName the resource name * @return the genesis config file */ - public static GenesisConfigFile fromResource(final String resourceName) { - return fromConfig(GenesisConfigFile.class.getResource(resourceName)); + public static GenesisConfig fromResource(final String resourceName) { + return fromConfig(GenesisConfig.class.getResource(resourceName)); } /** @@ -82,8 +82,8 @@ public static GenesisConfigFile fromResource(final String resourceName) { * @param jsonSource the json string * @return the genesis config file */ - public static GenesisConfigFile fromConfig(final URL jsonSource) { - return new GenesisConfigFile(new GenesisReader.FromURL(jsonSource)); + public static GenesisConfig fromConfig(final URL jsonSource) { + return new GenesisConfig(new GenesisReader.FromURL(jsonSource)); } /** @@ -92,7 +92,7 @@ public static GenesisConfigFile fromConfig(final URL jsonSource) { * @param json the json string * @return the genesis config file */ - public static GenesisConfigFile fromConfig(final String json) { + public static GenesisConfig fromConfig(final String json) { return fromConfig(JsonUtil.objectNodeFromString(json, false)); } @@ -102,8 +102,8 @@ public static GenesisConfigFile fromConfig(final String json) { * @param config the config * @return the genesis config file */ - public static GenesisConfigFile fromConfig(final ObjectNode config) { - return new GenesisConfigFile(new GenesisReader.FromObjectNode(config)); + public static GenesisConfig fromConfig(final ObjectNode config) { + return new GenesisConfig(new GenesisReader.FromObjectNode(config)); } /** @@ -137,7 +137,7 @@ public GenesisConfigOptions getConfigOptions() { * @param overrides the overrides * @return the config options */ - public GenesisConfigFile withOverrides(final Map overrides) { + public GenesisConfig withOverrides(final Map overrides) { this.overrides = overrides; return this; @@ -350,7 +350,7 @@ public List getForkTimestamps() { public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final GenesisConfigFile that = (GenesisConfigFile) o; + final GenesisConfig that = (GenesisConfig) o; return Objects.equals(genesisRoot, that.genesisRoot); } diff --git a/config/src/test/java/org/hyperledger/besu/config/CliqueConfigOptionsTest.java b/config/src/test/java/org/hyperledger/besu/config/CliqueConfigOptionsTest.java index f445730ac18..c8fb01b6a1c 100644 --- a/config/src/test/java/org/hyperledger/besu/config/CliqueConfigOptionsTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/CliqueConfigOptionsTest.java @@ -78,6 +78,6 @@ private CliqueConfigOptions fromConfigOptions(final Map cliqueCo final ObjectNode options = JsonUtil.objectNodeFromMap(cliqueConfigOptions); configNode.set("clique", options); rootNode.set("config", configNode); - return GenesisConfigFile.fromConfig(rootNode).getConfigOptions().getCliqueConfigOptions(); + return GenesisConfig.fromConfig(rootNode).getConfigOptions().getCliqueConfigOptions(); } } diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java index fe8149cc654..9b09362851f 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java @@ -260,7 +260,7 @@ void shouldGetChainIdWhenSpecified() { @Test void shouldSupportEmptyGenesisConfig() { - final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig("{}").getConfigOptions(); assertThat(config.isEthHash()).isFalse(); assertThat(config.isClique()).isFalse(); assertThat(config.isPoa()).isFalse(); @@ -291,7 +291,7 @@ void shouldNotReturnTerminalTotalDifficultyWhenNotSpecified() { @Test void isZeroBaseFeeShouldDefaultToFalse() { - final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig("{}").getConfigOptions(); assertThat(config.isZeroBaseFee()).isFalse(); } @@ -312,7 +312,7 @@ void asMapIncludesZeroBaseFee() { @Test void isFixedBaseFeeShouldDefaultToFalse() { - final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig("{}").getConfigOptions(); assertThat(config.isFixedBaseFee()).isFalse(); } @@ -412,6 +412,6 @@ private GenesisConfigOptions fromConfigOptions(final Map configO final ObjectNode rootNode = JsonUtil.createEmptyObjectNode(); final ObjectNode options = JsonUtil.objectNodeFromMap(configOptions); rootNode.set("config", options); - return GenesisConfigFile.fromConfig(rootNode).getConfigOptions(); + return GenesisConfig.fromConfig(rootNode).getConfigOptions(); } } diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigTest.java similarity index 89% rename from config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java rename to config/src/test/java/org/hyperledger/besu/config/GenesisConfigTest.java index 3e6b488b9bd..33ff2eb0a36 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.hyperledger.besu.config.GenesisConfigFile.fromConfig; +import static org.hyperledger.besu.config.GenesisConfig.fromConfig; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; @@ -39,15 +39,15 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.Test; -class GenesisConfigFileTest { +class GenesisConfigTest { private static final BigInteger MAINNET_CHAIN_ID = BigInteger.ONE; private static final BigInteger DEVELOPMENT_CHAIN_ID = BigInteger.valueOf(1337); - private static final GenesisConfigFile EMPTY_CONFIG = fromConfig("{}"); + private static final GenesisConfig EMPTY_CONFIG = fromConfig("{}"); @Test void shouldLoadMainnetConfigFile() { - final GenesisConfigFile config = GenesisConfigFile.mainnet(); + final GenesisConfig config = GenesisConfig.mainnet(); // Sanity check some basic properties to confirm this is the mainnet file. assertThat(config.getConfigOptions().isEthHash()).isTrue(); assertThat(config.getConfigOptions().getChainId()).hasValue(MAINNET_CHAIN_ID); @@ -64,7 +64,7 @@ void shouldLoadMainnetConfigFile() { @Test void shouldLoadDevelopmentConfigFile() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); // Sanity check some basic properties to confirm this is the dev file. assertThat(config.getConfigOptions().isEthHash()).isTrue(); assertThat(config.getConfigOptions().getChainId()).hasValue(DEVELOPMENT_CHAIN_ID); @@ -156,27 +156,27 @@ void shouldGetTimestamp() { @Test void shouldGetBaseFeeAtGenesis() { - GenesisConfigFile withBaseFeeAtGenesis = - GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0},\"baseFeePerGas\":\"0xa\"}"); + GenesisConfig withBaseFeeAtGenesis = + GenesisConfig.fromConfig("{\"config\":{\"londonBlock\":0},\"baseFeePerGas\":\"0xa\"}"); assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isPresent(); assertThat(withBaseFeeAtGenesis.getBaseFeePerGas().get().toLong()).isEqualTo(10L); } @Test void shouldGetDefaultBaseFeeAtGenesis() { - GenesisConfigFile withBaseFeeAtGenesis = - GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0}}"); + GenesisConfig withBaseFeeAtGenesis = + GenesisConfig.fromConfig("{\"config\":{\"londonBlock\":0}}"); // no specified baseFeePerGas: assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isNotPresent(); // supply a default genesis baseFeePerGas when london-at-genesis: assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas()) - .contains(GenesisConfigFile.BASEFEE_AT_GENESIS_DEFAULT_VALUE); + .contains(GenesisConfig.BASEFEE_AT_GENESIS_DEFAULT_VALUE); } @Test void shouldGetBaseFeeExplicitlyAtGenesis() { - GenesisConfigFile withBaseFeeNotAtGenesis = - GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":10},\"baseFeePerGas\":\"0xa\"}"); + GenesisConfig withBaseFeeNotAtGenesis = + GenesisConfig.fromConfig("{\"config\":{\"londonBlock\":10},\"baseFeePerGas\":\"0xa\"}"); // specified baseFeePerGas: Wei expectedBaseFee = Wei.of(0xa); assertThat(withBaseFeeNotAtGenesis.getBaseFeePerGas()).contains(expectedBaseFee); @@ -195,7 +195,7 @@ void shouldOverrideConfigOptionsBaseFeeWhenSpecified() { @Test void shouldGetTerminalTotalDifficultyAtGenesis() { - GenesisConfigFile withTerminalTotalDifficultyAtGenesis = + GenesisConfig withTerminalTotalDifficultyAtGenesis = fromConfig("{\"config\":{\"terminalTotalDifficulty\":1000}}"); assertThat(withTerminalTotalDifficultyAtGenesis.getConfigOptions().getTerminalTotalDifficulty()) .contains(UInt256.valueOf(1000L)); @@ -209,7 +209,7 @@ void shouldGetEmptyTerminalTotalDifficultyAtGenesis() { @Test void assertSepoliaTerminalTotalDifficulty() { GenesisConfigOptions sepoliaOptions = - GenesisConfigFile.fromResource("/sepolia.json").getConfigOptions(); + GenesisConfig.fromResource("/sepolia.json").getConfigOptions(); assertThat(sepoliaOptions.getTerminalTotalDifficulty()).isPresent(); assertThat(sepoliaOptions.getTerminalTotalDifficulty()) @@ -219,7 +219,7 @@ void assertSepoliaTerminalTotalDifficulty() { @Test void assertMainnetTerminalTotalDifficulty() { GenesisConfigOptions mainnetOptions = - GenesisConfigFile.fromResource("/mainnet.json").getConfigOptions(); + GenesisConfig.fromResource("/mainnet.json").getConfigOptions(); assertThat(mainnetOptions.getTerminalTotalDifficulty()).isPresent(); // tentative as of 2022-08-11: @@ -230,7 +230,7 @@ void assertMainnetTerminalTotalDifficulty() { @Test void assertTerminalTotalDifficultyOverride() { GenesisConfigOptions sepoliaOverrideOptions = - GenesisConfigFile.fromResource("/sepolia.json") + GenesisConfig.fromResource("/sepolia.json") .withOverrides(Map.of("terminalTotalDifficulty", String.valueOf(Long.MAX_VALUE))) .getConfigOptions(); @@ -241,8 +241,8 @@ void assertTerminalTotalDifficultyOverride() { @Test void shouldFindMergeNetSplitForkAndAlias() { - GenesisConfigFile mergeNetSplitGenesis = - GenesisConfigFile.fromConfig( + GenesisConfig mergeNetSplitGenesis = + GenesisConfig.fromConfig( "{\"config\":{\"mergeNetsplitBlock\":11},\"baseFeePerGas\":\"0xa\"}"); assertThat(mergeNetSplitGenesis.getForkBlockNumbers()).hasSize(1); assertThat(mergeNetSplitGenesis.getConfigOptions().getMergeNetSplitBlockNumber()).isPresent(); @@ -250,8 +250,8 @@ void shouldFindMergeNetSplitForkAndAlias() { .isEqualTo(11L); // assert empty if not present: - GenesisConfigFile londonGenesis = - GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":11},\"baseFeePerGas\":\"0xa\"}"); + GenesisConfig londonGenesis = + GenesisConfig.fromConfig("{\"config\":{\"londonBlock\":11},\"baseFeePerGas\":\"0xa\"}"); assertThat(londonGenesis.getForkBlockNumbers()).hasSize(1); assertThat(londonGenesis.getConfigOptions().getMergeNetSplitBlockNumber()).isEmpty(); } @@ -263,7 +263,7 @@ void shouldDefaultTimestampToZero() { @Test void shouldGetAllocations() { - final GenesisConfigFile config = + final GenesisConfig config = fromConfig( "{" + " \"alloc\": {" @@ -322,13 +322,13 @@ void shouldGetAllocations() { @Test void shouldGetEmptyAllocationsWhenAllocNotPresent() { - final GenesisConfigFile config = fromConfig("{}"); + final GenesisConfig config = fromConfig("{}"); assertThat(config.streamAllocations()).isEmpty(); } @Test void shouldGetLargeChainId() { - final GenesisConfigFile config = + final GenesisConfig config = fromConfig( "{\"config\": { \"chainId\": 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095 }}"); assertThat(config.getConfigOptions().getChainId()) @@ -349,7 +349,7 @@ void mustNotAcceptComments() { @Test void testOverridePresent() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); final int bigBlock = 999_999_999; final String bigBlockString = Integer.toString(bigBlock); final Map override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); @@ -368,7 +368,7 @@ void testOverridePresent() { @Test void testOverrideNull() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); final Map override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); override.put("istanbulBlock", null); override.put("chainId", null); @@ -384,7 +384,7 @@ void testOverrideNull() { @Test void testOverrideCaseInsensitivity() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); final int bigBlock = 999_999_999; final String bigBlockString = Integer.toString(bigBlock); final Map override = new HashMap<>(); @@ -405,7 +405,7 @@ void testOverrideCaseInsensitivity() { @Test void testOverrideEmptyString() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); final Map override = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); override.put("istanbulBlock", ""); override.put("chainId", ""); @@ -420,7 +420,7 @@ void testOverrideEmptyString() { @Test void testNoOverride() { - final GenesisConfigFile config = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig config = GenesisConfig.fromResource("/dev.json"); assertThat(config.getConfigOptions().getLondonBlockNumber()).hasValue(0); assertThat(config.getConfigOptions().getIstanbulBlockNumber()).isNotPresent(); @@ -433,7 +433,7 @@ void testNoOverride() { @Test void testConstantinopleFixShouldNotBeSupportedAlongPetersburg() { // petersburg node - final GenesisConfigFile config = GenesisConfigFile.fromResource("/all_forks.json"); + final GenesisConfig config = GenesisConfig.fromResource("/all_forks.json"); assertThat(config.getConfigOptions().getPetersburgBlockNumber()).hasValue(7); @@ -463,7 +463,7 @@ void shouldLoadForksInSortedOrder() throws IOException { "valid_config_with_custom_forks.json"), StandardCharsets.UTF_8))); - final GenesisConfigFile config = fromConfig(configNode); + final GenesisConfig config = fromConfig(configNode); assertThat(config.getForkBlockNumbers()).containsExactly(1L, 2L, 3L, 1035301L, 2222222L); assertThat(config.getConfigOptions().getChainId()).hasValue(BigInteger.valueOf(4)); @@ -483,7 +483,7 @@ void shouldLoadForksIgnoreClassicForkBlock() throws IOException { // declared (which we want to ignore) "valid_config_with_etc_forks.json"), StandardCharsets.UTF_8))); - final GenesisConfigFile config = fromConfig(configNode); + final GenesisConfig config = fromConfig(configNode); assertThat(config.getForkBlockNumbers()).containsExactly(1L, 2L, 3L, 1035301L); assertThat(config.getConfigOptions().getChainId()).hasValue(BigInteger.valueOf(61)); @@ -528,9 +528,9 @@ void shouldLoadForksIgnoreUnexpectedValues() throws IOException { "valid_config_with_unexpected_forks.json"), StandardCharsets.UTF_8))); - final GenesisConfigFile configFileNoUnexpectedForks = fromConfig(configNoUnexpectedForks); - final GenesisConfigFile configFileClassicFork = fromConfig(configClassicFork); - final GenesisConfigFile configFileMultipleUnexpectedForks = + final GenesisConfig configFileNoUnexpectedForks = fromConfig(configNoUnexpectedForks); + final GenesisConfig configFileClassicFork = fromConfig(configClassicFork); + final GenesisConfig configFileMultipleUnexpectedForks = fromConfig(configMultipleUnexpectedForks); assertThat(configFileNoUnexpectedForks.getForkBlockNumbers()) @@ -559,7 +559,7 @@ void roundTripForkIdBlocks() throws IOException { Resources.toString(Resources.getResource("all_forks.json"), StandardCharsets.UTF_8); final ObjectNode genesisNode = JsonUtil.objectNodeFromString(configText); - final GenesisConfigFile genesisConfig = fromConfig(genesisNode); + final GenesisConfig genesisConfig = fromConfig(genesisNode); final ObjectNode output = JsonUtil.objectNodeFromMap(genesisConfig.getConfigOptions().asMap()); @@ -567,7 +567,7 @@ void roundTripForkIdBlocks() throws IOException { .isEqualTo(JsonUtil.getJson(genesisNode.get("config"), true)); } - private GenesisConfigFile configWithProperty(final String key, final String value) { + private GenesisConfig configWithProperty(final String key, final String value) { return fromConfig("{\"" + key + "\":\"" + value + "\"}"); } diff --git a/config/src/test/java/org/hyperledger/besu/config/JsonBftConfigOptionsTest.java b/config/src/test/java/org/hyperledger/besu/config/JsonBftConfigOptionsTest.java index bbb4c4a6ceb..5a81108f0c8 100644 --- a/config/src/test/java/org/hyperledger/besu/config/JsonBftConfigOptionsTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/JsonBftConfigOptionsTest.java @@ -254,6 +254,6 @@ private BftConfigOptions fromConfigOptions(final Map ibftConfigO final ObjectNode options = JsonUtil.objectNodeFromMap(ibftConfigOptions); configNode.set("ibft2", options); rootNode.set("config", configNode); - return GenesisConfigFile.fromConfig(rootNode).getConfigOptions().getBftConfigOptions(); + return GenesisConfig.fromConfig(rootNode).getConfigOptions().getBftConfigOptions(); } } diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java index 47741206229..fcbf10e7ac3 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.CliqueConfigOptions; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.JsonCliqueConfigOptions; import org.hyperledger.besu.consensus.common.ForkSpec; @@ -61,7 +61,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() { + "\"byzantiumBlock\": 1035301}" + "}"; - final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig(jsonInput).getConfigOptions(); final ProtocolSchedule protocolSchedule = CliqueProtocolSchedule.create( config, @@ -91,7 +91,7 @@ public void parametersAlignWithMainnetWithAdjustments() { new ForksSchedule<>(List.of(new ForkSpec<>(0, JsonCliqueConfigOptions.DEFAULT))); final ProtocolSpec homestead = CliqueProtocolSchedule.create( - GenesisConfigFile.DEFAULT.getConfigOptions(), + GenesisConfig.DEFAULT.getConfigOptions(), forksSchedule, NODE_KEY, PrivacyParameters.DEFAULT, @@ -163,7 +163,7 @@ public void shouldValidateBaseFeeMarketTransition() { final String jsonInput = "{\"config\": " + "\t{\"chainId\": 1337,\n" + "\t\"londonBlock\": 2}\n" + "}"; - final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig(jsonInput).getConfigOptions(); final ForksSchedule forksSchedule = new ForksSchedule<>(List.of(new ForkSpec<>(0, JsonCliqueConfigOptions.DEFAULT))); final ProtocolSchedule protocolSchedule = diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java index 0ece2823327..51c55e52935 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueContext; import org.hyperledger.besu.consensus.clique.CliqueExtraData; @@ -110,7 +110,7 @@ void setup() { protocolSchedule = CliqueProtocolSchedule.create( - GenesisConfigFile.DEFAULT.getConfigOptions(), + GenesisConfig.DEFAULT.getConfigOptions(), new ForksSchedule<>(List.of()), proposerNodeKey, PrivacyParameters.DEFAULT, @@ -125,7 +125,7 @@ void setup() { CliqueHelpers.setCliqueContext(cliqueContext); final Block genesis = - GenesisState.fromConfig(GenesisConfigFile.mainnet(), protocolSchedule).getBlock(); + GenesisState.fromConfig(GenesisConfig.mainnet(), protocolSchedule).getBlock(); blockchain = createInMemoryBlockchain(genesis); protocolContext = new ProtocolContext(blockchain, stateArchive, cliqueContext, new BadBlockManager()); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java index 377757a322b..cd2130599e5 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.consensus.clique.CliqueBlockHeaderFunctions; import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; @@ -74,7 +74,7 @@ public class CliqueMinerExecutorTest { private static final int EPOCH_LENGTH = 10; private static final GenesisConfigOptions GENESIS_CONFIG_OPTIONS = - GenesisConfigFile.fromConfig("{}").getConfigOptions(); + GenesisConfig.fromConfig("{}").getConfigOptions(); private final NodeKey proposerNodeKey = NodeKeyUtils.generate(); private final Random random = new Random(21341234L); private Address localAddress; diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java index df5a313ae77..a4373b2aa36 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.BftConfigOptions; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.consensus.common.ForkSpec; import org.hyperledger.besu.consensus.common.ForksSchedule; @@ -110,8 +110,7 @@ public BlockHeaderValidator.Builder createBlockHeaderRuleset( } }; final GenesisConfigOptions configOptions = - GenesisConfigFile.fromConfig("{\"config\": {\"spuriousDragonBlock\":0}}") - .getConfigOptions(); + GenesisConfig.fromConfig("{\"config\": {\"spuriousDragonBlock\":0}}").getConfigOptions(); final ForksSchedule forksSchedule = new ForksSchedule<>(List.of(new ForkSpec<>(0, configOptions.getBftConfigOptions()))); final ProtocolSchedule protocolSchedule = diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java index 2fff61a8299..9bf74d0d085 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; @@ -46,7 +46,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() { + "\"LondonBlock\": 1559}" + "}"; - final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig(jsonInput).getConfigOptions(); final ProtocolSchedule protocolSchedule = MergeProtocolSchedule.create( config, @@ -67,7 +67,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() { @Test public void mergeSpecificModificationsAreUnappliedForShanghai() { - final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.mainnet().getConfigOptions(); final ProtocolSchedule protocolSchedule = MergeProtocolSchedule.create( config, @@ -108,7 +108,7 @@ public void mergeSpecificModificationsAreUnappliedForCancun_whenShanghaiNotConfi + "\"cancunTime\": 1000}" + "}"; - final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.fromConfig(jsonInput).getConfigOptions(); final ProtocolSchedule protocolSchedule = MergeProtocolSchedule.create( config, @@ -141,7 +141,7 @@ public void mergeSpecificModificationsAreUnappliedForCancun_whenShanghaiNotConfi @Test public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis() { - final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); + final GenesisConfigOptions config = GenesisConfig.mainnet().getConfigOptions(); final ProtocolSchedule protocolSchedule = MergeProtocolSchedule.create( config, @@ -178,7 +178,7 @@ public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis() public void parametersAlignWithMainnetWithAdjustments() { final ProtocolSpec london = MergeProtocolSchedule.create( - GenesisConfigFile.DEFAULT.getConfigOptions(), + GenesisConfig.DEFAULT.getConfigOptions(), false, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java index 90c4b6866e4..ea1fa73eaa5 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java @@ -132,7 +132,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { @Mock EthScheduler ethScheduler; - private final Address coinbase = genesisAllocations(getPosGenesisConfigFile()).findFirst().get(); + private final Address coinbase = genesisAllocations(getPosGenesisConfig()).findFirst().get(); private MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.builder() @@ -148,7 +148,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { private final ProtocolSchedule protocolSchedule = spy(getMergeProtocolSchedule()); private final GenesisState genesisState = - GenesisState.fromConfig(getPosGenesisConfigFile(), protocolSchedule); + GenesisState.fromConfig(getPosGenesisConfig(), protocolSchedule); private final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java index 582c8c5dd55..49174351cb0 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.consensus.merge.blockcreation; import org.hyperledger.besu.config.GenesisAccount; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.BadBlockManager; @@ -30,31 +30,31 @@ public interface MergeGenesisConfigHelper { - default GenesisConfigFile getPosGenesisConfigFile() { + default GenesisConfig getPosGenesisConfig() { try { final URI uri = MergeGenesisConfigHelper.class.getResource("/posAtGenesis.json").toURI(); - return GenesisConfigFile.fromSource(uri.toURL()); + return GenesisConfig.fromSource(uri.toURL()); } catch (final URISyntaxException | IOException e) { throw new IllegalStateException(e); } } - default GenesisConfigFile getPowGenesisConfigFile() { + default GenesisConfig getPowGenesisConfig() { try { final URI uri = MergeGenesisConfigHelper.class.getResource("/powAtGenesis.json").toURI(); - return GenesisConfigFile.fromSource(uri.toURL()); + return GenesisConfig.fromSource(uri.toURL()); } catch (final URISyntaxException | IOException e) { throw new IllegalStateException(e); } } - default Stream
genesisAllocations(final GenesisConfigFile configFile) { + default Stream
genesisAllocations(final GenesisConfig configFile) { return configFile.streamAllocations().map(GenesisAccount::address); } default ProtocolSchedule getMergeProtocolSchedule() { return MergeProtocolSchedule.create( - getPosGenesisConfigFile().getConfigOptions(), + getPosGenesisConfig().getConfigOptions(), false, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java index 22153eeceee..7ec2df35f23 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java @@ -70,7 +70,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper { private final MergeContext mergeContext = PostMergeContext.get(); private final ProtocolSchedule mockProtocolSchedule = getMergeProtocolSchedule(); private final GenesisState genesisState = - GenesisState.fromConfig(getPowGenesisConfigFile(), mockProtocolSchedule); + GenesisState.fromConfig(getPowGenesisConfig(), mockProtocolSchedule); private final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); private final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); @@ -78,7 +78,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper { private final ProtocolContext protocolContext = new ProtocolContext(blockchain, worldStateArchive, mergeContext, new BadBlockManager()); - private final Address coinbase = genesisAllocations(getPowGenesisConfigFile()).findFirst().get(); + private final Address coinbase = genesisAllocations(getPowGenesisConfig()).findFirst().get(); private final BlockHeaderTestFixture headerGenerator = new BlockHeaderTestFixture(); private final BaseFeeMarket feeMarket = new LondonFeeMarket(0, genesisState.getBlock().getHeader().getBaseFee()); @@ -132,7 +132,7 @@ public void reorgsAcrossTDDToDifferentTargetsWhenNotFinal() { Difficulty tdd = blockchain.getTotalDifficultyByHash(ttdA.getHash()).get(); assertThat(tdd.getAsBigInteger()) .isGreaterThan( - getPosGenesisConfigFile() + getPosGenesisConfig() .getConfigOptions() .getTerminalTotalDifficulty() .get() diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java index a9de97ae18a..426d18e3e1d 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java +++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.BftFork; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.JsonQbftConfigOptions; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.config.QbftConfigOptions; @@ -367,7 +367,7 @@ private static Block createGenesisBlock(final Set
validators) { private GenesisState createGenesisBlock(final String genesisFile) throws IOException { return GenesisState.fromConfig( - GenesisConfigFile.fromSource(Path.of(genesisFile).toUri().toURL()), + GenesisConfig.fromSource(Path.of(genesisFile).toUri().toURL()), ProtocolScheduleFixture.MAINNET); } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java index 7e1be90e10e..307979f827f 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.Block; @@ -45,7 +45,7 @@ public class BlockchainImporter { public BlockchainImporter(final URL blocksUrl, final String genesisJson) throws Exception { protocolSchedule = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(), + GenesisConfig.fromConfig(genesisJson).getConfigOptions(), MiningConfiguration.newDefault(), new BadBlockManager(), false, diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index b70c48ad026..4c4bf134855 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SECPPrivateKey; import org.hyperledger.besu.crypto.SignatureAlgorithm; @@ -298,12 +298,12 @@ record CreateOn(AbstractBlockCreator blockCreator, BlockHeader parentHeader) {} private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapters) { - final var genesisConfigFile = GenesisConfigFile.fromResource("/block-creation-genesis.json"); + final var genesisConfig = GenesisConfig.fromResource("/block-creation-genesis.json"); final ExecutionContextTestFixture executionContextTestFixture = - ExecutionContextTestFixture.builder(genesisConfigFile) + ExecutionContextTestFixture.builder(genesisConfig) .protocolSchedule( new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), protocolSpecAdapters, PrivacyParameters.DEFAULT, diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java index 2787189ece7..202b0fdee66 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java @@ -33,7 +33,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; @@ -132,7 +132,7 @@ public abstract class AbstractBlockTransactionSelectorTest { Address.extract(Hash.hash(keyPair.getPublicKey().getEncodedBytes())); protected final MetricsSystem metricsSystem = new NoOpMetricsSystem(); - protected GenesisConfigFile genesisConfigFile; + protected GenesisConfig genesisConfig; protected MutableBlockchain blockchain; protected TransactionPool transactionPool; protected MutableWorldState worldState; @@ -152,7 +152,7 @@ public abstract class AbstractBlockTransactionSelectorTest { @BeforeEach public void setup() { - genesisConfigFile = getGenesisConfigFile(); + genesisConfig = getGenesisConfig(); protocolSchedule = createProtocolSchedule(); transactionSelectionService = new TransactionSelectionServiceImpl(); defaultTestMiningConfiguration = @@ -162,8 +162,7 @@ public void setup() { MIN_OCCUPANCY_80_PERCENT, DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME); - final Block genesisBlock = - GenesisState.fromConfig(genesisConfigFile, protocolSchedule).getBlock(); + final Block genesisBlock = GenesisState.fromConfig(genesisConfig, protocolSchedule).getBlock(); blockchain = DefaultBlockchain.createMutable( @@ -198,7 +197,7 @@ public void setup() { }); } - protected abstract GenesisConfigFile getGenesisConfigFile(); + protected abstract GenesisConfig getGenesisConfig(); protected abstract ProtocolSchedule createProtocolSchedule(); @@ -232,7 +231,7 @@ protected ProcessableBlockHeader createBlock(final long gasLimit, final Wei base public void emptyPendingTransactionsResultsInEmptyVettingResult() { final ProtocolSchedule protocolSchedule = FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java index 327d4bd37d0..4aad300d511 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.MiningConfiguration; @@ -49,14 +49,14 @@ public class LegacyFeeMarketBlockTransactionSelectorTest extends AbstractBlockTransactionSelectorTest { @Override - protected GenesisConfigFile getGenesisConfigFile() { - return GenesisConfigFile.fromResource("/block-transaction-selector/gas-price-genesis.json"); + protected GenesisConfig getGenesisConfig() { + return GenesisConfig.fromResource("/block-transaction-selector/gas-price-genesis.json"); } @Override protected ProtocolSchedule createProtocolSchedule() { return new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java index 62eaf713c54..eb77c6df658 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java @@ -19,7 +19,7 @@ import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockTransactionSelector; @@ -60,14 +60,14 @@ public class LondonFeeMarketBlockTransactionSelectorTest extends AbstractBlockTransactionSelectorTest { @Override - protected GenesisConfigFile getGenesisConfigFile() { - return GenesisConfigFile.fromResource("/block-transaction-selector/london-genesis.json"); + protected GenesisConfig getGenesisConfig() { + return GenesisConfig.fromResource("/block-transaction-selector/london-genesis.json"); } @Override protected ProtocolSchedule createProtocolSchedule() { return new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java index e8b9baa0a73..8813fcf38c7 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; @@ -85,15 +85,15 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { @Test void createMainnetBlock1() throws IOException { - final var genesisConfigFile = GenesisConfigFile.mainnet(); + final var genesisConfig = GenesisConfig.mainnet(); final MiningConfiguration miningConfiguration = createMiningParameters(BLOCK_1_NONCE); final ExecutionContextTestFixture executionContextTestFixture = - ExecutionContextTestFixture.builder(genesisConfigFile) + ExecutionContextTestFixture.builder(genesisConfig) .protocolSchedule( new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create(0, Function.identity()), PrivacyParameters.DEFAULT, @@ -143,23 +143,23 @@ void createMainnetBlock1() throws IOException { @Test void createMainnetBlock1_fixedDifficulty1() { - final var genesisConfigFile = - GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); + final var genesisConfig = + GenesisConfig.fromResource("/block-creation-fixed-difficulty-genesis.json"); final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); final ExecutionContextTestFixture executionContextTestFixture = - ExecutionContextTestFixture.builder(genesisConfigFile) + ExecutionContextTestFixture.builder(genesisConfig) .protocolSchedule( new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> specBuilder.difficultyCalculator( FixedDifficultyCalculators.calculator( - genesisConfigFile.getConfigOptions()))), + genesisConfig.getConfigOptions()))), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, @@ -201,21 +201,21 @@ void createMainnetBlock1_fixedDifficulty1() { @Test void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() { - final var genesisConfigFile = - GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); + final var genesisConfig = + GenesisConfig.fromResource("/block-creation-fixed-difficulty-genesis.json"); final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> specBuilder.difficultyCalculator( FixedDifficultyCalculators.calculator( - genesisConfigFile.getConfigOptions()))), + genesisConfig.getConfigOptions()))), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, @@ -225,7 +225,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() { new NoOpMetricsSystem()) .createProtocolSchedule(); final ExecutionContextTestFixture executionContextTestFixture = - ExecutionContextTestFixture.builder(genesisConfigFile) + ExecutionContextTestFixture.builder(genesisConfig) .protocolSchedule(protocolSchedule) .build(); @@ -278,21 +278,21 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() { @Test void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() { - final var genesisConfigFile = - GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); + final var genesisConfig = + GenesisConfig.fromResource("/block-creation-fixed-difficulty-genesis.json"); final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> specBuilder.difficultyCalculator( FixedDifficultyCalculators.calculator( - genesisConfigFile.getConfigOptions()))), + genesisConfig.getConfigOptions()))), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, @@ -302,7 +302,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() { new NoOpMetricsSystem()) .createProtocolSchedule(); final ExecutionContextTestFixture executionContextTestFixture = - ExecutionContextTestFixture.builder(genesisConfigFile) + ExecutionContextTestFixture.builder(genesisConfig) .protocolSchedule(protocolSchedule) .build(); diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java index a029c4b4a49..5ad9635a263 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.entry; import static org.hyperledger.besu.evm.operation.BlockHashOperation.BlockHashLookup; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.TransactionType; @@ -70,8 +70,7 @@ public class TraceTransactionIntegrationTest { @BeforeEach public void setUp() { final ExecutionContextTestFixture contextTestFixture = - ExecutionContextTestFixture.builder(GenesisConfigFile.fromResource("/genesis-it.json")) - .build(); + ExecutionContextTestFixture.builder(GenesisConfig.fromResource("/genesis-it.json")).build(); genesisBlock = contextTestFixture.getGenesis(); blockchain = contextTestFixture.getBlockchain(); worldStateArchive = contextTestFixture.getStateArchive(); diff --git a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java index 4289a91a3c8..cff04abbdc5 100644 --- a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java +++ b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java @@ -16,7 +16,7 @@ import static java.util.Collections.emptyList; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; @@ -75,7 +75,7 @@ public static OperationBenchmarkHelper create() throws IOException { KeyValueSegmentIdentifier.BLOCKCHAIN, optimisticRocksDBColumnarKeyValueStorage); final ExecutionContextTestFixture executionContext = - ExecutionContextTestFixture.builder(GenesisConfigFile.fromResource("/genesis-jmh.json")) + ExecutionContextTestFixture.builder(GenesisConfig.fromResource("/genesis-jmh.json")) .blockchainKeyValueStorage(keyValueStorage) .build(); final MutableBlockchain blockchain = executionContext.getBlockchain(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index 0dcc3450121..56c33e55c7d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.trie.common.GenesisWorldStateProvider.createGenesisWorldState; import org.hyperledger.besu.config.GenesisAccount; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.Hash; @@ -53,11 +53,11 @@ public final class GenesisState { private final Block block; - private final GenesisConfigFile genesisConfigFile; + private final GenesisConfig genesisConfig; - private GenesisState(final Block block, final GenesisConfigFile genesisConfigFile) { + private GenesisState(final Block block, final GenesisConfig genesisConfig) { this.block = block; - this.genesisConfigFile = genesisConfigFile; + this.genesisConfig = genesisConfig; } /** @@ -68,7 +68,7 @@ private GenesisState(final Block block, final GenesisConfigFile genesisConfigFil * @return A new {@link GenesisState}. */ public static GenesisState fromJson(final String json, final ProtocolSchedule protocolSchedule) { - return fromConfig(GenesisConfigFile.fromConfig(json), protocolSchedule); + return fromConfig(GenesisConfig.fromConfig(json), protocolSchedule); } /** @@ -86,18 +86,18 @@ static GenesisState fromJsonSource( final URL jsonSource, final ProtocolSchedule protocolSchedule) { return fromConfig( - dataStorageConfiguration, GenesisConfigFile.fromConfig(jsonSource), protocolSchedule); + dataStorageConfiguration, GenesisConfig.fromConfig(jsonSource), protocolSchedule); } /** * Construct a {@link GenesisState} from a genesis file object. * - * @param config A {@link GenesisConfigFile} describing the genesis block. + * @param config A {@link GenesisConfig} describing the genesis block. * @param protocolSchedule A protocol Schedule associated with * @return A new {@link GenesisState}. */ public static GenesisState fromConfig( - final GenesisConfigFile config, final ProtocolSchedule protocolSchedule) { + final GenesisConfig config, final ProtocolSchedule protocolSchedule) { return fromConfig(DataStorageConfiguration.DEFAULT_CONFIG, config, protocolSchedule); } @@ -106,43 +106,42 @@ public static GenesisState fromConfig( * * @param dataStorageConfiguration A {@link DataStorageConfiguration} describing the storage * configuration - * @param genesisConfigFile A {@link GenesisConfigFile} describing the genesis block. + * @param genesisConfig A {@link GenesisConfig} describing the genesis block. * @param protocolSchedule A protocol Schedule associated with * @return A new {@link GenesisState}. */ public static GenesisState fromConfig( final DataStorageConfiguration dataStorageConfiguration, - final GenesisConfigFile genesisConfigFile, + final GenesisConfig genesisConfig, final ProtocolSchedule protocolSchedule) { - final var genesisStateRoot = - calculateGenesisStateRoot(dataStorageConfiguration, genesisConfigFile); + final var genesisStateRoot = calculateGenesisStateRoot(dataStorageConfiguration, genesisConfig); final Block block = new Block( - buildHeader(genesisConfigFile, genesisStateRoot, protocolSchedule), - buildBody(genesisConfigFile)); - return new GenesisState(block, genesisConfigFile); + buildHeader(genesisConfig, genesisStateRoot, protocolSchedule), + buildBody(genesisConfig)); + return new GenesisState(block, genesisConfig); } /** * Construct a {@link GenesisState} from a JSON object. * * @param genesisStateRoot The root of the genesis state. - * @param genesisConfigFile A {@link GenesisConfigFile} describing the genesis block. + * @param genesisConfig A {@link GenesisConfig} describing the genesis block. * @param protocolSchedule A protocol Schedule associated with * @return A new {@link GenesisState}. */ public static GenesisState fromStorage( final Hash genesisStateRoot, - final GenesisConfigFile genesisConfigFile, + final GenesisConfig genesisConfig, final ProtocolSchedule protocolSchedule) { final Block block = new Block( - buildHeader(genesisConfigFile, genesisStateRoot, protocolSchedule), - buildBody(genesisConfigFile)); - return new GenesisState(block, genesisConfigFile); + buildHeader(genesisConfig, genesisStateRoot, protocolSchedule), + buildBody(genesisConfig)); + return new GenesisState(block, genesisConfig); } - private static BlockBody buildBody(final GenesisConfigFile config) { + private static BlockBody buildBody(final GenesisConfig config) { final Optional> withdrawals = isShanghaiAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty(); @@ -159,7 +158,7 @@ public Block getBlock() { * @param target WorldView to write genesis state to */ public void writeStateTo(final MutableWorldState target) { - writeAccountsTo(target, genesisConfigFile.streamAllocations(), block.getHeader()); + writeAccountsTo(target, genesisConfig.streamAllocations(), block.getHeader()); } private static void writeAccountsTo( @@ -180,10 +179,9 @@ private static void writeAccountsTo( } private static Hash calculateGenesisStateRoot( - final DataStorageConfiguration dataStorageConfiguration, - final GenesisConfigFile genesisConfigFile) { + final DataStorageConfiguration dataStorageConfiguration, final GenesisConfig genesisConfig) { try (var worldState = createGenesisWorldState(dataStorageConfiguration)) { - writeAccountsTo(worldState, genesisConfigFile.streamAllocations(), null); + writeAccountsTo(worldState, genesisConfig.streamAllocations(), null); return worldState.rootHash(); } catch (Exception e) { throw new RuntimeException(e); @@ -191,7 +189,7 @@ private static Hash calculateGenesisStateRoot( } private static BlockHeader buildHeader( - final GenesisConfigFile genesis, + final GenesisConfig genesis, final Hash genesisRootHash, final ProtocolSchedule protocolSchedule) { @@ -228,7 +226,7 @@ private static BlockHeader buildHeader( .buildBlockHeader(); } - private static Address parseCoinbase(final GenesisConfigFile genesis) { + private static Address parseCoinbase(final GenesisConfig genesis) { return genesis .getCoinbase() .map(str -> withNiceErrorMessage("coinbase", str, Address::fromHexString)) @@ -250,39 +248,39 @@ private static IllegalArgumentException createInvalidBlockConfigException( "Invalid " + name + " in genesis block configuration: " + value, e); } - private static Hash parseParentHash(final GenesisConfigFile genesis) { + private static Hash parseParentHash(final GenesisConfig genesis) { return withNiceErrorMessage("parentHash", genesis.getParentHash(), Hash::fromHexStringLenient); } - private static Bytes parseExtraData(final GenesisConfigFile genesis) { + private static Bytes parseExtraData(final GenesisConfig genesis) { return withNiceErrorMessage("extraData", genesis.getExtraData(), Bytes::fromHexString); } - private static Difficulty parseDifficulty(final GenesisConfigFile genesis) { + private static Difficulty parseDifficulty(final GenesisConfig genesis) { return withNiceErrorMessage("difficulty", genesis.getDifficulty(), Difficulty::fromHexString); } - private static Hash parseMixHash(final GenesisConfigFile genesis) { + private static Hash parseMixHash(final GenesisConfig genesis) { return withNiceErrorMessage("mixHash", genesis.getMixHash(), Hash::fromHexStringLenient); } - private static long parseNonce(final GenesisConfigFile genesis) { + private static long parseNonce(final GenesisConfig genesis) { return withNiceErrorMessage("nonce", genesis.getNonce(), GenesisState::parseUnsignedLong); } - private static long parseBlobGasUsed(final GenesisConfigFile genesis) { + private static long parseBlobGasUsed(final GenesisConfig genesis) { return withNiceErrorMessage( "blobGasUsed", genesis.getBlobGasUsed(), GenesisState::parseUnsignedLong); } - private static BlobGas parseExcessBlobGas(final GenesisConfigFile genesis) { + private static BlobGas parseExcessBlobGas(final GenesisConfig genesis) { long excessBlobGas = withNiceErrorMessage( "excessBlobGas", genesis.getExcessBlobGas(), GenesisState::parseUnsignedLong); return BlobGas.of(excessBlobGas); } - private static Bytes32 parseParentBeaconBlockRoot(final GenesisConfigFile genesis) { + private static Bytes32 parseParentBeaconBlockRoot(final GenesisConfig genesis) { return withNiceErrorMessage( "parentBeaconBlockRoot", genesis.getParentBeaconBlockRoot(), Bytes32::fromHexString); } @@ -295,7 +293,7 @@ private static long parseUnsignedLong(final String value) { return Long.parseUnsignedLong(v, 16); } - private static boolean isShanghaiAtGenesis(final GenesisConfigFile genesis) { + private static boolean isShanghaiAtGenesis(final GenesisConfig genesis) { final OptionalLong shanghaiTimestamp = genesis.getConfigOptions().getShanghaiTime(); if (shanghaiTimestamp.isPresent()) { return genesis.getTimestamp() >= shanghaiTimestamp.getAsLong(); @@ -303,7 +301,7 @@ private static boolean isShanghaiAtGenesis(final GenesisConfigFile genesis) { return isCancunAtGenesis(genesis); } - private static boolean isCancunAtGenesis(final GenesisConfigFile genesis) { + private static boolean isCancunAtGenesis(final GenesisConfig genesis) { final OptionalLong cancunTimestamp = genesis.getConfigOptions().getCancunTime(); if (cancunTimestamp.isPresent()) { return genesis.getTimestamp() >= cancunTimestamp.getAsLong(); @@ -311,7 +309,7 @@ private static boolean isCancunAtGenesis(final GenesisConfigFile genesis) { return isPragueAtGenesis(genesis) || isCancunEOFAtGenesis(genesis); } - private static boolean isCancunEOFAtGenesis(final GenesisConfigFile genesis) { + private static boolean isCancunEOFAtGenesis(final GenesisConfig genesis) { final OptionalLong cancunEOFTimestamp = genesis.getConfigOptions().getCancunEOFTime(); if (cancunEOFTimestamp.isPresent()) { return genesis.getTimestamp() >= cancunEOFTimestamp.getAsLong(); @@ -319,7 +317,7 @@ private static boolean isCancunEOFAtGenesis(final GenesisConfigFile genesis) { return false; } - private static boolean isPragueAtGenesis(final GenesisConfigFile genesis) { + private static boolean isPragueAtGenesis(final GenesisConfig genesis) { final OptionalLong pragueTimestamp = genesis.getConfigOptions().getPragueTime(); if (pragueTimestamp.isPresent()) { return genesis.getTimestamp() >= pragueTimestamp.getAsLong(); @@ -327,7 +325,7 @@ private static boolean isPragueAtGenesis(final GenesisConfigFile genesis) { return isOsakaAtGenesis(genesis); } - private static boolean isOsakaAtGenesis(final GenesisConfigFile genesis) { + private static boolean isOsakaAtGenesis(final GenesisConfig genesis) { final OptionalLong osakaTimestamp = genesis.getConfigOptions().getOsakaTime(); if (osakaTimestamp.isPresent()) { return genesis.getTimestamp() >= osakaTimestamp.getAsLong(); @@ -335,7 +333,7 @@ private static boolean isOsakaAtGenesis(final GenesisConfigFile genesis) { return isFutureEipsTimeAtGenesis(genesis); } - private static boolean isFutureEipsTimeAtGenesis(final GenesisConfigFile genesis) { + private static boolean isFutureEipsTimeAtGenesis(final GenesisConfig genesis) { final OptionalLong futureEipsTime = genesis.getConfigOptions().getFutureEipsTime(); if (futureEipsTime.isPresent()) { return genesis.getTimestamp() >= futureEipsTime.getAsLong(); @@ -343,7 +341,7 @@ private static boolean isFutureEipsTimeAtGenesis(final GenesisConfigFile genesis return isExperimentalEipsTimeAtGenesis(genesis); } - private static boolean isExperimentalEipsTimeAtGenesis(final GenesisConfigFile genesis) { + private static boolean isExperimentalEipsTimeAtGenesis(final GenesisConfig genesis) { final OptionalLong experimentalEipsTime = genesis.getConfigOptions().getExperimentalEipsTime(); if (experimentalEipsTime.isPresent()) { return genesis.getTimestamp() >= experimentalEipsTime.getAsLong(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index d1a148ceedf..5ba94a78ad1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.mainnet.feemarket; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.feemarket.TransactionPriceCalculator; @@ -28,8 +28,7 @@ public class LondonFeeMarket implements BaseFeeMarket { private static final Logger LOG = LoggerFactory.getLogger(LondonFeeMarket.class); - static final Wei DEFAULT_BASEFEE_INITIAL_VALUE = - GenesisConfigFile.BASEFEE_AT_GENESIS_DEFAULT_VALUE; + static final Wei DEFAULT_BASEFEE_INITIAL_VALUE = GenesisConfig.BASEFEE_AT_GENESIS_DEFAULT_VALUE; static final long DEFAULT_BASEFEE_MAX_CHANGE_DENOMINATOR = 8L; static final long DEFAULT_SLACK_COEFFICIENT = 2L; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index 3391a0e162c..b705ba01117 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -20,7 +20,7 @@ import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.Blockchain; @@ -147,9 +147,9 @@ public static BlockchainSetupUtil createForEthashChain( } private static ProtocolSchedule mainnetProtocolScheduleProvider( - final GenesisConfigFile genesisConfigFile) { + final GenesisConfig genesisConfig) { return MainnetProtocolSchedule.fromConfig( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.newDefault(), new BadBlockManager(), @@ -170,12 +170,10 @@ private static BlockchainSetupUtil create( final ProtocolContextProvider protocolContextProvider, final EthScheduler scheduler) { try { - final GenesisConfigFile genesisConfigFile = - GenesisConfigFile.fromSource(chainResources.getGenesisURL()); - final ProtocolSchedule protocolSchedule = protocolScheduleProvider.get(genesisConfigFile); + final GenesisConfig genesisConfig = GenesisConfig.fromSource(chainResources.getGenesisURL()); + final ProtocolSchedule protocolSchedule = protocolScheduleProvider.get(genesisConfig); - final GenesisState genesisState = - GenesisState.fromConfig(genesisConfigFile, protocolSchedule); + final GenesisState genesisState = GenesisState.fromConfig(genesisConfig, protocolSchedule); final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); final WorldStateArchive worldArchive = storageFormat == DataStorageFormat.BONSAI @@ -267,7 +265,7 @@ private void importBlocks( } private interface ProtocolScheduleProvider { - ProtocolSchedule get(GenesisConfigFile genesisConfig); + ProtocolSchedule get(GenesisConfig genesisConfig); } private interface ProtocolContextProvider { diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java index b4eaec04d3e..873490fd451 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java @@ -17,7 +17,7 @@ import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; @@ -52,12 +52,12 @@ public class ExecutionContextTestFixture { private final ProtocolContext protocolContext; private ExecutionContextTestFixture( - final GenesisConfigFile genesisConfigFile, + final GenesisConfig genesisConfig, final ProtocolSchedule protocolSchedule, final KeyValueStorage blockchainKeyValueStorage, final KeyValueStorage variablesKeyValueStorage, final Optional dataStorageFormat) { - final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule); + final GenesisState genesisState = GenesisState.fromConfig(genesisConfig, protocolSchedule); this.genesis = genesisState.getBlock(); this.blockchainKeyValueStorage = blockchainKeyValueStorage; this.variablesKeyValueStorage = variablesKeyValueStorage; @@ -82,11 +82,11 @@ private ExecutionContextTestFixture( } public static ExecutionContextTestFixture create() { - return new Builder(GenesisConfigFile.mainnet()).build(); + return new Builder(GenesisConfig.mainnet()).build(); } - public static Builder builder(final GenesisConfigFile genesisConfigFile) { - return new Builder(genesisConfigFile); + public static Builder builder(final GenesisConfig genesisConfig) { + return new Builder(genesisConfig); } public Block getGenesis() { @@ -118,14 +118,14 @@ public ProtocolContext getProtocolContext() { } public static class Builder { - private final GenesisConfigFile genesisConfigFile; + private final GenesisConfig genesisConfig; private KeyValueStorage variablesKeyValueStorage; private KeyValueStorage blockchainKeyValueStorage; private ProtocolSchedule protocolSchedule; private Optional dataStorageFormat = Optional.empty(); - public Builder(final GenesisConfigFile genesisConfigFile) { - this.genesisConfigFile = genesisConfigFile; + public Builder(final GenesisConfig genesisConfig) { + this.genesisConfig = genesisConfig; } public Builder variablesKeyValueStorage(final KeyValueStorage keyValueStorage) { @@ -152,7 +152,7 @@ public ExecutionContextTestFixture build() { if (protocolSchedule == null) { protocolSchedule = new ProtocolScheduleBuilder( - genesisConfigFile.getConfigOptions(), + genesisConfig.getConfigOptions(), Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), @@ -172,7 +172,7 @@ public ExecutionContextTestFixture build() { } return new ExecutionContextTestFixture( - genesisConfigFile, + genesisConfig, protocolSchedule, variablesKeyValueStorage, blockchainKeyValueStorage, diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java index db1114e832b..fc5ca291233 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java @@ -16,7 +16,7 @@ import static org.hyperledger.besu.config.JsonUtil.normalizeKeys; -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.ethereum.chain.BadBlockManager; @@ -47,7 +47,7 @@ public class ProtocolScheduleFixture { private static GenesisConfigOptions getMainnetConfigOptions() { // this method avoids reading all the alloc accounts when all we want is the "config" section try (final JsonParser jsonParser = - new JsonFactory().createParser(GenesisConfigFile.class.getResource("/mainnet.json"))) { + new JsonFactory().createParser(GenesisConfig.class.getResource("/mainnet.json"))) { while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if ("config".equals(jsonParser.getCurrentName())) { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java index 9a6ddeaeb73..6d8d7350a25 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; @@ -34,7 +34,7 @@ public void reportedDifficultyForAllBlocksIsAFixedValue() { final ProtocolSchedule schedule = FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorIntegrationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorIntegrationTest.java index c9e43327d96..0d05376183d 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorIntegrationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorIntegrationTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SECPPrivateKey; import org.hyperledger.besu.crypto.SignatureAlgorithm; @@ -87,7 +87,7 @@ class AbstractBlockProcessorIntegrationTest { public void setUp() { final ExecutionContextTestFixture contextTestFixture = ExecutionContextTestFixture.builder( - GenesisConfigFile.fromResource( + GenesisConfig.fromResource( "/org/hyperledger/besu/ethereum/mainnet/genesis-bp-it.json")) .dataStorageFormat(DataStorageFormat.BONSAI) .build(); @@ -100,7 +100,7 @@ public void setUp() { private static Stream blockProcessorProvider() { final ExecutionContextTestFixture contextTestFixture = ExecutionContextTestFixture.builder( - GenesisConfigFile.fromResource( + GenesisConfig.fromResource( "/org/hyperledger/besu/ethereum/mainnet/genesis-bp-it.json")) .dataStorageFormat(DataStorageFormat.BONSAI) .build(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java index 9ce20cb6267..bec03463336 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; @@ -71,7 +71,7 @@ public void shouldReturnDefaultProtocolSpecsWhenCustomNumbersAreNotUsed() { public void shouldOnlyUseFrontierWhenEmptyJsonConfigIsUsed() { final ProtocolSchedule sched = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromConfig("{}").getConfigOptions(), + GenesisConfig.fromConfig("{}").getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), @@ -88,7 +88,7 @@ public void createFromConfigWithSettings() { "{\"config\": {\"homesteadBlock\": 2, \"daoForkBlock\": 3, \"eip150Block\": 14, \"eip158Block\": 15, \"byzantiumBlock\": 16, \"constantinopleBlock\": 18, \"petersburgBlock\": 19, \"chainId\":1234}}"; final ProtocolSchedule sched = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromConfig(json).getConfigOptions(), + GenesisConfig.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), @@ -122,7 +122,7 @@ public void outOfOrderConstantinoplesFail() { .isThrownBy( () -> MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromConfig(json).getConfigOptions(), + GenesisConfig.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java index 275adc9ff43..de0aa4a8cb8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.GenesisAccount; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SECPPrivateKey; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; @@ -105,13 +105,13 @@ public abstract class AbstractIsolationTests { .createKeyPair(SECPPrivateKey.create(key, "ECDSA")); protected final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); protected final GenesisState genesisState = - GenesisState.fromConfig(GenesisConfigFile.fromResource("/dev.json"), protocolSchedule); + GenesisState.fromConfig(GenesisConfig.fromResource("/dev.json"), protocolSchedule); protected final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); protected final TransactionPoolConfiguration poolConfiguration = @@ -144,7 +144,7 @@ public abstract class AbstractIsolationTests { ethScheduler); protected final List accounts = - GenesisConfigFile.fromResource("/dev.json") + GenesisConfig.fromResource("/dev.json") .streamAllocations() .filter(ga -> ga.privateKey() != null) .toList(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestBuilder.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestBuilder.java index 90c69925818..3bd629db1e6 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestBuilder.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestBuilder.java @@ -17,7 +17,7 @@ import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; @@ -48,7 +48,7 @@ public class EthProtocolManagerTestBuilder { private static final ProtocolSchedule DEFAULT_PROTOCOL_SCHEDULE = ProtocolScheduleFixture.MAINNET; private ProtocolSchedule protocolSchedule; - private GenesisConfigFile genesisConfigFile; + private GenesisConfig genesisConfig; private GenesisState genesisState; private Blockchain blockchain; private BigInteger networkId; @@ -76,9 +76,8 @@ public EthProtocolManagerTestBuilder setProtocolSchedule( return this; } - public EthProtocolManagerTestBuilder setGenesisConfigFile( - final GenesisConfigFile genesisConfigFile) { - this.genesisConfigFile = genesisConfigFile; + public EthProtocolManagerTestBuilder setGenesisConfigFile(final GenesisConfig genesisConfig) { + this.genesisConfig = genesisConfig; return this; } @@ -171,11 +170,11 @@ public EthProtocolManager build() { if (protocolSchedule == null) { protocolSchedule = DEFAULT_PROTOCOL_SCHEDULE; } - if (genesisConfigFile == null) { - genesisConfigFile = GenesisConfigFile.mainnet(); + if (genesisConfig == null) { + genesisConfig = GenesisConfig.mainnet(); } if (genesisState == null) { - genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule); + genesisState = GenesisState.fromConfig(genesisConfig, protocolSchedule); } if (blockchain == null) { blockchain = createInMemoryBlockchain(genesisState.getBlock()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java index 2bb1394a1d3..536f74aba68 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java @@ -16,7 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -57,7 +57,7 @@ public final class BlockBodiesMessageTest { public void setup() { protocolSchedule = FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java index 9173a7af48b..ab42e404431 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.eth.messages; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MiningConfiguration; @@ -64,7 +64,7 @@ public void blockHeadersRoundTrip() throws IOException { final List readHeaders = message.getHeaders( FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java index dfad68a65ee..aa47fd09a34 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -63,7 +63,7 @@ public class ChainHeadTrackerTest { private final ProtocolSchedule protocolSchedule = FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java index 7046270cd59..f69232eec4e 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.when; import static org.mockito.quality.Strictness.LENIENT; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.BlobsWithCommitments; @@ -174,7 +174,7 @@ protected TransactionTestFixture createBaseTransactionBaseFeeMarket(final int no protected abstract ExecutionContextTestFixture createExecutionContextTestFixture(); protected static ExecutionContextTestFixture createExecutionContextTestFixtureBaseFeeMarket() { - final var genesisConfigFile = GenesisConfigFile.fromResource("/txpool-test-genesis.json"); + final var genesisConfigFile = GenesisConfig.fromResource("/txpool-test-genesis.json"); final ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java index 4d47b909946..e29b8285c9c 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; @@ -117,10 +117,10 @@ public TestNode( .setBindPort(listenPort) .setSupportedProtocols(EthProtocol.get())); - final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromResource("/dev.json"); + final GenesisConfig genesisConfig = GenesisConfig.fromResource("/dev.json"); final ProtocolSchedule protocolSchedule = FixedDifficultyProtocolSchedule.create( - GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), + GenesisConfig.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, @@ -128,7 +128,7 @@ public TestNode( false, new NoOpMetricsSystem()); - final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule); + final GenesisState genesisState = GenesisState.fromConfig(genesisConfig, protocolSchedule); final BlockHeaderFunctions blockHeaderFunctions = ScheduleBasedBlockHeaderFunctions.create(protocolSchedule); final MutableBlockchain blockchain = diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java index 2574d4b8e39..7af78fa02e2 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java @@ -464,9 +464,9 @@ public void run() { .coinbase(coinbase) .difficulty( Difficulty.fromHexString( - genesisFileModule.providesGenesisConfigFile().getDifficulty())) + genesisFileModule.providesGenesisConfig().getDifficulty())) .number(0) - .gasLimit(genesisFileModule.providesGenesisConfigFile().getGasLimit()) + .gasLimit(genesisFileModule.providesGenesisConfig().getGasLimit()) .timestamp(0) .ommersHash(Hash.EMPTY_LIST_HASH) .stateRoot(Hash.EMPTY_TRIE_HASH) @@ -483,7 +483,7 @@ public void run() { .getBlockchain() .getChainHeadHeader() .getBaseFee() - .or(() -> genesisFileModule.providesGenesisConfigFile().getBaseFeePerGas()) + .or(() -> genesisFileModule.providesGenesisConfig().getBaseFeePerGas()) .orElse( protocolSpec.getFeeMarket().implementsBaseFee() ? Wei.of(0xa) : null)) .buildBlockHeader(); diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/GenesisFileModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/GenesisFileModule.java index 8512b5537e0..7af024bf18b 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/GenesisFileModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/GenesisFileModule.java @@ -16,7 +16,7 @@ import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.NetworkName; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId; import org.hyperledger.besu.ethereum.chain.GenesisState; @@ -64,14 +64,14 @@ protected GenesisFileModule(final String genesisConfig) { @Singleton @Provides - GenesisConfigFile providesGenesisConfigFile() { - return GenesisConfigFile.fromConfig(genesisConfig); + GenesisConfig providesGenesisConfig() { + return GenesisConfig.fromConfig(genesisConfig); } @Singleton @Provides - GenesisConfigOptions provideGenesisConfigOptions(final GenesisConfigFile genesisConfigFile) { - return genesisConfigFile.getConfigOptions(); + GenesisConfigOptions provideGenesisConfigOptions(final GenesisConfig genesisConfig) { + return genesisConfig.getConfigOptions(); } @Singleton @@ -88,8 +88,8 @@ ProtocolSchedule provideProtocolSchedule( @Singleton @Provides GenesisState provideGenesisState( - final GenesisConfigFile genesisConfigFile, final ProtocolSchedule protocolSchedule) { - return GenesisState.fromConfig(genesisConfigFile, protocolSchedule); + final GenesisConfig genesisConfig, final ProtocolSchedule protocolSchedule) { + return GenesisState.fromConfig(genesisConfig, protocolSchedule); } @Singleton diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java index fa0608a031c..487874d8e3d 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.GenesisState; @@ -63,7 +63,7 @@ private NodeSmartContractPermissioningController setupController( final ObjectNode jsonData = JsonUtil.objectNodeFromString(emptyContractFile, true); final GenesisState genesisState = - GenesisState.fromConfig(GenesisConfigFile.fromConfig(jsonData), protocolSchedule); + GenesisState.fromConfig(GenesisConfig.fromConfig(jsonData), protocolSchedule); final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); final WorldStateArchive worldArchive = createInMemoryWorldStateArchive(); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java index d9746cfcf5f..daea4a6d210 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.TransactionType; @@ -61,8 +61,7 @@ private TransactionSmartContractPermissioningController setupController( final GenesisState genesisState = GenesisState.fromConfig( - GenesisConfigFile.fromSource(this.getClass().getResource(resourceName)), - protocolSchedule); + GenesisConfig.fromSource(this.getClass().getResource(resourceName)), protocolSchedule); final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); final WorldStateArchive worldArchive = createInMemoryWorldStateArchive(); diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java index ea09a1eb983..a5e3d364fc2 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfig; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; @@ -57,7 +57,7 @@ public static Stream getTestParametersForConfig() throws IOException Arguments.of( "/BasicTests/difficultyMainNetwork.json", MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.mainnet() + GenesisConfig.mainnet() .withOverrides(postMergeOverrides).getConfigOptions(), EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())), Arguments.of(