From 35889529165acb6a2230c86c00a8225fef158c4c Mon Sep 17 00:00:00 2001 From: Usman Saleem Date: Thu, 21 Nov 2024 13:28:36 +1000 Subject: [PATCH] reverting artifactsignerprovider changes --- .../signing/ArtifactSignerProvider.java | 7 ++++--- .../config/DefaultArtifactSignerProvider.java | 18 +++++++++--------- .../SecpArtifactSignerProviderAdapter.java | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/signing/src/main/java/tech/pegasys/web3signer/signing/ArtifactSignerProvider.java b/signing/src/main/java/tech/pegasys/web3signer/signing/ArtifactSignerProvider.java index 4f0e1882a..985100271 100644 --- a/signing/src/main/java/tech/pegasys/web3signer/signing/ArtifactSignerProvider.java +++ b/signing/src/main/java/tech/pegasys/web3signer/signing/ArtifactSignerProvider.java @@ -13,6 +13,7 @@ package tech.pegasys.web3signer.signing; import java.io.Closeable; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -43,12 +44,12 @@ public interface ArtifactSignerProvider extends Closeable { Set availableIdentifiers(); /** - * Get the proxy public keys for the given consensus public key. Used for commit boost API. + * Get the proxy identifiers for the given identifier. Used for commit boost API. * - * @param consensusPubKey the identifier of the consensus signer + * @param identifier the identifier of the signer * @return Map of Key Type (BLS, SECP256K1) and corresponding proxy identifiers */ - Map> getProxyIdentifiers(final String consensusPubKey); + Map> getProxyIdentifiers(final String identifier); /** * Add a new signer to the signer provider. diff --git a/signing/src/main/java/tech/pegasys/web3signer/signing/config/DefaultArtifactSignerProvider.java b/signing/src/main/java/tech/pegasys/web3signer/signing/config/DefaultArtifactSignerProvider.java index b77fb80d8..82b087ddf 100644 --- a/signing/src/main/java/tech/pegasys/web3signer/signing/config/DefaultArtifactSignerProvider.java +++ b/signing/src/main/java/tech/pegasys/web3signer/signing/config/DefaultArtifactSignerProvider.java @@ -24,9 +24,10 @@ import java.io.File; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -45,7 +46,7 @@ public class DefaultArtifactSignerProvider implements ArtifactSignerProvider { private static final Logger LOG = LogManager.getLogger(); private final Supplier> artifactSignerCollectionSupplier; private final Map signers = new HashMap<>(); - private final Map> proxySigners = new HashMap<>(); + private final Map> proxySigners = new HashMap<>(); private final ExecutorService executorService = Executors.newSingleThreadExecutor(); private final Optional commitBoostKeystoresParameters; @@ -116,14 +117,14 @@ public Set availableIdentifiers() { } @Override - public Map> getProxyIdentifiers(final String consensusPubKey) { - final Set artifactSigners = - proxySigners.computeIfAbsent(consensusPubKey, k -> Set.of()); + public Map> getProxyIdentifiers(final String identifier) { + final List artifactSigners = + proxySigners.computeIfAbsent(identifier, k -> List.of()); return artifactSigners.stream() .collect( Collectors.groupingBy( ArtifactSigner::getKeyType, - Collectors.mapping(ArtifactSigner::getIdentifier, Collectors.toSet()))); + Collectors.mapping(ArtifactSigner::getIdentifier, Collectors.toList()))); } @Override @@ -141,7 +142,6 @@ public Future removeSigner(final String identifier) { return executorService.submit( () -> { signers.remove(identifier); - proxySigners.remove(identifier); LOG.info("Removed signer with identifier '{}'", identifier); return null; }); @@ -168,7 +168,7 @@ private void loadSecpProxySigners( SecpV3KeystoresBulkLoader.loadV3KeystoresUsingPasswordFileOrDir( proxySecpDir, keystoreParameter.getKeystoresPasswordFile()); final Collection secpSigners = secpSignersResults.getValues(); - proxySigners.computeIfAbsent(identifier, k -> new HashSet<>()).addAll(secpSigners); + proxySigners.computeIfAbsent(identifier, k -> new ArrayList<>()).addAll(secpSigners); } } @@ -184,7 +184,7 @@ private void loadBlsProxySigners( BlsKeystoreBulkLoader.loadKeystoresUsingPasswordFile( proxyBlsDir, keystoreParameter.getKeystoresPasswordFile()); final Collection blsSigners = blsSignersResult.getValues(); - proxySigners.computeIfAbsent(identifier, k -> new HashSet<>()).addAll(blsSigners); + proxySigners.computeIfAbsent(identifier, k -> new ArrayList<>()).addAll(blsSigners); } } } diff --git a/signing/src/main/java/tech/pegasys/web3signer/signing/config/SecpArtifactSignerProviderAdapter.java b/signing/src/main/java/tech/pegasys/web3signer/signing/config/SecpArtifactSignerProviderAdapter.java index 00013a598..36578bcdf 100644 --- a/signing/src/main/java/tech/pegasys/web3signer/signing/config/SecpArtifactSignerProviderAdapter.java +++ b/signing/src/main/java/tech/pegasys/web3signer/signing/config/SecpArtifactSignerProviderAdapter.java @@ -20,6 +20,7 @@ import tech.pegasys.web3signer.signing.KeyType; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -68,7 +69,7 @@ public Set availableIdentifiers() { } @Override - public Map> getProxyIdentifiers(final String identifier) { + public Map> getProxyIdentifiers(final String identifier) { throw new NotImplementedException(); }