Consensys / web3signer

Web3Signer is an open-source signing service capable of signing on multiple platforms (Ethereum1 and 2, Filecoin) using private keys stored in an external vault, or encrypted on a disk.
https://docs.web3signer.consensys.net/
Apache License 2.0
201 stars 78 forks source link

Keymanager API should not start if there is an error loading validators #934

Closed pablomendezroyo closed 1 year ago

pablomendezroyo commented 1 year ago

The keymanager API should not start if there has been an error loading validators. I have been able to reproduce this edge case when having a clock error and the signer was not able to load validators via files, the keymanager API started and was returning 0 validators loaded.

This is critical since the web3signer could be restarted in any situation and have the validators properly loaded.

IMO the web3signer should not start (exit 1) if there is an error loading validators.

The error

2023-10-30 23:48:10.984+00:00 | main | ERROR | Runner | Error loading signers
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: durationMillis must not be negative
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:?]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:?]
    at tech.pegasys.web3signer.core.Runner.run(Runner.java:121) [web3signer-core-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.core.Eth2Runner.run(Eth2Runner.java:382) [web3signer-core-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.commandline.subcommands.ModeSubCommand.run(ModeSubCommand.java:33) [web3signer-commandline-23.9.1.jar:23.9.1]
    at picocli.CommandLine.executeUserObject(CommandLine.java:1939) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine.access$1300(CommandLine.java:145) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2352) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2314) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2316) [picocli-4.6.2.jar:4.6.2]
    at picocli.CommandLine.execute(CommandLine.java:2078) [picocli-4.6.2.jar:4.6.2]
    at tech.pegasys.web3signer.commandline.CommandlineParser.parseCommandLine(CommandlineParser.java:85) [web3signer-commandline-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.Web3SignerApp.executeWithEnvironment(Web3SignerApp.java:50) [web3signer-app-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.Web3SignerApp.main(Web3SignerApp.java:35) [web3signer-app-23.9.1.jar:23.9.1]
Caused by: java.lang.IllegalArgumentException: durationMillis must not be negative
    at org.apache.commons.lang3.Validate.inclusiveBetween(Validate.java:1042) ~[commons-lang3-3.12.0.jar:3.12.0]
    at org.apache.commons.lang3.time.DurationFormatUtils.formatDuration(DurationFormatUtils.java:130) ~[commons-lang3-3.12.0.jar:3.12.0]
    at org.apache.commons.lang3.time.DurationFormatUtils.formatDuration(DurationFormatUtils.java:113) ~[commons-lang3-3.12.0.jar:3.12.0]
    at org.apache.commons.lang3.time.DurationFormatUtils.formatDurationHMS(DurationFormatUtils.java:82) ~[commons-lang3-3.12.0.jar:3.12.0]
    at tech.pegasys.web3signer.signing.config.SignerLoader.calculateTimeTaken(SignerLoader.java:123) ~[web3signer-signing-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.signing.config.SignerLoader.load(SignerLoader.java:98) ~[web3signer-signing-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.core.Eth2Runner.loadSignersFromKeyConfigFiles(Eth2Runner.java:298) ~[web3signer-core-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.core.Eth2Runner.lambda$createArtifactSignerProvider$2(Eth2Runner.java:253) ~[web3signer-core-23.9.1.jar:23.9.1]
    at tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider.lambda$load$1(DefaultArtifactSignerProvider.java:51) ~[web3signer-signing-23.9.1.jar:23.9.1]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
    at java.lang.Thread.run(Unknown Source) ~[?:?]
2023-10-30 23:48:11.146+00:00 | main | INFO  | Runner | Web3Signer has started with TLS disabled, and ready to handle signing requests on 0.0.0.0:9000
usmansaleem commented 1 year ago

Closing issue. Fixed the reported warning. /healthcheck can be used to determine if there were error during startup.