@ -37,45 +37,43 @@ import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig ;
import org.hyperledger.besu.cli.config.NetworkName ;
import org.hyperledger.besu.cli.config.ProfilesCompletionCandidates ;
import org.hyperledger.besu.cli.converter.MetricCategoryConverter ;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty ;
import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler ;
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler ;
import org.hyperledger.besu.cli.options.ApiConfigurationOptions ;
import org.hyperledger.besu.cli.options.ChainPruningOptions ;
import org.hyperledger.besu.cli.options.DnsOptions ;
import org.hyperledger.besu.cli.options.EngineRPCConfiguration ;
import org.hyperledger.besu.cli.options.EngineRPCOptions ;
import org.hyperledger.besu.cli.options.EthProtocolOptions ;
import org.hyperledger.besu.cli.options.EthstatsOptions ;
import org.hyperledger.besu.cli.options.EvmOptions ;
import org.hyperledger.besu.cli.options.GraphQlOptions ;
import org.hyperledger.besu.cli.options.InProcessRpcOptions ;
import org.hyperledger.besu.cli.options.IpcOptions ;
import org.hyperledger.besu.cli.options.JsonRpcHttpOptions ;
import org.hyperledger.besu.cli.options.LoggingLevelOption ;
import org.hyperledger.besu.cli.options.MetricsOptions ;
import org.hyperledger.besu.cli.options.MiningOptions ;
import org.hyperledger.besu.cli.options.NatOptions ;
import org.hyperledger.besu.cli.options.NativeLibraryOptions ;
import org.hyperledger.besu.cli.options.NetworkingOptions ;
import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption ;
import org.hyperledger.besu.cli.options.P2PDiscoveryOptions ;
import org.hyperledger.besu.cli.options.P2PTLSConfigOptions ;
import org.hyperledger.besu.cli.options.PermissionsOptions ;
import org.hyperledger.besu.cli.options.PluginsConfigurationOptions ;
import org.hyperledger.besu.cli.options.PrivacyPluginOptions ;
import org.hyperledger.besu.cli.options.RPCOptions ;
import org.hyperledger.besu.cli.options.RpcWebsocketOptions ;
import org.hyperledger.besu.cli.options.SynchronizerOptions ;
import org.hyperledger.besu.cli.options.TransactionPoolOptions ;
import org.hyperledger.besu.cli.options.stable.ApiConfigurationOptions ;
import org.hyperledger.besu.cli.options.stable.EngineRPCConfiguration ;
import org.hyperledger.besu.cli.options.stable.EngineRPCOptions ;
import org.hyperledger.besu.cli.options.stable.EthstatsOptions ;
import org.hyperledger.besu.cli.options.stable.GraphQlOptions ;
import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions ;
import org.hyperledger.besu.cli.options.stable.LoggingLevelOption ;
import org.hyperledger.besu.cli.options.stable.MetricsOptions ;
import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption ;
import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions ;
import org.hyperledger.besu.cli.options.stable.PermissionsOptions ;
import org.hyperledger.besu.cli.options.stable.PluginsConfigurationOptions ;
import org.hyperledger.besu.cli.options.stable.RpcWebsocketOptions ;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions ;
import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions ;
import org.hyperledger.besu.cli.options.unstable.ChainPruningOptions ;
import org.hyperledger.besu.cli.options.unstable.DnsOptions ;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions ;
import org.hyperledger.besu.cli.options.unstable.EvmOptions ;
import org.hyperledger.besu.cli.options.unstable.InProcessRpcOptions ;
import org.hyperledger.besu.cli.options.unstable.IpcOptions ;
import org.hyperledger.besu.cli.options.unstable.NatOptions ;
import org.hyperledger.besu.cli.options.unstable.NativeLibraryOptions ;
import org.hyperledger.besu.cli.options.unstable.NetworkingOptions ;
import org.hyperledger.besu.cli.options.unstable.P2PTLSConfigOptions ;
import org.hyperledger.besu.cli.options.unstable.PrivacyPluginOptions ;
import org.hyperledger.besu.cli.options.unstable.RPCOptions ;
import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions ;
import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner ;
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask ;
import org.hyperledger.besu.cli.subcommands.PasswordSubCommand ;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand ;
import org.hyperledger.besu.cli.subcommands.RetestethSubCommand ;
import org.hyperledger.besu.cli.subcommands.TxParseSubCommand ;
import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand ;
import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand ;
@ -115,7 +113,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration ;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries ;
import org.hyperledger.besu.ethereum.chain.Blockchain ;
import org.hyperledger.besu.ethereum.core.MiningParameters ;
import org.hyperledger.besu.ethereum.core.MiningConfiguration ;
import org.hyperledger.besu.ethereum.core.MiningParametersMetrics ;
import org.hyperledger.besu.ethereum.core.PrivacyParameters ;
import org.hyperledger.besu.ethereum.core.VersionMetadata ;
@ -170,8 +168,8 @@ import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService ;
import org.hyperledger.besu.plugin.services.TransactionSimulationService ;
import org.hyperledger.besu.plugin.services.exception.StorageException ;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory ;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry ;
import org.hyperledger.besu.plugin.services.mining.MiningService ;
import org.hyperledger.besu.plugin.services.p2p.P2PService ;
import org.hyperledger.besu.plugin.services.rlp.RlpConverterService ;
import org.hyperledger.besu.plugin.services.securitymodule.SecurityModule ;
@ -184,6 +182,7 @@ import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl ;
import org.hyperledger.besu.services.BesuPluginContextImpl ;
import org.hyperledger.besu.services.BlockchainServiceImpl ;
import org.hyperledger.besu.services.MiningServiceImpl ;
import org.hyperledger.besu.services.P2PServiceImpl ;
import org.hyperledger.besu.services.PermissioningServiceImpl ;
import org.hyperledger.besu.services.PicoCLIOptionsImpl ;
@ -332,7 +331,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Map < String , String > environment ;
private final MetricCategoryRegistryImpl metricCategoryRegistry =
new MetricCategoryRegistryImpl ( ) ;
private final MetricCategoryConverter metricCategoryConverter = new MetricCategoryConverter ( ) ;
private final PreSynchronizationTaskRunner preSynchronizationTaskRunner =
new PreSynchronizationTaskRunner ( ) ;
@ -342,7 +340,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
Suppliers . memoize ( this : : readGenesisConfigFile ) ;
private final Supplier < GenesisConfigOptions > genesisConfigOptionsSupplier =
Suppliers . memoize ( this : : readGenesisConfigOptions ) ;
private final Supplier < MiningParameters > miningParametersSupplier =
private final Supplier < MiningConfiguration > miningParametersSupplier =
Suppliers . memoize ( this : : getMiningParameters ) ;
private RocksDBPlugin rocksDBPlugin ;
@ -509,77 +507,95 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@CommandLine.ArgGroup ( validate = false , heading = "@|bold In-Process RPC Options|@%n" )
InProcessRpcOptions inProcessRpcOptions = InProcessRpcOptions . create ( ) ;
private static final String PRIVACY_DEPRECATION_PREFIX =
"Deprecated. Tessera-based privacy is deprecated. See CHANGELOG for alternative options. " ;
// Privacy Options Group
@CommandLine.ArgGroup ( validate = false , heading = "@|bold Privacy Options|@%n" )
@CommandLine.ArgGroup ( validate = false , heading = "@|bold (Deprecated) Privacy Options |@%n" )
PrivacyOptionGroup privacyOptionGroup = new PrivacyOptionGroup ( ) ;
static class PrivacyOptionGroup {
@Option (
names = { "--privacy-tls-enabled" } ,
paramLabel = MANDATORY_FILE_FORMAT_HELP ,
description = "Enable TLS for connecting to privacy enclave (default: ${DEFAULT-VALUE})" )
description =
PRIVACY_DEPRECATION_PREFIX
+ "Enable TLS for connecting to privacy enclave (default: ${DEFAULT-VALUE})" )
private final Boolean isPrivacyTlsEnabled = false ;
@Option (
names = "--privacy-tls-keystore-file" ,
paramLabel = MANDATORY_FILE_FORMAT_HELP ,
description =
"Path to a PKCS#12 formatted keystore; used to enable TLS on inbound connections." )
PRIVACY_DEPRECATION_PREFIX
+ "Path to a PKCS#12 formatted keystore; used to enable TLS on inbound connections." )
private final Path privacyKeyStoreFile = null ;
@Option (
names = "--privacy-tls-keystore-password-file" ,
paramLabel = MANDATORY_FILE_FORMAT_HELP ,
description = "Path to a file containing the password used to decrypt the keystore." )
description =
PRIVACY_DEPRECATION_PREFIX
+ "Path to a file containing the password used to decrypt the keystore." )
private final Path privacyKeyStorePasswordFile = null ;
@Option (
names = "--privacy-tls-known-enclave-file" ,
paramLabel = MANDATORY_FILE_FORMAT_HELP ,
description =
"Path to a file containing the fingerprints of the authorized privacy enclave." )
PRIVACY_DEPRECATION_PREFIX
+ "Path to a file containing the fingerprints of the authorized privacy enclave." )
private final Path privacyTlsKnownEnclaveFile = null ;
@Option (
names = { "--privacy-enabled" } ,
description = "Enable private transactions (default: ${DEFAULT-VALUE})" )
description =
PRIVACY_DEPRECATION_PREFIX + "Enable private transactions (default: ${DEFAULT-VALUE})" )
private final Boolean isPrivacyEnabled = false ;
@Option (
names = { "--privacy-multi-tenancy-enabled" } ,
description = "Enable multi-tenant private transactions (default: ${DEFAULT-VALUE})" )
description =
PRIVACY_DEPRECATION_PREFIX
+ "Enable multi-tenant private transactions (default: ${DEFAULT-VALUE})" )
private final Boolean isPrivacyMultiTenancyEnabled = false ;
@Option (
names = { "--privacy-url" } ,
description = "The URL on which the enclave is running" )
description = PRIVACY_DEPRECATION_PREFIX + "The URL on which the enclave is running" )
private final URI privacyUrl = PrivacyParameters . DEFAULT_ENCLAVE_URL ;
@Option (
names = { "--privacy-public-key-file" } ,
description = "The enclave's public key file" )
description = PRIVACY_DEPRECATION_PREFIX + "The enclave's public key file" )
private final File privacyPublicKeyFile = null ;
@Option (
names = { "--privacy-marker-transaction-signing-key-file" } ,
description =
"The name of a file containing the private key used to sign privacy marker transactions. If unset, each will be signed with a random key." )
PRIVACY_DEPRECATION_PREFIX
+ "The name of a file containing the private key used to sign privacy marker transactions. If unset, each will be signed with a random key." )
private final Path privateMarkerTransactionSigningKeyPath = null ;
@Option (
names = { "--privacy-enable-database-migration" } ,
description = "Enable private database metadata migration (default: ${DEFAULT-VALUE})" )
description =
PRIVACY_DEPRECATION_PREFIX
+ "Enable private database metadata migration (default: ${DEFAULT-VALUE})" )
private final Boolean migratePrivateDatabase = false ;
@Option (
names = { "--privacy-flexible-groups-enabled" } ,
description = "Enable flexible privacy groups (default: ${DEFAULT-VALUE})" )
description =
PRIVACY_DEPRECATION_PREFIX
+ "Enable flexible privacy groups (default: ${DEFAULT-VALUE})" )
private final Boolean isFlexiblePrivacyGroupsEnabled = false ;
@Option (
names = { "--privacy-nonce-always-increments" } ,
description =
"Enable private nonce "
PRIVACY_DEPRECATION_PREFIX
+ "Enable private nonce "
+ "incrementation even if the transaction didn't succeeded (default: ${DEFAULT-VALUE})" )
private final Boolean isPrivateNonceAlwaysIncrementsEnabled = false ;
}
@ -1108,7 +1124,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
PublicKeySubCommand . COMMAND_NAME , new PublicKeySubCommand ( commandLine . getOut ( ) ) ) ;
commandLine . addSubcommand (
PasswordSubCommand . COMMAND_NAME , new PasswordSubCommand ( commandLine . getOut ( ) ) ) ;
commandLine . addSubcommand ( RetestethSubCommand . COMMAND_NAME , new RetestethSubCommand ( ) ) ;
commandLine . addSubcommand (
RLPSubCommand . COMMAND_NAME , new RLPSubCommand ( commandLine . getOut ( ) , in ) ) ;
commandLine . addSubcommand (
@ -1136,10 +1151,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
commandLine . registerConverter ( Hash . class , Hash : : fromHexString ) ;
commandLine . registerConverter ( Optional . class , Optional : : of ) ;
commandLine . registerConverter ( Double . class , Double : : parseDouble ) ;
metricCategoryConverter . addCategories ( BesuMetricCategory . class ) ;
metricCategoryConverter . addCategories ( StandardMetricCategory . class ) ;
commandLine . registerConverter ( MetricCategory . class , metricCategoryConverter ) ;
}
private void handleStableOptions ( ) {
@ -1174,6 +1185,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext . addService ( PicoCLIOptions . class , new PicoCLIOptionsImpl ( commandLine ) ) ;
besuPluginContext . addService ( SecurityModuleService . class , securityModuleService ) ;
besuPluginContext . addService ( StorageService . class , storageService ) ;
metricCategoryRegistry . addCategories ( BesuMetricCategory . class ) ;
metricCategoryRegistry . addCategories ( StandardMetricCategory . class ) ;
besuPluginContext . addService ( MetricCategoryRegistry . class , metricCategoryRegistry ) ;
besuPluginContext . addService ( PermissioningService . class , permissioningService ) ;
besuPluginContext . addService ( PrivacyPluginService . class , privacyPluginService ) ;
@ -1191,10 +1205,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
rocksDBPlugin . register ( besuPluginContext ) ;
new InMemoryStoragePlugin ( ) . register ( besuPluginContext ) ;
metricCategoryRegistry
. getMetricCategories ( )
. forEach ( metricCategoryConverter : : addRegistryCategory ) ;
// register default security module
securityModuleService . register (
DEFAULT_SECURITY_MODULE , Suppliers . memoize ( this : : defaultSecurityModule ) ) ;
@ -1243,7 +1253,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void startPlugins ( final Runner runner ) {
blockchainServiceImpl . init (
besuController . getProtocolContext ( ) , besuController . getProtocolSchedule ( ) ) ;
besuController . getProtocolContext ( ) . getBlockchain ( ) , besuController . getProtocolSchedule ( ) ) ;
transactionSimulationServiceImpl . init (
besuController . getProtocolContext ( ) . getBlockchain ( ) ,
new TransactionSimulator (
@ -1293,6 +1303,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
miningParametersSupplier . get ( ) ) ,
besuController . getProtocolSchedule ( ) ) ) ;
besuPluginContext . addService (
MiningService . class , new MiningServiceImpl ( besuController . getMiningCoordinator ( ) ) ) ;
besuController . getAdditionalPluginServices ( ) . appendPluginServices ( besuPluginContext ) ;
besuPluginContext . startPlugins ( ) ;
}
@ -1303,6 +1316,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
// after start has been called on plugins
if ( Boolean . TRUE . equals ( privacyOptionGroup . isPrivacyEnabled ) ) {
logger . warn (
"--Xprivacy-plugin-enabled and related options are " + PRIVACY_DEPRECATION_PREFIX ) ;
if ( privacyOptionGroup . privateMarkerTransactionSigningKeyPath ! = null
& & privacyPluginService ! = null
@ -1342,7 +1357,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void setReleaseMetrics ( ) {
besuComponent
. getMetricsSystem ( )
. createLabelledGauge (
. createLabelledSupplied Gauge (
StandardMetricCategory . PROCESS , "release" , "Release information" , "version" )
. labels ( ( ) - > 1 , BesuInfo . version ( ) ) ;
}
@ -1891,6 +1906,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"--metrics-push-interval" ,
"--metrics-push-prometheus-job" ) ) ;
metricsOptions . setMetricCategoryRegistry ( metricCategoryRegistry ) ;
metricsOptions . validate ( commandLine ) ;
final MetricsConfiguration . Builder metricsConfigurationBuilder =
metricsOptions . toDomainObject ( ) ;
metricsConfigurationBuilder
@ -1903,7 +1922,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
? p2PDiscoveryOptions . autoDiscoverDefaultIP ( ) . getHostAddress ( )
: metricsOptions . getMetricsPushHost ( ) )
. hostsAllowlist ( hostsAllowlist ) ;
return metricsConfigurationBuilder . build ( ) ;
final var metricsConfiguration = metricsConfigurationBuilder . build ( ) ;
metricCategoryRegistry . setMetricsConfiguration ( metricsConfiguration ) ;
return metricsConfiguration ;
}
private PrivacyParameters privacyParameters ( ) {
@ -1926,6 +1947,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final PrivacyParameters . Builder privacyParametersBuilder = new PrivacyParameters . Builder ( ) ;
if ( Boolean . TRUE . equals ( privacyOptionGroup . isPrivacyEnabled ) ) {
logger . warn ( "--privacy-enabled and related options are " + PRIVACY_DEPRECATION_PREFIX ) ;
final String errorSuffix = "cannot be enabled with privacy." ;
if ( syncMode = = SyncMode . FAST ) {
throw new ParameterException ( commandLine , String . format ( "%s %s" , "Fast sync" , errorSuffix ) ) ;
@ -2121,7 +2143,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return txPoolConfBuilder . build ( ) ;
}
private MiningParameters getMiningParameters ( ) {
private MiningConfiguration getMiningParameters ( ) {
miningOptions . setTransactionSelectionService ( transactionSelectionServiceImpl ) ;
final var miningParameters = miningOptions . toDomainObject ( ) ;
getGenesisBlockPeriodSeconds ( genesisConfigOptionsSupplier . get ( ) )
@ -2173,8 +2195,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return dataStorageConfiguration ;
}
private void initMiningParametersMetrics ( final MiningParameters miningParameters ) {
new MiningParametersMetrics ( getMetricsSystem ( ) , miningParameters ) ;
private void initMiningParametersMetrics ( final MiningConfiguration miningConfiguration ) {
new MiningParametersMetrics ( getMetricsSystem ( ) , miningConfiguration ) ;
}
private OptionalInt getGenesisBlockPeriodSeconds (