Skip to content

Commit

Permalink
Removing privacy from Besu
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Feb 27, 2025
1 parent 3d41ccb commit 35f99dc
Show file tree
Hide file tree
Showing 247 changed files with 39 additions and 19,155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
Expand Down Expand Up @@ -103,7 +102,6 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private MiningConfiguration miningConfiguration;
private TransactionPoolConfiguration txPoolConfiguration;
private final List<String> runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional<JsonRpcConfiguration> engineRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
Expand Down Expand Up @@ -167,7 +165,6 @@ public BesuNode(
final List<String> extraCLIOptions,
final List<String> staticNodes,
final boolean isDnsEnabled,
final Optional<PrivacyParameters> privacyParameters,
final List<String> runCommand,
final Optional<KeyPair> keyPair,
final boolean isStrictTxReplayProtectionEnabled,
Expand Down Expand Up @@ -232,7 +229,6 @@ public BesuNode(
this.extraCLIOptions = extraCLIOptions;
this.staticNodes = staticNodes;
this.isDnsEnabled = isDnsEnabled;
privacyParameters.ifPresent(this::setPrivacyParameters);
this.environment = environment;
LOG.info("Created BesuNode {}", this);
}
Expand Down Expand Up @@ -691,14 +687,6 @@ public void setTransactionPoolConfiguration(
this.txPoolConfiguration = txPoolConfiguration;
}

public PrivacyParameters getPrivacyParameters() {
return privacyParameters;
}

public void setPrivacyParameters(final PrivacyParameters privacyParameters) {
this.privacyParameters = privacyParameters;
}

public DataStorageConfiguration getDataStorageConfiguration() {
return dataStorageConfiguration;
}
Expand Down Expand Up @@ -780,7 +768,6 @@ public String toString() {
.add("keyPair", keyPair)
.add("p2pEnabled", p2pEnabled)
.add("discoveryEnabled", discoveryEnabled)
.add("privacyEnabled", privacyParameters.isEnabled())
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.SecurityModuleService;
import org.hyperledger.besu.plugin.services.StorageService;
Expand All @@ -84,7 +83,6 @@
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.hyperledger.besu.plugin.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyGroupGenesisProvider;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyPluginPayloadProvider;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestSigningPrivateMarkerTransactionFactory;
Expand Down
94 changes: 10 additions & 84 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static java.util.function.Predicate.isEqual;
import static java.util.function.Predicate.not;
import static org.hyperledger.besu.controller.BesuController.CACHE_PATH;
import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIVACY;

import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
Expand Down Expand Up @@ -56,7 +55,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketService;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.PrivateWebSocketMethodsFactory;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketMethodsFactory;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.blockheaders.NewBlockHeadersSubscriptionService;
Expand All @@ -65,19 +63,15 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.pending.PendingTransactionSubscriptionService;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.syncing.SyncingSubscriptionService;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.PrivacyQueries;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration;
Expand All @@ -104,7 +98,6 @@
import org.hyperledger.besu.ethereum.permissioning.node.InsufficientPeersPermissioningProvider;
import org.hyperledger.besu.ethereum.permissioning.node.NodePermissioningController;
import org.hyperledger.besu.ethereum.permissioning.node.PeerPermissionsAdapter;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionObserver;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.stratum.StratumServer;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
Expand Down Expand Up @@ -740,19 +733,13 @@ public Runner build() {
apiConfiguration,
miningConfiguration);

final PrivacyParameters privacyParameters = besuController.getPrivacyParameters();

final FilterManager filterManager =
new FilterManagerBuilder()
.blockchainQueries(blockchainQueries)
.transactionPool(transactionPool)
.privacyParameters(privacyParameters)
.build();
vertx.deployVerticle(filterManager);

createPrivateTransactionObserver(
filterManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());

final P2PNetwork peerNetwork = networkRunner.getNetwork();

Optional<StratumServer> stratumServer = Optional.empty();
Expand Down Expand Up @@ -784,8 +771,7 @@ public Runner build() {
nodePermissioningController.flatMap(NodePermissioningController::localConfigController);

final Optional<AccountPermissioningController> accountPermissioningController =
buildAccountPermissioningController(
permissioningConfiguration, besuController, transactionSimulator);
buildAccountPermissioningController(permissioningConfiguration, transactionSimulator);

final Optional<AccountLocalConfigPermissioningController>
accountLocalConfigPermissioningController =
Expand Down Expand Up @@ -814,7 +800,6 @@ public Runner build() {
filterManager,
accountLocalConfigPermissioningController,
nodeLocalConfigPermissioningController,
privacyParameters,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
Expand Down Expand Up @@ -861,7 +846,6 @@ public Runner build() {
filterManager,
accountLocalConfigPermissioningController,
nodeLocalConfigPermissioningController,
privacyParameters,
engineJsonRpcConfiguration.get(),
webSocketConfiguration,
metricsConfiguration,
Expand Down Expand Up @@ -958,7 +942,6 @@ public Runner build() {
filterManager,
accountLocalConfigPermissioningController,
nodeLocalConfigPermissioningController,
privacyParameters,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
Expand All @@ -970,8 +953,7 @@ public Runner build() {
transactionSimulator,
besuController.getProtocolManager().ethContext().getScheduler());

createLogsSubscriptionService(
context.getBlockchain(), subscriptionManager, privacyParameters, blockchainQueries);
createLogsSubscriptionService(context.getBlockchain(), subscriptionManager);

createNewBlockHeadersSubscriptionService(
context.getBlockchain(), blockchainQueries, subscriptionManager);
Expand All @@ -985,14 +967,8 @@ public Runner build() {
webSocketConfiguration,
subscriptionManager,
nonEngineMethods,
privacyParameters,
protocolSchedule,
blockchainQueries,
DefaultAuthenticationService.create(vertx, webSocketConfiguration),
metricsSystem));

createPrivateTransactionObserver(
subscriptionManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
}

final Optional<MetricsService> metricsService = createMetricsService(metricsConfiguration);
Expand Down Expand Up @@ -1040,7 +1016,6 @@ public Runner build() {
filterManager,
accountLocalConfigPermissioningController,
nodeLocalConfigPermissioningController,
privacyParameters,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
Expand Down Expand Up @@ -1081,7 +1056,6 @@ public Runner build() {
filterManager,
accountLocalConfigPermissioningController,
nodeLocalConfigPermissioningController,
privacyParameters,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
Expand Down Expand Up @@ -1174,19 +1148,19 @@ private Optional<NodePermissioningController> buildNodePermissioningController(

private Optional<AccountPermissioningController> buildAccountPermissioningController(
final Optional<PermissioningConfiguration> permissioningConfiguration,
final BesuController besuController,
final TransactionSimulator transactionSimulator) {

if (permissioningConfiguration.isPresent()) {
final Optional<AccountPermissioningController> accountPermissioningController =
AccountPermissioningControllerFactory.create(
permissioningConfiguration.get(), transactionSimulator, metricsSystem);

accountPermissioningController.ifPresent(
permissioningController ->
besuController
.getProtocolSchedule()
.setPermissionTransactionFilter(permissioningController::isPermitted));
// MRW - was this only doing privacy-related things?
/*accountPermissioningController.ifPresent(
permissioningController ->
besuController
.getProtocolSchedule()
.setPermissionTransactionFilter(permissioningController::isPermitted));*/

return accountPermissioningController;
} else {
Expand Down Expand Up @@ -1243,7 +1217,6 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
final FilterManager filterManager,
final Optional<AccountLocalConfigPermissioningController> accountAllowlistController,
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistController,
final PrivacyParameters privacyParameters,
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
Expand Down Expand Up @@ -1279,7 +1252,6 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
accountAllowlistController,
nodeAllowlistController,
jsonRpcApis,
privacyParameters,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
Expand Down Expand Up @@ -1326,48 +1298,13 @@ private SubscriptionManager createSubscriptionManager(
}

private void createLogsSubscriptionService(
final Blockchain blockchain,
final SubscriptionManager subscriptionManager,
final PrivacyParameters privacyParameters,
final BlockchainQueries blockchainQueries) {

Optional<PrivacyQueries> privacyQueries = Optional.empty();
if (privacyParameters.isEnabled()) {
privacyQueries =
Optional.of(
new PrivacyQueries(
blockchainQueries, privacyParameters.getPrivateWorldStateReader()));
}
final Blockchain blockchain, final SubscriptionManager subscriptionManager) {

final LogsSubscriptionService logsSubscriptionService =
new LogsSubscriptionService(subscriptionManager, privacyQueries);
new LogsSubscriptionService(subscriptionManager);

// monitoring public logs
blockchain.observeLogs(logsSubscriptionService);

// monitoring private logs
if (privacyParameters.isEnabled()) {
blockchain.observeBlockAdded(logsSubscriptionService::checkPrivateLogs);
}
}

private void createPrivateTransactionObserver(
final PrivateTransactionObserver privateTransactionObserver,
final PrivacyParameters privacyParameters,
final BlockHeader genesisBlockHeader) {
// register privateTransactionObserver as observer of events fired by the flexible precompile.
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()
&& privacyParameters.isMultiTenancyEnabled()) {
final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(FlexiblePrivacyPrecompiledContract)
besuController
.getProtocolSchedule()
.getByBlockHeader(genesisBlockHeader)
.getPrecompileContractRegistry()
.get(FLEXIBLE_PRIVACY);

flexiblePrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver);
}
}

private void createSyncingSubscriptionService(
Expand All @@ -1390,23 +1327,12 @@ private WebSocketService createWebsocketService(
final WebSocketConfiguration configuration,
final SubscriptionManager subscriptionManager,
final Map<String, JsonRpcMethod> jsonRpcMethods,
final PrivacyParameters privacyParameters,
final ProtocolSchedule protocolSchedule,
final BlockchainQueries blockchainQueries,
final Optional<AuthenticationService> authenticationService,
final ObservableMetricsSystem metricsSystem) {

final WebSocketMethodsFactory websocketMethodsFactory =
new WebSocketMethodsFactory(subscriptionManager, jsonRpcMethods);

if (privacyParameters.isEnabled()) {
final PrivateWebSocketMethodsFactory privateWebSocketMethodsFactory =
new PrivateWebSocketMethodsFactory(
privacyParameters, subscriptionManager, protocolSchedule, blockchainQueries);

privateWebSocketMethodsFactory.methods().forEach(websocketMethodsFactory::addMethods);
}

rpcEndpointServiceImpl
.getPluginMethods(configuration.getRpcApis())
.values()
Expand Down
Loading

0 comments on commit 35f99dc

Please sign in to comment.