-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Commit boost API - Get Public Keys (#1031)
* `--commit-boost-api-enabled=<true|false>`. To enable commit boost API * `--proxy-keystores-path`. Path to the directory that will read and store encrypted proxy keys in v4 (BLS) and v3 (SECP) formats. * `--proxy-keystores-password-file`. The path to file that contains password to encrypt and decrypt proxy keystores. * Implement route and handlers for `/signer/v1/get_pubkeys` * Load proxy signers from local directories * refactoring DefaultArtifactSignerProvider and unit test
- Loading branch information
1 parent
9335457
commit 68db6b7
Showing
17 changed files
with
672 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...rc/main/java/tech/pegasys/web3signer/commandline/config/PicoCommitBoostApiParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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; | ||
import picocli.CommandLine.Model.CommandSpec; | ||
import picocli.CommandLine.Option; | ||
import picocli.CommandLine.ParameterException; | ||
import picocli.CommandLine.Spec; | ||
|
||
public class PicoCommitBoostApiParameters implements KeystoresParameters { | ||
@Spec private CommandSpec commandSpec; // injected by picocli | ||
|
||
@CommandLine.Option( | ||
names = {"--commit-boost-api-enabled"}, | ||
paramLabel = "<BOOL>", | ||
description = "Enable the commit boost API (default: ${DEFAULT-VALUE}).", | ||
arity = "1") | ||
private boolean isCommitBoostApiEnabled = false; | ||
|
||
@Option( | ||
names = {"--proxy-keystores-path"}, | ||
description = | ||
"The path to a writeable directory to store v3 and v4 proxy keystores for commit boost API.", | ||
paramLabel = PATH_FORMAT_HELP) | ||
private Path keystoresPath; | ||
|
||
@Option( | ||
names = {"--proxy-keystores-password-file"}, | ||
description = | ||
"The path to the password file used to encrypt/decrypt proxy keystores for commit boost API.", | ||
paramLabel = PATH_FORMAT_HELP) | ||
private Path keystoresPasswordFile; | ||
|
||
@Override | ||
public Path getKeystoresPath() { | ||
return keystoresPath; | ||
} | ||
|
||
@Override | ||
public Path getKeystoresPasswordsPath() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Path getKeystoresPasswordFile() { | ||
return keystoresPasswordFile; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return isCommitBoostApiEnabled; | ||
} | ||
|
||
public void validateParameters() throws ParameterException { | ||
if (!isCommitBoostApiEnabled) { | ||
return; | ||
} | ||
|
||
if (keystoresPath == null) { | ||
throw new ParameterException( | ||
commandSpec.commandLine(), | ||
"Commit boost API is enabled, but --proxy-keystores-path not set"); | ||
} | ||
|
||
if (keystoresPasswordFile == null) { | ||
throw new ParameterException( | ||
commandSpec.commandLine(), | ||
"Commit boost API is enabled, but --proxy-keystores-password-file not set"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
core/src/main/java/tech/pegasys/web3signer/core/routes/eth2/CommitBoostPublicKeysRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2024 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.core.routes.eth2; | ||
|
||
import tech.pegasys.web3signer.core.Context; | ||
import tech.pegasys.web3signer.core.routes.Web3SignerRoute; | ||
import tech.pegasys.web3signer.core.service.http.handlers.commitboost.CommitBoostPublicKeysHandler; | ||
|
||
import io.vertx.core.http.HttpMethod; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.web.impl.BlockingHandlerDecorator; | ||
|
||
public class CommitBoostPublicKeysRoute implements Web3SignerRoute { | ||
private static final String PATH = "/signer/v1/get_pubkeys"; | ||
private final Context context; | ||
|
||
public CommitBoostPublicKeysRoute(final Context context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public void register() { | ||
context | ||
.getRouter() | ||
.route(HttpMethod.GET, PATH) | ||
.produces(JSON_HEADER) | ||
.handler( | ||
new BlockingHandlerDecorator( | ||
new CommitBoostPublicKeysHandler(context.getArtifactSignerProviders()), false)) | ||
.failureHandler(context.getErrorHandler()) | ||
.failureHandler( | ||
ctx -> { | ||
final int statusCode = ctx.statusCode(); | ||
if (statusCode == 500) { | ||
ctx.response() | ||
.setStatusCode(statusCode) | ||
.end( | ||
new JsonObject() | ||
.put("code", statusCode) | ||
.put("message", "Internal Server Error") | ||
.encode()); | ||
} else { | ||
ctx.next(); // go to global failure handler | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.