Extend BesuConfiguration service (#6584)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/6088/merge
Fabio Di Fabio 9 months ago committed by GitHub
parent 8d25b24cd7
commit 1d2d0375cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  3. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  4. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  5. 10
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  6. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  7. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java
  8. 55
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  9. 1
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  10. 32
      besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
  11. 19
      besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
  12. 18
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  13. 4
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  14. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java
  15. 6
      ethereum/eth/src/jmh/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderBenchmark.java
  16. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommandOptionsModule.java
  17. 2
      plugin-api/build.gradle
  18. 13
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/BesuConfiguration.java

@ -45,6 +45,7 @@
- Adds `storage rocksdb x-stats` subcommand [#6540](https://github.com/hyperledger/besu/pull/6540)
- New `eth_blobBaseFee`JSON-RPC method [#6581](https://github.com/hyperledger/besu/pull/6581)
- Upgrade reference tests to version 13.1 [#6574](https://github.com/hyperledger/besu/pull/6574)
- Extend `BesuConfiguration` service [#6584](https://github.com/hyperledger/besu/pull/6584)
### Bug fixes
- Fix the way an advertised host configured with `--p2p-host` is treated when communicating with the originator of a PING packet [#6225](https://github.com/hyperledger/besu/pull/6225)

@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
@ -109,6 +110,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final WebSocketConfiguration webSocketConfiguration;
private final JsonRpcIpcConfiguration jsonRpcIpcConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final DataStorageConfiguration dataStorageConfiguration;
private Optional<PermissioningConfiguration> permissioningConfiguration;
private final ApiConfiguration apiConfiguration;
private final GenesisConfigurationProvider genesisConfigProvider;
@ -145,6 +147,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final ApiConfiguration apiConfiguration,
final DataStorageConfiguration dataStorageConfiguration,
final Optional<String> keyfilePath,
final boolean devMode,
final NetworkName network,
@ -195,6 +198,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.metricsConfiguration = metricsConfiguration;
this.permissioningConfiguration = permissioningConfiguration;
this.apiConfiguration = apiConfiguration;
this.dataStorageConfiguration = dataStorageConfiguration;
this.genesisConfigProvider = genesisConfigProvider;
this.devMode = devMode;
this.network = network;
@ -690,6 +694,10 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.privacyParameters = privacyParameters;
}
public DataStorageConfiguration getDataStorageConfiguration() {
return dataStorageConfiguration;
}
public boolean isDevMode() {
return devMode;
}

@ -145,8 +145,12 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final StorageServiceImpl storageService = new StorageServiceImpl();
final SecurityModuleServiceImpl securityModuleService = new SecurityModuleServiceImpl();
final Path dataDir = node.homeDirectory();
final BesuConfiguration commonPluginConfiguration =
new BesuConfigurationImpl(dataDir, dataDir.resolve(DATABASE_PATH));
final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
commonPluginConfiguration.init(
dataDir,
dataDir.resolve(DATABASE_PATH),
node.getDataStorageConfiguration(),
node.getMiningParameters());
final BesuPluginContextImpl besuPluginContext =
besuPluginContextMap.computeIfAbsent(
node,

@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider;
@ -48,6 +49,7 @@ public class BesuNodeConfiguration {
private final MetricsConfiguration metricsConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final ApiConfiguration apiConfiguration;
private final DataStorageConfiguration dataStorageConfiguration;
private final Optional<String> keyFilePath;
private final boolean devMode;
private final GenesisConfigurationProvider genesisConfigProvider;
@ -84,6 +86,7 @@ public class BesuNodeConfiguration {
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final ApiConfiguration apiConfiguration,
final DataStorageConfiguration dataStorageConfiguration,
final Optional<String> keyFilePath,
final boolean devMode,
final NetworkName network,
@ -117,6 +120,7 @@ public class BesuNodeConfiguration {
this.metricsConfiguration = metricsConfiguration;
this.permissioningConfiguration = permissioningConfiguration;
this.apiConfiguration = apiConfiguration;
this.dataStorageConfiguration = dataStorageConfiguration;
this.keyFilePath = keyFilePath;
this.dataPath = dataPath;
this.devMode = devMode;
@ -183,6 +187,10 @@ public class BesuNodeConfiguration {
return apiConfiguration;
}
public DataStorageConfiguration getDataStorageConfiguration() {
return dataStorageConfiguration;
}
public Optional<String> getKeyFilePath() {
return keyFilePath;
}

@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider;
@ -73,6 +74,8 @@ public class BesuNodeConfigurationBuilder {
private MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().build();
private Optional<PermissioningConfiguration> permissioningConfiguration = Optional.empty();
private ApiConfiguration apiConfiguration = ImmutableApiConfiguration.builder().build();
private DataStorageConfiguration dataStorageConfiguration =
DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
private String keyFilePath = null;
private boolean devMode = true;
private GenesisConfigurationProvider genesisConfigProvider = ignore -> Optional.empty();
@ -506,6 +509,12 @@ public class BesuNodeConfigurationBuilder {
return this;
}
public BesuNodeConfigurationBuilder dataStorageConfiguration(
final DataStorageConfiguration dataStorageConfiguration) {
this.dataStorageConfiguration = dataStorageConfiguration;
return this;
}
public BesuNodeConfiguration build() {
return new BesuNodeConfiguration(
name,
@ -519,6 +528,7 @@ public class BesuNodeConfigurationBuilder {
metricsConfiguration,
permissioningConfiguration,
apiConfiguration,
dataStorageConfiguration,
Optional.ofNullable(keyFilePath),
devMode,
network,

@ -72,6 +72,7 @@ public class BesuNodeFactory {
config.getMetricsConfiguration(),
config.getPermissioningConfiguration(),
config.getApiConfiguration(),
config.getDataStorageConfiguration(),
config.getKeyFilePath(),
config.isDevMode(),
config.getNetwork(),

@ -76,6 +76,7 @@ public class PrivacyNode implements AutoCloseable {
private final boolean isFlexiblePrivacyEnabled;
private final boolean isMultitenancyEnabled;
private final boolean isPrivacyPluginEnabled;
private final BesuNodeConfiguration besuConfig;
public PrivacyNode(
final PrivacyNodeConfiguration privacyConfiguration,
@ -89,7 +90,7 @@ public class PrivacyNode implements AutoCloseable {
selectEnclave(enclaveType, enclaveDir, config, privacyConfiguration, containerNetwork);
this.vertx = vertx;
final BesuNodeConfiguration besuConfig = config;
this.besuConfig = config;
isFlexiblePrivacyEnabled = privacyConfiguration.isFlexiblePrivacyGroupEnabled();
isMultitenancyEnabled = privacyConfiguration.isMultitenancyEnabled();
@ -108,6 +109,7 @@ public class PrivacyNode implements AutoCloseable {
besuConfig.getMetricsConfiguration(),
besuConfig.getPermissioningConfiguration(),
besuConfig.getApiConfiguration(),
besuConfig.getDataStorageConfiguration(),
besuConfig.getKeyFilePath(),
besuConfig.isDevMode(),
besuConfig.getNetwork(),
@ -272,6 +274,8 @@ public class PrivacyNode implements AutoCloseable {
private PrivacyStorageProvider createKeyValueStorageProvider(
final Path dataLocation, final Path dbLocation) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(dataLocation, dbLocation, null, besuConfig.getMiningParameters());
return new PrivacyKeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValuePrivacyStorageFactory(
@ -284,7 +288,7 @@ public class PrivacyNode implements AutoCloseable {
DEFAULT_IS_HIGH_SPEC),
Arrays.asList(KeyValueSegmentIdentifier.values()),
RocksDBMetricsFactory.PRIVATE_ROCKS_DB_METRICS)))
.withCommonConfiguration(new BesuConfigurationImpl(dataLocation, dbLocation))
.withCommonConfiguration(besuConfiguration)
.withMetricsSystem(new NoOpMetricsSystem())
.build();
}

@ -138,6 +138,7 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
@ -173,6 +174,7 @@ import org.hyperledger.besu.plugin.services.storage.PrivacyKeyValueStorageFactor
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin;
import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelectorFactory;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
@ -893,9 +895,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private MetricsConfiguration metricsConfiguration;
private Optional<PermissioningConfiguration> permissioningConfiguration;
private Optional<TLSConfiguration> p2pTLSConfiguration;
private DataStorageConfiguration dataStorageConfiguration;
private Collection<EnodeURL> staticNodes;
private BesuController besuController;
private BesuConfiguration pluginCommonConfiguration;
private BesuConfigurationImpl pluginCommonConfiguration;
private MiningParameters miningParameters;
private BesuComponent besuComponent;
@ -1000,7 +1003,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
this.securityModuleService = securityModuleService;
this.permissioningService = permissioningService;
this.privacyPluginService = privacyPluginService;
pluginCommonConfiguration = new BesuCommandConfigurationService();
this.pluginCommonConfiguration = new BesuConfigurationImpl();
besuPluginContext.addService(BesuConfiguration.class, pluginCommonConfiguration);
this.pkiBlockCreationConfigProvider = pkiBlockCreationConfigProvider;
this.rpcEndpointServiceImpl = rpcEndpointServiceImpl;
@ -1076,7 +1079,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
validateOptions();
configure();
configureNativeLibs();
besuController = initController();
besuController = buildController();
besuPluginContext.beforeExternalServices();
@ -1098,7 +1101,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
@VisibleForTesting
void setBesuConfiguration(final BesuConfiguration pluginCommonConfiguration) {
void setBesuConfiguration(final BesuConfigurationImpl pluginCommonConfiguration) {
this.pluginCommonConfiguration = pluginCommonConfiguration;
}
@ -1674,6 +1677,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
unstableIpcOptions.getIpcPath(),
unstableIpcOptions.getRpcIpcApis());
apiConfiguration = apiConfigurationOptions.apiConfiguration(getMiningParameters());
dataStorageConfiguration = getDataStorageConfiguration();
// hostsWhitelist is a hidden option. If it is specified, add the list to hostAllowlist
if (!hostsWhitelist.isEmpty()) {
// if allowlist == default values, remove the default values
@ -1736,10 +1740,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
}
private BesuController initController() {
return buildController();
}
/**
* Builds BesuController
*
@ -1761,6 +1761,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
* @return instance of BesuControllerBuilder
*/
public BesuControllerBuilder getControllerBuilder() {
pluginCommonConfiguration.init(
dataDir(),
dataDir().resolve(DATABASE_PATH),
getDataStorageConfiguration(),
getMiningParameters());
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
return controllerBuilderFactory
.fromEthNetworkConfig(
@ -1771,6 +1776,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.transactionSelectorFactory(getTransactionSelectorFactory())
.pluginTransactionValidatorFactory(getPluginTransactionValidatorFactory())
.dataDirectory(dataDir())
.dataStorageConfiguration(getDataStorageConfiguration())
.miningParameters(getMiningParameters())
.transactionPoolConfiguration(buildTransactionPoolConfiguration())
.nodeKey(new NodeKey(securityModule()))
@ -1792,7 +1798,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.requiredBlocks(requiredBlocks)
.reorgLoggingThreshold(reorgLoggingThreshold)
.evmConfiguration(unstableEvmOptions.toDomainObject())
.dataStorageConfiguration(dataStorageOptions.toDomainObject())
.maxPeers(p2PDiscoveryOptionGroup.maxPeers)
.maxRemotelyInitiatedPeers(maxRemoteInitiatedPeers)
.randomPeerPriority(p2PDiscoveryOptionGroup.randomPeerPriority)
@ -2127,6 +2132,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return miningParameters;
}
private DataStorageConfiguration getDataStorageConfiguration() {
if (dataStorageConfiguration == null) {
dataStorageConfiguration = dataStorageOptions.toDomainObject();
}
return dataStorageConfiguration;
}
private OptionalInt getGenesisBlockPeriodSeconds(
final GenesisConfigOptions genesisConfigOptions) {
if (genesisConfigOptions.isClique()) {
@ -2538,24 +2550,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return loggingLevelOption.getLogLevel();
}
private class BesuCommandConfigurationService implements BesuConfiguration {
@Override
public Path getStoragePath() {
return dataDir().resolve(DATABASE_PATH);
}
@Override
public Path getDataPath() {
return dataDir();
}
@Override
public int getDatabaseVersion() {
return dataStorageOptions.toDomainObject().getDataStorageFormat().getDatabaseVersion();
}
}
private void instantiateSignatureAlgorithmFactory() {
if (SignatureAlgorithmFactory.isInstanceSet()) {
return;
@ -2714,12 +2708,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
builder.setHighSpecEnabled();
}
if (dataStorageOptions.toDomainObject().getUnstable().getBonsaiLimitTrieLogsEnabled()) {
if (getDataStorageConfiguration().getUnstable().getBonsaiLimitTrieLogsEnabled()) {
builder.setLimitTrieLogsEnabled();
builder.setTrieLogRetentionLimit(
dataStorageOptions.toDomainObject().getBonsaiMaxLayersToLoad());
builder.setTrieLogRetentionLimit(getDataStorageConfiguration().getBonsaiMaxLayersToLoad());
builder.setTrieLogsPruningWindowSize(
dataStorageOptions.toDomainObject().getUnstable().getBonsaiTrieLogPruningWindowSize());
getDataStorageConfiguration().getUnstable().getBonsaiTrieLogPruningWindowSize());
}
builder.setTxPoolImplementation(buildTransactionPoolConfiguration().getTxPoolImplementation());

@ -576,6 +576,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
checkNotNull(gasLimitCalculator, "Missing gas limit calculator");
checkNotNull(evmConfiguration, "Missing evm config");
checkNotNull(networkingConfiguration, "Missing network configuration");
checkNotNull(dataStorageConfiguration, "Missing data storage configuration");
prepForBuild();
final ProtocolSchedule protocolSchedule = createProtocolSchedule();

@ -14,25 +14,37 @@
*/
package org.hyperledger.besu.services;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import java.nio.file.Path;
/** A concrete implementation of BesuConfiguration which is used in Besu plugin framework. */
public class BesuConfigurationImpl implements BesuConfiguration {
private final Path storagePath;
private final Path dataPath;
private Path storagePath;
private Path dataPath;
private DataStorageConfiguration dataStorageConfiguration;
private MiningParameters miningParameters;
/**
* BesuConfigurationImpl Constructor.
* Post creation initialization
*
* @param dataPath The Path representing data folder
* @param storagePath The path representing storage folder
* @param dataStorageConfiguration The data storage configuration
* @param miningParameters The mining parameters
*/
public BesuConfigurationImpl(final Path dataPath, final Path storagePath) {
public void init(
final Path dataPath,
final Path storagePath,
final DataStorageConfiguration dataStorageConfiguration,
final MiningParameters miningParameters) {
this.dataPath = dataPath;
this.storagePath = storagePath;
this.dataStorageConfiguration = dataStorageConfiguration;
this.miningParameters = miningParameters;
}
@Override
@ -44,4 +56,14 @@ public class BesuConfigurationImpl implements BesuConfiguration {
public Path getDataPath() {
return dataPath;
}
@Override
public int getDatabaseVersion() {
return dataStorageConfiguration.getDataStorageFormat().getDatabaseVersion();
}
@Override
public Wei getMinGasPrice() {
return miningParameters.getMinTransactionGasPrice();
}
}

@ -41,6 +41,7 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.keyvalue.PrivacyKeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@ -97,11 +98,15 @@ public class PrivacyTest {
private BesuController setUpControllerWithPrivacyEnabled(final boolean flexibleEnabled)
throws IOException, URISyntaxException {
final Path dbDir = Files.createTempDirectory(dataDir, "database");
final var miningParameters = MiningParameters.newDefault();
final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
final PrivacyParameters privacyParameters =
new PrivacyParameters.Builder()
.setEnabled(true)
.setEnclaveUrl(new URI("http://127.0.0.1:8000"))
.setStorageProvider(createKeyValueStorageProvider(dataDir, dbDir))
.setStorageProvider(
createKeyValueStorageProvider(
dataDir, dbDir, dataStorageConfiguration, miningParameters))
.setEnclaveFactory(new EnclaveFactory(vertx))
.setFlexiblePrivacyGroupsEnabled(flexibleEnabled)
.build();
@ -111,7 +116,8 @@ public class PrivacyTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault())
.miningParameters(miningParameters)
.dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.dataDirectory(dataDir)
@ -125,7 +131,12 @@ public class PrivacyTest {
}
private PrivacyStorageProvider createKeyValueStorageProvider(
final Path dataDir, final Path dbDir) {
final Path dataDir,
final Path dbDir,
final DataStorageConfiguration dataStorageConfiguration,
final MiningParameters miningParameters) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(dataDir, dbDir, dataStorageConfiguration, miningParameters);
return new PrivacyKeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValuePrivacyStorageFactory(
@ -138,7 +149,7 @@ public class PrivacyTest {
DEFAULT_IS_HIGH_SPEC),
Arrays.asList(KeyValueSegmentIdentifier.values()),
RocksDBMetricsFactory.PRIVATE_ROCKS_DB_METRICS)))
.withCommonConfiguration(new BesuConfigurationImpl(dataDir, dbDir))
.withCommonConfiguration(besuConfiguration)
.withMetricsSystem(new NoOpMetricsSystem())
.build();
}

@ -164,12 +164,13 @@ public final class RunnerTest {
final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead");
final Path dbAhead = dataDirAhead.resolve("database");
final int blockCount = 500;
final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dbAhead));
final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dataDirAhead));
final NodeKey behindDbNodeKey = NodeKeyUtils.generate();
final SynchronizerConfiguration syncConfigAhead =
SynchronizerConfiguration.builder().syncMode(SyncMode.FULL).build();
final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem();
final var miningParameters = MiningParameters.newDefault();
final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
// Setup Runner with blocks
final BesuController controllerAhead =
getController(
@ -177,7 +178,8 @@ public final class RunnerTest {
syncConfigAhead,
dataDirAhead,
aheadDbNodeKey,
createKeyValueStorageProvider(dataDirAhead, dbAhead),
createKeyValueStorageProvider(
dataDirAhead, dbAhead, dataStorageConfiguration, miningParameters),
noOpMetricsSystem);
setupState(
blockCount, controllerAhead.getProtocolSchedule(), controllerAhead.getProtocolContext());
@ -376,7 +378,13 @@ public final class RunnerTest {
return GenesisConfigFile.fromConfig(jsonNode);
}
private StorageProvider createKeyValueStorageProvider(final Path dataDir, final Path dbDir) {
private StorageProvider createKeyValueStorageProvider(
final Path dataDir,
final Path dbDir,
final DataStorageConfiguration dataStorageConfiguration,
final MiningParameters miningParameters) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(dataDir, dbDir, dataStorageConfiguration, miningParameters);
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValueStorageFactory(
@ -388,7 +396,7 @@ public final class RunnerTest {
DEFAULT_IS_HIGH_SPEC),
Arrays.asList(KeyValueSegmentIdentifier.values()),
RocksDBMetricsFactory.PUBLIC_ROCKS_DB_METRICS))
.withCommonConfiguration(new BesuConfigurationImpl(dataDir, dbDir))
.withCommonConfiguration(besuConfiguration)
.withMetricsSystem(new NoOpMetricsSystem())
.build();
}

@ -75,13 +75,13 @@ import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.StorageService;
import org.hyperledger.besu.plugin.services.securitymodule.SecurityModule;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageFactory;
import org.hyperledger.besu.plugin.services.storage.PrivacyKeyValueStorageFactory;
import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PluginTransactionValidatorServiceImpl;
@ -207,7 +207,7 @@ public abstract class CommandTestAbstract {
@Mock protected StorageServiceImpl storageService;
@Mock protected SecurityModuleServiceImpl securityModuleService;
@Mock protected SecurityModule securityModule;
@Mock protected BesuConfiguration commonPluginConfiguration;
@Mock protected BesuConfigurationImpl commonPluginConfiguration;
@Mock protected KeyValueStorageFactory rocksDBStorageFactory;
@Mock protected PrivacyKeyValueStorageFactory rocksDBSPrivacyStorageFactory;
@Mock protected PicoCLIOptions cliOptions;

@ -205,6 +205,11 @@ public abstract class AbstractIsolationTests {
public int getDatabaseVersion() {
return 2;
}
@Override
public Wei getMinGasPrice() {
return MiningParameters.newDefault().getMinTransactionGasPrice();
}
})
.withMetricsSystem(new NoOpMetricsSystem())
.build();

@ -24,6 +24,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
@ -160,6 +161,9 @@ public class WorldStateDownloaderBenchmark {
}
private StorageProvider createKeyValueStorageProvider(final Path dataDir, final Path dbDir) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(
dataDir, dbDir, DataStorageConfiguration.DEFAULT_CONFIG, MiningParameters.newDefault());
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValueStorageFactory(
@ -171,7 +175,7 @@ public class WorldStateDownloaderBenchmark {
DEFAULT_IS_HIGH_SPEC),
Arrays.asList(KeyValueSegmentIdentifier.values()),
RocksDBMetricsFactory.PUBLIC_ROCKS_DB_METRICS))
.withCommonConfiguration(new BesuConfigurationImpl(dataDir, dbDir))
.withCommonConfiguration(besuConfiguration)
.withMetricsSystem(new NoOpMetricsSystem())
.build();
}

@ -88,7 +88,9 @@ public class EvmToolCommandOptionsModule {
@Provides
@Singleton
BesuConfiguration provideBesuConfiguration() {
return new BesuConfigurationImpl(dataPath, dataPath.resolve(BesuController.DATABASE_PATH));
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration.init(dataPath, dataPath.resolve(BesuController.DATABASE_PATH), null, null);
return besuConfiguration;
}
@Option(

@ -69,7 +69,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = '3+WNtdl1idY70N/MwVBbopU2ZWyWiu12YV1qaYXprZ8='
knownHash = 'f6P3+XG9GjPYEg7zrXHlujoE2/4axgd+EjKGDDJVVp8='
}
check.dependsOn('checkAPIChanges')

@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.plugin.services;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.plugin.Unstable;
import java.nio.file.Path;
@ -41,7 +42,13 @@ public interface BesuConfiguration extends BesuService {
* @return Database version.
*/
@Unstable
default int getDatabaseVersion() {
return 1;
}
int getDatabaseVersion();
/**
* The runtime value of the min gas price
*
* @return min gas price in wei
*/
@Unstable
Wei getMinGasPrice();
}

Loading…
Cancel
Save