remove vestigial whitelist methods (#7449)

* remove vestigial whitelist methods

* rename param and method

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/7473/head
Sally MacFarlane 3 months ago committed by GitHub
parent ad19d4c7ff
commit b4869e7b86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java
  2. 27
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java
  3. 22
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java
  4. 6
      ethereum/permissioning/src/test/resources/permissioning_config_whitelists.toml

@ -177,9 +177,7 @@ public enum RpcMethod {
PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"), PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"),
PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"), PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"),
PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"), PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"),
PERM_REMOVE_ACCOUNTS_FROM_WHITELIST("perm_removeAccountsFromWhitelist"),
PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"), PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"),
PERM_REMOVE_NODES_FROM_WHITELIST("perm_removeNodesFromWhitelist"),
PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"), PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"),
RPC_MODULES("rpc_modules"), RPC_MODULES("rpc_modules"),
TRACE_BLOCK("trace_block"), TRACE_BLOCK("trace_block"),

@ -27,8 +27,6 @@ import org.apache.tuweni.toml.TomlParseResult;
public class PermissioningConfigurationBuilder { public class PermissioningConfigurationBuilder {
@Deprecated public static final String ACCOUNTS_WHITELIST_KEY = "accounts-whitelist";
@Deprecated public static final String NODES_WHITELIST_KEY = "nodes-whitelist";
public static final String ACCOUNTS_ALLOWLIST_KEY = "accounts-allowlist"; public static final String ACCOUNTS_ALLOWLIST_KEY = "accounts-allowlist";
public static final String NODES_ALLOWLIST_KEY = "nodes-allowlist"; public static final String NODES_ALLOWLIST_KEY = "nodes-allowlist";
@ -69,8 +67,7 @@ public class PermissioningConfigurationBuilder {
if (localConfigNodePermissioningEnabled) { if (localConfigNodePermissioningEnabled) {
final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath); final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath);
final TomlArray nodeAllowlistTomlArray = final TomlArray nodeAllowlistTomlArray = getArray(nodePermissioningToml, NODES_ALLOWLIST_KEY);
getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY);
permissioningConfiguration.setNodePermissioningConfigFilePath( permissioningConfiguration.setNodePermissioningConfigFilePath(
nodePermissioningConfigFilepath); nodePermissioningConfigFilepath);
@ -104,8 +101,7 @@ public class PermissioningConfigurationBuilder {
if (localConfigAccountPermissioningEnabled) { if (localConfigAccountPermissioningEnabled) {
final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath); final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath);
final TomlArray accountAllowlistTomlArray = final TomlArray accountAllowlistTomlArray =
getAllowlistArray( getArray(accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY);
accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY);
permissioningConfiguration.setAccountPermissioningConfigFilePath( permissioningConfiguration.setAccountPermissioningConfigFilePath(
accountPermissioningConfigFilepath); accountPermissioningConfigFilepath);
@ -137,23 +133,14 @@ public class PermissioningConfigurationBuilder {
} }
/** /**
* This method allows support for both keys for now. Whitelist TOML keys will be removed in future * This method retrieves an array from parsed toml, using the given key.
* (breaking change)
* *
* @param tomlParseResult result of a prior toml parse * @param tomlParseResult result of a prior toml parse
* @param primaryKey key to fetch * @param key key to fetch
* @param alternateKey alternate key to fetch * @return The array matching the key if it exists, or null.
* @return In order: the array of the primaryKey if it exists, or the array of the alternateKey if
* it exists, or null.
*/ */
private static TomlArray getAllowlistArray( private static TomlArray getArray(final TomlParseResult tomlParseResult, final String key) {
final TomlParseResult tomlParseResult, final String primaryKey, final String alternateKey) { return tomlParseResult.getArray(key);
final TomlArray array = tomlParseResult.getArray(primaryKey);
if (array == null) {
return tomlParseResult.getArray(alternateKey);
} else {
return array;
}
} }
private static TomlParseResult readToml(final String filepath) throws Exception { private static TomlParseResult readToml(final String filepath) throws Exception {

@ -36,10 +36,6 @@ 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 =
"/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 =
@ -61,24 +57,6 @@ public class LocalPermissioningConfigurationBuilderTest {
private final String VALID_NODE_ID = private final String VALID_NODE_ID =
"6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0"; "6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0";
@Test
public void permissioningConfig_usingDeprecatedKeysIsStillValid() throws Exception {
final String uri = "enode://" + VALID_NODE_ID + "@192.168.0.9:4567";
final String uri2 = "enode://" + VALID_NODE_ID + "@192.169.0.9:4568";
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_VALID_WHITELISTS);
final Path toml = createTempFile("toml", Resources.toByteArray(configFile));
LocalPermissioningConfiguration permissioningConfiguration = permissioningConfig(toml);
assertThat(permissioningConfiguration.isAccountAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountAllowlist())
.containsExactly("0x0000000000000000000000000000000000000009");
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeAllowlist())
.containsExactly(EnodeURLImpl.fromString(uri), EnodeURLImpl.fromString(uri2));
}
@Test @Test
public void permissioningConfig() throws Exception { public void permissioningConfig() 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";

@ -1,6 +0,0 @@
# Permissioning TOML file
# NOTE whitelist is being deprecated in favor of allowlist
# support for whitelist will be removed in future
accounts-whitelist=["0x0000000000000000000000000000000000000009"]
nodes-whitelist=["enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567","enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.169.0.9:4568"]
Loading…
Cancel
Save