Replace custom required options check with standard way (#7738)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/7813/head
Fabio Di Fabio 4 weeks ago committed by GitHub
parent 8e3735fae5
commit 71906fa9d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      besu/build.gradle
  2. 14
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  3. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java
  4. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
  5. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java
  6. 3
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java
  7. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
  8. 2
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  9. 77
      gradle/verification-metadata.xml
  10. 2
      platform/build.gradle

@ -68,20 +68,21 @@ dependencies {
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'
implementation 'com.google.dagger:dagger' implementation 'com.google.dagger:dagger'
implementation 'com.graphql-java:graphql-java' implementation 'com.graphql-java:graphql-java'
implementation 'commons-net:commons-net'
implementation 'info.picocli:picocli' implementation 'info.picocli:picocli'
implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-core'
implementation 'io.vertx:vertx-web' implementation 'io.vertx:vertx-web'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.logging.log4j:log4j-core'
implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-config' implementation 'io.tmio:tuweni-config'
implementation 'io.tmio:tuweni-toml' implementation 'io.tmio:tuweni-toml'
implementation 'io.tmio:tuweni-units' implementation 'io.tmio:tuweni-units'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.logging.log4j:log4j-core'
implementation 'org.hibernate.validator:hibernate-validator'
implementation 'org.rocksdb:rocksdbjni'
implementation 'org.springframework.security:spring-security-crypto' implementation 'org.springframework.security:spring-security-crypto'
implementation 'org.xerial.snappy:snappy-java' implementation 'org.xerial.snappy:snappy-java'
implementation 'tech.pegasys:jc-kzg-4844' implementation 'tech.pegasys:jc-kzg-4844'
implementation 'org.rocksdb:rocksdbjni'
implementation 'commons-net:commons-net'
runtimeOnly 'org.apache.logging.log4j:log4j-jul' runtimeOnly 'org.apache.logging.log4j:log4j-jul'
runtimeOnly 'com.splunk.logging:splunk-library-javalogging' runtimeOnly 'com.splunk.logging:splunk-library-javalogging'

@ -1421,7 +1421,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
} }
private void validateOptions() { private void validateOptions() {
validateRequiredOptions();
issueOptionWarnings(); issueOptionWarnings();
validateP2PInterface(p2PDiscoveryOptions.p2pInterface); validateP2PInterface(p2PDiscoveryOptions.p2pInterface);
validateMiningParams(); validateMiningParams();
@ -1475,19 +1474,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
dataStorageOptions.validate(commandLine); dataStorageOptions.validate(commandLine);
} }
private void validateRequiredOptions() {
commandLine
.getCommandSpec()
.options()
.forEach(
option -> {
if (option.required() && option.stringValues().isEmpty()) {
throw new ParameterException(
this.commandLine, "Missing required option: " + option.longestName());
}
});
}
private void validateMiningParams() { private void validateMiningParams() {
miningOptions.validate( miningOptions.validate(
commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger); commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger);

@ -23,6 +23,7 @@ import org.hyperledger.besu.cli.util.VersionProvider;
import java.io.PrintWriter; import java.io.PrintWriter;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.security.crypto.bcrypt.BCrypt; import org.springframework.security.crypto.bcrypt.BCrypt;
import picocli.CommandLine.Command; import picocli.CommandLine.Command;
import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Model.CommandSpec;
@ -75,6 +76,7 @@ public class PasswordSubCommand implements Runnable {
static class HashSubCommand implements Runnable { static class HashSubCommand implements Runnable {
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@NotEmpty
@Option( @Option(
names = "--password", names = "--password",
arity = "1..1", arity = "1..1",

@ -54,6 +54,7 @@ import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import io.vertx.core.Vertx; import io.vertx.core.Vertx;
import jakarta.validation.constraints.NotBlank;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -335,6 +336,7 @@ public class BlocksSubCommand implements Runnable {
arity = "1..1") arity = "1..1")
private final BlockExportFormat format = BlockExportFormat.RLP; private final BlockExportFormat format = BlockExportFormat.RLP;
@NotBlank
@Option( @Option(
names = "--to", names = "--to",
required = true, required = true,

@ -33,6 +33,7 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.LockSupport;
import jakarta.validation.constraints.NotBlank;
import picocli.CommandLine.Command; import picocli.CommandLine.Command;
import picocli.CommandLine.Option; import picocli.CommandLine.Option;
import picocli.CommandLine.ParentCommand; import picocli.CommandLine.ParentCommand;
@ -55,6 +56,7 @@ public class BackupState implements Runnable {
arity = "1..1") arity = "1..1")
private final Long block = Long.MAX_VALUE; private final Long block = Long.MAX_VALUE;
@NotBlank
@Option( @Option(
names = "--backup-path", names = "--backup-path",
required = true, required = true,

@ -52,6 +52,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import jakarta.validation.constraints.NotBlank;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -70,6 +71,7 @@ class GenerateBlockchainConfig implements Runnable {
private final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM = private final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance); Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
@NotBlank
@Option( @Option(
required = true, required = true,
names = "--config-file", names = "--config-file",
@ -78,6 +80,7 @@ class GenerateBlockchainConfig implements Runnable {
arity = "1..1") arity = "1..1")
private final File configurationFile = null; private final File configurationFile = null;
@NotBlank
@Option( @Option(
required = true, required = true,
names = "--to", names = "--to",

@ -46,6 +46,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import jakarta.validation.constraints.NotBlank;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -64,6 +65,7 @@ public class RestoreState implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(RestoreState.class); private static final Logger LOG = LoggerFactory.getLogger(RestoreState.class);
@NotBlank
@Option( @Option(
names = "--backup-path", names = "--backup-path",
required = true, required = true,

@ -113,6 +113,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry;
import io.vertx.core.Vertx; import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions; import io.vertx.core.VertxOptions;
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.net.util.SubnetUtils.SubnetInfo; import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
@ -621,6 +622,7 @@ public abstract class CommandTestAbstract {
@CommandLine.Command @CommandLine.Command
public static class TestBesuCommandWithRequiredOption extends TestBesuCommand { public static class TestBesuCommandWithRequiredOption extends TestBesuCommand {
@NotEmpty
@CommandLine.Option( @CommandLine.Option(
names = {"--accept-terms-and-conditions"}, names = {"--accept-terms-and-conditions"},
description = "You must explicitly accept terms and conditions", description = "You must explicitly accept terms and conditions",

@ -123,6 +123,19 @@
<sha256 value="f1c10522cbc763fd351c790b57c251edcc1efd052da78d150ba07b55337f7b2d" origin="Generated by Gradle"/> <sha256 value="f1c10522cbc763fd351c790b57c251edcc1efd052da78d150ba07b55337f7b2d" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="com.fasterxml" name="classmate" version="1.5.1">
<artifact name="classmate-1.5.1.jar">
<sha256 value="aab4de3006808c09d25dd4ff4a3611cfb63c95463cfd99e73d2e1680d229a33b" origin="Generated by Gradle"/>
</artifact>
<artifact name="classmate-1.5.1.pom">
<sha256 value="24de66a0029fddc259594c7bc7c5ae046a222c35bf367c739a07297599b51fae" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml" name="oss-parent" version="35">
<artifact name="oss-parent-35.pom">
<sha256 value="afc05ed21064eacac8de3002530cb192208bd114eb248417dad1886cbf54056e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.fasterxml" name="oss-parent" version="43"> <component group="com.fasterxml" name="oss-parent" version="43">
<artifact name="oss-parent-43.pom"> <artifact name="oss-parent-43.pom">
<sha256 value="e5585cc1c37079b2e3817a8997945736f158831844d59d0e4d3a45b27611f926" origin="Generated by Gradle"/> <sha256 value="e5585cc1c37079b2e3817a8997945736f158831844d59d0e4d3a45b27611f926" origin="Generated by Gradle"/>
@ -3008,6 +3021,14 @@
<sha256 value="a7702c487026802784b5797b62330a8b8d6592bf0f4737b25c67a5eac82659c0" origin="Generated by Gradle"/> <sha256 value="a7702c487026802784b5797b62330a8b8d6592bf0f4737b25c67a5eac82659c0" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="jakarta.validation" name="jakarta.validation-api" version="3.0.2">
<artifact name="jakarta.validation-api-3.0.2.jar">
<sha256 value="291c25e6910cc6a7ebd96d4c6baebf6d7c37676c5482c2d96146e901b62c1fc9" origin="Generated by Gradle"/>
</artifact>
<artifact name="jakarta.validation-api-3.0.2.pom">
<sha256 value="0a7b9c6327968afe0d82f7cf4facbda7e157968c5808d69bcb8019863b298dc4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="jakarta.ws.rs" name="all" version="4.0.0"> <component group="jakarta.ws.rs" name="all" version="4.0.0">
<artifact name="all-4.0.0.pom"> <artifact name="all-4.0.0.pom">
<sha256 value="ec1f50dde92f0b7bddd82a5b65dc23df11e15a272be1f3ace39587896fce7e9b" origin="Generated by Gradle"/> <sha256 value="ec1f50dde92f0b7bddd82a5b65dc23df11e15a272be1f3ace39587896fce7e9b" origin="Generated by Gradle"/>
@ -3694,6 +3715,11 @@
<sha256 value="762a79bfbde73cff4f99ce86cb66abdf0e12f5cf8aff979e7d37b65d55736fc4" origin="Generated by Gradle"/> <sha256 value="762a79bfbde73cff4f99ce86cb66abdf0e12f5cf8aff979e7d37b65d55736fc4" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="org.apache.maven" name="maven" version="3.6.3">
<artifact name="maven-3.6.3.pom">
<sha256 value="d2d86245ea66149bc14d2dd72bbb961f964dd658b809a0573252c06531eeec16" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.maven" name="maven" version="3.9.9"> <component group="org.apache.maven" name="maven" version="3.9.9">
<artifact name="maven-3.9.9.pom"> <artifact name="maven-3.9.9.pom">
<sha256 value="d24ed68923df210d085bb5d386d4336d12ede5473392e159d5e6e64497af6f39" origin="Generated by Gradle"/> <sha256 value="d24ed68923df210d085bb5d386d4336d12ede5473392e159d5e6e64497af6f39" origin="Generated by Gradle"/>
@ -3707,6 +3733,11 @@
<sha256 value="65ddf76b92a707b9f1240eccbb4774b30d4c77778671291fd355e06d4d3a96df" origin="Generated by Gradle"/> <sha256 value="65ddf76b92a707b9f1240eccbb4774b30d4c77778671291fd355e06d4d3a96df" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="org.apache.maven" name="maven-parent" version="33">
<artifact name="maven-parent-33.pom">
<sha256 value="3856e3fcd169502d5f12fe2452604ebf6c7c025f15656bfa558ea99ed29d73ea" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.maven" name="maven-parent" version="43"> <component group="org.apache.maven" name="maven-parent" version="43">
<artifact name="maven-parent-43.pom"> <artifact name="maven-parent-43.pom">
<sha256 value="468a1262e9aaa5febf9d604e2836267f815351f2b4520f28fb17f53c71e33554" origin="Generated by Gradle"/> <sha256 value="468a1262e9aaa5febf9d604e2836267f815351f2b4520f28fb17f53c71e33554" origin="Generated by Gradle"/>
@ -5015,6 +5046,19 @@
<sha256 value="6d535f94efb663bdb682c9f27a50335394688009642ba7a9677504bc1be4129b" origin="Generated by Gradle"/> <sha256 value="6d535f94efb663bdb682c9f27a50335394688009642ba7a9677504bc1be4129b" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="org.hibernate.validator" name="hibernate-validator" version="8.0.1.Final">
<artifact name="hibernate-validator-8.0.1.Final.jar">
<sha256 value="8c1244a498231091fe723d9666a93444ee9f93607245c6b29829dc5fe57a335c" origin="Generated by Gradle"/>
</artifact>
<artifact name="hibernate-validator-8.0.1.Final.pom">
<sha256 value="f747ead364203a836e2a21eb55b7436716576fbd70faf92c4e0128c23dbc426f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.hibernate.validator" name="hibernate-validator-parent" version="8.0.1.Final">
<artifact name="hibernate-validator-parent-8.0.1.Final.pom">
<sha256 value="34b596f4f3d2ff52b504123db26faad19a61175a6c0b1012d75a7ff29567e727" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.hyperledger.besu" name="arithmetic" version="0.9.7"> <component group="org.hyperledger.besu" name="arithmetic" version="0.9.7">
<artifact name="arithmetic-0.9.7.jar"> <artifact name="arithmetic-0.9.7.jar">
<sha256 value="54b1f4edbbc06bd974c5b3aad5acc21c85213997c8b91b051fe240f90d674f93" origin="Generated by Gradle"/> <sha256 value="54b1f4edbbc06bd974c5b3aad5acc21c85213997c8b91b051fe240f90d674f93" origin="Generated by Gradle"/>
@ -5194,6 +5238,39 @@
<sha256 value="000dd616298aebd21a9d5731874df083d7298424b91e037b73cbdd07ebc83e0e" origin="Generated by Gradle"/> <sha256 value="000dd616298aebd21a9d5731874df083d7298424b91e037b73cbdd07ebc83e0e" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </component>
<component group="org.jboss" name="jboss-parent" version="39">
<artifact name="jboss-parent-39.pom">
<sha256 value="04dff075a00094b63061af407d2816d9cde66795acae376a054bdfe8ba31e664" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jboss.arquillian" name="arquillian-bom" version="1.7.0.Alpha10">
<artifact name="arquillian-bom-1.7.0.Alpha10.pom">
<sha256 value="0bf2ce391957e3ae82305a4ccdcdec047cc3127af94eae8073073bd819ec1e1d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jboss.logging" name="jboss-logging" version="3.4.3.Final">
<artifact name="jboss-logging-3.4.3.Final.jar">
<sha256 value="0b324cca4d550060e51e70cc0045a6cce62f264278ec1f5082aafeb670fcac49" origin="Generated by Gradle"/>
</artifact>
<artifact name="jboss-logging-3.4.3.Final.pom">
<sha256 value="f7639433422e8bf1f397db7575f2ab954cc20f7d1581b33f6d978db30943afec" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jboss.shrinkwrap" name="shrinkwrap-bom" version="1.2.6">
<artifact name="shrinkwrap-bom-1.2.6.pom">
<sha256 value="1c0ac801aa3125bde5e8816ba878a3243259c396d2f38e676e2852a9cc550036" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jboss.shrinkwrap.descriptors" name="shrinkwrap-descriptors-bom" version="2.0.0">
<artifact name="shrinkwrap-descriptors-bom-2.0.0.pom">
<sha256 value="878eb071ad1f4b0c81568536b2a3a4f7de85a814afc5b196d9a99b5e3c0a6583" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jboss.shrinkwrap.resolver" name="shrinkwrap-resolver-bom" version="3.1.4">
<artifact name="shrinkwrap-resolver-bom-3.1.4.pom">
<sha256 value="53d45df757388b693a37493b74e0d7a938c5734c15f82629d40a29dea9ceb74f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains" name="annotations" version="13.0"> <component group="org.jetbrains" name="annotations" version="13.0">
<artifact name="annotations-13.0.jar"> <artifact name="annotations-13.0.jar">
<sha256 value="ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478" origin="Generated by Gradle"/> <sha256 value="ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478" origin="Generated by Gradle"/>

@ -127,6 +127,8 @@ dependencies {
api 'org.fusesource.jansi:jansi:2.4.1' api 'org.fusesource.jansi:jansi:2.4.1'
api 'org.hibernate.validator:hibernate-validator:8.0.1.Final'
api 'org.hyperledger.besu:arithmetic:0.9.7' api 'org.hyperledger.besu:arithmetic:0.9.7'
api 'org.hyperledger.besu:blake2bf:0.9.7' api 'org.hyperledger.besu:blake2bf:0.9.7'
api 'org.hyperledger.besu:bls12-381:0.9.7' api 'org.hyperledger.besu:bls12-381:0.9.7'

Loading…
Cancel
Save