Skip to content

Commit

Permalink
remove vestigial whitelist methods (#7449)
Browse files Browse the repository at this point in the history
* remove vestigial whitelist methods

* rename param and method

Signed-off-by: Sally MacFarlane <[email protected]>

---------

Signed-off-by: Sally MacFarlane <[email protected]>
  • Loading branch information
macfarla authored Aug 14, 2024
1 parent ad19d4c commit b4869e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ public enum RpcMethod {
PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"),
PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"),
PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"),
PERM_REMOVE_ACCOUNTS_FROM_WHITELIST("perm_removeAccountsFromWhitelist"),
PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"),
PERM_REMOVE_NODES_FROM_WHITELIST("perm_removeNodesFromWhitelist"),
PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"),
RPC_MODULES("rpc_modules"),
TRACE_BLOCK("trace_block"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

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 NODES_ALLOWLIST_KEY = "nodes-allowlist";

Expand Down Expand Up @@ -69,8 +67,7 @@ private static LocalPermissioningConfiguration loadNodePermissioning(

if (localConfigNodePermissioningEnabled) {
final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath);
final TomlArray nodeAllowlistTomlArray =
getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY);
final TomlArray nodeAllowlistTomlArray = getArray(nodePermissioningToml, NODES_ALLOWLIST_KEY);

permissioningConfiguration.setNodePermissioningConfigFilePath(
nodePermissioningConfigFilepath);
Expand Down Expand Up @@ -104,8 +101,7 @@ private static LocalPermissioningConfiguration loadAccountPermissioning(
if (localConfigAccountPermissioningEnabled) {
final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath);
final TomlArray accountAllowlistTomlArray =
getAllowlistArray(
accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY);
getArray(accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY);

permissioningConfiguration.setAccountPermissioningConfigFilePath(
accountPermissioningConfigFilepath);
Expand Down Expand Up @@ -137,23 +133,14 @@ private static LocalPermissioningConfiguration loadAccountPermissioning(
}

/**
* This method allows support for both keys for now. Whitelist TOML keys will be removed in future
* (breaking change)
* This method retrieves an array from parsed toml, using the given key.
*
* @param tomlParseResult result of a prior toml parse
* @param primaryKey key to fetch
* @param alternateKey alternate key to fetch
* @return In order: the array of the primaryKey if it exists, or the array of the alternateKey if
* it exists, or null.
* @param key key to fetch
* @return The array matching the key if it exists, or null.
*/
private static TomlArray getAllowlistArray(
final TomlParseResult tomlParseResult, final String primaryKey, final String alternateKey) {
final TomlArray array = tomlParseResult.getArray(primaryKey);
if (array == null) {
return tomlParseResult.getArray(alternateKey);
} else {
return array;
}
private static TomlArray getArray(final TomlParseResult tomlParseResult, final String key) {
return tomlParseResult.getArray(key);
}

private static TomlParseResult readToml(final String filepath) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class LocalPermissioningConfigurationBuilderTest {

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 =
"/permissioning_config_account_allowlist_only.toml";
private static final String PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY =
Expand All @@ -61,24 +57,6 @@ public class LocalPermissioningConfigurationBuilderTest {
private final String VALID_NODE_ID =
"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
public void permissioningConfig() throws Exception {
final String uri = "enode://" + VALID_NODE_ID + "@192.168.0.9:4567";
Expand Down

This file was deleted.

0 comments on commit b4869e7

Please sign in to comment.