rename more "whitelist" occurrences to "allowlist" (#1133)

* rename more whitelist occurrences; change allowlisted to allowed and reword where we ended up with allowlisting

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/1137/head
Sally MacFarlane 4 years ago committed by GitHub
parent 785b26b1fa
commit 9e224ed7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java
  2. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java
  3. 8
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  4. 69
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  5. 18
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java
  6. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java
  7. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java
  8. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java
  9. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java
  10. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java
  11. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  12. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java
  13. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java
  14. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java
  15. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java
  16. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java
  17. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java
  18. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java
  19. 26
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java
  20. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java
  21. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java
  22. 2
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java
  23. 122
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java
  24. 22
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java
  25. 6
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeAllowlistUpdatedEvent.java
  26. 14
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java
  27. 11
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java
  28. 8
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java
  29. 126
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java
  30. 22
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java

@ -37,7 +37,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
} }
@Test @Test
public void testNodeCannotConnectWhnAllowlistedOnChainButNotLocal() { public void testNodeCannotConnectWhenAllowedOnChainButNotLocally() {
// add permissioned node after cluster start because we need enode URI for local config // add permissioned node after cluster start because we need enode URI for local config
permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode); permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode);
@ -60,7 +60,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
} }
@Test @Test
public void testNodeCannotConnectWhenAllowlistedLocalButNotOnChain() { public void testNodeCannotConnectWhenAllowedLocallyButNotOnChain() {
// onchain allowlist: A, B // onchain allowlist: A, B
// local allowlist: A, B, C // local allowlist: A, B, C
@ -82,7 +82,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
} }
@Test @Test
public void testNodesCanConnectWhenAllowlistedBothOnChainAndLocal() { public void testNodesCanConnectWhenAllowedBothOnChainAndLocally() {
// add permissioned node after cluster start because we need enode URI for local config // add permissioned node after cluster start because we need enode URI for local config
permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode, forbiddenNode); permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode, forbiddenNode);
permissionedCluster.addNode(permissionedNode); permissionedCluster.addNode(permissionedNode);

@ -56,19 +56,19 @@ class NodeSmartContractPermissioningAcceptanceTestBase extends AcceptanceTestBas
return new Cluster(clusterConfiguration, net); return new Cluster(clusterConfiguration, net);
} }
protected Node permissionedNode(final String name, final Node... localConfigAllowListedNodes) { protected Node permissionedNode(final String name, final Node... localConfigAllowedNodes) {
return permissionedNode(name, GENESIS_FILE, localConfigAllowListedNodes); return permissionedNode(name, GENESIS_FILE, localConfigAllowedNodes);
} }
protected Node permissionedNode( protected Node permissionedNode(
final String name, final String genesisFile, final Node... localConfigAllowListedNodes) { final String name, final String genesisFile, final Node... localConfigAllowedNodes) {
PermissionedNodeBuilder permissionedNodeBuilder = PermissionedNodeBuilder permissionedNodeBuilder =
this.permissionedNodeBuilder this.permissionedNodeBuilder
.name(name) .name(name)
.genesisFile(genesisFile) .genesisFile(genesisFile)
.nodesContractEnabled(CONTRACT_ADDRESS); .nodesContractEnabled(CONTRACT_ADDRESS);
if (localConfigAllowListedNodes != null && localConfigAllowListedNodes.length > 0) { if (localConfigAllowedNodes != null && localConfigAllowedNodes.length > 0) {
permissionedNodeBuilder.nodesPermittedInConfig(localConfigAllowListedNodes); permissionedNodeBuilder.nodesPermittedInConfig(localConfigAllowedNodes);
} }
return permissionedNodeBuilder.build(); return permissionedNodeBuilder.build();
} }

