Skip to content

Commit

Permalink
review suggestions: use v3Keystores instead of the term wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
usmansaleem committed Sep 4, 2023
1 parent 58ad6eb commit b865aef
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class SignerConfiguration {
private Optional<ClientTlsOptions> downstreamTlsOptions;
private final Duration startupTimeout;
private final ChainIdProvider chainIdProvider;
private final Optional<KeystoresParameters> walletBulkloadParameters;
private final Optional<KeystoresParameters> v3KeystoresBulkloadParameters;

public SignerConfiguration(
final String hostname,
Expand Down Expand Up @@ -122,7 +122,7 @@ public SignerConfiguration(
final Optional<ClientTlsOptions> downstreamTlsOptions,
final ChainIdProvider chainIdProvider,
final Optional<String> trustedSetup,
final Optional<KeystoresParameters> walletBulkloadParameters) {
final Optional<KeystoresParameters> v3KeystoresBulkloadParameters) {
this.hostname = hostname;
this.logLevel = logLevel;
this.httpRpcPort = httpRpcPort;
Expand Down Expand Up @@ -166,7 +166,7 @@ public SignerConfiguration(
this.downstreamTlsOptions = downstreamTlsOptions;
this.chainIdProvider = chainIdProvider;
this.trustedSetup = trustedSetup;
this.walletBulkloadParameters = walletBulkloadParameters;
this.v3KeystoresBulkloadParameters = v3KeystoresBulkloadParameters;
}

public String hostname() {
Expand Down Expand Up @@ -349,7 +349,7 @@ public Optional<String> getTrustedSetup() {
return trustedSetup;
}

public Optional<KeystoresParameters> getWalletBulkloadParameters() {
return walletBulkloadParameters;
public Optional<KeystoresParameters> getV3KeystoresBulkloadParameters() {
return v3KeystoresBulkloadParameters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class SignerConfigurationBuilder {
private ChainIdProvider chainIdProvider = new ConfigurationChainId(DEFAULT_CHAIN_ID);
private String trustedSetup;

private KeystoresParameters walletBulkloadParameters;
private KeystoresParameters v3KeystoresBulkloadParameters;

public SignerConfigurationBuilder withLogLevel(final Level logLevel) {
this.logLevel = logLevel;
Expand Down Expand Up @@ -311,9 +311,9 @@ public SignerConfigurationBuilder withTrustedSetup(final String trustedSetup) {
return this;
}

public SignerConfigurationBuilder withWalletBulkloadParameters(
final KeystoresParameters walletBulkloadParameters) {
this.walletBulkloadParameters = walletBulkloadParameters;
public SignerConfigurationBuilder withV3KeystoresBulkloadParameters(
final KeystoresParameters v3KeystoresBulkloadParameters) {
this.v3KeystoresBulkloadParameters = v3KeystoresBulkloadParameters;
return this;
}

Expand Down Expand Up @@ -365,6 +365,6 @@ public SignerConfiguration build() {
Optional.ofNullable(downstreamTlsOptions),
chainIdProvider,
Optional.ofNullable(trustedSetup),
Optional.ofNullable(walletBulkloadParameters));
Optional.ofNullable(v3KeystoresBulkloadParameters));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_SECRET_ACCESS_KEY_OPTION;
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_TAG_NAMES_FILTER_OPTION;
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_TAG_VALUES_FILTER_OPTION;
import static tech.pegasys.web3signer.commandline.config.PicoV3WalletBulkloadParameters.WALLETS_PASSWORDS_PATH;
import static tech.pegasys.web3signer.commandline.config.PicoV3WalletBulkloadParameters.WALLETS_PASSWORD_FILE;
import static tech.pegasys.web3signer.commandline.config.PicoV3WalletBulkloadParameters.WALLETS_PATH;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PASSWORDS_PATH;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PASSWORD_FILE;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PATH;

import tech.pegasys.web3signer.core.config.ClientAuthConstraints;
import tech.pegasys.web3signer.core.config.TlsOptions;
Expand Down Expand Up @@ -157,7 +157,9 @@ public List<String> createCmdLineParams() {
String.format(YAML_NUMERIC_FMT, "eth1.chain-id", signerConfig.getChainIdProvider().id()));
yamlConfig.append(createDownstreamTlsArgs());

signerConfig.getWalletBulkloadParameters().ifPresent(setWalletBulkloadParameters(yamlConfig));
signerConfig
.getV3KeystoresBulkloadParameters()
.ifPresent(setV3KeystoresBulkloadParameters(yamlConfig));
}

signerConfig
Expand All @@ -181,27 +183,27 @@ public List<String> createCmdLineParams() {
return params;
}

private Consumer<? super KeystoresParameters> setWalletBulkloadParameters(
private Consumer<? super KeystoresParameters> setV3KeystoresBulkloadParameters(
final StringBuilder yamlConfig) {
return keystoresParameters -> {
yamlConfig.append(
String.format(
YAML_STRING_FMT,
WALLETS_PATH.replace("--", "eth1."),
KEYSTORES_PATH.replace("--", "eth1."),
keystoresParameters.getKeystoresPath().toAbsolutePath()));

if (keystoresParameters.getKeystoresPasswordsPath() != null) {
yamlConfig.append(
String.format(
YAML_STRING_FMT,
WALLETS_PASSWORDS_PATH.replace("--", "eth1."),
KEYSTORES_PASSWORDS_PATH.replace("--", "eth1."),
keystoresParameters.getKeystoresPasswordsPath().toAbsolutePath()));
}
if (keystoresParameters.getKeystoresPasswordFile() != null) {
yamlConfig.append(
String.format(
YAML_STRING_FMT,
WALLETS_PASSWORD_FILE.replace("--", "eth1."),
KEYSTORES_PASSWORD_FILE.replace("--", "eth1."),
keystoresParameters.getKeystoresPasswordFile().toAbsolutePath()));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_SECRET_ACCESS_KEY_OPTION;
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_TAG_NAMES_FILTER_OPTION;
import static tech.pegasys.web3signer.commandline.PicoCliAwsSecretsManagerParameters.AWS_SECRETS_TAG_VALUES_FILTER_OPTION;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PASSWORDS_PATH;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PASSWORD_FILE;
import static tech.pegasys.web3signer.signing.config.KeystoresParameters.KEYSTORES_PATH;

import tech.pegasys.web3signer.commandline.config.PicoV3WalletBulkloadParameters;
import tech.pegasys.web3signer.core.config.ClientAuthConstraints;
import tech.pegasys.web3signer.core.config.TlsOptions;
import tech.pegasys.web3signer.core.config.client.ClientTlsOptions;
Expand Down Expand Up @@ -131,23 +133,25 @@ public List<String> createCmdLineParams() {
createAzureArgs(params);
}

signerConfig.getWalletBulkloadParameters().ifPresent(setWalletBulkloadParameters(params));
signerConfig
.getV3KeystoresBulkloadParameters()
.ifPresent(setV3KeystoresBulkloadParameters(params));
}

return params;
}

private static Consumer<KeystoresParameters> setWalletBulkloadParameters(
private static Consumer<KeystoresParameters> setV3KeystoresBulkloadParameters(
final List<String> params) {
return keystoresParameters -> {
params.add(PicoV3WalletBulkloadParameters.WALLETS_PATH);
params.add(KEYSTORES_PATH);
params.add(keystoresParameters.getKeystoresPath().toAbsolutePath().toString());
if (keystoresParameters.getKeystoresPasswordsPath() != null) {
params.add(PicoV3WalletBulkloadParameters.WALLETS_PASSWORDS_PATH);
params.add(KEYSTORES_PASSWORDS_PATH);
params.add(keystoresParameters.getKeystoresPasswordsPath().toAbsolutePath().toString());
}
if (keystoresParameters.getKeystoresPasswordFile() != null) {
params.add(PicoV3WalletBulkloadParameters.WALLETS_PASSWORD_FILE);
params.add(KEYSTORES_PASSWORD_FILE);
params.add(keystoresParameters.getKeystoresPasswordFile().toAbsolutePath().toString());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void walletFilesAreBulkloaded(
new SignerConfigurationBuilder()
.withUseConfigFile(useConfigFile)
.withMode("eth1")
.withWalletBulkloadParameters(walletBulkloadParameters);
.withV3KeystoresBulkloadParameters(walletBulkloadParameters);

startSigner(configBuilder.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*/
package tech.pegasys.web3signer.commandline.config;

import tech.pegasys.web3signer.commandline.DefaultCommandValues;
import static tech.pegasys.web3signer.commandline.DefaultCommandValues.PATH_FORMAT_HELP;

import tech.pegasys.web3signer.signing.config.KeystoresParameters;

import java.nio.file.Path;
Expand All @@ -22,27 +23,31 @@
public class PicoKeystoresParameters implements KeystoresParameters {

@Option(
names = {"--keystores-path"},
names = {KEYSTORES_PATH},
description =
"The path to a directory storing Eth2 keystores. Keystore files must use a .json file extension.",
paramLabel = DefaultCommandValues.PATH_FORMAT_HELP)
"The path to a directory storing v4 keystores. Keystore files must use a .json file extension.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPath;

@Option(
names = {"--keystores-passwords-path"},
names = {KEYSTORES_PASSWORDS_PATH},
description =
"The path to a directory with the corresponding password files for the keystores."
"The path to a directory with the corresponding password files for the v4 keystores."
+ " Filename must match the corresponding keystore filename but with a .txt extension."
+ " This cannot be set if --keystores-password-file is also specified.",
paramLabel = DefaultCommandValues.PATH_FORMAT_HELP)
+ " This cannot be set if "
+ KEYSTORES_PASSWORD_FILE
+ " is also specified.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPasswordsPath;

@Option(
names = {"--keystores-password-file"},
names = {KEYSTORES_PASSWORD_FILE},
description =
"The path to a file that contains the password that all keystores use."
+ " This cannot be set if --keystores-passwords-path is also specified.",
paramLabel = DefaultCommandValues.PATH_FORMAT_HELP)
+ " This cannot be set if "
+ KEYSTORES_PASSWORDS_PATH
+ " is also specified.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPasswordFile;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2022 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.web3signer.commandline.config;

import static tech.pegasys.web3signer.commandline.DefaultCommandValues.PATH_FORMAT_HELP;

import tech.pegasys.web3signer.signing.config.KeystoresParameters;

import java.nio.file.Path;

import picocli.CommandLine.Option;

public class PicoV3KeystoresBulkloadParameters implements KeystoresParameters {
@Option(
names = {KEYSTORES_PATH},
description =
"The path to a directory storing v3 keystore files. Keystore files must use a .json file extension.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPath;

@Option(
names = {KEYSTORES_PASSWORDS_PATH},
description =
"The path to a directory with the corresponding password files for the v3 keystore files. "
+ "Filename must match the corresponding wallet filename but with a .txt extension. This cannot be set if "
+ KEYSTORES_PASSWORD_FILE
+ " is also specified.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPasswordsPath;

@Option(
names = {KEYSTORES_PASSWORD_FILE},
description =
"The path to a file that contains the password that all keystores use. This cannot be set if "
+ KEYSTORES_PASSWORDS_PATH
+ " is also specified.",
paramLabel = PATH_FORMAT_HELP)
private Path keystoresPasswordFile;

@Override
public Path getKeystoresPath() {
return keystoresPath;
}

@Override
public Path getKeystoresPasswordsPath() {
return keystoresPasswordsPath;
}

@Override
public Path getKeystoresPasswordFile() {
return keystoresPasswordFile;
}
}

This file was deleted.

Loading

0 comments on commit b865aef

Please sign in to comment.