diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java index 73b8188e30..43396f1ed8 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java @@ -34,7 +34,6 @@ import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.util.NetworkUtility; @@ -74,7 +73,6 @@ public abstract class PeerDiscoveryAgent implements DisconnectCallback { protected final List bootstrapPeers; private final List peerRequirements = new CopyOnWriteArrayList<>(); private final PeerBlacklist peerBlacklist; - private final Optional nodeWhitelistController; private final Optional nodePermissioningController; private final MetricsSystem metricsSystem; /* The peer controller, which takes care of the state machine of peers. */ @@ -98,7 +96,6 @@ public PeerDiscoveryAgent( final SECP256K1.KeyPair keyPair, final DiscoveryConfiguration config, final PeerBlacklist peerBlacklist, - final Optional nodeWhitelistController, final Optional nodePermissioningController, final MetricsSystem metricsSystem) { this.metricsSystem = metricsSystem; @@ -108,7 +105,6 @@ public PeerDiscoveryAgent( validateConfiguration(config); this.peerBlacklist = peerBlacklist; - this.nodeWhitelistController = nodeWhitelistController; this.nodePermissioningController = nodePermissioningController; this.bootstrapPeers = config.getBootstrapPeers().stream() @@ -183,7 +179,6 @@ private PeerDiscoveryController createController() { PEER_REFRESH_INTERVAL_MS, PeerRequirement.combine(peerRequirements), peerBlacklist, - nodeWhitelistController, nodePermissioningController, peerBondedObservers, peerDroppedObservers, diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java index ea9753f620..e2910e209d 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java @@ -22,7 +22,6 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.TimerUtil; import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.VertxTimerUtil; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricsSystem; @@ -61,16 +60,9 @@ public VertxPeerDiscoveryAgent( final KeyPair keyPair, final DiscoveryConfiguration config, final PeerBlacklist peerBlacklist, - final Optional nodeWhitelistController, final Optional nodePermissioningController, final MetricsSystem metricsSystem) { - super( - keyPair, - config, - peerBlacklist, - nodeWhitelistController, - nodePermissioningController, - metricsSystem); + super(keyPair, config, peerBlacklist, nodePermissioningController, metricsSystem); checkArgument(vertx != null, "vertx instance cannot be null"); this.vertx = vertx; diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java index 84a79c028b..1d585498c1 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java @@ -27,9 +27,7 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerTable.EvictResult.EvictOutcome; import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; -import tech.pegasys.pantheon.ethereum.permissioning.node.NodeWhitelistUpdatedEvent; import tech.pegasys.pantheon.metrics.Counter; import tech.pegasys.pantheon.metrics.LabelledMetric; import tech.pegasys.pantheon.metrics.MetricCategory; @@ -121,7 +119,6 @@ public class PeerDiscoveryController { private final DiscoveryPeer localPeer; private final OutboundMessageHandler outboundMessageHandler; private final PeerBlacklist peerBlacklist; - private final Optional nodeWhitelistController; private final Optional nodePermissioningController; private final DiscoveryProtocolLogger discoveryProtocolLogger; private final LabelledMetric interactionCounter; @@ -155,7 +152,6 @@ public PeerDiscoveryController( final long tableRefreshIntervalMs, final PeerRequirement peerRequirement, final PeerBlacklist peerBlacklist, - final Optional nodeWhitelistController, final Optional nodePermissioningController, final Subscribers> peerBondedObservers, final Subscribers> peerDroppedObservers, @@ -169,7 +165,6 @@ public PeerDiscoveryController( this.tableRefreshIntervalMs = tableRefreshIntervalMs; this.peerRequirement = peerRequirement; this.peerBlacklist = peerBlacklist; - this.nodeWhitelistController = nodeWhitelistController; this.nodePermissioningController = nodePermissioningController; this.outboundMessageHandler = outboundMessageHandler; this.peerBondedObservers = peerBondedObservers; @@ -243,9 +238,6 @@ public void start() { Math.min(REFRESH_CHECK_INTERVAL_MILLIS, tableRefreshIntervalMs), this::refreshTableIfRequired); tableRefreshTimerId = OptionalLong.of(timerId); - - nodeWhitelistController.ifPresent( - c -> c.subscribeToListUpdatedEvent(this::handleNodeWhitelistUpdatedEvent)); } public CompletableFuture stop() { @@ -375,10 +367,6 @@ private boolean addToPeerTable(final DiscoveryPeer peer) { return true; } - private void handleNodeWhitelistUpdatedEvent(final NodeWhitelistUpdatedEvent event) { - event.getRemovedNodes().stream().map(DiscoveryPeer::fromEnode).forEach(this::dropFromPeerTable); - } - @VisibleForTesting boolean dropFromPeerTable(final DiscoveryPeer peer) { final EvictResult evictResult = peerTable.tryEvict(peer); diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java index 8b7cbaa592..fd8baf683c 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java @@ -41,7 +41,6 @@ import tech.pegasys.pantheon.ethereum.p2p.wire.PeerInfo; import tech.pegasys.pantheon.ethereum.p2p.wire.SubProtocol; import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.metrics.Counter; import tech.pegasys.pantheon.metrics.LabelledMetric; @@ -733,8 +732,6 @@ public static class Builder { private Optional nodePermissioningController = Optional.empty(); private Blockchain blockchain = null; private Vertx vertx; - private Optional - nodeLocalConfigPermissioningController = Optional.empty(); public P2PNetwork build() { validate(); @@ -767,9 +764,6 @@ private void validate() { !nodePermissioningController.isPresent() || blockchain != null, "Network permissioning needs to listen to BlockAddedEvents. Blockchain can't be null."); checkState(vertx != null, "Vertx must be set."); - checkState( - nodeLocalConfigPermissioningController != null, - "NodeLocalConfigPermissioningController must be set."); } private PeerDiscoveryAgent createDiscoveryAgent() { @@ -779,7 +773,6 @@ private PeerDiscoveryAgent createDiscoveryAgent() { keyPair, config.getDiscovery(), peerBlacklist, - nodeLocalConfigPermissioningController, nodePermissioningController, metricsSystem); } @@ -790,21 +783,6 @@ public Builder vertx(final Vertx vertx) { return this; } - public Builder nodeLocalConfigPermissioningController( - final Optional - nodeLocalConfigPermissioningController) { - checkNotNull(nodeLocalConfigPermissioningController); - this.nodeLocalConfigPermissioningController = nodeLocalConfigPermissioningController; - return this; - } - - public Builder nodeLocalConfigPermissioningController( - final NodeLocalConfigPermissioningController nodeLocalConfigPermissioningController) { - this.nodeLocalConfigPermissioningController = - Optional.ofNullable(nodeLocalConfigPermissioningController); - return this; - } - public Builder keyPair(final KeyPair keyPair) { checkNotNull(keyPair); this.keyPair = keyPair; diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTestHelper.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTestHelper.java index e251a1047c..8a55aae3b0 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTestHelper.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTestHelper.java @@ -23,7 +23,6 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PingPacketData; import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.enode.EnodeURL; @@ -176,7 +175,6 @@ public static class AgentBuilder { private final AtomicInteger nextAvailablePort; private PeerBlacklist blacklist = new PeerBlacklist(); - private Optional whitelist = Optional.empty(); private Optional nodePermissioningController = Optional.empty(); private List bootstrapPeers = Collections.emptyList(); private boolean active = true; @@ -204,12 +202,6 @@ private List asEnodes(final List peers) { .collect(Collectors.toList()); } - public AgentBuilder whiteList( - final Optional whitelist) { - this.whitelist = whitelist; - return this; - } - public AgentBuilder nodePermissioningController(final NodePermissioningController controller) { this.nodePermissioningController = Optional.ofNullable(controller); return this; @@ -232,12 +224,7 @@ public MockPeerDiscoveryAgent build() { config.setActive(active); return new MockPeerDiscoveryAgent( - SECP256K1.KeyPair.generate(), - config, - blacklist, - whitelist, - nodePermissioningController, - agents); + SECP256K1.KeyPair.generate(), config, blacklist, nodePermissioningController, agents); } } } diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTimestampsTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTimestampsTest.java index 7f3442ca07..0ce29d3458 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTimestampsTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryTimestampsTest.java @@ -65,7 +65,6 @@ public void lastSeenAndFirstDiscoveredTimestampsUpdatedOnMessage() { () -> true, new PeerBlacklist(), Optional.empty(), - Optional.empty(), new Subscribers<>(), new Subscribers<>(), new NoOpMetricsSystem()); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java index 5ce8ac7855..508bd4998d 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java @@ -18,7 +18,6 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryAgent; import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerDiscoveryController.AsyncExecutor; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -41,16 +40,9 @@ public MockPeerDiscoveryAgent( final KeyPair keyPair, final DiscoveryConfiguration config, final PeerBlacklist peerBlacklist, - final Optional nodeWhitelistController, final Optional nodePermissioningController, final Map agentNetwork) { - super( - keyPair, - config, - peerBlacklist, - nodeWhitelistController, - nodePermissioningController, - new NoOpMetricsSystem()); + super(keyPair, config, peerBlacklist, nodePermissioningController, new NoOpMetricsSystem()); this.agentNetwork = agentNetwork; } diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java index cbc6adec7b..3366a5a493 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java @@ -41,8 +41,6 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerTable.EvictResult; import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; -import tech.pegasys.pantheon.ethereum.permissioning.LocalPermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.NodePermissioningController; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.util.Subscribers; @@ -53,10 +51,6 @@ import tech.pegasys.pantheon.util.uint.UInt256; import tech.pegasys.pantheon.util.uint.UInt256Value; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -70,7 +64,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import com.google.common.collect.Lists; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -89,9 +82,6 @@ public class PeerDiscoveryControllerTest { private KeyPair localKeyPair; private final AtomicInteger counter = new AtomicInteger(1); private final PeerDiscoveryTestHelper helper = new PeerDiscoveryTestHelper(); - private final String selfEnodeString = - "enode://5f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.10:1111"; - private final EnodeURL selfEnode = EnodeURL.fromString(selfEnodeString); @Before public void initializeMocks() { @@ -1060,71 +1050,6 @@ public void shouldNotRespondToPingFromNonWhitelistedDiscoveryPeer() { assertThat(controller.getPeers()).doesNotContain(peers.get(0)); } - @Test - public void whenObservingNodeWhitelistAndNodeIsRemovedShouldEvictPeerFromPeerTable() - throws IOException { - final PeerTable peerTableSpy = spy(peerTable); - final List peers = createPeersInLastBucket(localPeer, 1); - final DiscoveryPeer peer = peers.get(0); - peerTableSpy.tryAdd(peer); - - final LocalPermissioningConfiguration config = permissioningConfigurationWithTempFile(); - final URI peerURI = URI.create(peer.getEnodeURLString()); - config.setNodeWhitelist(Lists.newArrayList(peerURI)); - final NodeLocalConfigPermissioningController nodeLocalConfigPermissioningController = - new NodeLocalConfigPermissioningController( - config, Collections.emptyList(), selfEnode.getNodeId()); - - controller = - getControllerBuilder() - .whitelist(nodeLocalConfigPermissioningController) - .peerTable(peerTableSpy) - .build(); - - controller.start(); - nodeLocalConfigPermissioningController.removeNodes(Lists.newArrayList(peerURI.toString())); - - verify(peerTableSpy).tryEvict(eq(DiscoveryPeer.fromURI(peerURI))); - } - - @Test - @SuppressWarnings({"unchecked", "rawtypes"}) - public void whenObservingNodeWhitelistAndNodeIsRemovedShouldNotifyPeerDroppedObservers() - throws IOException { - final PeerTable peerTableSpy = spy(peerTable); - final List peers = createPeersInLastBucket(localPeer, 1); - final DiscoveryPeer peer = peers.get(0); - peerTableSpy.tryAdd(peer); - - final LocalPermissioningConfiguration config = permissioningConfigurationWithTempFile(); - final URI peerURI = URI.create(peer.getEnodeURLString()); - config.setNodeWhitelist(Lists.newArrayList(peerURI)); - final NodeLocalConfigPermissioningController nodeLocalConfigPermissioningController = - new NodeLocalConfigPermissioningController( - config, Collections.emptyList(), selfEnode.getNodeId()); - - final Consumer peerDroppedEventConsumer = mock(Consumer.class); - final Subscribers> peerDroppedSubscribers = new Subscribers(); - peerDroppedSubscribers.subscribe(peerDroppedEventConsumer); - - doReturn(EvictResult.evicted()).when(peerTableSpy).tryEvict(any()); - - controller = - getControllerBuilder() - .whitelist(nodeLocalConfigPermissioningController) - .peerTable(peerTableSpy) - .peerDroppedObservers(peerDroppedSubscribers) - .build(); - - controller.start(); - nodeLocalConfigPermissioningController.removeNodes(Lists.newArrayList(peerURI.toString())); - - ArgumentCaptor captor = ArgumentCaptor.forClass(PeerDroppedEvent.class); - verify(peerDroppedEventConsumer).accept(captor.capture()); - assertThat(captor.getValue().getPeer()) - .isEqualTo(DiscoveryPeer.fromURI(peer.getEnodeURLString())); - } - @Test @SuppressWarnings({"unchecked", "rawtypes"}) public void whenPeerIsNotEvictedDropFromTableShouldReturnFalseAndNotifyZeroObservers() { @@ -1205,20 +1130,9 @@ private PeerDiscoveryController startPeerDiscoveryController( return controller; } - private LocalPermissioningConfiguration permissioningConfigurationWithTempFile() - throws IOException { - final LocalPermissioningConfiguration config = LocalPermissioningConfiguration.createDefault(); - Path tempFile = Files.createTempFile("test", "test"); - tempFile.toFile().deleteOnExit(); - config.setNodePermissioningConfigFilePath(tempFile.toAbsolutePath().toString()); - config.setAccountPermissioningConfigFilePath(tempFile.toAbsolutePath().toString()); - return config; - } - static class ControllerBuilder { private Collection discoPeers = Collections.emptyList(); private PeerBlacklist blacklist = new PeerBlacklist(); - private Optional whitelist = Optional.empty(); private Optional nodePermissioningController = Optional.empty(); private MockTimerUtil timerUtil = new MockTimerUtil(); private KeyPair keypair; @@ -1248,11 +1162,6 @@ ControllerBuilder blacklist(final PeerBlacklist blacklist) { return this; } - ControllerBuilder whitelist(final NodeLocalConfigPermissioningController whitelist) { - this.whitelist = Optional.of(whitelist); - return this; - } - ControllerBuilder nodePermissioningController(final NodePermissioningController controller) { this.nodePermissioningController = Optional.of(controller); return this; @@ -1314,7 +1223,6 @@ PeerDiscoveryController build() { TABLE_REFRESH_INTERVAL_MS, PEER_REQUIREMENT, blacklist, - whitelist, nodePermissioningController, peerBondedObservers, peerDroppedObservers, diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java index 111b6d4274..f14c8b70f5 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryTableRefreshTest.java @@ -66,7 +66,6 @@ public void tableRefreshSingleNode() { () -> true, new PeerBlacklist(), Optional.empty(), - Optional.empty(), new Subscribers<>(), new Subscribers<>(), new NoOpMetricsSystem())); diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/network/P2PNetworkTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/network/P2PNetworkTest.java index 6ba2f38482..e8c30008ed 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/network/P2PNetworkTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/network/P2PNetworkTest.java @@ -286,7 +286,6 @@ public void rejectIncomingConnectionFromNonWhitelistedPeer() throws Exception { try (final P2PNetwork localNetwork = builder() .nodePermissioningController(nodePermissioningController) - .nodeLocalConfigPermissioningController(localWhitelistController) .blockchain(blockchain) .build(); final P2PNetwork remoteNetwork = builder().build()) { diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningController.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningController.java index ab7f60342c..1fba30b302 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningController.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningController.java @@ -12,6 +12,7 @@ */ package tech.pegasys.pantheon.ethereum.permissioning.node; +import tech.pegasys.pantheon.ethereum.permissioning.NodeLocalConfigPermissioningController; import tech.pegasys.pantheon.ethereum.permissioning.node.provider.SyncStatusNodePermissioningProvider; import tech.pegasys.pantheon.util.Subscribers; import tech.pegasys.pantheon.util.enode.EnodeURL; @@ -100,4 +101,11 @@ public long subscribeToUpdates(final Runnable callback) { public boolean unsubscribeFromUpdates(final long id) { return permissioningUpdateSubscribers.unsubscribe(id); } + + public Optional localConfigController() { + return getProviders().stream() + .filter(p -> p instanceof NodeLocalConfigPermissioningController) + .findFirst() + .map(n -> (NodeLocalConfigPermissioningController) n); + } } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java index 7bcaf3d36b..175506eede 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java @@ -246,27 +246,17 @@ public Runner build() { new TransactionSimulator( context.getBlockchain(), context.getWorldStateArchive(), protocolSchedule); - BytesValue localNodeId = keyPair.getPublicKey().getEncodedBytes(); + final BytesValue localNodeId = keyPair.getPublicKey().getEncodedBytes(); final Optional nodePermissioningController = buildNodePermissioningController( bootnodesAsEnodeURLs, synchronizer, transactionSimulator, localNodeId); - final Optional nodeWhitelistController = - nodePermissioningController - .flatMap( - n -> - n.getProviders().stream() - .filter(p -> p instanceof NodeLocalConfigPermissioningController) - .findFirst()) - .map(n -> (NodeLocalConfigPermissioningController) n); - NetworkBuilder inactiveNetwork = (caps) -> new NoopP2PNetwork(); NetworkBuilder activeNetwork = (caps) -> DefaultP2PNetwork.builder() .vertx(vertx) .keyPair(keyPair) - .nodeLocalConfigPermissioningController(nodeWhitelistController) .config(networkConfig) .peerBlacklist(peerBlacklist) .metricsSystem(metricsSystem) @@ -311,6 +301,9 @@ public Runner build() { .map(DefaultPeer::fromEnodeURL) .forEach(peerNetwork::addMaintainConnectionPeer); + final Optional nodeLocalConfigPermissioningController = + nodePermissioningController.flatMap(NodePermissioningController::localConfigController); + Optional jsonRpcHttpService = Optional.empty(); if (jsonRpcConfiguration.isEnabled()) { final Map jsonRpcMethods = @@ -327,7 +320,7 @@ public Runner build() { jsonRpcConfiguration.getRpcApis(), filterManager, accountWhitelistController, - nodeWhitelistController, + nodeLocalConfigPermissioningController, privacyParameters, jsonRpcConfiguration, webSocketConfiguration, @@ -354,7 +347,7 @@ public Runner build() { webSocketConfiguration.getRpcApis(), filterManager, accountWhitelistController, - nodeWhitelistController, + nodeLocalConfigPermissioningController, privacyParameters, jsonRpcConfiguration, webSocketConfiguration,