@ -669,8 +669,8 @@ public class RunnerBuilder {
final Set<Capability> supportedCapabilities, final Set<Capability> supportedCapabilities,
final Collection<RpcApi> jsonRpcApis, final Collection<RpcApi> jsonRpcApis,
final FilterManager filterManager, final FilterManager filterManager,
final Optional<AccountLocalConfigPermissioningController> accountWhitelistController, final Optional<AccountLocalConfigPermissioningController> accountAllowlistController,
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController, final Optional<NodeLocalConfigPermissioningController> nodeAllowlistController,
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration, final WebSocketConfiguration webSocketConfiguration,
@ -692,8 +692,8 @@ public class RunnerBuilder {
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
accountWhitelistController, accountAllowlistController,
nodeWhitelistController, nodeAllowlistController,
jsonRpcApis, jsonRpcApis,
privacyParameters, privacyParameters,
jsonRpcConfiguration, jsonRpcConfiguration,

@ -590,7 +590,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void nodePermissioningTomlPathMustUseOption() throws IOException { public void nodePermissioningTomlPathMustUseOption() throws IOException {
final List<URI> allowlistedNodes = final List<URI> allowedNodes =
Lists.newArrayList( Lists.newArrayList(
URI.create( URI.create(
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567"), "enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567"),
@ -600,18 +600,18 @@ public class BesuCommandTest extends CommandTestAbstract {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_TOML); final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_TOML);
final Path permToml = createTempFile("toml", Resources.toByteArray(configFile)); final Path permToml = createTempFile("toml", Resources.toByteArray(configFile));
final String allowlistedNodesString = final String allowedNodesString =
allowlistedNodes.stream().map(Object::toString).collect(Collectors.joining(",")); allowedNodes.stream().map(Object::toString).collect(Collectors.joining(","));
parseCommand( parseCommand(
"--permissions-nodes-config-file-enabled", "--permissions-nodes-config-file-enabled",
"--permissions-nodes-config-file", "--permissions-nodes-config-file",
permToml.toString(), permToml.toString(),
"--bootnodes", "--bootnodes",
allowlistedNodesString); allowedNodesString);
final LocalPermissioningConfiguration localPermissioningConfiguration = final LocalPermissioningConfiguration localPermissioningConfiguration =
LocalPermissioningConfiguration.createDefault(); LocalPermissioningConfiguration.createDefault();
localPermissioningConfiguration.setNodePermissioningConfigFilePath(permToml.toString()); localPermissioningConfiguration.setNodePermissioningConfigFilePath(permToml.toString());
localPermissioningConfiguration.setNodeAllowlist(allowlistedNodes); localPermissioningConfiguration.setNodeAllowlist(allowedNodes);
verify(mockRunnerBuilder) verify(mockRunnerBuilder)
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture()); .permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
@ -2026,8 +2026,10 @@ public class BesuCommandTest extends CommandTestAbstract {
.contains("Domain cannot be empty string or null string."); .contains("Domain cannot be empty string or null string.");
} }
/** test deprecated CLI option * */
@Deprecated
@Test @Test
public void rpcHttpHostAllowlistAcceptsSingleArgument() { public void rpcHttpHostWhitelistAcceptsSingleArgument() {
parseCommand("--host-whitelist", "a"); parseCommand("--host-whitelist", "a");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
@ -2042,9 +2044,25 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
} }
@Test
public void rpcHttpHostAllowlistAcceptsSingleArgument() {
parseCommand("--host-allowlist", "a");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(1);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("localhost");
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test @Test
public void rpcHttpHostAllowlistAcceptsMultipleArguments() { public void rpcHttpHostAllowlistAcceptsMultipleArguments() {
parseCommand("--host-whitelist", "a,b"); parseCommand("--host-allowlist", "a,b");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build(); verify(mockRunnerBuilder).build();
@ -2060,7 +2078,24 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistAcceptsDoubleComma() { public void rpcHttpHostAllowlistAcceptsDoubleComma() {
parseCommand("--host-whitelist", "a,,b"); parseCommand("--host-allowlist", "a,,b");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("*", "localhost");
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Deprecated
@Test
public void rpcHttpHostWhitelistAllowlistAcceptsMultipleFlags() {
parseCommand("--host-whitelist=a", "--host-allowlist=b");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build(); verify(mockRunnerBuilder).build();
@ -2076,7 +2111,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistAcceptsMultipleFlags() { public void rpcHttpHostAllowlistAcceptsMultipleFlags() {
parseCommand("--host-whitelist=a", "--host-whitelist=b"); parseCommand("--host-allowlist=a", "--host-allowlist=b");
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build(); verify(mockRunnerBuilder).build();
@ -2093,7 +2128,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFail() { public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFail() {
final String[] origins = {"friend", "*"}; final String[] origins = {"friend", "*"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -2105,7 +2140,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFailStarFirst() { public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFailStarFirst() {
final String[] origins = {"*", "friend"}; final String[] origins = {"*", "friend"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -2117,7 +2152,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistAllWithAnotherHostnameMustFail() { public void rpcHttpHostAllowlistAllWithAnotherHostnameMustFail() {
final String[] origins = {"friend", "all"}; final String[] origins = {"friend", "all"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -2129,7 +2164,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistWithNoneMustBuildEmptyList() { public void rpcHttpHostAllowlistWithNoneMustBuildEmptyList() {
final String[] origins = {"none"}; final String[] origins = {"none"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build(); verify(mockRunnerBuilder).build();
@ -2143,7 +2178,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFail() { public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFail() {
final String[] origins = {"http://domain1.com", "none"}; final String[] origins = {"http://domain1.com", "none"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -2155,7 +2190,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFailNoneFirst() { public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFailNoneFirst() {
final String[] origins = {"none", "http://domain1.com"}; final String[] origins = {"none", "http://domain1.com"};
parseCommand("--host-whitelist", String.join(",", origins)); parseCommand("--host-allowlist", String.join(",", origins));
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -2166,7 +2201,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void rpcHttpHostAllowlistEmptyValueFails() { public void rpcHttpHostAllowlistEmptyValueFails() {
parseCommand("--host-whitelist="); parseCommand("--host-allowlist=");
Mockito.verifyZeroInteractions(mockRunnerBuilder); Mockito.verifyZeroInteractions(mockRunnerBuilder);
@ -3065,7 +3100,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Rule public TemporaryFolder testFolder = new TemporaryFolder(); @Rule public TemporaryFolder testFolder = new TemporaryFolder();
@Test @Test
public void errorIsRaisedIfStaticNodesAreNotAllowlisted() throws IOException { public void errorIsRaisedIfStaticNodesAreNotAllowed() throws IOException {
final File staticNodesFile = testFolder.newFile("static-nodes.json"); final File staticNodesFile = testFolder.newFile("static-nodes.json");
staticNodesFile.deleteOnExit(); staticNodesFile.deleteOnExit();
final File permissioningConfig = testFolder.newFile("permissioning"); final File permissioningConfig = testFolder.newFile("permissioning");

@ -34,7 +34,7 @@ public class GraphQLConfiguration {
private int port; private int port;
private String host; private String host;
private List<String> corsAllowedDomains = Collections.emptyList(); private List<String> corsAllowedDomains = Collections.emptyList();
private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private List<String> hostsAllowlist = Arrays.asList("localhost", "127.0.0.1");
private long httpTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds(); private long httpTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds();
public static GraphQLConfiguration createDefault() { public static GraphQLConfiguration createDefault() {
@ -81,13 +81,13 @@ public class GraphQLConfiguration {
this.corsAllowedDomains = corsAllowedDomains; this.corsAllowedDomains = corsAllowedDomains;
} }
Collection<String> getHostsWhitelist() { Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsAllowlist);
} }
public void setHostsAllowlist(final List<String> hostsWhitelist) { public void setHostsAllowlist(final List<String> hostsAllowlist) {
checkNotNull(hostsWhitelist); checkNotNull(hostsAllowlist);
this.hostsWhitelist = hostsWhitelist; this.hostsAllowlist = hostsAllowlist;
} }
public Long getHttpTimeoutSec() { public Long getHttpTimeoutSec() {
@ -105,7 +105,7 @@ public class GraphQLConfiguration {
.add("port", port) .add("port", port)
.add("host", host) .add("host", host)
.add("corsAllowedDomains", corsAllowedDomains) .add("corsAllowedDomains", corsAllowedDomains)
.add("hostsWhitelist", hostsWhitelist) .add("hostsAllowlist", hostsAllowlist)
.add("httpTimeoutSec", httpTimeoutSec) .add("httpTimeoutSec", httpTimeoutSec)
.toString(); .toString();
} }
@ -123,11 +123,11 @@ public class GraphQLConfiguration {
&& port == that.port && port == that.port
&& Objects.equals(host, that.host) && Objects.equals(host, that.host)
&& Objects.equals(corsAllowedDomains, that.corsAllowedDomains) && Objects.equals(corsAllowedDomains, that.corsAllowedDomains)
&& Objects.equals(hostsWhitelist, that.hostsWhitelist); && Objects.equals(hostsAllowlist, that.hostsAllowlist);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist); return Objects.hash(enabled, port, host, corsAllowedDomains, hostsAllowlist);
} }
} }

@ -192,8 +192,8 @@ public class GraphQLHttpService {
private Handler<RoutingContext> checkWhitelistHostHeader() { private Handler<RoutingContext> checkWhitelistHostHeader() {
return event -> { return event -> {
final Optional<String> hostHeader = getAndValidateHostHeader(event); final Optional<String> hostHeader = getAndValidateHostHeader(event);
if (config.getHostsWhitelist().contains("*") if (config.getHostsAllowlist().contains("*")
|| (hostHeader.isPresent() && hostIsInWhitelist(hostHeader.get()))) { || (hostHeader.isPresent() && hostIsInAllowlist(hostHeader.get()))) {
event.next(); event.next();
} else { } else {
final HttpServerResponse response = event.response(); final HttpServerResponse response = event.response();
@ -219,13 +219,13 @@ public class GraphQLHttpService {
return Optional.ofNullable(Iterables.get(splitHostHeader, 0)); return Optional.ofNullable(Iterables.get(splitHostHeader, 0));
} }
private boolean hostIsInWhitelist(final String hostHeader) { private boolean hostIsInAllowlist(final String hostHeader) {
if (config.getHostsWhitelist().stream() if (config.getHostsAllowlist().stream()
.anyMatch( .anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { allowlistEntry -> allowlistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true; return true;
} else { } else {
LOG.trace("Host not in whitelist: '{}'", hostHeader); LOG.trace("Host not in allowlist: '{}'", hostHeader);
return false; return false;
} }
} }

@ -37,7 +37,7 @@ public class JsonRpcConfiguration {
private String host; private String host;
private List<String> corsAllowedDomains = Collections.emptyList(); private List<String> corsAllowedDomains = Collections.emptyList();
private List<RpcApi> rpcApis; private List<RpcApi> rpcApis;
private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private List<String> hostsAllowlist = Arrays.asList("localhost", "127.0.0.1");
private boolean authenticationEnabled = false; private boolean authenticationEnabled = false;
private String authenticationCredentialsFile; private String authenticationCredentialsFile;
private File authenticationPublicKeyFile; private File authenticationPublicKeyFile;
@ -104,11 +104,11 @@ public class JsonRpcConfiguration {
} }
public Collection<String> getHostsAllowlist() { public Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsAllowlist);
} }
public void setHostsAllowlist(final List<String> hostsWhitelist) { public void setHostsAllowlist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist; this.hostsAllowlist = hostsWhitelist;
} }
public boolean isAuthenticationEnabled() { public boolean isAuthenticationEnabled() {
@ -158,7 +158,7 @@ public class JsonRpcConfiguration {
.add("port", port) .add("port", port)
.add("host", host) .add("host", host)
.add("corsAllowedDomains", corsAllowedDomains) .add("corsAllowedDomains", corsAllowedDomains)
.add("hostsWhitelist", hostsWhitelist) .add("hostsAllowlist", hostsAllowlist)
.add("rpcApis", rpcApis) .add("rpcApis", rpcApis)
.add("authenticationEnabled", authenticationEnabled) .add("authenticationEnabled", authenticationEnabled)
.add("authenticationCredentialsFile", authenticationCredentialsFile) .add("authenticationCredentialsFile", authenticationCredentialsFile)
@ -183,7 +183,7 @@ public class JsonRpcConfiguration {
&& Objects.equals(host, that.host) && Objects.equals(host, that.host)
&& Objects.equals(corsAllowedDomains, that.corsAllowedDomains) && Objects.equals(corsAllowedDomains, that.corsAllowedDomains)
&& Objects.equals(rpcApis, that.rpcApis) && Objects.equals(rpcApis, that.rpcApis)
&& Objects.equals(hostsWhitelist, that.hostsWhitelist) && Objects.equals(hostsAllowlist, that.hostsAllowlist)
&& Objects.equals(authenticationCredentialsFile, that.authenticationCredentialsFile) && Objects.equals(authenticationCredentialsFile, that.authenticationCredentialsFile)
&& Objects.equals(authenticationPublicKeyFile, that.authenticationPublicKeyFile); && Objects.equals(authenticationPublicKeyFile, that.authenticationPublicKeyFile);
} }
@ -196,7 +196,7 @@ public class JsonRpcConfiguration {
host, host,
corsAllowedDomains, corsAllowedDomains,
rpcApis, rpcApis,
hostsWhitelist, hostsAllowlist,
authenticationEnabled, authenticationEnabled,
authenticationCredentialsFile, authenticationCredentialsFile,
authenticationPublicKeyFile); authenticationPublicKeyFile);

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException; import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -52,10 +53,10 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
if (nodeWhitelistPermissioningController.isPresent()) { if (nodeWhitelistPermissioningController.isPresent()) {
try { try {
final List<String> enodeURLs = enodeListParam.getStringList(); final List<String> enodeURLs = enodeListParam.getStringList();
final NodeLocalConfigPermissioningController.NodesWhitelistResult nodesWhitelistResult = final NodesAllowlistResult nodesAllowlistResult =
nodeWhitelistPermissioningController.get().addNodes(enodeURLs); nodeWhitelistPermissioningController.get().addNodes(enodeURLs);
switch (nodesWhitelistResult.result()) { switch (nodesAllowlistResult.result()) {
case SUCCESS: case SUCCESS:
return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
case ERROR_EMPTY_ENTRY: case ERROR_EMPTY_ENTRY:

@ -47,7 +47,7 @@ public class PermGetNodesAllowlist implements JsonRpcMethod {
try { try {
if (nodeWhitelistPermissioningController.isPresent()) { if (nodeWhitelistPermissioningController.isPresent()) {
final List<String> enodeList = final List<String> enodeList =
nodeWhitelistPermissioningController.get().getNodesWhitelist(); nodeWhitelistPermissioningController.get().getNodesAllowlist();
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList);
} else { } else {

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException; import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -51,10 +52,10 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
if (nodeWhitelistPermissioningController.isPresent()) { if (nodeWhitelistPermissioningController.isPresent()) {
try { try {
final List<String> enodeURLs = enodeListParam.getStringList(); final List<String> enodeURLs = enodeListParam.getStringList();
final NodeLocalConfigPermissioningController.NodesWhitelistResult nodesWhitelistResult = final NodesAllowlistResult nodesAllowlistResult =
nodeWhitelistPermissioningController.get().removeNodes(enodeURLs); nodeWhitelistPermissioningController.get().removeNodes(enodeURLs);
switch (nodesWhitelistResult.result()) { switch (nodesAllowlistResult.result()) {
case SUCCESS: case SUCCESS:
return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
case ERROR_EMPTY_ENTRY: case ERROR_EMPTY_ENTRY:

@ -77,7 +77,7 @@ public enum JsonRpcError {
PARENT_BLOCK_NOT_FOUND(-32000, "Parent block not found"), PARENT_BLOCK_NOT_FOUND(-32000, "Parent block not found"),
// Permissioning/Account allowlist errors // Permissioning/Account allowlist errors
ACCOUNT_ALLOWLIST_NOT_ENABLED(-32000, "Account allowlisting has not been enabled"), ACCOUNT_ALLOWLIST_NOT_ENABLED(-32000, "Account allowlist has not been enabled"),
ACCOUNT_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of accounts"), ACCOUNT_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of accounts"),
ACCOUNT_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid account"), ACCOUNT_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid account"),
ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate accounts"), ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate accounts"),
@ -85,7 +85,7 @@ public enum JsonRpcError {
ACCOUNT_ALLOWLIST_ABSENT_ENTRY(-32000, "Cannot remove an absent account from allowlist"), ACCOUNT_ALLOWLIST_ABSENT_ENTRY(-32000, "Cannot remove an absent account from allowlist"),
// Permissioning/Node allowlist errors // Permissioning/Node allowlist errors
NODE_ALLOWLIST_NOT_ENABLED(-32000, "Node allowlisting has not been enabled"), NODE_ALLOWLIST_NOT_ENABLED(-32000, "Node allowlist has not been enabled"),
NODE_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of nodes"), NODE_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of nodes"),
NODE_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid node"), NODE_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid node"),
NODE_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate nodes"), NODE_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate nodes"),
@ -103,7 +103,7 @@ public enum JsonRpcError {
ALLOWLIST_RELOAD_ERROR( ALLOWLIST_RELOAD_ERROR(
-32000, -32000,
"Error reloading permissions file. Please use perm_getAccountsAllowlist and perm_getNodesAllowlist to review the current state of the allowlists"), "Error reloading permissions file. Please use perm_getAccountsAllowlist and perm_getNodesAllowlist to review the current state of the allowlists"),
PERMISSIONING_NOT_ENABLED(-32000, "Node/Account allowlisting has not been enabled"), PERMISSIONING_NOT_ENABLED(-32000, "Node/Account allowlist has not been enabled"),
NON_PERMITTED_NODE_CANNOT_BE_ADDED_AS_A_PEER(-32000, "Cannot add a non-permitted node as a peer"), NON_PERMITTED_NODE_CANNOT_BE_ADDED_AS_A_PEER(-32000, "Cannot add a non-permitted node as a peer"),
// Permissioning/Authorization errors // Permissioning/Authorization errors

@ -108,7 +108,7 @@ public class WebSocketService {
LOG.trace("Websocket authentication token {}", token); LOG.trace("Websocket authentication token {}", token);
} }
if (!hasAllowlistedHostnameHeader(Optional.ofNullable(websocket.headers().get("Host")))) { if (!hasAllowedHostnameHeader(Optional.ofNullable(websocket.headers().get("Host")))) {
websocket.reject(403); websocket.reject(403);
} }
@ -233,7 +233,7 @@ public class WebSocketService {
private Handler<RoutingContext> checkAllowlistHostHeader() { private Handler<RoutingContext> checkAllowlistHostHeader() {
return event -> { return event -> {
if (hasAllowlistedHostnameHeader(Optional.ofNullable(event.request().host()))) { if (hasAllowedHostnameHeader(Optional.ofNullable(event.request().host()))) {
event.next(); event.next();
} else { } else {
final HttpServerResponse response = event.response(); final HttpServerResponse response = event.response();
@ -248,7 +248,7 @@ public class WebSocketService {
} }
@VisibleForTesting @VisibleForTesting
public boolean hasAllowlistedHostnameHeader(final Optional<String> header) { public boolean hasAllowedHostnameHeader(final Optional<String> header) {
return configuration.getHostsAllowlist().contains("*") return configuration.getHostsAllowlist().contains("*")
|| header.map(value -> checkHostInAllowlist(validateHostHeader(value))).orElse(false); || header.map(value -> checkHostInAllowlist(validateHostHeader(value))).orElse(false);
} }

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@ -110,7 +110,7 @@ public class PermAddNodesToAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList()))) when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -125,7 +125,7 @@ public class PermAddNodesToAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -140,7 +140,7 @@ public class PermAddNodesToAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>()))) when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -153,7 +153,7 @@ public class PermAddNodesToAllowlistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -169,7 +169,7 @@ public class PermAddNodesToAllowlistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@ -111,7 +111,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList()))) when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -126,7 +126,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -141,7 +141,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>()))) when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -154,7 +154,7 @@ public class PermAddNodesToWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -170,7 +170,7 @@ public class PermAddNodesToWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any())) when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);

@ -71,14 +71,14 @@ public class PermGetNodesAllowlistTest {
new JsonRpcSuccessResponse( new JsonRpcSuccessResponse(
request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3));
when(nodeLocalConfigPermissioningController.getNodesWhitelist()) when(nodeLocalConfigPermissioningController.getNodesAllowlist())
.thenReturn(buildNodesList(enode1, enode2, enode3)); .thenReturn(buildNodesList(enode1, enode2, enode3));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
verifyNoMoreInteractions(nodeLocalConfigPermissioningController); verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
} }
@ -88,13 +88,13 @@ public class PermGetNodesAllowlistTest {
final JsonRpcResponse expected = final JsonRpcResponse expected =
new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList()); new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList());
when(nodeLocalConfigPermissioningController.getNodesWhitelist()).thenReturn(buildNodesList()); when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList());
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
verifyNoMoreInteractions(nodeLocalConfigPermissioningController); verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
} }

@ -72,14 +72,14 @@ public class PermGetNodesWhitelistTest {
new JsonRpcSuccessResponse( new JsonRpcSuccessResponse(
request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3));
when(nodeLocalConfigPermissioningController.getNodesWhitelist()) when(nodeLocalConfigPermissioningController.getNodesAllowlist())
.thenReturn(buildNodesList(enode1, enode2, enode3)); .thenReturn(buildNodesList(enode1, enode2, enode3));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
verifyNoMoreInteractions(nodeLocalConfigPermissioningController); verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
} }
@ -89,13 +89,13 @@ public class PermGetNodesWhitelistTest {
final JsonRpcResponse expected = final JsonRpcResponse expected =
new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList()); new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList());
when(nodeLocalConfigPermissioningController.getNodesWhitelist()).thenReturn(buildNodesList()); when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList());
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
verifyNoMoreInteractions(nodeLocalConfigPermissioningController); verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
} }

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@ -93,7 +93,7 @@ public class PermRemoveNodesFromAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList()))) when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -106,7 +106,7 @@ public class PermRemoveNodesFromAllowlistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -122,7 +122,7 @@ public class PermRemoveNodesFromAllowlistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -152,7 +152,7 @@ public class PermRemoveNodesFromAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -167,7 +167,7 @@ public class PermRemoveNodesFromAllowlistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>()))) when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -183,7 +183,7 @@ public class PermRemoveNodesFromAllowlistTest {
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn( .thenReturn(
new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@ -94,7 +94,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList()))) when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -107,7 +107,7 @@ public class PermRemoveNodesFromWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -123,7 +123,7 @@ public class PermRemoveNodesFromWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -153,7 +153,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -168,7 +168,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>()))) when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);
@ -184,7 +184,7 @@ public class PermRemoveNodesFromWhitelistTest {
when(nodeLocalConfigPermissioningController.removeNodes(any())) when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn( .thenReturn(
new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED));
final JsonRpcResponse actual = method.response(request); final JsonRpcResponse actual = method.response(request);

@ -104,7 +104,7 @@ public class WebSocketHostAllowlistTest {
@Test @Test
public void websocketRequestWithDefaultHeaderAndDefaultConfigIsAccepted() { public void websocketRequestWithDefaultHeaderAndDefaultConfigIsAccepted() {
boolean result = websocketService.hasAllowlistedHostnameHeader(Optional.of("localhost:50012")); boolean result = websocketService.hasAllowedHostnameHeader(Optional.of("localhost:50012"));
assertThat(result).isTrue(); assertThat(result).isTrue();
} }
@ -115,7 +115,7 @@ public class WebSocketHostAllowlistTest {
@Test @Test
public void websocketRequestWithEmptyHeaderAndDefaultConfigIsRejected() { public void websocketRequestWithEmptyHeaderAndDefaultConfigIsRejected() {
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of(""))).isFalse(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of(""))).isFalse();
} }
@Test @Test
@ -126,8 +126,8 @@ public class WebSocketHostAllowlistTest {
@Test @Test
public void websocketRequestWithAnyHostnameAndWildcardConfigIsAccepted() { public void websocketRequestWithAnyHostnameAndWildcardConfigIsAccepted() {
webSocketConfiguration.setHostsAllowlist(Collections.singletonList("*")); webSocketConfiguration.setHostsAllowlist(Collections.singletonList("*"));
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally"))).isTrue(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally"))).isTrue();
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("foe"))).isTrue(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("foe"))).isTrue();
} }
@Test @Test
@ -138,15 +138,15 @@ public class WebSocketHostAllowlistTest {
} }
@Test @Test
public void websocketRequestWithAllowlistedHostIsAccepted() { public void websocketRequestWithAllowedHostIsAccepted() {
webSocketConfiguration.setHostsAllowlist(hostsAllowlist); webSocketConfiguration.setHostsAllowlist(hostsAllowlist);
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally"))).isTrue(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally"))).isTrue();
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:12345"))).isTrue(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:12345"))).isTrue();
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("friend"))).isTrue(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("friend"))).isTrue();
} }
@Test @Test
public void httpRequestWithAllowlistedHostIsAccepted(final TestContext context) { public void httpRequestWithAllowedHostIsAccepted(final TestContext context) {
webSocketConfiguration.setHostsAllowlist(hostsAllowlist); webSocketConfiguration.setHostsAllowlist(hostsAllowlist);
doHttpRequestAndVerify(context, "ally", 400); doHttpRequestAndVerify(context, "ally", 400);
doHttpRequestAndVerify(context, "ally:12345", 400); doHttpRequestAndVerify(context, "ally:12345", 400);
@ -156,7 +156,7 @@ public class WebSocketHostAllowlistTest {
@Test @Test
public void websocketRequestWithUnknownHostIsRejected() { public void websocketRequestWithUnknownHostIsRejected() {
webSocketConfiguration.setHostsAllowlist(hostsAllowlist); webSocketConfiguration.setHostsAllowlist(hostsAllowlist);
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("foe"))).isFalse(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("foe"))).isFalse();
} }
@Test @Test
@ -169,9 +169,9 @@ public class WebSocketHostAllowlistTest {
public void websocketRequestWithMalformedHostIsRejected() { public void websocketRequestWithMalformedHostIsRejected() {
webSocketConfiguration.setAuthenticationEnabled(false); webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setHostsAllowlist(hostsAllowlist); webSocketConfiguration.setHostsAllowlist(hostsAllowlist);
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:friend"))).isFalse(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:friend"))).isFalse();
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:123456"))).isFalse(); assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:123456"))).isFalse();
assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:friend:1234"))) assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:friend:1234")))
.isFalse(); .isFalse();
} }

