@ -285,7 +285,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final StorageServiceImpl storageService ;
private final SecurityModuleServiceImpl securityModuleService ;
private final PermissioningServiceImpl permissioningService ;
private final PrivacyPluginServiceImpl privacyPluginPlugin Service ;
private final PrivacyPluginServiceImpl privacyPluginService ;
private final RpcEndpointServiceImpl rpcEndpointServiceImpl ;
private final Map < String , String > environment ;
@ -1161,7 +1161,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final StorageServiceImpl storageService ,
final SecurityModuleServiceImpl securityModuleService ,
final PermissioningServiceImpl permissioningService ,
final PrivacyPluginServiceImpl privacyPluginPlugin Service ,
final PrivacyPluginServiceImpl privacyPluginService ,
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider ,
final RpcEndpointServiceImpl rpcEndpointServiceImpl ) {
this . logger = logger ;
@ -1175,7 +1175,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
this . storageService = storageService ;
this . securityModuleService = securityModuleService ;
this . permissioningService = permissioningService ;
this . privacyPluginPlugin Service = privacyPlugin PluginService ;
this . privacyPluginService = privacyPluginService ;
pluginCommonConfiguration = new BesuCommandConfigurationService ( ) ;
besuPluginContext . addService ( BesuConfiguration . class , pluginCommonConfiguration ) ;
this . pkiBlockCreationConfigProvider = pkiBlockCreationConfigProvider ;
@ -1224,6 +1224,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
configure ( ) ;
initController ( ) ;
startPlugins ( ) ;
validatePluginOptions ( ) ;
preSynchronization ( ) ;
startSynchronization ( ) ;
@ -1317,7 +1318,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext . addService ( StorageService . class , storageService ) ;
besuPluginContext . addService ( MetricCategoryRegistry . class , metricCategoryRegistry ) ;
besuPluginContext . addService ( PermissioningService . class , permissioningService ) ;
besuPluginContext . addService ( PrivacyPluginService . class , privacyPluginPlugin Service ) ;
besuPluginContext . addService ( PrivacyPluginService . class , privacyPluginService ) ;
besuPluginContext . addService ( RpcEndpointService . class , rpcEndpointServiceImpl ) ;
// register built-in plugins
@ -1418,6 +1419,47 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext . startPlugins ( ) ;
}
private void validatePluginOptions ( ) {
// plugins do not 'wire up' until start has been called
// consequently you can only do some configuration checks
// after start has been called on plugins
if ( isPrivacyEnabled ) {
if ( privateMarkerTransactionSigningKeyPath ! = null
& & privacyPluginService ! = null
& & privacyPluginService . getPrivateMarkerTransactionFactory ( ) ! = null ) {
throw new ParameterException (
commandLine ,
"--privacy-marker-transaction-signing-key-file can not be used in conjunction with a plugin that specifies a PrivateMarkerTransactionFactory" ) ;
}
if ( Wei . ZERO . compareTo ( minTransactionGasPrice ) < 0 ) {
// if gas is required, cannot use random keys to sign private tx
// ie --privacy-marker-transaction-signing-key-file must be set
if ( privateMarkerTransactionSigningKeyPath = = null
& & ( privacyPluginService = = null
| | privacyPluginService . getPrivateMarkerTransactionFactory ( ) = = null ) ) {
throw new ParameterException (
commandLine ,
"Not a free gas network. --privacy-marker-transaction-signing-key-file must be specified and must be a funded account. Private transactions cannot be signed by random (non-funded) accounts in paid gas networks" ) ;
}
}
if ( unstablePrivacyPluginOptions . isPrivacyPluginEnabled ( )
& & privacyPluginService . getPayloadProvider ( ) = = null ) {
throw new ParameterException (
commandLine ,
"No Payload Provider has been provided. You must register one when enabling privacy plugin!" ) ;
}
if ( unstablePrivacyPluginOptions . isPrivacyPluginEnabled ( ) & & isFlexiblePrivacyGroupsEnabled ) {
throw new ParameterException (
commandLine , "Privacy Plugin can not be used with flexible (onchain) privacy groups" ) ;
}
}
}
public void configureLogging ( final boolean announce ) {
// To change the configuration if color was enabled/disabled
Configurator . reconfigure ( ) ;
@ -2165,19 +2207,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"Privacy multi-tenancy requires either http authentication to be enabled or WebSocket authentication to be enabled" ) ;
}
if ( unstablePrivacyPluginOptions . isPrivacyPluginEnabled ( )
& & privacyPluginPluginService . getPayloadProvider ( ) = = null ) {
// The plugin may register the payload provider in start or register.
// At this point we have only called start.
logger . warn (
"No Payload Provider has been provided. You must register one when enabling privacy plugin!" ) ;
}
if ( unstablePrivacyPluginOptions . isPrivacyPluginEnabled ( ) & & isFlexiblePrivacyGroupsEnabled ) {
throw new ParameterException (
commandLine , "Privacy Plugin can not be used with flexible (onchain) privacy groups" ) ;
}
privacyParametersBuilder . setEnabled ( true ) ;
privacyParametersBuilder . setEnclaveUrl ( privacyUrl ) ;
privacyParametersBuilder . setMultiTenancyEnabled ( isPrivacyMultiTenancyEnabled ) ;
@ -2192,7 +2221,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
commandLine , "Privacy multi-tenancy and privacy public key cannot be used together" ) ;
}
if ( ! hasPrivacyPublicKey & & ! isPrivacyMultiTenancyEnabled ) {
if ( ! hasPrivacyPublicKey
& & ! isPrivacyMultiTenancyEnabled
& & ! unstablePrivacyPluginOptions . isPrivacyPluginEnabled ( ) ) {
throw new ParameterException (
commandLine , "Please specify Enclave public key file path to enable privacy" ) ;
}
@ -2209,26 +2240,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
}
if ( Wei . ZERO . compareTo ( minTransactionGasPrice ) < 0 ) {
// if gas is required, cannot use random keys to sign private tx
// ie --privacy-marker-transaction-signing-key-file must be set
if ( privateMarkerTransactionSigningKeyPath = = null
& & ( privacyPluginPluginService = = null
| | privacyPluginPluginService . getPrivateMarkerTransactionFactory ( ) = = null ) ) {
throw new ParameterException (
commandLine ,
"Not a free gas network. --privacy-marker-transaction-signing-key-file must be specified and must be a funded account. Private transactions cannot be signed by random (non-funded) accounts in paid gas networks" ) ;
}
}
if ( privateMarkerTransactionSigningKeyPath ! = null
& & privacyPluginPluginService ! = null
& & privacyPluginPluginService . getPrivateMarkerTransactionFactory ( ) ! = null ) {
throw new ParameterException (
commandLine ,
"--privacy-marker-transaction-signing-key-file can not be used in conjunction with a plugin that specifies a PrivateMarkerTransactionFactory" ) ;
}
privacyParametersBuilder . setPrivateKeyPath ( privateMarkerTransactionSigningKeyPath ) ;
privacyParametersBuilder . setStorageProvider (
privacyKeyStorageProvider ( keyValueStorageName + "-privacy" ) ) ;
@ -2252,7 +2263,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
| | rpcWsApis . contains ( RpcApis . GOQUORUM . name ( ) ) ) ) {
logger . warn ( "Cannot use GOQUORUM API methods when not in GoQuorum mode." ) ;
}
privacyParametersBuilder . setPrivacyService ( privacyPluginPlugin Service ) ;
privacyParametersBuilder . setPrivacyService ( privacyPluginService ) ;
final PrivacyParameters privacyParameters = privacyParametersBuilder . build ( ) ;
if ( isPrivacyEnabled ) {