@ -149,7 +149,7 @@ public class MainnetTransactionValidator implements TransactionValidator {
if (!isSenderAllowed(transaction, validationParams)) { if (!isSenderAllowed(transaction, validationParams)) {
return ValidationResult.invalid( return ValidationResult.invalid(
TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED, TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED,
String.format("Sender %s is not on the Account Whitelist", transaction.getSender())); String.format("Sender %s is not on the Account Allowlist", transaction.getSender()));
} }
return ValidationResult.valid(); return ValidationResult.valid();

@ -516,7 +516,7 @@ public class TransactionPoolTest {
} }
@Test @Test
public void shouldAllowTransactionWhenAccountWhitelistControllerIsNotPresent() { public void shouldAllowTransactionWhenAccountAllowlistControllerIsNotPresent() {
givenTransactionIsValid(transaction1); givenTransactionIsValid(transaction1);
assertThat(transactionPool.addLocalTransaction(transaction1)).isEqualTo(valid()); assertThat(transactionPool.addLocalTransaction(transaction1)).isEqualTo(valid());

@ -216,7 +216,7 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
configuration = updatedConfig; configuration = updatedConfig;
} catch (Exception e) { } catch (Exception e) {
LOG.warn( LOG.warn(
"Error reloading permissions file. In-memory allowlisted accounts will be reverted to previous valid configuration. " "Error reloading permissions file. In-memory accounts allowlist will be reverted to previous valid configuration. "
+ "Details: {}", + "Details: {}",
e.getMessage()); e.getMessage());
accountAllowlist.clear(); accountAllowlist.clear();

@ -16,8 +16,8 @@ package org.hyperledger.besu.ethereum.permissioning;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE; import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.node.NodeAllowlistUpdatedEvent;
import org.hyperledger.besu.ethereum.permissioning.node.NodePermissioningProvider; import org.hyperledger.besu.ethereum.permissioning.node.NodePermissioningProvider;
import org.hyperledger.besu.ethereum.permissioning.node.NodeWhitelistUpdatedEvent;
import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter; import org.hyperledger.besu.plugin.services.metrics.Counter;
@ -47,9 +47,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
private LocalPermissioningConfiguration configuration; private LocalPermissioningConfiguration configuration;
private final List<EnodeURL> fixedNodes; private final List<EnodeURL> fixedNodes;
private final Bytes localNodeId; private final Bytes localNodeId;
private final List<EnodeURL> nodesWhitelist = new ArrayList<>(); private final List<EnodeURL> nodesAllowlist = new ArrayList<>();
private final AllowlistPersistor allowlistPersistor; private final AllowlistPersistor allowlistPersistor;
private final Subscribers<Consumer<NodeWhitelistUpdatedEvent>> nodeWhitelistUpdatedObservers = private final Subscribers<Consumer<NodeAllowlistUpdatedEvent>> nodeAllowlistUpdatedObservers =
Subscribers.create(); Subscribers.create();
private final Counter checkCounter; private final Counter checkCounter;
@ -106,8 +106,8 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
} }
} }
public NodesWhitelistResult addNodes(final List<String> enodeURLs) { public NodesAllowlistResult addNodes(final List<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs); final NodesAllowlistResult inputValidationResult = validInput(enodeURLs);
if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) { if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) {
return inputValidationResult; return inputValidationResult;
} }
@ -115,31 +115,31 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
enodeURLs.stream().map(EnodeURL::fromString).collect(Collectors.toList()); enodeURLs.stream().map(EnodeURL::fromString).collect(Collectors.toList());
for (EnodeURL peer : peers) { for (EnodeURL peer : peers) {
if (nodesWhitelist.contains(peer)) { if (nodesAllowlist.contains(peer)) {
return new NodesWhitelistResult( return new NodesAllowlistResult(
AllowlistOperationResult.ERROR_EXISTING_ENTRY, AllowlistOperationResult.ERROR_EXISTING_ENTRY,
String.format("Specified peer: %s already exists in whitelist.", peer.getNodeId())); String.format("Specified peer: %s already exists in allowlist.", peer.getNodeId()));
} }
} }
final List<EnodeURL> oldWhitelist = new ArrayList<>(this.nodesWhitelist); final List<EnodeURL> oldAllowlist = new ArrayList<>(this.nodesAllowlist);
peers.forEach(this::addNode); peers.forEach(this::addNode);
notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(peers, Collections.emptyList())); notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(peers, Collections.emptyList()));
final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist); final NodesAllowlistResult updateConfigFileResult = updateAllowlistInConfigFile(oldAllowlist);
if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) { if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) {
return updateConfigFileResult; return updateConfigFileResult;
} }
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS);
} }
public boolean addNode(final EnodeURL enodeURL) { public boolean addNode(final EnodeURL enodeURL) {
return nodesWhitelist.add(enodeURL); return nodesAllowlist.add(enodeURL);
} }
public NodesWhitelistResult removeNodes(final List<String> enodeURLs) { public NodesAllowlistResult removeNodes(final List<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs); final NodesAllowlistResult inputValidationResult = validInput(enodeURLs);
if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) { if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) {
return inputValidationResult; return inputValidationResult;
} }
@ -148,61 +148,61 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
boolean anyBootnode = peers.stream().anyMatch(fixedNodes::contains); boolean anyBootnode = peers.stream().anyMatch(fixedNodes::contains);
if (anyBootnode) { if (anyBootnode) {
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED); return new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
} }
for (EnodeURL peer : peers) { for (EnodeURL peer : peers) {
if (!(nodesWhitelist.contains(peer))) { if (!(nodesAllowlist.contains(peer))) {
return new NodesWhitelistResult( return new NodesAllowlistResult(
AllowlistOperationResult.ERROR_ABSENT_ENTRY, AllowlistOperationResult.ERROR_ABSENT_ENTRY,
String.format("Specified peer: %s does not exist in whitelist.", peer.getNodeId())); String.format("Specified peer: %s does not exist in allowlist.", peer.getNodeId()));
} }
} }
final List<EnodeURL> oldWhitelist = new ArrayList<>(this.nodesWhitelist); final List<EnodeURL> oldAllowlist = new ArrayList<>(this.nodesAllowlist);
peers.forEach(this::removeNode); peers.forEach(this::removeNode);
notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(Collections.emptyList(), peers)); notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(Collections.emptyList(), peers));
final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist); final NodesAllowlistResult updateConfigFileResult = updateAllowlistInConfigFile(oldAllowlist);
if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) { if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) {
return updateConfigFileResult; return updateConfigFileResult;
} }
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS);
} }
private boolean removeNode(final EnodeURL enodeURL) { private boolean removeNode(final EnodeURL enodeURL) {
return nodesWhitelist.remove(enodeURL); return nodesAllowlist.remove(enodeURL);
} }
private NodesWhitelistResult updateWhitelistInConfigFile(final List<EnodeURL> oldWhitelist) { private NodesAllowlistResult updateAllowlistInConfigFile(final List<EnodeURL> oldAllowlist) {
try { try {
verifyConfigurationFileState(peerToEnodeURI(oldWhitelist)); verifyConfigurationFileState(peerToEnodeURI(oldAllowlist));
updateConfigurationFile(peerToEnodeURI(nodesWhitelist)); updateConfigurationFile(peerToEnodeURI(nodesAllowlist));
verifyConfigurationFileState(peerToEnodeURI(nodesWhitelist)); verifyConfigurationFileState(peerToEnodeURI(nodesAllowlist));
} catch (IOException e) { } catch (IOException e) {
revertState(oldWhitelist); revertState(oldAllowlist);
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_ALLOWLIST_PERSIST_FAIL); return new NodesAllowlistResult(AllowlistOperationResult.ERROR_ALLOWLIST_PERSIST_FAIL);
} catch (AllowlistFileSyncException e) { } catch (AllowlistFileSyncException e) {
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_ALLOWLIST_FILE_SYNC); return new NodesAllowlistResult(AllowlistOperationResult.ERROR_ALLOWLIST_FILE_SYNC);
} }
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS);
} }
private NodesWhitelistResult validInput(final List<String> peers) { private NodesAllowlistResult validInput(final List<String> peers) {
if (peers == null || peers.isEmpty()) { if (peers == null || peers.isEmpty()) {
return new NodesWhitelistResult( return new NodesAllowlistResult(
AllowlistOperationResult.ERROR_EMPTY_ENTRY, String.format("Null/empty peers list")); AllowlistOperationResult.ERROR_EMPTY_ENTRY, String.format("Null/empty peers list"));
} }
if (peerListHasDuplicates(peers)) { if (peerListHasDuplicates(peers)) {
return new NodesWhitelistResult( return new NodesAllowlistResult(
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY, AllowlistOperationResult.ERROR_DUPLICATED_ENTRY,
String.format("Specified peer list contains duplicates")); String.format("Specified peer list contains duplicates"));
} }
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS);
} }
private boolean peerListHasDuplicates(final List<String> peers) { private boolean peerListHasDuplicates(final List<String> peers) {
@ -218,9 +218,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
allowlistPersistor.updateConfig(ALLOWLIST_TYPE.NODES, nodes); allowlistPersistor.updateConfig(ALLOWLIST_TYPE.NODES, nodes);
} }
private void revertState(final List<EnodeURL> nodesWhitelist) { private void revertState(final List<EnodeURL> nodesAllowlist) {
this.nodesWhitelist.clear(); this.nodesAllowlist.clear();
this.nodesWhitelist.addAll(nodesWhitelist); this.nodesAllowlist.addAll(nodesAllowlist);
} }
private Collection<String> peerToEnodeURI(final Collection<EnodeURL> peers) { private Collection<String> peerToEnodeURI(final Collection<EnodeURL> peers) {
@ -235,16 +235,16 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
if (Objects.equals(localNodeId, node.getNodeId())) { if (Objects.equals(localNodeId, node.getNodeId())) {
return true; return true;
} }
return nodesWhitelist.stream().anyMatch(p -> EnodeURL.sameListeningEndpoint(p, node)); return nodesAllowlist.stream().anyMatch(p -> EnodeURL.sameListeningEndpoint(p, node));
} }
public List<String> getNodesWhitelist() { public List<String> getNodesAllowlist() {
return nodesWhitelist.stream().map(Object::toString).collect(Collectors.toList()); return nodesAllowlist.stream().map(Object::toString).collect(Collectors.toList());
} }
public synchronized void reload() throws RuntimeException { public synchronized void reload() throws RuntimeException {
final List<EnodeURL> currentAccountsList = new ArrayList<>(nodesWhitelist); final List<EnodeURL> currentAccountsList = new ArrayList<>(nodesAllowlist);
nodesWhitelist.clear(); nodesAllowlist.clear();
try { try {
final LocalPermissioningConfiguration updatedConfig = final LocalPermissioningConfiguration updatedConfig =
@ -257,59 +257,59 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
readNodesFromConfig(updatedConfig); readNodesFromConfig(updatedConfig);
configuration = updatedConfig; configuration = updatedConfig;
createNodeWhitelistModifiedEventAfterReload(currentAccountsList, nodesWhitelist); createNodeAllowlistModifiedEventAfterReload(currentAccountsList, nodesAllowlist);
} catch (Exception e) { } catch (Exception e) {
LOG.warn( LOG.warn(
"Error reloading permissions file. In-memory whitelisted nodes will be reverted to previous valid configuration. " "Error reloading permissions file. In-memory nodes allowlist will be reverted to previous valid configuration. "
+ "Details: {}", + "Details: {}",
e.getMessage()); e.getMessage());
nodesWhitelist.clear(); nodesAllowlist.clear();
nodesWhitelist.addAll(currentAccountsList); nodesAllowlist.addAll(currentAccountsList);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
private void createNodeWhitelistModifiedEventAfterReload( private void createNodeAllowlistModifiedEventAfterReload(
final List<EnodeURL> previousNodeWhitelist, final List<EnodeURL> currentNodesList) { final List<EnodeURL> previousNodeAllowlist, final List<EnodeURL> currentNodesList) {
final List<EnodeURL> removedNodes = final List<EnodeURL> removedNodes =
previousNodeWhitelist.stream() previousNodeAllowlist.stream()
.filter(n -> !currentNodesList.contains(n)) .filter(n -> !currentNodesList.contains(n))
.collect(Collectors.toList()); .collect(Collectors.toList());
final List<EnodeURL> addedNodes = final List<EnodeURL> addedNodes =
currentNodesList.stream() currentNodesList.stream()
.filter(n -> !previousNodeWhitelist.contains(n)) .filter(n -> !previousNodeAllowlist.contains(n))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!removedNodes.isEmpty() || !addedNodes.isEmpty()) { if (!removedNodes.isEmpty() || !addedNodes.isEmpty()) {
notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(addedNodes, removedNodes)); notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(addedNodes, removedNodes));
} }
} }
public long subscribeToListUpdatedEvent(final Consumer<NodeWhitelistUpdatedEvent> subscriber) { public long subscribeToListUpdatedEvent(final Consumer<NodeAllowlistUpdatedEvent> subscriber) {
return nodeWhitelistUpdatedObservers.subscribe(subscriber); return nodeAllowlistUpdatedObservers.subscribe(subscriber);
} }
private void notifyListUpdatedSubscribers(final NodeWhitelistUpdatedEvent event) { private void notifyListUpdatedSubscribers(final NodeAllowlistUpdatedEvent event) {
LOG.trace( LOG.trace(
"Sending NodeWhitelistUpdatedEvent (added: {}, removed {})", "Sending NodeAllowlistUpdatedEvent (added: {}, removed {})",
event.getAddedNodes().size(), event.getAddedNodes().size(),
event.getRemovedNodes().size()); event.getRemovedNodes().size());
nodeWhitelistUpdatedObservers.forEach(c -> c.accept(event)); nodeAllowlistUpdatedObservers.forEach(c -> c.accept(event));
} }
public static class NodesWhitelistResult { public static class NodesAllowlistResult {
private final AllowlistOperationResult result; private final AllowlistOperationResult result;
private final Optional<String> message; private final Optional<String> message;
NodesWhitelistResult(final AllowlistOperationResult result, final String message) { NodesAllowlistResult(final AllowlistOperationResult result, final String message) {
this.result = result; this.result = result;
this.message = Optional.of(message); this.message = Optional.of(message);
} }
@VisibleForTesting @VisibleForTesting
public NodesWhitelistResult(final AllowlistOperationResult result) { public NodesAllowlistResult(final AllowlistOperationResult result) {
this.result = result; this.result = result;
this.message = Optional.empty(); this.message = Optional.empty();
} }

@ -67,21 +67,21 @@ public class PermissioningConfigurationBuilder {
if (localConfigNodePermissioningEnabled) { if (localConfigNodePermissioningEnabled) {
final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath); final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath);
final TomlArray nodeWhitelistTomlArray = final TomlArray nodeAllowlistTomlArray =
getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY); getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY);
permissioningConfiguration.setNodePermissioningConfigFilePath( permissioningConfiguration.setNodePermissioningConfigFilePath(
nodePermissioningConfigFilepath); nodePermissioningConfigFilepath);
if (nodeWhitelistTomlArray != null) { if (nodeAllowlistTomlArray != null) {
List<URI> nodesWhitelistToml = List<URI> nodesAllowlistToml =
nodeWhitelistTomlArray nodeAllowlistTomlArray
.toList() .toList()
.parallelStream() .parallelStream()
.map(Object::toString) .map(Object::toString)
.map(EnodeURL::asURI) .map(EnodeURL::asURI)
.collect(Collectors.toList()); .collect(Collectors.toList());
permissioningConfiguration.setNodeAllowlist(nodesWhitelistToml); permissioningConfiguration.setNodeAllowlist(nodesAllowlistToml);
} else { } else {
throw new Exception( throw new Exception(
NODES_ALLOWLIST_KEY NODES_ALLOWLIST_KEY
@ -100,22 +100,22 @@ public class PermissioningConfigurationBuilder {
if (localConfigAccountPermissioningEnabled) { if (localConfigAccountPermissioningEnabled) {
final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath); final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath);
final TomlArray accountWhitelistTomlArray = final TomlArray accountAllowlistTomlArray =
getAllowlistArray( getAllowlistArray(
accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY); accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY);
permissioningConfiguration.setAccountPermissioningConfigFilePath( permissioningConfiguration.setAccountPermissioningConfigFilePath(
accountPermissioningConfigFilepath); accountPermissioningConfigFilepath);
if (accountWhitelistTomlArray != null) { if (accountAllowlistTomlArray != null) {
List<String> accountsWhitelistToml = List<String> accountsAllowlistToml =
accountWhitelistTomlArray accountAllowlistTomlArray
.toList() .toList()
.parallelStream() .parallelStream()
.map(Object::toString) .map(Object::toString)
.collect(Collectors.toList()); .collect(Collectors.toList());
accountsWhitelistToml.stream() accountsAllowlistToml.stream()
.filter(s -> !AccountLocalConfigPermissioningController.isValidAccountString(s)) .filter(s -> !AccountLocalConfigPermissioningController.isValidAccountString(s))
.findFirst() .findFirst()
.ifPresent( .ifPresent(
@ -123,7 +123,7 @@ public class PermissioningConfigurationBuilder {
throw new IllegalArgumentException("Invalid account " + s); throw new IllegalArgumentException("Invalid account " + s);
}); });
permissioningConfiguration.setAccountAllowlist(accountsWhitelistToml); permissioningConfiguration.setAccountAllowlist(accountsAllowlistToml);
} else { } else {
throw new Exception( throw new Exception(
ACCOUNTS_ALLOWLIST_KEY ACCOUNTS_ALLOWLIST_KEY

@ -20,12 +20,12 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class NodeWhitelistUpdatedEvent { public class NodeAllowlistUpdatedEvent {
private final List<EnodeURL> addedNodes; private final List<EnodeURL> addedNodes;
private final List<EnodeURL> removedNodes; private final List<EnodeURL> removedNodes;
public NodeWhitelistUpdatedEvent( public NodeAllowlistUpdatedEvent(
final List<EnodeURL> addedNodes, final List<EnodeURL> removedNodes) { final List<EnodeURL> addedNodes, final List<EnodeURL> removedNodes) {
this.addedNodes = addedNodes != null ? addedNodes : Collections.emptyList(); this.addedNodes = addedNodes != null ? addedNodes : Collections.emptyList();
this.removedNodes = removedNodes != null ? removedNodes : Collections.emptyList(); this.removedNodes = removedNodes != null ? removedNodes : Collections.emptyList();
@ -47,7 +47,7 @@ public class NodeWhitelistUpdatedEvent {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
NodeWhitelistUpdatedEvent that = (NodeWhitelistUpdatedEvent) o; NodeAllowlistUpdatedEvent that = (NodeAllowlistUpdatedEvent) o;
return Objects.equals(addedNodes, that.addedNodes) return Objects.equals(addedNodes, that.addedNodes)
&& Objects.equals(removedNodes, that.removedNodes); && Objects.equals(removedNodes, that.removedNodes);
} }

@ -36,14 +36,14 @@ public class AllowlistPersistorTest {
private AllowlistPersistor allowlistPersistor; private AllowlistPersistor allowlistPersistor;
private File tempFile; private File tempFile;
private final String accountsWhitelist = private final String accountsAllowlist =
String.format("%s=[%s]", ALLOWLIST_TYPE.ACCOUNTS.getTomlKey(), "\"account1\",\"account2\""); String.format("%s=[%s]", ALLOWLIST_TYPE.ACCOUNTS.getTomlKey(), "\"account1\",\"account2\"");
private final String nodesWhitelist = private final String nodesAllowlist =
String.format("%s=[%s]", ALLOWLIST_TYPE.NODES.getTomlKey(), "\"node1\",\"node2\""); String.format("%s=[%s]", ALLOWLIST_TYPE.NODES.getTomlKey(), "\"node1\",\"node2\"");
@Before @Before
public void setUp() throws IOException { public void setUp() throws IOException {
List<String> lines = Lists.newArrayList(nodesWhitelist, accountsWhitelist); List<String> lines = Lists.newArrayList(nodesAllowlist, accountsAllowlist);
tempFile = File.createTempFile("test", "test"); tempFile = File.createTempFile("test", "test");
tempFile.deleteOnExit(); tempFile.deleteOnExit();
Files.write(tempFile.toPath(), lines, StandardOpenOption.WRITE, StandardOpenOption.CREATE); Files.write(tempFile.toPath(), lines, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
@ -66,7 +66,7 @@ public class AllowlistPersistorTest {
@Test @Test
public void lineShouldBeAdded() throws IOException { public void lineShouldBeAdded() throws IOException {
final ALLOWLIST_TYPE key = ALLOWLIST_TYPE.NODES; final ALLOWLIST_TYPE key = ALLOWLIST_TYPE.NODES;
final Set<String> updatedWhitelist = Collections.singleton("node5"); final Set<String> updatedAllowlist = Collections.singleton("node5");
assertThat(countLines()).isEqualTo(2); assertThat(countLines()).isEqualTo(2);
assertThat(hasKey(key)).isTrue(); assertThat(hasKey(key)).isTrue();
@ -76,7 +76,7 @@ public class AllowlistPersistorTest {
assertThat(countLines()).isEqualTo(1); assertThat(countLines()).isEqualTo(1);
assertThat(hasKey(key)).isFalse(); assertThat(hasKey(key)).isFalse();
allowlistPersistor.addNewConfigItem(key, updatedWhitelist); allowlistPersistor.addNewConfigItem(key, updatedAllowlist);
assertThat(countLines()).isEqualTo(2); assertThat(countLines()).isEqualTo(2);
assertThat(hasKey(key)).isTrue(); assertThat(hasKey(key)).isTrue();
@ -88,13 +88,13 @@ public class AllowlistPersistorTest {
String newValue = "node5"; String newValue = "node5";
assertThat(countLines()).isEqualTo(2); assertThat(countLines()).isEqualTo(2);
assertThat(hasKeyAndExactLineContent(key, nodesWhitelist)).isTrue(); assertThat(hasKeyAndExactLineContent(key, nodesAllowlist)).isTrue();
allowlistPersistor.updateConfig(key, Collections.singleton(newValue)); allowlistPersistor.updateConfig(key, Collections.singleton(newValue));
assertThat(countLines()).isEqualTo(2); assertThat(countLines()).isEqualTo(2);
assertThat(hasKeyAndContainsValue(key, newValue)).isTrue(); assertThat(hasKeyAndContainsValue(key, newValue)).isTrue();
assertThat(hasKeyAndExactLineContent(key, nodesWhitelist)).isFalse(); assertThat(hasKeyAndExactLineContent(key, nodesAllowlist)).isFalse();
} }
@Test @Test

@ -31,8 +31,11 @@ import org.junit.Test;
public class LocalPermissioningConfigurationBuilderTest { public class LocalPermissioningConfigurationBuilderTest {
private static final String PERMISSIONING_CONFIG_VALID = "/permissioning_config.toml"; private static final String PERMISSIONING_CONFIG_VALID = "/permissioning_config.toml";
@Deprecated
private static final String PERMISSIONING_CONFIG_VALID_WHITELISTS = private static final String PERMISSIONING_CONFIG_VALID_WHITELISTS =
"/permissioning_config_whitelists.toml"; "/permissioning_config_whitelists.toml";
private static final String PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY = private static final String PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY =
"/permissioning_config_account_allowlist_only.toml"; "/permissioning_config_account_allowlist_only.toml";
private static final String PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY = private static final String PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY =
@ -90,7 +93,7 @@ public class LocalPermissioningConfigurationBuilderTest {
} }
@Test @Test
public void permissioningConfigWithOnlyNodeWhitelistSet() throws Exception { public void permissioningConfigWithOnlyNodeAllowlistSet() throws Exception {
final String uri = "enode://" + VALID_NODE_ID + "@192.168.0.9:4567"; final String uri = "enode://" + VALID_NODE_ID + "@192.168.0.9:4567";
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY); final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY);
@ -106,7 +109,7 @@ public class LocalPermissioningConfigurationBuilderTest {
} }
@Test @Test
public void permissioningConfigWithOnlyAccountWhitelistSet() throws Exception { public void permissioningConfigWithOnlyAccountAllowlistSet() throws Exception {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY); final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY);
final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); final Path toml = createTempFile("toml", Resources.toByteArray(configFile));
@ -145,7 +148,7 @@ public class LocalPermissioningConfigurationBuilderTest {
} }
@Test @Test
public void permissioningConfigWithEmptyWhitelistMustNotError() throws Exception { public void permissioningConfigWithEmptyAllowlistMustNotError() throws Exception {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_EMPTY_ALLOWLISTS); final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_EMPTY_ALLOWLISTS);
final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); final Path toml = createTempFile("toml", Resources.toByteArray(configFile));
@ -158,7 +161,7 @@ public class LocalPermissioningConfigurationBuilderTest {
} }
@Test @Test
public void permissioningConfigWithAbsentWhitelistMustThrowException() throws Exception { public void permissioningConfigWithAbsentAllowlistMustThrowException() throws Exception {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ABSENT_ALLOWLISTS); final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ABSENT_ALLOWLISTS);
final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); final Path toml = createTempFile("toml", Resources.toByteArray(configFile));

@ -40,7 +40,7 @@ public class LocalPermissioningConfigurationTest {
} }
@Test @Test
public void setNodeWhitelist() { public void setNodeAllowlist() {
final LocalPermissioningConfiguration configuration = final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault(); LocalPermissioningConfiguration.createDefault();
configuration.setNodeAllowlist(Arrays.asList(nodes)); configuration.setNodeAllowlist(Arrays.asList(nodes));
@ -49,7 +49,7 @@ public class LocalPermissioningConfigurationTest {
} }
@Test @Test
public void setNodeWhiteListPassingNull() { public void setNodeAllowListPassingNull() {
final LocalPermissioningConfiguration configuration = final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault(); LocalPermissioningConfiguration.createDefault();
configuration.setNodeAllowlist(null); configuration.setNodeAllowlist(null);
@ -58,7 +58,7 @@ public class LocalPermissioningConfigurationTest {
} }
@Test @Test
public void setAccountWhitelist() { public void setAccountAllowlist() {
final String[] accounts = {"1111111111111111", "2222222222222222", "ffffffffffffffff"}; final String[] accounts = {"1111111111111111", "2222222222222222", "ffffffffffffffff"};
final LocalPermissioningConfiguration configuration = final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault(); LocalPermissioningConfiguration.createDefault();
@ -68,7 +68,7 @@ public class LocalPermissioningConfigurationTest {
} }
@Test @Test
public void setAccountWhiteListPassingNull() { public void setAccountAllowListPassingNull() {
final LocalPermissioningConfiguration configuration = final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault(); LocalPermissioningConfiguration.createDefault();
configuration.setAccountAllowlist(null); configuration.setAccountAllowlist(null);

@ -28,7 +28,8 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.permissioning.node.NodeWhitelistUpdatedEvent; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult;
import org.hyperledger.besu.ethereum.permissioning.node.NodeAllowlistUpdatedEvent;
import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter; import org.hyperledger.besu.plugin.services.metrics.Counter;
@ -103,103 +104,84 @@ public class NodeLocalConfigPermissioningControllerTest {
@Test @Test
public void whenAddNodesWithValidInputShouldReturnSuccess() { public void whenAddNodesWithValidInputShouldReturnSuccess() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.SUCCESS);
new NodeLocalConfigPermissioningController.NodesWhitelistResult( NodesAllowlistResult actualResult = controller.addNodes(Lists.newArrayList(enode1));
AllowlistOperationResult.SUCCESS);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.addNodes(Lists.newArrayList(enode1));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
assertThat(controller.getNodesWhitelist()).containsExactly(enode1); assertThat(controller.getNodesAllowlist()).containsExactly(enode1);
} }
@Test @Test
public void whenAddNodesInputHasExistingNodeShouldReturnAddErrorExistingEntry() { public void whenAddNodesInputHasExistingNodeShouldReturnAddErrorExistingEntry() {
controller.addNodes(Arrays.asList(enode1)); controller.addNodes(Arrays.asList(enode1));
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_EXISTING_ENTRY);
AllowlistOperationResult.ERROR_EXISTING_ENTRY); NodesAllowlistResult actualResult = controller.addNodes(Lists.newArrayList(enode1, enode2));
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.addNodes(Lists.newArrayList(enode1, enode2));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError() { public void whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = NodesAllowlistResult actualResult = controller.addNodes(Arrays.asList(enode1, enode1));
controller.addNodes(Arrays.asList(enode1, enode1));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenAddNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() { public void whenAddNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(new ArrayList<>());
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(new ArrayList<>());
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenAddNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() { public void whenAddNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(null);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(null);
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry() { public void whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_ABSENT_ENTRY);
AllowlistOperationResult.ERROR_ABSENT_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1, enode2));
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(Lists.newArrayList(enode1, enode2));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenRemoveNodesInputHasDuplicateNodesShouldReturnErrorDuplicatedEntry() { public void whenRemoveNodesInputHasDuplicateNodesShouldReturnErrorDuplicatedEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1, enode1));
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(Lists.newArrayList(enode1, enode1));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() { public void whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(new ArrayList<>());
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(new ArrayList<>());
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@Test @Test
public void whenRemoveNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() { public void whenRemoveNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY); NodesAllowlistResult actualResult = controller.removeNodes(null);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(null);
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
} }
@ -287,7 +269,7 @@ public class NodeLocalConfigPermissioningControllerTest {
@Test @Test
public void public void
whenCheckingIfNodeIsPermittedDiscoveryPortShouldNotBeConsidered_whitelistedNodeHasDiscDisabled() { whenCheckingIfNodeIsPermittedDiscoveryPortShouldNotBeConsidered_allowedNodeHasDiscDisabled() {
String peerWithDiscoveryPortSet = String peerWithDiscoveryPortSet =
"enode://aaaa80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@127.0.0.1:30303?discport=0"; "enode://aaaa80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@127.0.0.1:30303?discport=0";
String peerWithoutDiscoveryPortSet = String peerWithoutDiscoveryPortSet =
@ -330,16 +312,16 @@ public class NodeLocalConfigPermissioningControllerTest {
List<String> newNode1 = singletonList(EnodeURL.fromString(enode1).toString()); List<String> newNode1 = singletonList(EnodeURL.fromString(enode1).toString());
List<String> newNode2 = singletonList(EnodeURL.fromString(enode2).toString()); List<String> newNode2 = singletonList(EnodeURL.fromString(enode2).toString());
assertThat(controller.getNodesWhitelist().size()).isEqualTo(0); assertThat(controller.getNodesAllowlist().size()).isEqualTo(0);
controller.addNodes(newNode1); controller.addNodes(newNode1);
assertThat(controller.getNodesWhitelist().size()).isEqualTo(1); assertThat(controller.getNodesAllowlist().size()).isEqualTo(1);
doThrow(new IOException()).when(allowlistPersistor).updateConfig(any(), any()); doThrow(new IOException()).when(allowlistPersistor).updateConfig(any(), any());
controller.addNodes(newNode2); controller.addNodes(newNode2);
assertThat(controller.getNodesWhitelist().size()).isEqualTo(1); assertThat(controller.getNodesAllowlist().size()).isEqualTo(1);
assertThat(controller.getNodesWhitelist()).isEqualTo(newNode1); assertThat(controller.getNodesAllowlist()).isEqualTo(newNode1);
verify(allowlistPersistor, times(3)).verifyConfigFileMatchesState(any(), any()); verify(allowlistPersistor, times(3)).verifyConfigFileMatchesState(any(), any());
verify(allowlistPersistor, times(2)).updateConfig(any(), any()); verify(allowlistPersistor, times(2)).updateConfig(any(), any());
@ -365,7 +347,7 @@ public class NodeLocalConfigPermissioningControllerTest {
controller.reload(); controller.reload();
assertThat(controller.getNodesWhitelist()).containsExactly(expectedEnodeURL); assertThat(controller.getNodesAllowlist()).containsExactly(expectedEnodeURL);
} }
@Test @Test
@ -389,15 +371,15 @@ public class NodeLocalConfigPermissioningControllerTest {
.isInstanceOf(RuntimeException.class) .isInstanceOf(RuntimeException.class)
.hasMessageContaining("Unable to read permissioning TOML config file"); .hasMessageContaining("Unable to read permissioning TOML config file");
assertThat(controller.getNodesWhitelist()).containsExactly(expectedEnodeURI); assertThat(controller.getNodesAllowlist()).containsExactly(expectedEnodeURI);
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void whenAddingNodeShouldNotifyWhitelistModifiedSubscribers() { public void whenAddingNodeShouldNotifyAllowlistModifiedSubscribers() {
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent = final NodeAllowlistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent( new NodeAllowlistUpdatedEvent(
Lists.newArrayList(EnodeURL.fromString(enode1)), Collections.emptyList()); Lists.newArrayList(EnodeURL.fromString(enode1)), Collections.emptyList());
controller.subscribeToListUpdatedEvent(consumer); controller.subscribeToListUpdatedEvent(consumer);
@ -411,7 +393,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenAddingNodeDoesNotAddShouldNotNotifyAllowlistModifiedSubscribers() { public void whenAddingNodeDoesNotAddShouldNotNotifyAllowlistModifiedSubscribers() {
// adding node before subscribing to allowlist modified events // adding node before subscribing to allowlist modified events
controller.addNodes(Lists.newArrayList(enode1)); controller.addNodes(Lists.newArrayList(enode1));
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
controller.subscribeToListUpdatedEvent(consumer); controller.subscribeToListUpdatedEvent(consumer);
// won't add duplicate node // won't add duplicate node
@ -426,9 +408,9 @@ public class NodeLocalConfigPermissioningControllerTest {
// adding node before subscribing to allowlist modified events // adding node before subscribing to allowlist modified events
controller.addNodes(Lists.newArrayList(enode1)); controller.addNodes(Lists.newArrayList(enode1));
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent = final NodeAllowlistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent( new NodeAllowlistUpdatedEvent(
Collections.emptyList(), Lists.newArrayList(EnodeURL.fromString(enode1))); Collections.emptyList(), Lists.newArrayList(EnodeURL.fromString(enode1)));
controller.subscribeToListUpdatedEvent(consumer); controller.subscribeToListUpdatedEvent(consumer);
@ -440,7 +422,7 @@ public class NodeLocalConfigPermissioningControllerTest {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void whenRemovingNodeDoesNotRemoveShouldNotifyAllowlistModifiedSubscribers() { public void whenRemovingNodeDoesNotRemoveShouldNotifyAllowlistModifiedSubscribers() {
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
controller.subscribeToListUpdatedEvent(consumer); controller.subscribeToListUpdatedEvent(consumer);
// won't remove absent node // won't remove absent node
@ -451,17 +433,15 @@ public class NodeLocalConfigPermissioningControllerTest {
@Test @Test
public void whenRemovingBootnodeShouldReturnRemoveBootnodeError() { public void whenRemovingBootnodeShouldReturnRemoveBootnodeError() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected = NodesAllowlistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult( new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
bootnodesList.add(EnodeURL.fromString(enode1)); bootnodesList.add(EnodeURL.fromString(enode1));
controller.addNodes(Lists.newArrayList(enode1, enode2)); controller.addNodes(Lists.newArrayList(enode1, enode2));
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1));
controller.removeNodes(Lists.newArrayList(enode1));
assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
assertThat(controller.getNodesWhitelist()).containsExactly(enode1, enode2); assertThat(controller.getNodesAllowlist()).containsExactly(enode1, enode2);
} }
@Test @Test
@ -470,9 +450,9 @@ public class NodeLocalConfigPermissioningControllerTest {
final Path permissionsFile = createPermissionsFileWithNode(enode2); final Path permissionsFile = createPermissionsFileWithNode(enode2);
final LocalPermissioningConfiguration permissioningConfig = final LocalPermissioningConfiguration permissioningConfig =
mock(LocalPermissioningConfiguration.class); mock(LocalPermissioningConfiguration.class);
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent = final NodeAllowlistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent( new NodeAllowlistUpdatedEvent(
Lists.newArrayList(EnodeURL.fromString(enode2)), Lists.newArrayList(EnodeURL.fromString(enode2)),
Lists.newArrayList(EnodeURL.fromString(enode1))); Lists.newArrayList(EnodeURL.fromString(enode1)));
@ -497,7 +477,7 @@ public class NodeLocalConfigPermissioningControllerTest {
final Path permissionsFile = createPermissionsFileWithNode(enode1); final Path permissionsFile = createPermissionsFileWithNode(enode1);
final LocalPermissioningConfiguration permissioningConfig = final LocalPermissioningConfiguration permissioningConfig =
mock(LocalPermissioningConfiguration.class); mock(LocalPermissioningConfiguration.class);
final Consumer<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class); final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
when(permissioningConfig.getNodePermissioningConfigFilePath()) when(permissioningConfig.getNodePermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString()); .thenReturn(permissionsFile.toAbsolutePath().toString());

@ -45,7 +45,7 @@ public class MetricsConfiguration {
private final String pushHost; private final String pushHost;
private final int pushInterval; private final int pushInterval;
private final String prometheusJob; private final String prometheusJob;
private final List<String> hostsWhitelist; private final List<String> hostsAllowlist;
private final boolean timersEnabled; private final boolean timersEnabled;
public static Builder builder() { public static Builder builder() {
@ -62,7 +62,7 @@ public class MetricsConfiguration {
final String pushHost, final String pushHost,
final int pushInterval, final int pushInterval,
final String prometheusJob, final String prometheusJob,
final List<String> hostsWhitelist, final List<String> hostsAllowlist,
final boolean timersEnabled) { final boolean timersEnabled) {
this.enabled = enabled; this.enabled = enabled;
this.port = port; this.port = port;
@ -73,7 +73,7 @@ public class MetricsConfiguration {
this.pushHost = pushHost; this.pushHost = pushHost;
this.pushInterval = pushInterval; this.pushInterval = pushInterval;
this.prometheusJob = prometheusJob; this.prometheusJob = prometheusJob;
this.hostsWhitelist = hostsWhitelist; this.hostsAllowlist = hostsAllowlist;
this.timersEnabled = timersEnabled; this.timersEnabled = timersEnabled;
} }
@ -122,7 +122,7 @@ public class MetricsConfiguration {
} }
Collection<String> getHostsAllowlist() { Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsAllowlist);
} }
public boolean isTimersEnabled() { public boolean isTimersEnabled() {
@ -141,7 +141,7 @@ public class MetricsConfiguration {
.add("pushHost", pushHost) .add("pushHost", pushHost)
.add("pushInterval", pushInterval) .add("pushInterval", pushInterval)
.add("prometheusJob", prometheusJob) .add("prometheusJob", prometheusJob)
.add("hostsWhitelist", hostsWhitelist) .add("hostsAllowlist", hostsAllowlist)
.toString(); .toString();
} }
@ -163,7 +163,7 @@ public class MetricsConfiguration {
&& Objects.equals(metricCategories, that.metricCategories) && Objects.equals(metricCategories, that.metricCategories)
&& Objects.equals(pushHost, that.pushHost) && Objects.equals(pushHost, that.pushHost)
&& Objects.equals(prometheusJob, that.prometheusJob) && Objects.equals(prometheusJob, that.prometheusJob)
&& Objects.equals(hostsWhitelist, that.hostsWhitelist); && Objects.equals(hostsAllowlist, that.hostsAllowlist);
} }
@Override @Override
@ -178,7 +178,7 @@ public class MetricsConfiguration {
pushHost, pushHost,
pushInterval, pushInterval,
prometheusJob, prometheusJob,
hostsWhitelist); hostsAllowlist);
} }
public static class Builder { public static class Builder {
@ -191,7 +191,7 @@ public class MetricsConfiguration {
private String pushHost = DEFAULT_METRICS_PUSH_HOST; private String pushHost = DEFAULT_METRICS_PUSH_HOST;
private int pushInterval = 15; private int pushInterval = 15;
private String prometheusJob = "besu-client"; private String prometheusJob = "besu-client";
private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private List<String> hostsAllowlist = Arrays.asList("localhost", "127.0.0.1");
private boolean timersEnabled = DEFAULT_TIMERS_ENABLED; private boolean timersEnabled = DEFAULT_TIMERS_ENABLED;
private Builder() {} private Builder() {}
@ -241,8 +241,8 @@ public class MetricsConfiguration {
return this; return this;
} }
public Builder hostsAllowlist(final List<String> hostsWhitelist) { public Builder hostsAllowlist(final List<String> hostsAllowlist) {
this.hostsWhitelist = hostsWhitelist; this.hostsAllowlist = hostsAllowlist;
return this; return this;
} }
@ -262,7 +262,7 @@ public class MetricsConfiguration {
pushHost, pushHost,
pushInterval, pushInterval,
prometheusJob, prometheusJob,
hostsWhitelist, hostsAllowlist,
timersEnabled); timersEnabled);
} }
} }

Loading…
Cancel
Save