From 9eb32836b710bd997887c5c1f77436710be9eff1 Mon Sep 17 00:00:00 2001 From: Usman Saleem Date: Wed, 18 Jan 2023 22:51:00 +1000 Subject: [PATCH] Fix javadocs to allow build to pass in JDK 17 (#4834) - Added missing javadocs so that javadoc doclint passes against JDK 17 (invoke by Besu gradle build). - Exclude following packages from javadoc lint: org.hyperledger.besu.privacy.contracts.generated org.hyperledger.besu.tests.acceptance.* - Temporarily exclude ethereum and evm submodule for doc lint checks. - Run the javadoc task using GitHub actions (use Java 17) to report any javadoc errors during the PR builds - Updating plugin-api build.gradle with new hash as javadoc comments caused it to change Signed-off-by: Usman Saleem --- .circleci/config.yml | 4 - .github/workflows/checks.yml | 16 +- .../main/java/org/hyperledger/besu/Besu.java | 6 + .../java/org/hyperledger/besu/BesuInfo.java | 15 + .../java/org/hyperledger/besu/Runner.java | 60 ++++ .../org/hyperledger/besu/RunnerBuilder.java | 270 +++++++++++++++ .../besu/chainexport/BlockExporter.java | 12 + .../besu/chainexport/RlpBlockExporter.java | 6 + .../besu/chainimport/JsonBlockImporter.java | 11 + .../besu/chainimport/RlpBlockImporter.java | 20 ++ .../besu/chainimport/internal/BlockData.java | 44 +++ .../besu/chainimport/internal/ChainData.java | 11 + .../chainimport/internal/TransactionData.java | 24 ++ .../org/hyperledger/besu/cli/BesuCommand.java | 132 +++++++- .../cli/ConfigurationOverviewBuilder.java | 53 +++ .../besu/cli/DefaultCommandValues.java | 39 +++ .../besu/cli/NetworkDeprecationMessage.java | 7 + .../besu/cli/config/EthNetworkConfig.java | 76 +++++ .../besu/cli/config/NetworkName.java | 42 +++ .../besu/cli/converter/FractionConverter.java | 1 + .../converter/MetricCategoryConverter.java | 17 + .../cli/converter/PercentageConverter.java | 1 + .../FractionConversionException.java | 6 + .../PercentageConversionException.java | 6 + .../exception/RpcApisConversionException.java | 6 + .../custom/CorsAllowedOriginsProperty.java | 2 + .../custom/EnodeToURIPropertyConverter.java | 7 + .../custom/JsonRPCAllowlistHostsProperty.java | 2 + .../besu/cli/custom/RpcAuthFileValidator.java | 9 + .../error/BesuExecutionExceptionHandler.java | 1 + .../error/BesuParameterExceptionHandler.java | 6 + .../BesuLoggingConfigurationFactory.java | 1 + .../logging/XmlExtensionConfiguration.java | 7 + .../besu/cli/options/OptionParser.java | 43 +++ .../options/stable/DataStorageOptions.java | 11 + .../cli/options/stable/EthstatsOptions.java | 16 + .../options/stable/LoggingLevelOption.java | 18 + .../stable/NodePrivateKeyFileOption.java | 11 + .../options/stable/P2PTLSConfigOptions.java | 13 + .../options/unstable/ChainPruningOptions.java | 18 + .../besu/cli/options/unstable/DnsOptions.java | 22 ++ .../options/unstable/EthProtocolOptions.java | 12 + .../besu/cli/options/unstable/EvmOptions.java | 7 + .../besu/cli/options/unstable/IpcOptions.java | 27 ++ .../cli/options/unstable/LauncherOptions.java | 16 + .../options/unstable/MetricsCLIOptions.java | 12 + .../cli/options/unstable/MiningOptions.java | 36 ++ .../besu/cli/options/unstable/NatOptions.java | 16 + .../unstable/NativeLibraryOptions.java | 26 ++ .../options/unstable/NetworkingOptions.java | 13 + .../unstable/PkiBlockCreationOptions.java | 22 ++ .../unstable/PrivacyPluginOptions.java | 11 + .../besu/cli/options/unstable/RPCOptions.java | 16 + .../options/unstable/SynchronizerOptions.java | 17 + .../unstable/TransactionPoolOptions.java | 12 + .../presynctasks/PreSynchronizationTask.java | 7 +- .../PreSynchronizationTaskRunner.java | 11 + .../PrivateDatabaseMigrationPreSyncTask.java | 7 + .../cli/subcommands/PasswordSubCommand.java | 10 +- .../cli/subcommands/PublicKeySubCommand.java | 20 ++ .../cli/subcommands/RetestethSubCommand.java | 2 + .../subcommands/ValidateConfigSubCommand.java | 12 +- .../subcommands/blocks/BlockExportFormat.java | 2 + .../subcommands/blocks/BlockImportFormat.java | 3 + .../subcommands/blocks/BlocksSubCommand.java | 9 + .../cli/subcommands/operator/BackupState.java | 1 + .../operator/GenerateLogBloomCache.java | 1 + .../operator/OperatorSubCommand.java | 8 + .../subcommands/operator/RestoreState.java | 1 + .../cli/subcommands/rlp/RLPSubCommand.java | 8 + .../besu/cli/subcommands/rlp/RLPType.java | 7 + .../cli/util/BesuCommandCustomFactory.java | 5 + .../cli/util/CascadingDefaultProvider.java | 9 + .../besu/cli/util/CommandLineUtils.java | 13 + .../util/ConfigOptionSearchAndRunHandler.java | 15 + .../EnvironmentVariableDefaultProvider.java | 6 + .../util/TomlConfigFileDefaultProvider.java | 8 + .../besu/cli/util/VersionProvider.java | 6 + .../besu/controller/BesuController.java | 117 +++++++ .../controller/BesuControllerBuilder.java | 284 ++++++++++++++++ .../controller/BftBesuControllerBuilder.java | 11 + .../BftQueryPluginServiceFactory.java | 10 + .../CliqueBesuControllerBuilder.java | 1 + .../CliqueQueryPluginServiceFactory.java | 7 + ...onsensusScheduleBesuControllerBuilder.java | 24 +- .../controller/IbftBesuControllerBuilder.java | 1 + .../IbftLegacyBesuControllerBuilder.java | 2 + .../IbftQueryPluginServiceFactory.java | 9 + .../MainnetBesuControllerBuilder.java | 1 + .../MergeBesuControllerBuilder.java | 18 + .../controller/MiningParameterOverrides.java | 6 + .../controller/NoopPluginServiceFactory.java | 1 + .../besu/controller/PluginServiceFactory.java | 6 + .../controller/QbftBesuControllerBuilder.java | 1 + .../TransitionBesuControllerBuilder.java | 7 + .../besu/services/BesuConfigurationImpl.java | 7 + .../besu/services/BesuEventsImpl.java | 9 + .../besu/services/BesuPluginContextImpl.java | 35 ++ .../services/PermissioningServiceImpl.java | 11 + .../besu/services/PicoCLIOptionsImpl.java | 6 + .../services/PrivacyPluginServiceImpl.java | 1 + .../besu/services/RpcEndpointServiceImpl.java | 13 + .../services/SecurityModuleServiceImpl.java | 1 + .../besu/services/StorageServiceImpl.java | 2 + .../PermissioningConfigurationValidator.java | 8 + .../util/PrivateStorageMigrationBuilder.java | 12 + build.gradle | 14 +- .../besu/config/BftConfigOptions.java | 56 ++++ .../org/hyperledger/besu/config/BftFork.java | 43 +++ .../besu/config/CheckpointConfigOptions.java | 32 ++ .../besu/config/CliqueConfigOptions.java | 22 ++ .../besu/config/DiscoveryOptions.java | 18 + .../besu/config/EthashConfigOptions.java | 17 + .../besu/config/GenesisAllocation.java | 42 +++ .../besu/config/GenesisConfigFile.java | 118 +++++++ .../besu/config/GenesisConfigOptions.java | 238 +++++++++++++- .../besu/config/GoQuorumOptions.java | 10 + .../besu/config/IbftLegacyConfigOptions.java | 32 ++ .../besu/config/JsonBftConfigOptions.java | 8 + .../besu/config/JsonGenesisConfigOptions.java | 21 ++ .../besu/config/JsonQbftConfigOptions.java | 9 + .../org/hyperledger/besu/config/JsonUtil.java | 140 ++++++++ .../besu/config/Keccak256ConfigOptions.java | 17 + .../besu/config/MergeConfigOptions.java | 11 + .../hyperledger/besu/config/PowAlgorithm.java | 9 + .../besu/config/QbftConfigOptions.java | 16 + .../org/hyperledger/besu/config/QbftFork.java | 21 ++ .../besu/config/StubGenesisConfigOptions.java | 247 ++++++++++++++ .../besu/config/TransitionsConfigOptions.java | 17 + .../BlockHeaderValidationRulesetFactory.java | 10 + .../consensus/clique/CliqueBlockHashing.java | 1 + .../clique/CliqueBlockHeaderFunctions.java | 1 + .../clique/CliqueBlockInterface.java | 17 + .../besu/consensus/clique/CliqueContext.java | 17 + .../clique/CliqueDifficultyCalculator.java | 6 + .../consensus/clique/CliqueExtraData.java | 66 ++++ .../besu/consensus/clique/CliqueHelpers.java | 36 ++ .../consensus/clique/CliqueMiningTracker.java | 31 ++ .../clique/CliqueProtocolSchedule.java | 19 ++ .../blockcreation/CliqueBlockCreator.java | 16 + .../blockcreation/CliqueBlockMiner.java | 12 + .../blockcreation/CliqueBlockScheduler.java | 9 + .../blockcreation/CliqueMinerExecutor.java | 18 + .../CliqueMiningCoordinator.java | 14 + .../blockcreation/CliqueProposerSelector.java | 5 + .../CliqueDifficultyValidationRule.java | 1 + .../CliqueExtraDataValidationRule.java | 6 + .../CoinbaseHeaderValidationRule.java | 6 + .../SignerRateLimitValidationRule.java | 1 + .../VoteValidationRule.java | 1 + .../clique/jsonrpc/CliqueJsonRpcMethods.java | 6 + .../methods/CliqueGetSignerMetrics.java | 8 + .../jsonrpc/methods/CliqueGetSigners.java | 7 + .../methods/CliqueGetSignersAtHash.java | 7 + .../jsonrpc/methods/CliqueProposals.java | 6 + .../clique/jsonrpc/methods/Discard.java | 6 + .../clique/jsonrpc/methods/Propose.java | 6 + .../common/BftValidatorOverrides.java | 12 + .../besu/consensus/common/BlockInterface.java | 25 ++ .../CombinedProtocolScheduleFactory.java | 8 + .../consensus/common/ConsensusHelpers.java | 8 + .../besu/consensus/common/EpochManager.java | 18 + .../besu/consensus/common/ForkSpec.java | 22 ++ .../besu/consensus/common/ForksSchedule.java | 21 ++ .../consensus/common/MigratingContext.java | 11 + .../common/MigratingMiningCoordinator.java | 12 + .../common/MigratingProtocolContext.java | 17 + .../besu/consensus/common/PoaContext.java | 6 + .../consensus/common/PoaQueryServiceImpl.java | 13 + .../common/bft/BaseBftProtocolSchedule.java | 18 + .../consensus/common/bft/BftBlockHashing.java | 20 ++ .../common/bft/BftBlockHeaderFunctions.java | 19 ++ .../common/bft/BftBlockInterface.java | 26 ++ .../besu/consensus/common/bft/BftContext.java | 17 + .../consensus/common/bft/BftEventQueue.java | 15 + .../consensus/common/bft/BftExecutors.java | 34 ++ .../consensus/common/bft/BftExtraData.java | 35 ++ .../common/bft/BftExtraDataCodec.java | 43 +++ .../common/bft/BftForksScheduleFactory.java | 24 ++ .../besu/consensus/common/bft/BftHelpers.java | 23 ++ .../consensus/common/bft/BftProcessor.java | 5 + .../common/bft/ConsensusRoundIdentifier.java | 10 + .../common/bft/EthSynchronizerUpdater.java | 6 + .../common/bft/EventMultiplexer.java | 11 + .../besu/consensus/common/bft/Gossiper.java | 6 + .../consensus/common/bft/MessageTracker.java | 17 + .../common/bft/MutableBftConfigOptions.java | 57 +++- .../consensus/common/bft/SizeLimitedMap.java | 14 + .../common/bft/SynchronizerUpdater.java | 7 + .../common/bft/UniqueMessageMulticaster.java | 7 + .../besu/consensus/common/bft/Vote.java | 35 ++ .../bft/blockcreation/BftBlockCreator.java | 16 + .../blockcreation/BftBlockCreatorFactory.java | 63 ++++ .../blockcreation/BftMiningCoordinator.java | 16 + .../bft/blockcreation/ProposerSelector.java | 10 +- .../consensus/common/bft/events/BftEvent.java | 5 + .../common/bft/events/BftEvents.java | 11 + .../bft/events/BftReceivedMessageEvent.java | 11 + .../common/bft/events/BlockTimerExpiry.java | 5 + .../common/bft/events/NewChainHead.java | 5 + .../common/bft/events/RoundExpiry.java | 5 + .../BftVanityDataValidationRule.java | 1 + .../messagedata/AbstractBftMessageData.java | 16 + .../bft/messagewrappers/BftMessage.java | 38 +++ .../bft/network/PeerConnectionTracker.java | 11 + .../bft/network/ValidatorMulticaster.java | 12 + .../common/bft/network/ValidatorPeers.java | 6 + .../common/bft/payload/Authored.java | 6 + .../consensus/common/bft/payload/Payload.java | 27 ++ .../common/bft/payload/RoundSpecific.java | 6 + .../common/bft/payload/SignedData.java | 28 ++ .../bft/protocol/BftProtocolManager.java | 1 + .../bft/queries/BftQueryServiceImpl.java | 10 + .../bft/statemachine/BaseBftController.java | 34 ++ .../statemachine/BaseBlockHeightManager.java | 21 ++ .../bft/statemachine/BftEventHandler.java | 22 ++ .../bft/statemachine/BftFinalState.java | 75 +++++ .../BlockHeightManagerFactory.java | 11 + .../bft/statemachine/FutureMessageBuffer.java | 24 ++ .../bft/validation/ValidationHelpers.java | 16 + .../AbstractGetSignerMetricsMethod.java | 14 + .../jsonrpc/AbstractVoteProposerMethod.java | 12 + .../common/validator/ValidatorProvider.java | 29 ++ .../common/validator/ValidatorVote.java | 28 ++ .../common/validator/VoteProvider.java | 28 ++ .../consensus/common/validator/VoteType.java | 2 + .../blockbased/BlockValidatorProvider.java | 18 + .../blockbased/BlockVoteProvider.java | 7 + ...ftBlockHeaderValidationRulesetFactory.java | 1 + .../consensus/ibft/IbftExtraDataCodec.java | 12 + .../ibft/IbftForksSchedulesFactory.java | 7 + .../consensus/ibft/IbftLegacyContext.java | 17 + .../consensus/ibft/IbftProtocolSchedule.java | 20 ++ .../ibft/jsonrpc/IbftJsonRpcMethods.java | 6 + .../methods/IbftDiscardValidatorVote.java | 6 + .../jsonrpc/methods/IbftGetPendingVotes.java | 6 + .../jsonrpc/methods/IbftGetSignerMetrics.java | 8 + .../methods/IbftGetValidatorsByBlockHash.java | 7 + .../IbftGetValidatorsByBlockNumber.java | 7 + .../methods/IbftProposeValidatorVote.java | 6 + .../ibft/messagedata/CommitMessageData.java | 18 + .../consensus/ibft/messagedata/IbftV2.java | 5 + .../ibft/messagedata/PrepareMessageData.java | 18 + .../ibft/messagedata/ProposalMessageData.java | 18 + .../messagedata/RoundChangeMessageData.java | 18 + .../ibft/messagewrappers/Commit.java | 22 ++ .../ibft/messagewrappers/Prepare.java | 17 + .../ibft/messagewrappers/Proposal.java | 29 ++ .../ibft/messagewrappers/RoundChange.java | 28 ++ .../ibft/network/IbftMessageTransmitter.java | 33 ++ .../consensus/ibft/payload/CommitPayload.java | 24 ++ .../consensus/ibft/payload/IbftPayload.java | 1 + .../ibft/payload/MessageFactory.java | 36 ++ .../ibft/payload/PayloadDeserializers.java | 39 +++ .../ibft/payload/PreparePayload.java | 18 + .../ibft/payload/PreparedCertificate.java | 28 ++ .../ibft/payload/ProposalPayload.java | 18 + .../ibft/payload/RoundChangeCertificate.java | 34 ++ .../ibft/payload/RoundChangePayload.java | 18 + .../ibft/protocol/IbftSubProtocol.java | 8 + .../ibft/queries/IbftQueryServiceImpl.java | 8 + .../BaseIbftBlockHeightManager.java | 21 ++ .../statemachine/IbftBlockHeightManager.java | 15 + .../IbftBlockHeightManagerFactory.java | 15 + .../ibft/statemachine/IbftController.java | 12 + .../ibft/statemachine/IbftRound.java | 51 +++ .../ibft/statemachine/IbftRoundFactory.java | 26 ++ .../statemachine/NoOpBlockHeightManager.java | 6 + .../statemachine/PreparedRoundArtifacts.java | 17 + .../statemachine/RoundChangeArtifacts.java | 23 ++ .../ibft/statemachine/RoundChangeManager.java | 31 +- .../ibft/statemachine/RoundState.java | 54 +++ .../FutureRoundProposalMessageValidator.java | 14 + .../ibft/validation/MessageValidator.java | 28 ++ .../validation/MessageValidatorFactory.java | 30 ++ .../ProposalBlockConsistencyValidator.java | 9 + .../RoundChangeCertificateValidator.java | 30 ++ .../RoundChangeMessageValidator.java | 14 + .../RoundChangePayloadValidator.java | 22 ++ .../ibft/validation/SignedDataValidator.java | 26 ++ .../ibftlegacy/IbftBlockHashing.java | 1 + ...ftBlockHeaderValidationRulesetFactory.java | 1 + .../consensus/ibftlegacy/IbftExtraData.java | 47 +++ .../consensus/ibftlegacy/IbftHelpers.java | 8 + .../ibftlegacy/IbftLegacyBlockInterface.java | 17 + .../ibftlegacy/IbftProtocolSchedule.java | 17 + .../LegacyIbftBlockHeaderFunctions.java | 1 + .../blockcreation/IbftBlockCreator.java | 14 + .../IbftExtraDataValidationRule.java | 6 + .../VoteValidationRule.java | 1 + .../protocol/Istanbul99Protocol.java | 9 + .../protocol/Istanbul99ProtocolManager.java | 15 + .../consensus/merge/MergeBlockProcessor.java | 12 + .../besu/consensus/merge/MergeContext.java | 119 +++++++ .../merge/MergeProtocolSchedule.java | 24 ++ .../merge/MergeValidationRulesetFactory.java | 1 + .../consensus/merge/PostMergeContext.java | 27 ++ .../merge/TransitionBackwardSyncContext.java | 11 + .../merge/TransitionBestPeerComparator.java | 9 + .../consensus/merge/TransitionContext.java | 9 + .../merge/TransitionProtocolSchedule.java | 67 ++++ .../besu/consensus/merge/TransitionUtils.java | 43 +++ .../merge/UnverifiedForkchoiceSupplier.java | 1 + .../blockcreation/MergeBlockCreator.java | 24 ++ .../merge/blockcreation/MergeCoordinator.java | 60 ++++ .../blockcreation/MergeMiningCoordinator.java | 159 +++++++++ .../blockcreation/PayloadIdentifier.java | 25 ++ .../blockcreation/TransitionCoordinator.java | 12 + .../ConstantOmmersHashRule.java | 1 + .../IncrementalTimestampRule.java | 1 + .../MergeConsensusRule.java | 8 + .../NoDifficultyRule.java | 1 + .../headervalidationrules/NoNonceRule.java | 1 + .../qbft/MutableQbftConfigOptions.java | 10 + ...ftBlockHeaderValidationRulesetFactory.java | 1 + .../besu/consensus/qbft/QbftContext.java | 14 + .../consensus/qbft/QbftExtraDataCodec.java | 24 ++ .../qbft/QbftForksSchedulesFactory.java | 7 + .../consensus/qbft/QbftProtocolSchedule.java | 29 ++ .../blockcreation/PkiQbftBlockCreator.java | 15 + .../QbftBlockCreatorFactory.java | 11 + .../QbftValidatorsValidationRule.java | 5 + .../qbft/jsonrpc/QbftJsonRpcMethods.java | 7 + .../methods/QbftDiscardValidatorVote.java | 6 + .../jsonrpc/methods/QbftGetPendingVotes.java | 6 + .../jsonrpc/methods/QbftGetSignerMetrics.java | 8 + .../methods/QbftGetValidatorsByBlockHash.java | 7 + .../QbftGetValidatorsByBlockNumber.java | 7 + .../methods/QbftProposeValidatorVote.java | 6 + .../qbft/messagedata/CommitMessageData.java | 18 + .../qbft/messagedata/PrepareMessageData.java | 18 + .../qbft/messagedata/ProposalMessageData.java | 19 ++ .../consensus/qbft/messagedata/QbftV1.java | 5 + .../messagedata/RoundChangeMessageData.java | 19 ++ .../qbft/messagewrappers/Commit.java | 22 ++ .../qbft/messagewrappers/Prepare.java | 17 + .../qbft/messagewrappers/Proposal.java | 30 ++ .../qbft/messagewrappers/RoundChange.java | 35 ++ .../qbft/network/QbftMessageTransmitter.java | 34 ++ .../consensus/qbft/payload/CommitPayload.java | 24 ++ .../qbft/payload/MessageFactory.java | 37 +++ .../qbft/payload/PreparePayload.java | 18 + .../qbft/payload/PreparedRoundMetadata.java | 17 + .../qbft/payload/ProposalPayload.java | 19 ++ .../consensus/qbft/payload/QbftPayload.java | 12 + .../qbft/payload/RoundChangePayload.java | 18 + .../pki/DefaultKeyStoreWrapperProvider.java | 27 ++ .../pki/PkiBlockCreationConfiguration.java | 23 ++ ...PkiBlockCreationConfigurationProvider.java | 13 + .../qbft/pki/PkiQbftBlockHashing.java | 12 + .../qbft/pki/PkiQbftBlockHeaderFunctions.java | 7 + .../consensus/qbft/pki/PkiQbftExtraData.java | 22 ++ .../qbft/pki/PkiQbftExtraDataCodec.java | 15 +- .../qbft/protocol/Istanbul100SubProtocol.java | 8 + .../BaseQbftBlockHeightManager.java | 21 ++ .../CreateBlockForProposalBehaviour.java | 7 + .../statemachine/NoOpBlockHeightManager.java | 6 + .../statemachine/PreparedCertificate.java | 23 ++ .../statemachine/QbftBlockHeightManager.java | 15 + .../QbftBlockHeightManagerFactory.java | 16 + .../qbft/statemachine/QbftController.java | 13 + .../qbft/statemachine/QbftRound.java | 63 ++++ .../qbft/statemachine/QbftRoundFactory.java | 26 ++ .../statemachine/RoundChangeArtifacts.java | 23 ++ .../qbft/statemachine/RoundChangeManager.java | 29 ++ .../qbft/statemachine/RoundState.java | 54 +++ .../qbft/validation/CommitValidator.java | 21 ++ .../FutureRoundProposalMessageValidator.java | 14 + .../qbft/validation/MessageValidator.java | 54 +++ .../validation/MessageValidatorFactory.java | 30 ++ .../qbft/validation/PrepareValidator.java | 20 ++ .../validation/ProposalPayloadValidator.java | 26 ++ .../qbft/validation/ProposalValidator.java | 26 ++ .../RoundChangeMessageValidator.java | 17 + .../RoundChangePayloadValidator.java | 12 + .../validator/ForkingValidatorProvider.java | 9 + .../TransactionValidatorProvider.java | 8 + .../ValidatorContractController.java | 16 + .../ValidatorModeTransitionLogger.java | 17 + .../besu/crypto/AbstractSECP256.java | 28 ++ .../hyperledger/besu/crypto/BesuProvider.java | 3 + .../besu/crypto/Blake2bfMessageDigest.java | 10 + .../hyperledger/besu/crypto/ECPointUtil.java | 13 + .../org/hyperledger/besu/crypto/Hash.java | 2 + .../org/hyperledger/besu/crypto/KeyPair.java | 32 ++ .../besu/crypto/KeyPairSecurityModule.java | 15 + .../hyperledger/besu/crypto/KeyPairUtil.java | 56 ++++ .../besu/crypto/MessageDigestFactory.java | 8 + .../org/hyperledger/besu/crypto/NodeKey.java | 23 ++ .../hyperledger/besu/crypto/SECP256K1.java | 3 + .../hyperledger/besu/crypto/SECP256R1.java | 4 + .../besu/crypto/SECPPrivateKey.java | 27 ++ .../besu/crypto/SECPPublicKey.java | 31 ++ .../besu/crypto/SECPSignature.java | 36 ++ .../besu/crypto/SecureRandomProvider.java | 15 +- .../besu/crypto/SignatureAlgorithm.java | 143 ++++++++ .../crypto/SignatureAlgorithmFactory.java | 16 +- .../besu/crypto/SignatureAlgorithmType.java | 33 ++ .../crypto/altbn128/AbstractFieldPoint.java | 22 ++ .../besu/crypto/altbn128/AbstractFqp.java | 28 ++ .../crypto/altbn128/AltBn128Fq12Pairer.java | 13 + .../crypto/altbn128/AltBn128Fq12Point.java | 27 ++ .../crypto/altbn128/AltBn128Fq2Point.java | 31 ++ .../besu/crypto/altbn128/AltBn128Point.java | 28 ++ .../besu/crypto/altbn128/FieldElement.java | 60 ++++ .../besu/crypto/altbn128/FieldPoint.java | 35 ++ .../hyperledger/besu/crypto/altbn128/Fq.java | 27 ++ .../besu/crypto/altbn128/Fq12.java | 33 ++ .../hyperledger/besu/crypto/altbn128/Fq2.java | 29 ++ .../hyperledger/besu/datatypes/Address.java | 59 +++- .../org/hyperledger/besu/datatypes/Hash.java | 25 ++ .../org/hyperledger/besu/datatypes/Wei.java | 82 +++++ .../org/hyperledger/besu/enclave/Enclave.java | 68 ++++ .../besu/enclave/EnclaveClientException.java | 19 ++ .../EnclaveConfigurationException.java | 6 + .../besu/enclave/EnclaveFactory.java | 43 +++ .../besu/enclave/EnclaveIOException.java | 12 + .../besu/enclave/EnclaveServerException.java | 13 + .../besu/enclave/GoQuorumEnclave.java | 38 +++ .../besu/enclave/RequestTransmitter.java | 34 ++ .../besu/enclave/VertxRequestTransmitter.java | 18 + .../types/CreatePrivacyGroupRequest.java | 29 ++ .../types/DeletePrivacyGroupRequest.java | 17 + .../besu/enclave/types/ErrorResponse.java | 12 + .../types/FindPrivacyGroupRequest.java | 11 + .../types/GoQuorumReceiveResponse.java | 29 ++ .../enclave/types/GoQuorumSendRequest.java | 23 ++ .../types/GoQuorumSendSignedRequest.java | 17 + .../types/GoQuorumStoreRawRequest.java | 11 + .../besu/enclave/types/PrivacyGroup.java | 75 +++++ .../besu/enclave/types/ReceiveRequest.java | 22 ++ .../besu/enclave/types/ReceiveResponse.java | 23 ++ .../types/RetrievePrivacyGroupRequest.java | 11 + .../besu/enclave/types/SendRequest.java | 17 + .../besu/enclave/types/SendRequestBesu.java | 13 + .../besu/enclave/types/SendRequestLegacy.java | 13 + .../besu/enclave/types/SendResponse.java | 11 + .../besu/enclave/types/StoreRawResponse.java | 11 + .../besu/consensus/merge/ForkchoiceEvent.java | 33 ++ .../consensus/merge/MergeStateHandler.java | 8 + .../merge/UnverifiedForkchoiceListener.java | 6 + .../besu/ethstats/EthStatsService.java | 15 + .../exception/UnsupportedForkException.java | 6 + .../hyperledger/besu/evm/AccessListEntry.java | 34 ++ .../java/org/hyperledger/besu/evm/EVM.java | 39 +++ .../hyperledger/besu/evm/EvmSpecVersion.java | 19 ++ .../org/hyperledger/besu/evm/MainnetEVMs.java | 307 ++++++++++++++++++ .../evm/ModificationNotAllowedException.java | 2 + .../hyperledger/besu/evm/account/Account.java | 3 + .../besu/evm/account/AccountStorageEntry.java | 29 ++ .../besu/evm/account/EvmAccount.java | 7 + .../besu/evm/code/CodeFactory.java | 11 + .../besu/evm/code/CodeInvalid.java | 12 + .../besu/evm/code/CodeSection.java | 40 +++ .../org/hyperledger/besu/evm/code/CodeV0.java | 7 + .../org/hyperledger/besu/evm/code/CodeV1.java | 7 + .../besu/evm/code/CodeV1Validation.java | 7 + .../hyperledger/besu/evm/code/EOFLayout.java | 49 +++ .../CachedInvalidCodeRule.java | 12 + .../ContractValidationRule.java | 7 + .../contractvalidation/MaxCodeSizeRule.java | 12 + .../contractvalidation/PrefixCodeRule.java | 6 + .../besu/evm/fluent/EVMExecutor.java | 233 ++++++++++++- .../besu/evm/fluent/SimpleAccount.java | 17 + .../besu/evm/fluent/SimpleWorld.java | 9 + .../besu/evm/frame/ExceptionalHaltReason.java | 47 +++ .../hyperledger/besu/evm/frame/Memory.java | 1 + .../besu/evm/frame/MessageFrame.java | 252 ++++++++++++++ .../gascalculator/BerlinGasCalculator.java | 12 + .../gascalculator/ByzantiumGasCalculator.java | 9 + .../ConstantinopleGasCalculator.java | 1 + .../gascalculator/DieHardGasCalculator.java | 1 + .../gascalculator/FrontierGasCalculator.java | 21 ++ .../besu/evm/gascalculator/GasCalculator.java | 11 + .../gascalculator/HomesteadGasCalculator.java | 1 + .../gascalculator/IstanbulGasCalculator.java | 1 + .../gascalculator/LondonGasCalculator.java | 2 + .../gascalculator/ShanghaiGasCalculator.java | 1 + .../SpuriousDragonGasCalculator.java | 1 + .../TangerineWhistleGasCalculator.java | 1 + .../besu/evm/internal/CodeCache.java | 34 ++ .../besu/evm/internal/EvmConfiguration.java | 18 + .../besu/evm/internal/FixedStack.java | 52 +++ .../besu/evm/internal/MemoryEntry.java | 17 + .../besu/evm/internal/OperandStack.java | 6 + .../besu/evm/internal/ReturnStack.java | 28 ++ .../besu/evm/internal/StorageEntry.java | 17 + .../hyperledger/besu/evm/internal/Words.java | 14 + .../org/hyperledger/besu/evm/log/Log.java | 17 + .../hyperledger/besu/evm/log/LogTopic.java | 30 ++ .../besu/evm/log/LogsBloomFilter.java | 81 ++++- .../evm/operation/AbstractCallOperation.java | 22 ++ .../operation/AbstractCreateOperation.java | 25 ++ .../operation/AbstractFixedCostOperation.java | 22 ++ .../besu/evm/operation/AbstractOperation.java | 14 + .../besu/evm/operation/AddModOperation.java | 12 + .../besu/evm/operation/AddOperation.java | 13 + .../besu/evm/operation/AddressOperation.java | 6 + .../besu/evm/operation/AndOperation.java | 13 + .../besu/evm/operation/BalanceOperation.java | 12 + .../besu/evm/operation/BaseFeeOperation.java | 6 + .../evm/operation/BlockHashOperation.java | 6 + .../besu/evm/operation/ByteOperation.java | 13 + .../besu/evm/operation/CallCodeOperation.java | 6 + .../evm/operation/CallDataCopyOperation.java | 6 + .../evm/operation/CallDataLoadOperation.java | 6 + .../evm/operation/CallDataSizeOperation.java | 6 + .../besu/evm/operation/CallFOperation.java | 16 + .../besu/evm/operation/CallOperation.java | 6 + .../evm/operation/CallValueOperation.java | 6 + .../besu/evm/operation/CallerOperation.java | 6 + .../besu/evm/operation/ChainIdOperation.java | 7 + .../besu/evm/operation/CodeCopyOperation.java | 6 + .../besu/evm/operation/CodeSizeOperation.java | 6 + .../besu/evm/operation/CoinbaseOperation.java | 6 + .../besu/evm/operation/Create2Operation.java | 7 + .../besu/evm/operation/CreateOperation.java | 7 + .../evm/operation/DelegateCallOperation.java | 6 + .../evm/operation/DifficultyOperation.java | 6 + .../besu/evm/operation/DivOperation.java | 13 + .../besu/evm/operation/DupOperation.java | 17 + .../besu/evm/operation/EqOperation.java | 13 + .../besu/evm/operation/ExpOperation.java | 6 + .../evm/operation/ExtCodeCopyOperation.java | 15 + .../evm/operation/ExtCodeHashOperation.java | 12 + .../evm/operation/ExtCodeSizeOperation.java | 12 + .../besu/evm/operation/GasLimitOperation.java | 6 + .../besu/evm/operation/GasOperation.java | 6 + .../besu/evm/operation/GasPriceOperation.java | 6 + .../besu/evm/operation/GtOperation.java | 13 + .../besu/evm/operation/InvalidOperation.java | 15 + .../besu/evm/operation/IsZeroOperation.java | 13 + .../besu/evm/operation/JumpDestOperation.java | 7 + .../besu/evm/operation/JumpFOperation.java | 16 + .../besu/evm/operation/JumpOperation.java | 6 + .../besu/evm/operation/JumpiOperation.java | 6 + .../evm/operation/Keccak256Operation.java | 6 + .../besu/evm/operation/LogOperation.java | 7 + .../besu/evm/operation/LtOperation.java | 13 + .../besu/evm/operation/MLoadOperation.java | 6 + .../besu/evm/operation/MSizeOperation.java | 6 + .../besu/evm/operation/MStore8Operation.java | 6 + .../besu/evm/operation/MStoreOperation.java | 6 + .../besu/evm/operation/ModOperation.java | 12 + .../besu/evm/operation/MulModOperation.java | 12 + .../besu/evm/operation/MulOperation.java | 13 + .../besu/evm/operation/NotOperation.java | 13 + .../besu/evm/operation/NumberOperation.java | 6 + .../besu/evm/operation/Operation.java | 53 +++ .../besu/evm/operation/OperationRegistry.java | 30 ++ .../besu/evm/operation/OrOperation.java | 13 + .../besu/evm/operation/OriginOperation.java | 6 + .../besu/evm/operation/PCOperation.java | 6 + .../besu/evm/operation/PopOperation.java | 13 + .../evm/operation/PrevRanDaoOperation.java | 6 + .../besu/evm/operation/Push0Operation.java | 13 + .../besu/evm/operation/PushOperation.java | 19 ++ .../operation/RelativeJumpIfOperation.java | 7 + .../evm/operation/RelativeJumpOperation.java | 17 + .../RelativeJumpVectorOperation.java | 14 + .../besu/evm/operation/RetFOperation.java | 8 + .../operation/ReturnDataCopyOperation.java | 8 + .../operation/ReturnDataSizeOperation.java | 6 + .../besu/evm/operation/ReturnOperation.java | 6 + .../besu/evm/operation/RevertOperation.java | 6 + .../besu/evm/operation/SDivOperation.java | 12 + .../besu/evm/operation/SGtOperation.java | 13 + .../besu/evm/operation/SLoadOperation.java | 6 + .../besu/evm/operation/SLtOperation.java | 13 + .../besu/evm/operation/SModOperation.java | 12 + .../besu/evm/operation/SStoreOperation.java | 15 + .../besu/evm/operation/SarOperation.java | 13 + .../evm/operation/SelfBalanceOperation.java | 6 + .../evm/operation/SelfDestructOperation.java | 6 + .../besu/evm/operation/ShlOperation.java | 13 + .../besu/evm/operation/ShrOperation.java | 13 + .../evm/operation/SignExtendOperation.java | 12 + .../evm/operation/StaticCallOperation.java | 6 + .../besu/evm/operation/StopOperation.java | 13 + .../besu/evm/operation/SubOperation.java | 13 + .../besu/evm/operation/SwapOperation.java | 17 + .../evm/operation/TimestampOperation.java | 6 + .../besu/evm/operation/VirtualOperation.java | 6 + .../besu/evm/operation/XorOperation.java | 13 + .../AbstractAltBnPrecompiledContract.java | 23 ++ .../AbstractBLS12PrecompiledContract.java | 16 + .../AbstractPrecompiledContract.java | 11 + .../AltBN128AddPrecompiledContract.java | 13 + .../AltBN128MulPrecompiledContract.java | 13 + .../AltBN128PairingPrecompiledContract.java | 15 + .../BLAKE2BFPrecompileContract.java | 6 + .../BLS12G1AddPrecompiledContract.java | 2 + .../BLS12G1MulPrecompiledContract.java | 2 + .../BLS12G1MultiExpPrecompiledContract.java | 2 + .../BLS12G2AddPrecompiledContract.java | 2 + .../BLS12G2MulPrecompiledContract.java | 2 + .../BLS12G2MultiExpPrecompiledContract.java | 2 + .../BLS12MapFp2ToG2PrecompiledContract.java | 2 + .../BLS12MapFpToG1PrecompiledContract.java | 2 + .../BLS12PairingPrecompiledContract.java | 2 + ...ularExponentiationPrecompiledContract.java | 69 +++- .../precompile/ECRECPrecompiledContract.java | 6 + .../evm/precompile/IDPrecompiledContract.java | 6 + .../MainnetPrecompiledContracts.java | 48 +++ .../PrecompileContractRegistry.java | 13 + .../evm/precompile/PrecompiledContract.java | 40 +++ .../RIPEMD160PrecompiledContract.java | 6 + .../precompile/SHA256PrecompiledContract.java | 6 + .../processor/AbstractMessageProcessor.java | 27 +- .../processor/ContractCreationProcessor.java | 19 ++ .../evm/processor/MessageCallProcessor.java | 14 + .../tracing/EstimateGasOperationTracer.java | 11 + .../besu/evm/tracing/OperationTracer.java | 32 ++ .../besu/evm/tracing/StandardJsonTracer.java | 19 ++ .../evm/worldstate/AbstractWorldUpdater.java | 27 +- .../besu/evm/worldstate/MutableWorldView.java | 1 + .../besu/evm/worldstate/StackedUpdater.java | 12 + .../evm/worldstate/UpdateTrackingAccount.java | 28 ++ .../besu/evm/worldstate/WorldState.java | 12 + .../besu/evm/worldstate/WorldView.java | 1 + .../evm/worldstate/WrappedEvmAccount.java | 16 + gradle.properties | 2 +- .../besu/metrics/BesuMetricCategory.java | 17 + .../metrics/MetricCategoryRegistryImpl.java | 6 + .../besu/metrics/MetricsProtocol.java | 9 + .../besu/metrics/MetricsService.java | 8 + .../besu/metrics/ObservableMetricsSystem.java | 12 + .../hyperledger/besu/metrics/Observation.java | 29 ++ .../besu/metrics/RunnableCounter.java | 16 + .../besu/metrics/RunnableTimedCounter.java | 13 + .../besu/metrics/StandardMetricCategory.java | 3 + .../besu/metrics/noop/NoOpMetricsSystem.java | 53 +++ .../besu/metrics/noop/NoOpValueCollector.java | 1 + .../opentelemetry/MetricsOtelPushService.java | 2 + .../opentelemetry/OpenTelemetryCounter.java | 7 + .../opentelemetry/OpenTelemetryGauge.java | 9 + .../opentelemetry/OpenTelemetrySystem.java | 14 + .../opentelemetry/OpenTelemetryTimer.java | 9 + .../prometheus/MetricsConfiguration.java | 181 +++++++++++ .../prometheus/MetricsHttpService.java | 13 + .../prometheus/MetricsPushGatewayService.java | 7 + .../metrics/prometheus/PrometheusGauge.java | 8 + .../prometheus/PrometheusMetricsSystem.java | 26 ++ .../metrics/vertx/VertxMetricsAdapter.java | 6 + .../vertx/VertxMetricsAdapterFactory.java | 6 + .../besu/metrics/rocksdb/RocksDBStats.java | 14 + .../org/hyperledger/besu/nat/NatMethod.java | 13 + .../org/hyperledger/besu/nat/NatService.java | 12 + .../besu/nat/core/AbstractNatManager.java | 19 ++ .../hyperledger/besu/nat/core/IpDetector.java | 7 + .../hyperledger/besu/nat/core/NatManager.java | 1 + .../besu/nat/core/NatMethodDetector.java | 6 + .../besu/nat/core/domain/NatPortMapping.java | 40 +++ .../besu/nat/core/domain/NatServiceType.java | 10 +- .../besu/nat/core/domain/NetworkProtocol.java | 2 + .../exception/NatInitializationException.java | 12 + .../besu/nat/docker/DockerDetector.java | 1 + .../besu/nat/docker/DockerNatManager.java | 15 + .../besu/nat/docker/HostBasedIpDetector.java | 1 + .../nat/kubernetes/KubernetesDetector.java | 1 + .../nat/kubernetes/KubernetesNatManager.java | 12 + .../service/KubernetesServiceType.java | 11 + .../service/LoadBalancerBasedDetector.java | 6 + .../besu/nat/upnp/OkHttpStreamClient.java | 6 + .../hyperledger/besu/pki/PkiException.java | 18 + .../hyperledger/besu/pki/cms/CmsCreator.java | 7 + .../besu/pki/cms/CmsValidator.java | 6 + .../pki/config/PkiKeyStoreConfiguration.java | 120 +++++++ .../org/hyperledger/besu/pki/crl/CRLUtil.java | 7 + .../pki/keystore/AbstractKeyStoreWrapper.java | 6 + .../pki/keystore/HardwareKeyStoreWrapper.java | 26 ++ .../besu/pki/keystore/KeyStoreWrapper.java | 43 +++ .../pki/keystore/SoftwareKeyStoreWrapper.java | 34 ++ plugin-api/build.gradle | 2 +- .../besu/plugin/data/EnodeURL.java | 56 ++++ .../besu/plugin/data/LogWithMetadata.java | 30 ++ .../plugin/data/PrivacyGenesisAccount.java | 1 + .../besu/plugin/data/PrivateTransaction.java | 1 + .../besu/plugin/data/Quantity.java | 5 + .../besu/plugin/data/Restriction.java | 9 + .../besu/plugin/data/SyncStatus.java | 1 + .../besu/plugin/data/TransactionType.java | 37 +++ .../UnsignedPrivateMarkerTransaction.java | 36 ++ .../besu/plugin/services/BesuEvents.java | 2 + .../services/PluginVersionsProvider.java | 6 + .../plugin/services/PrivacyPluginService.java | 22 +- .../services/metrics/LabelledGauge.java | 7 + .../plugin/services/rpc/PluginRpcRequest.java | 6 + .../SecurityModuleException.java | 25 ++ .../securitymodule/data/Signature.java | 10 + .../services/storage/KeyValueStorage.java | 8 +- .../PrivacyKeyValueStorageFactory.java | 1 + .../storage/SnappableKeyValueStorage.java | 6 + .../storage/SnappedKeyValueStorage.java | 11 + .../RocksDBKeyValuePrivacyStorageFactory.java | 5 + .../RocksDBKeyValueStorageFactory.java | 44 +++ .../storage/rocksdb/RocksDBMetrics.java | 35 ++ .../rocksdb/RocksDBMetricsFactory.java | 18 + .../storage/rocksdb/RocksDBPlugin.java | 12 + .../storage/rocksdb/RocksDbIterator.java | 22 ++ .../rocksdb/RocksDbSegmentIdentifier.java | 13 + .../services/storage/rocksdb/RocksDbUtil.java | 2 + .../configuration/DatabaseMetadata.java | 51 +++ .../configuration/RocksDBCLIOptions.java | 37 +++ .../configuration/RocksDBConfiguration.java | 47 +++ .../RocksDBConfigurationBuilder.java | 54 +++ .../RocksDBFactoryConfiguration.java | 35 ++ .../RocksDBColumnarKeyValueSnapshot.java | 10 + .../RocksDBColumnarKeyValueStorage.java | 33 ++ .../segmented/RocksDBSnapshotTransaction.java | 29 ++ .../unsegmented/RocksDBKeyValueStorage.java | 8 + .../unsegmented/RocksDBTransaction.java | 8 + .../kvstore/InMemoryKeyValueStorage.java | 17 + .../kvstore/InMemoryStoragePlugin.java | 7 + ...ansactionTransitionValidatorDecorator.java | 6 + .../LimitedInMemoryKeyValueStorage.java | 5 + .../kvstore/SegmentedKeyValueStorage.java | 46 ++- .../SegmentedKeyValueStorageAdapter.java | 18 + ...ansactionTransitionValidatorDecorator.java | 10 + .../services/pipeline/BatchingReadPipe.java | 20 ++ .../besu/services/pipeline/Pipe.java | 10 +- .../besu/services/pipeline/Pipeline.java | 15 + .../services/pipeline/PipelineBuilder.java | 29 +- .../besu/services/pipeline/Stage.java | 6 + .../services/tasks/CachingTaskCollection.java | 23 ++ .../services/tasks/InMemoryTaskQueue.java | 17 + .../tasks/InMemoryTasksPriorityQueues.java | 19 ++ .../hyperledger/besu/services/tasks/Task.java | 10 + .../besu/services/tasks/TaskCollection.java | 7 +- .../services/tasks/TasksPriorityProvider.java | 11 + .../kvstore/AbstractKeyValueStorageTest.java | 134 ++++++++ .../besu/testutil/BlockTestUtil.java | 63 ++++ .../besu/testutil/JsonTestParameters.java | 76 +++++ .../besu/testutil/MockExecutorService.java | 33 ++ .../hyperledger/besu/testutil/TestClock.java | 23 ++ .../testutil/EnclaveConfiguration.java | 58 ++++ .../testutil/EnclaveEncryptorType.java | 9 + .../testutil/EnclaveKeyConfiguration.java | 29 ++ .../enclave/testutil/EnclaveKeyUtils.java | 7 + .../enclave/testutil/EnclaveTestHarness.java | 39 +++ .../enclave/testutil/EnclaveType.java | 9 + .../testutil/NoopEnclaveTestHarness.java | 7 + .../enclave/testutil/TesseraTestHarness.java | 9 + .../testutil/TesseraTestHarnessFactory.java | 34 ++ .../hyperledger/besu/util/EndianUtils.java | 15 + .../hyperledger/besu/util/ExceptionUtils.java | 1 + .../hyperledger/besu/util/FutureUtils.java | 12 +- .../besu/util/IllegalPortException.java | 6 + .../util/InvalidConfigurationException.java | 6 + .../org/hyperledger/besu/util/LimitedSet.java | 5 +- .../besu/util/Log4j2ConfiguratorUtil.java | 20 ++ .../hyperledger/besu/util/NetworkUtility.java | 42 +++ .../hyperledger/besu/util/Preconditions.java | 9 + .../besu/util/Slf4jLambdaHelper.java | 28 ++ .../hyperledger/besu/util/Subscribers.java | 21 +- .../besu/util/io/RollingFileReader.java | 25 ++ .../besu/util/io/RollingFileWriter.java | 20 ++ .../besu/util/log/FramedLogMessage.java | 13 + .../besu/util/number/ByteUnits.java | 2 + .../besu/util/number/Fraction.java | 29 ++ .../besu/util/number/Percentage.java | 17 + .../besu/util/number/PositiveNumber.java | 12 + .../besu/util/platform/PlatformDetector.java | 38 +++ 763 files changed, 15266 insertions(+), 74 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9428da85c..1b65d2834 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -197,10 +197,6 @@ jobs: name: IntegrationTests command: | ./gradlew --no-daemon integrationTest - - run: - name: Javadoc - command: | - ./gradlew --no-daemon javadoc - run: name: CompileJmh command: | diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a1fa3e391..22b58f39f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -19,4 +19,18 @@ jobs: java-version: 11 cache: gradle - name: spotless - run: ./gradlew --no-daemon --parallel clean spotlessCheck \ No newline at end of file + run: ./gradlew --no-daemon --parallel clean spotlessCheck + javadoc_17: + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Set up Java 17 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 17 + cache: gradle + - name: javadoc (JDK 17) + run: ./gradlew --no-daemon clean javadoc \ No newline at end of file diff --git a/besu/src/main/java/org/hyperledger/besu/Besu.java b/besu/src/main/java/org/hyperledger/besu/Besu.java index efde865ba..993f7b3a9 100644 --- a/besu/src/main/java/org/hyperledger/besu/Besu.java +++ b/besu/src/main/java/org/hyperledger/besu/Besu.java @@ -28,8 +28,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import picocli.CommandLine.RunLast; +/** Besu bootstrap class. */ public final class Besu { + /** + * The main entrypoint to Besu application + * + * @param args command line arguments. + */ public static void main(final String... args) { final Logger logger = setupLogging(); diff --git a/besu/src/main/java/org/hyperledger/besu/BesuInfo.java b/besu/src/main/java/org/hyperledger/besu/BesuInfo.java index 7c664ad28..080e4e637 100644 --- a/besu/src/main/java/org/hyperledger/besu/BesuInfo.java +++ b/besu/src/main/java/org/hyperledger/besu/BesuInfo.java @@ -18,6 +18,10 @@ import org.hyperledger.besu.util.platform.PlatformDetector; import java.util.Optional; +/** + * Represent Besu information such as version, OS etc. Used with --version option and during Besu + * start. + */ public final class BesuInfo { private static final String CLIENT = "besu"; private static final String VERSION = BesuInfo.class.getPackage().getImplementationVersion(); @@ -26,10 +30,21 @@ public final class BesuInfo { private BesuInfo() {} + /** + * Generate Besu version + * + * @return Besu version in format such as besu/v22.10.3/linux-aarch_64/openjdk-java-11 + */ public static String version() { return String.format("%s/v%s/%s/%s", CLIENT, VERSION, OS, VM); } + /** + * Generate node name including identity. + * + * @param maybeIdentity optional node identity to include in the version string. + * @return Version with optional identity if provided. + */ public static String nodeName(final Optional maybeIdentity) { return maybeIdentity .map(identity -> String.format("%s/%s/v%s/%s/%s", CLIENT, identity, VERSION, OS, VM)) diff --git a/besu/src/main/java/org/hyperledger/besu/Runner.java b/besu/src/main/java/org/hyperledger/besu/Runner.java index b27797a94..fb4facf0e 100644 --- a/besu/src/main/java/org/hyperledger/besu/Runner.java +++ b/besu/src/main/java/org/hyperledger/besu/Runner.java @@ -51,6 +51,7 @@ import io.vertx.core.Vertx; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** The Runner controls various Besu services lifecycle. */ public class Runner implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(Runner.class); @@ -77,6 +78,26 @@ public class Runner implements AutoCloseable { private final Optional autoTransactionLogBloomCachingService; + /** + * Instantiates a new Runner. + * + * @param vertx the vertx + * @param networkRunner the network runner + * @param natService the nat service + * @param jsonRpc the json rpc + * @param engineJsonRpc the engine json rpc + * @param graphQLHttp the graph ql http + * @param webSocketRpc the web socket rpc + * @param ipcJsonRpc the ipc json rpc + * @param stratumServer the stratum server + * @param metrics the metrics + * @param ethStatsService the eth stats service + * @param besuController the besu controller + * @param dataDir the data dir + * @param pidPath the pid path + * @param transactionLogBloomCacher the transaction log bloom cacher + * @param blockchain the blockchain + */ Runner( final Vertx vertx, final NetworkRunner networkRunner, @@ -115,6 +136,7 @@ public class Runner implements AutoCloseable { new TransactionPoolEvictionService(vertx, besuController.getTransactionPool()); } + /** Start external services. */ public void startExternalServices() { LOG.info("Starting external services ... "); metrics.ifPresent(service -> waitForServiceToStart("metrics", service.start())); @@ -132,6 +154,7 @@ public class Runner implements AutoCloseable { ethStatsService.ifPresent(EthStatsService::start); } + /** Start ethereum main loop. */ public void startEthereumMainLoop() { try { LOG.info("Starting Ethereum main loop ... "); @@ -154,6 +177,7 @@ public class Runner implements AutoCloseable { } } + /** Stop services. */ public void stop() { transactionPoolEvictionService.stop(); jsonRpc.ifPresent(service -> waitForServiceToStop("jsonRpc", service.stop())); @@ -184,6 +208,7 @@ public class Runner implements AutoCloseable { shutdown.countDown(); } + /** Await stop. */ public void awaitStop() { try { shutdown.await(); @@ -328,22 +353,47 @@ public class Runner implements AutoCloseable { }); } + /** + * Gets json rpc port. + * + * @return the json rpc port + */ public Optional getJsonRpcPort() { return jsonRpc.map(service -> service.socketAddress().getPort()); } + /** + * Gets engine json rpc port. + * + * @return the engine json rpc port + */ public Optional getEngineJsonRpcPort() { return engineJsonRpc.map(service -> service.socketAddress().getPort()); } + /** + * Gets GraphQl http port. + * + * @return the graph ql http port + */ public Optional getGraphQLHttpPort() { return graphQLHttp.map(service -> service.socketAddress().getPort()); } + /** + * Gets web socket port. + * + * @return the web socket port + */ public Optional getWebSocketPort() { return webSocketRpc.map(service -> service.socketAddress().getPort()); } + /** + * Gets metrics port. + * + * @return the metrics port + */ public Optional getMetricsPort() { if (metrics.isPresent()) { return metrics.get().getPort(); @@ -352,6 +402,11 @@ public class Runner implements AutoCloseable { } } + /** + * Gets local enode. + * + * @return the local enode + */ @VisibleForTesting Optional getLocalEnode() { return networkRunner.getNetwork().getLocalEnode(); @@ -359,6 +414,11 @@ public class Runner implements AutoCloseable { @FunctionalInterface private interface SynchronousShutdown { + /** + * Await for shutdown. + * + * @throws InterruptedException the interrupted exception + */ void await() throws InterruptedException; } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 227c64f3f..6d1a0f574 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -147,6 +147,7 @@ import org.apache.tuweni.units.bigints.UInt256; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** The builder for Runner class. */ public class RunnerBuilder { private static final Logger LOG = LoggerFactory.getLogger(RunnerBuilder.class); @@ -195,26 +196,56 @@ public class RunnerBuilder { private boolean legacyForkIdEnabled; private Optional rpcMaxLogsRange; + /** + * Add Vertx. + * + * @param vertx the vertx instance + * @return runner builder + */ public RunnerBuilder vertx(final Vertx vertx) { this.vertx = vertx; return this; } + /** + * Add Besu controller. + * + * @param besuController the besu controller + * @return the runner builder + */ public RunnerBuilder besuController(final BesuController besuController) { this.besuController = besuController; return this; } + /** + * P2p enabled. + * + * @param p2pEnabled the p 2 p enabled + * @return the runner builder + */ public RunnerBuilder p2pEnabled(final boolean p2pEnabled) { this.p2pEnabled = p2pEnabled; return this; } + /** + * TLSConfiguration p2pTLSConfiguration. + * + * @param p2pTLSConfiguration the TLSConfiguration p2pTLSConfiguration + * @return the runner builder + */ public RunnerBuilder p2pTLSConfiguration(final TLSConfiguration p2pTLSConfiguration) { this.p2pTLSConfiguration = Optional.of(p2pTLSConfiguration); return this; } + /** + * Optional TLSConfiguration p2pTLSConfiguration. + * + * @param p2pTLSConfiguration the TLSConfiguration p2pTLSConfiguration + * @return the runner builder + */ public RunnerBuilder p2pTLSConfiguration(final Optional p2pTLSConfiguration) { if (null != p2pTLSConfiguration) { this.p2pTLSConfiguration = p2pTLSConfiguration; @@ -222,188 +253,403 @@ public class RunnerBuilder { return this; } + /** + * Enable Discovery. + * + * @param discovery the discovery + * @return the runner builder + */ public RunnerBuilder discovery(final boolean discovery) { this.discovery = discovery; return this; } + /** + * Add Eth network config. + * + * @param ethNetworkConfig the eth network config + * @return the runner builder + */ public RunnerBuilder ethNetworkConfig(final EthNetworkConfig ethNetworkConfig) { this.ethNetworkConfig = ethNetworkConfig; return this; } + /** + * Add Networking configuration. + * + * @param networkingConfiguration the networking configuration + * @return the runner builder + */ public RunnerBuilder networkingConfiguration( final NetworkingConfiguration networkingConfiguration) { this.networkingConfiguration = networkingConfiguration; return this; } + /** + * Add P2p advertised host. + * + * @param p2pAdvertisedHost the P2P advertised host + * @return the runner builder + */ public RunnerBuilder p2pAdvertisedHost(final String p2pAdvertisedHost) { this.p2pAdvertisedHost = p2pAdvertisedHost; return this; } + /** + * Add P2P Listener interface ip/host name. + * + * @param ip the ip + * @return the runner builder + */ public RunnerBuilder p2pListenInterface(final String ip) { checkArgument(!isNull(ip), "Invalid null value supplied for p2pListenInterface"); this.p2pListenInterface = ip; return this; } + /** + * Add P2P listen port. + * + * @param p2pListenPort the p 2 p listen port + * @return the runner builder + */ public RunnerBuilder p2pListenPort(final int p2pListenPort) { this.p2pListenPort = p2pListenPort; return this; } + /** + * Add Nat method. + * + * @param natMethod the nat method + * @return the runner builder + */ public RunnerBuilder natMethod(final NatMethod natMethod) { this.natMethod = natMethod; return this; } + /** + * Add Nat manager service name. + * + * @param natManagerServiceName the nat manager service name + * @return the runner builder + */ public RunnerBuilder natManagerServiceName(final String natManagerServiceName) { this.natManagerServiceName = natManagerServiceName; return this; } + /** + * Enable Nat method fallback. + * + * @param natMethodFallbackEnabled the nat method fallback enabled + * @return the runner builder + */ public RunnerBuilder natMethodFallbackEnabled(final boolean natMethodFallbackEnabled) { this.natMethodFallbackEnabled = natMethodFallbackEnabled; return this; } + /** + * Add Max peers. + * + * @param maxPeers the max peers + * @return the runner builder + */ public RunnerBuilder maxPeers(final int maxPeers) { this.maxPeers = maxPeers; return this; } + /** + * Enable Limit remote wire connections. + * + * @param limitRemoteWireConnectionsEnabled the limit remote wire connections enabled + * @return the runner builder + */ public RunnerBuilder limitRemoteWireConnectionsEnabled( final boolean limitRemoteWireConnectionsEnabled) { this.limitRemoteWireConnectionsEnabled = limitRemoteWireConnectionsEnabled; return this; } + /** + * Add Fraction remote connections allowed. + * + * @param fractionRemoteConnectionsAllowed the fraction remote connections allowed + * @return the runner builder + */ public RunnerBuilder fractionRemoteConnectionsAllowed( final float fractionRemoteConnectionsAllowed) { this.fractionRemoteConnectionsAllowed = fractionRemoteConnectionsAllowed; return this; } + /** + * Enable Random peer priority. + * + * @param randomPeerPriority the random peer priority + * @return the runner builder + */ public RunnerBuilder randomPeerPriority(final boolean randomPeerPriority) { this.randomPeerPriority = randomPeerPriority; return this; } + /** + * Add Ethstats url. + * + * @param ethstatsUrl the ethstats url + * @return the runner builder + */ public RunnerBuilder ethstatsUrl(final String ethstatsUrl) { this.ethstatsUrl = ethstatsUrl; return this; } + /** + * Add Ethstats contact. + * + * @param ethstatsContact the ethstats contact + * @return the runner builder + */ public RunnerBuilder ethstatsContact(final String ethstatsContact) { this.ethstatsContact = ethstatsContact; return this; } + /** + * Add Json RPC configuration. + * + * @param jsonRpcConfiguration the json rpc configuration + * @return the runner builder + */ public RunnerBuilder jsonRpcConfiguration(final JsonRpcConfiguration jsonRpcConfiguration) { this.jsonRpcConfiguration = jsonRpcConfiguration; return this; } + /** + * Add Engine json RPC configuration. + * + * @param engineJsonRpcConfiguration the engine json rpc configuration + * @return the runner builder + */ public RunnerBuilder engineJsonRpcConfiguration( final JsonRpcConfiguration engineJsonRpcConfiguration) { this.engineJsonRpcConfiguration = Optional.ofNullable(engineJsonRpcConfiguration); return this; } + /** + * Add GraphQl configuration. + * + * @param graphQLConfiguration the graph ql configuration + * @return the runner builder + */ public RunnerBuilder graphQLConfiguration(final GraphQLConfiguration graphQLConfiguration) { this.graphQLConfiguration = graphQLConfiguration; return this; } + /** + * Add Web socket configuration. + * + * @param webSocketConfiguration the web socket configuration + * @return the runner builder + */ public RunnerBuilder webSocketConfiguration(final WebSocketConfiguration webSocketConfiguration) { this.webSocketConfiguration = webSocketConfiguration; return this; } + /** + * Add Api configuration. + * + * @param apiConfiguration the api configuration + * @return the runner builder + */ public RunnerBuilder apiConfiguration(final ApiConfiguration apiConfiguration) { this.apiConfiguration = apiConfiguration; return this; } + /** + * Add Permissioning configuration. + * + * @param permissioningConfiguration the permissioning configuration + * @return the runner builder + */ public RunnerBuilder permissioningConfiguration( final Optional permissioningConfiguration) { this.permissioningConfiguration = permissioningConfiguration; return this; } + /** + * Add pid path. + * + * @param pidPath the pid path + * @return the runner builder + */ public RunnerBuilder pidPath(final Path pidPath) { this.pidPath = Optional.ofNullable(pidPath); return this; } + /** + * Add Data dir. + * + * @param dataDir the data dir + * @return the runner builder + */ public RunnerBuilder dataDir(final Path dataDir) { this.dataDir = dataDir; return this; } + /** + * Add list of Banned node id. + * + * @param bannedNodeIds the banned node ids + * @return the runner builder + */ public RunnerBuilder bannedNodeIds(final Collection bannedNodeIds) { this.bannedNodeIds.addAll(bannedNodeIds); return this; } + /** + * Add Metrics configuration. + * + * @param metricsConfiguration the metrics configuration + * @return the runner builder + */ public RunnerBuilder metricsConfiguration(final MetricsConfiguration metricsConfiguration) { this.metricsConfiguration = metricsConfiguration; return this; } + /** + * Add Metrics system. + * + * @param metricsSystem the metrics system + * @return the runner builder + */ public RunnerBuilder metricsSystem(final ObservableMetricsSystem metricsSystem) { this.metricsSystem = metricsSystem; return this; } + /** + * Add Permissioning service. + * + * @param permissioningService the permissioning service + * @return the runner builder + */ public RunnerBuilder permissioningService(final PermissioningServiceImpl permissioningService) { this.permissioningService = permissioningService; return this; } + /** + * Add Static nodes collection. + * + * @param staticNodes the static nodes + * @return the runner builder + */ public RunnerBuilder staticNodes(final Collection staticNodes) { this.staticNodes = staticNodes; return this; } + /** + * Add Node identity string. + * + * @param identityString the identity string + * @return the runner builder + */ public RunnerBuilder identityString(final Optional identityString) { this.identityString = identityString; return this; } + /** + * Add Besu plugin context. + * + * @param besuPluginContext the besu plugin context + * @return the runner builder + */ public RunnerBuilder besuPluginContext(final BesuPluginContextImpl besuPluginContext) { this.besuPluginContext = besuPluginContext; return this; } + /** + * Enable Auto log bloom caching. + * + * @param autoLogBloomCaching the auto log bloom caching + * @return the runner builder + */ public RunnerBuilder autoLogBloomCaching(final boolean autoLogBloomCaching) { this.autoLogBloomCaching = autoLogBloomCaching; return this; } + /** + * Add Storage provider. + * + * @param storageProvider the storage provider + * @return the runner builder + */ public RunnerBuilder storageProvider(final StorageProvider storageProvider) { this.storageProvider = storageProvider; return this; } + /** + * Add Rpc endpoint service. + * + * @param rpcEndpointService the rpc endpoint service + * @return the runner builder + */ public RunnerBuilder rpcEndpointService(final RpcEndpointServiceImpl rpcEndpointService) { this.rpcEndpointServiceImpl = rpcEndpointService; return this; } + /** + * Add Json Rpc Ipc configuration. + * + * @param jsonRpcIpcConfiguration the json rpc ipc configuration + * @return the runner builder + */ public RunnerBuilder jsonRpcIpcConfiguration( final JsonRpcIpcConfiguration jsonRpcIpcConfiguration) { this.jsonRpcIpcConfiguration = jsonRpcIpcConfiguration; return this; } + /** + * Add Rpc max logs range. + * + * @param rpcMaxLogsRange the rpc max logs range + * @return the runner builder + */ public RunnerBuilder rpcMaxLogsRange(final Long rpcMaxLogsRange) { this.rpcMaxLogsRange = rpcMaxLogsRange > 0 ? Optional.of(rpcMaxLogsRange) : Optional.empty(); return this; } + /** + * Build Runner instance. + * + * @return the runner + */ public Runner build() { Preconditions.checkNotNull(besuController); @@ -965,6 +1211,13 @@ public class RunnerBuilder { } } + /** + * Gets fixed nodes. Visible for testing. + * + * @param someFixedNodes the fixed nodes + * @param moreFixedNodes nodes added to fixed nodes + * @return the fixed and more nodes combined + */ @VisibleForTesting public static Collection getFixedNodes( final Collection someFixedNodes, final Collection moreFixedNodes) { @@ -1176,15 +1429,32 @@ public class RunnerBuilder { return MetricsService.create(vertx, configuration, metricsSystem); } + /** + * Gets minimum peers. + * + * @return the minimum peers + */ public int getMinPeers() { return minPeers; } + /** + * Add Minimum peers. + * + * @param minPeers the minimum peers + * @return the runner builder + */ public RunnerBuilder minPeers(final int minPeers) { this.minPeers = minPeers; return this; } + /** + * Add Legacy fork id. + * + * @param legacyEth64ForkIdEnabled the legacy eth64 fork id enabled + * @return the runner builder + */ public RunnerBuilder legacyForkId(final boolean legacyEth64ForkIdEnabled) { this.legacyForkIdEnabled = legacyEth64ForkIdEnabled; return this; diff --git a/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java b/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java index 9e3336377..de5b058fc 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java @@ -33,6 +33,11 @@ public abstract class BlockExporter { private static final Logger LOG = LoggerFactory.getLogger(BlockExporter.class); private final Blockchain blockchain; + /** + * Instantiates a new Block exporter. + * + * @param blockchain the blockchain + */ protected BlockExporter(final Blockchain blockchain) { this.blockchain = blockchain; } @@ -90,6 +95,13 @@ public abstract class BlockExporter { LOG.info("Export complete at block {}", blockNumber); } + /** + * Export block. + * + * @param outputStream The FileOutputStream where the block will be exported + * @param block The block to export + * @throws IOException In case of an error while exporting. + */ protected abstract void exportBlock(final FileOutputStream outputStream, final Block block) throws IOException; } diff --git a/besu/src/main/java/org/hyperledger/besu/chainexport/RlpBlockExporter.java b/besu/src/main/java/org/hyperledger/besu/chainexport/RlpBlockExporter.java index fcd7ec569..cfca4f7f9 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainexport/RlpBlockExporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainexport/RlpBlockExporter.java @@ -23,8 +23,14 @@ import java.io.IOException; import org.apache.tuweni.bytes.Bytes; +/** The Rlp block exporter. */ public class RlpBlockExporter extends BlockExporter { + /** + * Instantiates a new Rlp block exporter. + * + * @param blockchain the blockchain + */ public RlpBlockExporter(final Blockchain blockchain) { super(blockchain); } diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java b/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java index 23e38fc16..435d7737d 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java @@ -52,6 +52,11 @@ public class JsonBlockImporter { private final ObjectMapper mapper; private final BesuController controller; + /** + * Instantiates a new Json block importer. + * + * @param controller the controller + */ public JsonBlockImporter(final BesuController controller) { this.controller = controller; mapper = new ObjectMapper(); @@ -61,6 +66,12 @@ public class JsonBlockImporter { mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); } + /** + * Import chain. + * + * @param chainJson the chain json + * @throws IOException the io exception + */ public void importChain(final String chainJson) throws IOException { warnIfDatabaseIsNotEmpty(); diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java b/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java index 80c7dae50..d65425c8c 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java @@ -80,6 +80,17 @@ public class RlpBlockImporter implements Closeable { return importBlockchain(blocks, besuController, skipPowValidation, 0L, Long.MAX_VALUE); } + /** + * Import blockchain. + * + * @param blocks the blocks + * @param besuController the besu controller + * @param skipPowValidation the skip pow validation + * @param startBlock the start block + * @param endBlock the end block + * @return the rlp block importer - import result + * @throws IOException the io exception + */ public RlpBlockImporter.ImportResult importBlockchain( final Path blocks, final BesuController besuController, @@ -279,12 +290,21 @@ public class RlpBlockImporter implements Closeable { } } + /** The Import result. */ public static final class ImportResult { + /** The difficulty. */ public final Difficulty td; + /** The Count. */ final int count; + /** + * Instantiates a new Import result. + * + * @param td the td + * @param count the count + */ ImportResult(final Difficulty td, final int count) { this.td = td; this.count = count; diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java index 1ce886ed5..b8dde10a7 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java @@ -33,6 +33,9 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +/** + * Represents BlockData used in ChainData. Meant to be constructed by Json serializer/deserializer. + */ @JsonIgnoreProperties("comment") public class BlockData { @@ -42,6 +45,15 @@ public class BlockData { private final Optional
coinbase; private final Optional extraData; + /** + * Constructor for BlockData + * + * @param number Block number in hex format. + * @param parentHash Parent hash in hex format. + * @param coinbase Coinbase Address in hex format. + * @param extraData Extra data in hex format. + * @param transactions list of TransactionData. + */ @JsonCreator public BlockData( @JsonProperty("number") final Optional number, @@ -56,27 +68,59 @@ public class BlockData { this.transactionData = transactions; } + /** + * Gets number. + * + * @return the number + */ public Optional getNumber() { return number; } + /** + * Gets parent hash. + * + * @return the parent hash + */ public Optional getParentHash() { return parentHash; } + /** + * Gets coinbase. + * + * @return the coinbase + */ public Optional
getCoinbase() { return coinbase; } + /** + * Gets extra data. + * + * @return the extra data + */ public Optional getExtraData() { return extraData; } + /** + * Stream transactions. + * + * @param worldState the world state + * @return the stream of Transaction + */ public Stream streamTransactions(final WorldState worldState) { final NonceProvider nonceProvider = getNonceProvider(worldState); return transactionData.stream().map((tx) -> tx.getSignedTransaction(nonceProvider)); } + /** + * Gets nonce provider. + * + * @param worldState the world state + * @return the nonce provider + */ public NonceProvider getNonceProvider(final WorldState worldState) { final HashMap currentNonceValues = new HashMap<>(); return (Address address) -> diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/ChainData.java b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/ChainData.java index 1c525255c..cb9528b7e 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/ChainData.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/ChainData.java @@ -20,16 +20,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +/** The Chain data. */ @JsonIgnoreProperties("comment") public class ChainData { private final List blocks; + /** + * Instantiates a new Chain data. + * + * @param blocks the blocks + */ @JsonCreator public ChainData(@JsonProperty("blocks") final List blocks) { this.blocks = blocks; } + /** + * Gets blocks. + * + * @return the blocks + */ public List getBlocks() { return blocks; } diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/TransactionData.java b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/TransactionData.java index 7831f50fa..6358021af 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/TransactionData.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/TransactionData.java @@ -33,6 +33,7 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +/** The Transaction data. */ @JsonIgnoreProperties("comment") public class TransactionData { @@ -46,6 +47,16 @@ public class TransactionData { private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); + /** + * Instantiates a new Transaction data. + * + * @param gasLimit the gas limit + * @param gasPrice the gas price + * @param data the data + * @param value the value + * @param to the to + * @param secretKey the secret key + */ @JsonCreator public TransactionData( @JsonProperty("gasLimit") final String gasLimit, @@ -62,6 +73,12 @@ public class TransactionData { this.privateKey = SIGNATURE_ALGORITHM.get().createPrivateKey(Bytes32.fromHexString(secretKey)); } + /** + * Gets signed transaction. + * + * @param nonceProvider the nonce provider + * @return the signed transaction + */ public Transaction getSignedTransaction(final NonceProvider nonceProvider) { final KeyPair keyPair = SIGNATURE_ALGORITHM.get().createKeyPair(privateKey); @@ -78,8 +95,15 @@ public class TransactionData { .signAndBuild(keyPair); } + /** The interface Nonce provider. */ @FunctionalInterface public interface NonceProvider { + /** + * Get Nonce. + * + * @param address the address + * @return the Nonce + */ long get(final Address address); } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index cccc5c4af..4bf0a8ef1 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -252,6 +252,7 @@ import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; +/** Represents the main Besu CLI command that runs the Besu Ethereum client full node. */ @SuppressWarnings("FieldCanBeLocal") // because Picocli injected fields report false positives @Command( description = "This command runs the Besu Ethereum client full node.", @@ -1319,8 +1320,21 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private Vertx vertx; private EnodeDnsConfiguration enodeDnsConfiguration; private KeyValueStorageProvider keyValueStorageProvider; + /** Sets GoQuorum compatibility mode. */ protected Boolean isGoQuorumCompatibilityMode = false; + /** + * Besu command constructor. + * + * @param logger Logger instance + * @param rlpBlockImporter RlpBlockImporter supplier + * @param jsonBlockImporterFactory instance of {@code Function} + * @param rlpBlockExporterFactory instance of {@code Function} + * @param runnerBuilder instance of RunnerBuilder + * @param controllerBuilderFactory instance of BesuController.Builder + * @param besuPluginContext instance of BesuPluginContextImpl + * @param environment Environment variables map + */ public BesuCommand( final Logger logger, final Supplier rlpBlockImporter, @@ -1347,6 +1361,24 @@ public class BesuCommand implements DefaultCommandValues, Runnable { new RpcEndpointServiceImpl()); } + /** + * Overloaded Besu command constructor visible for testing. + * + * @param logger Logger instance + * @param rlpBlockImporter RlpBlockImporter supplier + * @param jsonBlockImporterFactory instance of {@code Function} + * @param rlpBlockExporterFactory instance of {@code Function} + * @param runnerBuilder instance of RunnerBuilder + * @param controllerBuilderFactory instance of BesuController.Builder + * @param besuPluginContext instance of BesuPluginContextImpl + * @param environment Environment variables map + * @param storageService instance of StorageServiceImpl + * @param securityModuleService instance of SecurityModuleServiceImpl + * @param permissioningService instance of PermissioningServiceImpl + * @param privacyPluginService instance of PrivacyPluginServiceImpl + * @param pkiBlockCreationConfigProvider instance of PkiBlockCreationConfigurationProvider + * @param rpcEndpointServiceImpl instance of RpcEndpointServiceImpl + */ @VisibleForTesting protected BesuCommand( final Logger logger, @@ -1381,6 +1413,17 @@ public class BesuCommand implements DefaultCommandValues, Runnable { this.rpcEndpointServiceImpl = rpcEndpointServiceImpl; } + /** + * Parse Besu command line arguments. Visible for testing. + * + * @param resultHandler execution strategy. See PicoCLI. Typical argument is RunLast. + * @param parameterExceptionHandler Exception handler for handling parameters + * @param executionExceptionHandler Exception handler for business logic + * @param in Standard input stream + * @param args arguments to Besu command + * @return success or failure exit code. + */ + @VisibleForTesting public int parse( final IExecutionStrategy resultHandler, final BesuParameterExceptionHandler parameterExceptionHandler, @@ -1581,6 +1624,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } // loadKeyPair() is public because it is accessed by subcommands + + /** + * Load key pair from private key. Visible to be accessed by subcommands. + * + * @param nodePrivateKeyFile File containing private key + * @return KeyPair loaded from private key file + */ public KeyPair loadKeyPair(final File nodePrivateKeyFile) { return KeyPairUtil.loadKeyPair(resolveNodePrivateKeyFile(nodePrivateKeyFile)); } @@ -1722,6 +1772,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .labels(() -> 1, BesuInfo.version()); } + /** + * Configure logging framework for Besu + * + * @param announce sets to true to print the logging level on standard output + */ public void configureLogging(final boolean announce) { // To change the configuration if color was enabled/disabled Log4j2ConfiguratorUtil.reconfigure(); @@ -1735,6 +1790,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } + /** + * Logging in Color enabled or not. + * + * @return Optional true or false representing logging color is enabled. Empty if not set. + */ public static Optional getColorEnabled() { return Optional.ofNullable(colorEnabled); } @@ -1826,6 +1886,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } + /** + * Validates P2P interface IP address/host name. Visible for testing. + * + * @param p2pInterface IP Address/host name + */ protected void validateP2PInterface(final String p2pInterface) { final String failMessage = "The provided --p2p-interface is not available: " + p2pInterface; try { @@ -1890,7 +1955,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } - public void validateRpcOptionsParams() { + private void validateRpcOptionsParams() { final Predicate configuredApis = apiName -> Arrays.stream(RpcApis.values()) @@ -1936,7 +2001,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } - public void validateChainDataPruningParams() { + private void validateChainDataPruningParams() { if (unstableChainPruningOptions.getChainDataPruningEnabled() && unstableChainPruningOptions.getChainDataPruningBlocksRetained() < ChainPruningOptions.DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED) { @@ -2156,6 +2221,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { besuController = buildController(); } + /** + * Builds BesuController + * + * @return instance of BesuController + */ public BesuController buildController() { try { return getControllerBuilder().build(); @@ -2164,6 +2234,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } + /** + * Builds BesuControllerBuilder which can be used to build BesuController + * + * @return instance of BesuControllerBuilder + */ public BesuControllerBuilder getControllerBuilder() { final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName); return controllerBuilderFactory @@ -2517,6 +2592,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .build(); } + /** + * Metrics Configuration for Besu + * + * @return instance of MetricsConfiguration. + */ public MetricsConfiguration metricsConfiguration() { if (metricsOptionGroup.isMetricsEnabled && metricsOptionGroup.isMetricsPushEnabled) { throw new ParameterException( @@ -2798,7 +2878,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return privacyParameters; } - public WorldStateArchive createPrivateWorldStateArchive(final StorageProvider storageProvider) { + private WorldStateArchive createPrivateWorldStateArchive(final StorageProvider storageProvider) { final WorldStateStorage privateWorldStateStorage = storageProvider.createPrivateWorldStateStorage(); final WorldStatePreimageStorage preimageStorage = @@ -2956,6 +3036,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return runner; } + /** + * Builds Vertx instance from VertxOptions. Visible for testing. + * + * @param vertxOptions Instance of VertxOptions + * @return Instance of Vertx. + */ + @VisibleForTesting protected Vertx createVertx(final VertxOptions vertxOptions) { return Vertx.vertx(vertxOptions); } @@ -3082,7 +3169,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } - // dataDir() is public because it is accessed by subcommands + /** + * Returns data directory used by Besu. Visible as it is accessed by other subcommands. + * + * @return Path representing data directory. + */ public Path dataDir() { return dataPath.toAbsolutePath(); } @@ -3132,6 +3223,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { + DefaultCommandValues.PERMISSIONING_CONFIG_LOCATION; } + /** + * Metrics System used by Besu + * + * @return Instance of MetricsSystem + */ public MetricsSystem getMetricsSystem() { return metricsSystem.get(); } @@ -3160,14 +3256,31 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .collect(Collectors.toList()); } + /** + * Besu CLI Paramaters exception handler used by VertX. Visible for testing. + * + * @return instance of BesuParameterExceptionHandler + */ + @VisibleForTesting public BesuParameterExceptionHandler parameterExceptionHandler() { return new BesuParameterExceptionHandler(this::getLogLevel); } + /** + * Returns BesuExecutionExceptionHandler. Visible as it is used in testing. + * + * @return instance of BesuExecutionExceptionHandler used by Vertx. + */ public BesuExecutionExceptionHandler executionExceptionHandler() { return new BesuExecutionExceptionHandler(); } + /** + * Represents Enode DNS Configuration. Visible for testing. + * + * @return instance of EnodeDnsConfiguration + */ + @VisibleForTesting public EnodeDnsConfiguration getEnodeDnsConfiguration() { if (enodeDnsConfiguration == null) { enodeDnsConfiguration = unstableDnsOptions.toDomainObject(); @@ -3191,6 +3304,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { }); } + /** + * Check if required ports are available + * + * @throws InvalidConfigurationException if ports are not available. + */ protected void checkIfRequiredPortsAreAvailable() { final List unavailablePorts = new ArrayList<>(); getEffectivePorts().stream() @@ -3343,6 +3461,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return genesisConfigOptions.getEcCurve(); } + /** Enables Go Quorum Compatibility mode. Visible for testing. */ + @VisibleForTesting protected void enableGoQuorumCompatibilityMode() { // this static flag is read by the RLP decoder GoQuorumOptions.setGoQuorumCompatibilityMode(true); @@ -3415,7 +3535,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return engineRPCOptionGroup.overrideEngineRpcEnabled || isMergeEnabled(); } - public static List getJDKEnabledCipherSuites() { + private static List getJDKEnabledCipherSuites() { try { final SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); @@ -3426,7 +3546,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } } - public static List getJDKEnabledProtocols() { + private static List getJDKEnabledProtocols() { try { final SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index ea1ccd5df..546f4f83c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -26,6 +26,7 @@ import oshi.PlatformEnum; import oshi.SystemInfo; import oshi.hardware.HardwareAbstractionLayer; +/** The Configuration overview builder. */ public class ConfigurationOverviewBuilder { private String network; private String dataStorage; @@ -36,46 +37,98 @@ public class ConfigurationOverviewBuilder { private Collection engineApis; private boolean isHighSpec = false; + /** + * Sets network. + * + * @param network the network + * @return the network + */ public ConfigurationOverviewBuilder setNetwork(final String network) { this.network = network; return this; } + /** + * Sets data storage. + * + * @param dataStorage the data storage + * @return the data storage + */ public ConfigurationOverviewBuilder setDataStorage(final String dataStorage) { this.dataStorage = dataStorage; return this; } + /** + * Sets sync mode. + * + * @param syncMode the sync mode + * @return the sync mode + */ public ConfigurationOverviewBuilder setSyncMode(final String syncMode) { this.syncMode = syncMode; return this; } + /** + * Sets rpc port. + * + * @param rpcPort the rpc port + * @return the rpc port + */ public ConfigurationOverviewBuilder setRpcPort(final Integer rpcPort) { this.rpcPort = rpcPort; return this; } + /** + * Sets rpc http apis. + * + * @param rpcHttpApis the rpc http apis + * @return the rpc http apis + */ public ConfigurationOverviewBuilder setRpcHttpApis(final Collection rpcHttpApis) { this.rpcHttpApis = rpcHttpApis; return this; } + /** + * Sets engine port. + * + * @param enginePort the engine port + * @return the engine port + */ public ConfigurationOverviewBuilder setEnginePort(final Integer enginePort) { this.enginePort = enginePort; return this; } + /** + * Sets engine apis. + * + * @param engineApis the engine apis + * @return the engine apis + */ public ConfigurationOverviewBuilder setEngineApis(final Collection engineApis) { this.engineApis = engineApis; return this; } + /** + * Sets high spec enabled. + * + * @return the high spec enabled + */ public ConfigurationOverviewBuilder setHighSpecEnabled() { isHighSpec = true; return this; } + /** + * Build configuration overview. + * + * @return the string representing configuration overview + */ public String build() { final List lines = new ArrayList<>(); lines.add("Besu " + BesuInfo.class.getPackage().getImplementationVersion()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java b/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java index 2ca3b5d7a..490b433a9 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java @@ -32,43 +32,82 @@ import java.util.List; import org.apache.tuweni.bytes.Bytes; import picocli.CommandLine; +/** The interface Default command values. */ public interface DefaultCommandValues { + /** The constant CONFIG_FILE_OPTION_NAME. */ String CONFIG_FILE_OPTION_NAME = "--config-file"; + /** The constant MANDATORY_PATH_FORMAT_HELP. */ String MANDATORY_PATH_FORMAT_HELP = ""; + /** The constant MANDATORY_FILE_FORMAT_HELP. */ String MANDATORY_FILE_FORMAT_HELP = ""; + /** The constant MANDATORY_DIRECTORY_FORMAT_HELP. */ String MANDATORY_DIRECTORY_FORMAT_HELP = ""; + /** The constant BESU_HOME_PROPERTY_NAME. */ String BESU_HOME_PROPERTY_NAME = "besu.home"; + /** The constant DEFAULT_DATA_DIR_PATH. */ String DEFAULT_DATA_DIR_PATH = "./build/data"; + /** The constant MANDATORY_INTEGER_FORMAT_HELP. */ String MANDATORY_INTEGER_FORMAT_HELP = ""; + /** The constant MANDATORY_DOUBLE_FORMAT_HELP. */ String MANDATORY_DOUBLE_FORMAT_HELP = ""; + /** The constant MANDATORY_LONG_FORMAT_HELP. */ String MANDATORY_LONG_FORMAT_HELP = ""; + /** The constant MANDATORY_MODE_FORMAT_HELP. */ String MANDATORY_MODE_FORMAT_HELP = ""; + /** The constant MANDATORY_NETWORK_FORMAT_HELP. */ String MANDATORY_NETWORK_FORMAT_HELP = ""; + /** The constant MANDATORY_NODE_ID_FORMAT_HELP. */ String MANDATORY_NODE_ID_FORMAT_HELP = ""; + /** The constant DEFAULT_MIN_TRANSACTION_GAS_PRICE. */ Wei DEFAULT_MIN_TRANSACTION_GAS_PRICE = Wei.of(1000); + /** The constant DEFAULT_RPC_TX_FEE_CAP. */ Wei DEFAULT_RPC_TX_FEE_CAP = TransactionPoolConfiguration.DEFAULT_RPC_TX_FEE_CAP; + /** The constant DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO. */ Double DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO = 0.8; + /** The constant DEFAULT_EXTRA_DATA. */ Bytes DEFAULT_EXTRA_DATA = Bytes.EMPTY; + /** The constant PERMISSIONING_CONFIG_LOCATION. */ String PERMISSIONING_CONFIG_LOCATION = "permissions_config.toml"; + /** The constant MANDATORY_HOST_FORMAT_HELP. */ String MANDATORY_HOST_FORMAT_HELP = ""; + /** The constant MANDATORY_PORT_FORMAT_HELP. */ String MANDATORY_PORT_FORMAT_HELP = ""; + /** The constant DEFAULT_NAT_METHOD. */ NatMethod DEFAULT_NAT_METHOD = NatMethod.AUTO; + /** The constant DEFAULT_JWT_ALGORITHM. */ JwtAlgorithm DEFAULT_JWT_ALGORITHM = JwtAlgorithm.RS256; + /** The constant FAST_SYNC_MIN_PEER_COUNT. */ int FAST_SYNC_MIN_PEER_COUNT = 5; + /** The constant DEFAULT_MAX_PEERS. */ int DEFAULT_MAX_PEERS = 25; + /** The constant DEFAULT_P2P_PEER_LOWER_BOUND. */ int DEFAULT_P2P_PEER_LOWER_BOUND = 25; + /** The constant DEFAULT_HTTP_MAX_CONNECTIONS. */ int DEFAULT_HTTP_MAX_CONNECTIONS = 80; + /** The constant DEFAULT_WS_MAX_CONNECTIONS. */ int DEFAULT_WS_MAX_CONNECTIONS = 80; + /** The constant DEFAULT_WS_MAX_FRAME_SIZE. */ int DEFAULT_WS_MAX_FRAME_SIZE = 1024 * 1024; + /** The constant DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED. */ float DEFAULT_FRACTION_REMOTE_WIRE_CONNECTIONS_ALLOWED = RlpxConfiguration.DEFAULT_FRACTION_REMOTE_CONNECTIONS_ALLOWED; + /** The constant DEFAULT_KEY_VALUE_STORAGE_NAME. */ String DEFAULT_KEY_VALUE_STORAGE_NAME = "rocksdb"; + /** The constant DEFAULT_SECURITY_MODULE. */ String DEFAULT_SECURITY_MODULE = "localfile"; + /** The constant DEFAULT_KEYSTORE_TYPE. */ String DEFAULT_KEYSTORE_TYPE = "JKS"; + /** The Default tls protocols. */ List DEFAULT_TLS_PROTOCOLS = List.of("TLSv1.3", "TLSv1.2"); + /** + * Gets default besu data path. + * + * @param command the command + * @return the default besu data path + */ static Path getDefaultBesuDataPath(final Object command) { // this property is retrieved from Gradle tasks or Besu running shell script. final String besuHomeProperty = System.getProperty(BESU_HOME_PROPERTY_NAME); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java b/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java index cc771dd74..10c97d6a5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/NetworkDeprecationMessage.java @@ -19,8 +19,15 @@ import org.hyperledger.besu.util.log.FramedLogMessage; import java.util.List; +/** The Network deprecation message. */ public class NetworkDeprecationMessage { + /** + * Generate deprecation message for specified testnet network. + * + * @param network the network + * @return the deprecation message for specified network + */ public static String generate(final NetworkName network) { if (network.getDeprecationDate().isEmpty()) { throw new AssertionError("Deprecation date is not set. Cannot print a deprecation message"); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java index da5af5142..3af85016c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java @@ -30,6 +30,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; +/** The Eth network config. */ public class EthNetworkConfig { private final String genesisConfig; @@ -37,6 +38,14 @@ public class EthNetworkConfig { private final List bootNodes; private final String dnsDiscoveryUrl; + /** + * Instantiates a new Eth network config. + * + * @param genesisConfig the genesis config + * @param networkId the network id + * @param bootNodes the boot nodes + * @param dnsDiscoveryUrl the dns discovery url + */ public EthNetworkConfig( final String genesisConfig, final BigInteger networkId, @@ -50,18 +59,38 @@ public class EthNetworkConfig { this.dnsDiscoveryUrl = dnsDiscoveryUrl; } + /** + * Gets genesis config. + * + * @return the genesis config + */ public String getGenesisConfig() { return genesisConfig; } + /** + * Gets network id. + * + * @return the network id + */ public BigInteger getNetworkId() { return networkId; } + /** + * Gets boot nodes. + * + * @return the boot nodes + */ public List getBootNodes() { return bootNodes; } + /** + * Gets dns discovery url. + * + * @return the dns discovery url + */ public String getDnsDiscoveryUrl() { return dnsDiscoveryUrl; } @@ -100,6 +129,12 @@ public class EthNetworkConfig { + '}'; } + /** + * Gets network config. + * + * @param networkName the network name + * @return the network config + */ public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) { final String genesisContent = jsonConfig(networkName.getGenesisFile()); final GenesisConfigOptions genesisConfigOptions = @@ -128,10 +163,17 @@ public class EthNetworkConfig { } } + /** + * Json config string. + * + * @param network the network + * @return the string + */ public static String jsonConfig(final NetworkName network) { return jsonConfig(network.getGenesisFile()); } + /** The type Builder. */ public static class Builder { private String dnsDiscoveryUrl; @@ -139,6 +181,11 @@ public class EthNetworkConfig { private BigInteger networkId; private List bootNodes; + /** + * Instantiates a new Builder. + * + * @param ethNetworkConfig the eth network config + */ public Builder(final EthNetworkConfig ethNetworkConfig) { this.genesisConfig = ethNetworkConfig.genesisConfig; this.networkId = ethNetworkConfig.networkId; @@ -146,26 +193,55 @@ public class EthNetworkConfig { this.dnsDiscoveryUrl = ethNetworkConfig.dnsDiscoveryUrl; } + /** + * Sets genesis config. + * + * @param genesisConfig the genesis config + * @return the genesis config + */ public Builder setGenesisConfig(final String genesisConfig) { this.genesisConfig = genesisConfig; return this; } + /** + * Sets network id. + * + * @param networkId the network id + * @return the network id + */ public Builder setNetworkId(final BigInteger networkId) { this.networkId = networkId; return this; } + /** + * Sets boot nodes. + * + * @param bootNodes the boot nodes + * @return the boot nodes + */ public Builder setBootNodes(final List bootNodes) { this.bootNodes = bootNodes; return this; } + /** + * Sets dns discovery url. + * + * @param dnsDiscoveryUrl the dns discovery url + * @return the dns discovery url + */ public Builder setDnsDiscoveryUrl(final String dnsDiscoveryUrl) { this.dnsDiscoveryUrl = dnsDiscoveryUrl; return this; } + /** + * Build eth network config. + * + * @return the eth network config + */ public EthNetworkConfig build() { return new EthNetworkConfig(genesisConfig, networkId, bootNodes, dnsDiscoveryUrl); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java b/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java index c1f5e148c..7657037cb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java @@ -19,17 +19,29 @@ import java.util.Optional; import org.apache.commons.lang3.StringUtils; +/** The enum Network name. */ public enum NetworkName { + /** Mainnet network name. */ MAINNET("/mainnet.json", BigInteger.valueOf(1)), + /** Rinkeby network name. */ RINKEBY("/rinkeby.json", BigInteger.valueOf(4)), + /** Sepolia network name. */ SEPOLIA("/sepolia.json", BigInteger.valueOf(11155111)), + /** Goerli network name. */ GOERLI("/goerli.json", BigInteger.valueOf(5)), + /** Dev network name. */ DEV("/dev.json", BigInteger.valueOf(2018), false), + /** Future EIPs network name. */ FUTURE_EIPS("/future.json", BigInteger.valueOf(2022), false), + /** Experimental EIPs network name. */ EXPERIMENTAL_EIPS("/experimental.json", BigInteger.valueOf(2023), false), + /** Classic network name. */ CLASSIC("/classic.json", BigInteger.valueOf(1)), + /** Kotti network name. */ KOTTI("/kotti.json", BigInteger.valueOf(6)), + /** Mordor network name. */ MORDOR("/mordor.json", BigInteger.valueOf(7)), + /** Ecip 1049 dev network name. */ ECIP1049_DEV("/ecip1049_dev.json", BigInteger.valueOf(2021)); private final String genesisFile; @@ -62,26 +74,56 @@ public enum NetworkName { } } + /** + * Gets genesis file. + * + * @return the genesis file + */ public String getGenesisFile() { return genesisFile; } + /** + * Gets network id. + * + * @return the network id + */ public BigInteger getNetworkId() { return networkId; } + /** + * Can fast sync boolean. + * + * @return the boolean + */ public boolean canFastSync() { return canFastSync; } + /** + * Normalize string. + * + * @return the string + */ public String normalize() { return StringUtils.capitalize(name().toLowerCase()); } + /** + * Is deprecated boolean. + * + * @return the boolean + */ public boolean isDeprecated() { return deprecationDate != null; } + /** + * Gets deprecation date. + * + * @return the deprecation date + */ public Optional getDeprecationDate() { return Optional.ofNullable(deprecationDate); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/FractionConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/FractionConverter.java index e3fc06489..969a6be8e 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/FractionConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/FractionConverter.java @@ -19,6 +19,7 @@ import org.hyperledger.besu.util.number.Fraction; import picocli.CommandLine; +/** The Fraction converter to convert floats in CLI. */ public class FractionConverter implements CommandLine.ITypeConverter { @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java index 9752c6df2..684c3ce30 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java @@ -23,6 +23,7 @@ import java.util.Map; import com.google.common.annotations.VisibleForTesting; import picocli.CommandLine; +/** The Metric category converter for CLI options. */ public class MetricCategoryConverter implements CommandLine.ITypeConverter { private final Map metricCategories = new HashMap<>(); @@ -36,15 +37,31 @@ public class MetricCategoryConverter implements CommandLine.ITypeConverter the type parameter + * @param categoryEnum the category enum + */ public & MetricCategory> void addCategories(final Class categoryEnum) { EnumSet.allOf(categoryEnum) .forEach(category -> metricCategories.put(category.name(), category)); } + /** + * Add registry category. + * + * @param metricCategory the metric category + */ public void addRegistryCategory(final MetricCategory metricCategory) { metricCategories.put(metricCategory.getName().toUpperCase(), metricCategory); } + /** + * Gets metric categories. + * + * @return the metric categories + */ @VisibleForTesting Map getMetricCategories() { return metricCategories; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/PercentageConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/PercentageConverter.java index d1b4ad836..23a2d94d3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/PercentageConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/PercentageConverter.java @@ -19,6 +19,7 @@ import org.hyperledger.besu.util.number.Percentage; import picocli.CommandLine; +/** The Percentage Cli type converter. */ public class PercentageConverter implements CommandLine.ITypeConverter { @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/FractionConversionException.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/FractionConversionException.java index dd9082138..4dc3d446b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/FractionConversionException.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/FractionConversionException.java @@ -16,8 +16,14 @@ package org.hyperledger.besu.cli.converter.exception; import static java.lang.String.format; +/** The custom Fraction conversion exception. */ public final class FractionConversionException extends Exception { + /** + * Instantiates a new Fraction conversion exception. + * + * @param value the value + */ public FractionConversionException(final String value) { super(format("Invalid value: %s, should be a decimal between 0.0 and 1.0 inclusive.", value)); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PercentageConversionException.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PercentageConversionException.java index 42eab9494..f016996d2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PercentageConversionException.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/PercentageConversionException.java @@ -16,8 +16,14 @@ package org.hyperledger.besu.cli.converter.exception; import static java.lang.String.format; +/** The custom Percentage conversion exception. */ public final class PercentageConversionException extends Exception { + /** + * Instantiates a new Percentage conversion exception. + * + * @param value the invalid value to add in exception message + */ public PercentageConversionException(final String value) { super(format("Invalid value: %s, should be a number between 0 and 100 inclusive.", value)); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/RpcApisConversionException.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/RpcApisConversionException.java index 0de6ea638..8d58a1663 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/RpcApisConversionException.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/converter/exception/RpcApisConversionException.java @@ -16,8 +16,14 @@ package org.hyperledger.besu.cli.converter.exception; import static java.lang.String.format; +/** The custom Rpc Apis conversion exception. */ public final class RpcApisConversionException extends Exception { + /** + * Instantiates a new Rpc apis conversion exception. + * + * @param name the invalid Rpc Api name to report in exception message + */ public RpcApisConversionException(final String name) { super(format("Invalid value: %s", name)); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/custom/CorsAllowedOriginsProperty.java b/besu/src/main/java/org/hyperledger/besu/cli/custom/CorsAllowedOriginsProperty.java index 2b3a04b52..9bdb2599d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/custom/CorsAllowedOriginsProperty.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/custom/CorsAllowedOriginsProperty.java @@ -28,10 +28,12 @@ import javax.annotation.Nonnull; import com.google.common.base.Splitter; import com.google.common.base.Strings; +/** The Cors allowed origins property used in CLI */ public class CorsAllowedOriginsProperty extends AbstractList { private final List domains = new ArrayList<>(); + /** Instantiates a new Cors allowed origins property. */ public CorsAllowedOriginsProperty() {} @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/custom/EnodeToURIPropertyConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/custom/EnodeToURIPropertyConverter.java index b2bd34fdb..c51a1772d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/custom/EnodeToURIPropertyConverter.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/custom/EnodeToURIPropertyConverter.java @@ -22,14 +22,21 @@ import java.util.function.Function; import com.google.common.annotations.VisibleForTesting; import picocli.CommandLine.ITypeConverter; +/** The Enode to uri property converter. */ public class EnodeToURIPropertyConverter implements ITypeConverter { private final Function converter; + /** Instantiates a new Enode to uri property converter. */ EnodeToURIPropertyConverter() { this.converter = (s) -> EnodeURLImpl.fromString(s).toURI(); } + /** + * Instantiates a new Enode to uri property converter. + * + * @param converter the converter + */ @VisibleForTesting EnodeToURIPropertyConverter(final Function converter) { this.converter = converter; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/custom/JsonRPCAllowlistHostsProperty.java b/besu/src/main/java/org/hyperledger/besu/cli/custom/JsonRPCAllowlistHostsProperty.java index d99ba0b3b..6eec1f0ef 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/custom/JsonRPCAllowlistHostsProperty.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/custom/JsonRPCAllowlistHostsProperty.java @@ -25,10 +25,12 @@ import javax.annotation.Nonnull; import com.google.common.base.Splitter; import com.google.common.base.Strings; +/** The Json Rpc allowlist hosts list for CLI option. */ public class JsonRPCAllowlistHostsProperty extends AbstractList { private final List hostnamesAllowlist = new ArrayList<>(); + /** Instantiates a new Json rpc allowlist hosts property. */ public JsonRPCAllowlistHostsProperty() {} @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidator.java b/besu/src/main/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidator.java index d21227259..35c5bf138 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidator.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidator.java @@ -27,8 +27,17 @@ import org.apache.tuweni.toml.TomlParseResult; import picocli.CommandLine; import picocli.CommandLine.ParameterException; +/** The Rpc authentication file validator. */ public class RpcAuthFileValidator { + /** + * Validate auth file. + * + * @param commandLine the command line to use for parameter exceptions + * @param filename the auth file + * @param type the RPC type + * @return the auth filename + */ public static String validate( final CommandLine commandLine, final String filename, final String type) { diff --git a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java index 83b12bac8..77b458eb7 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuExecutionExceptionHandler.java @@ -18,6 +18,7 @@ import picocli.CommandLine; import picocli.CommandLine.IExecutionExceptionHandler; import picocli.CommandLine.Model.CommandSpec; +/** Custom Execution Exception Handler used by PicoCLI framework. */ public class BesuExecutionExceptionHandler implements IExecutionExceptionHandler { @Override public int handleExecutionException( diff --git a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuParameterExceptionHandler.java b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuParameterExceptionHandler.java index 03bf38d27..54fa2504b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/error/BesuParameterExceptionHandler.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/error/BesuParameterExceptionHandler.java @@ -21,10 +21,16 @@ import org.apache.logging.log4j.Level; import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; +/** The custom parameter exception handler for Besu PicoCLI. */ public class BesuParameterExceptionHandler implements CommandLine.IParameterExceptionHandler { private final Supplier levelSupplier; + /** + * Instantiates a new Besu parameter exception handler. + * + * @param levelSupplier the logging level supplier + */ public BesuParameterExceptionHandler(final Supplier levelSupplier) { this.levelSupplier = levelSupplier; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/logging/BesuLoggingConfigurationFactory.java b/besu/src/main/java/org/hyperledger/besu/cli/logging/BesuLoggingConfigurationFactory.java index f7e593a82..c4af7e23b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/logging/BesuLoggingConfigurationFactory.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/logging/BesuLoggingConfigurationFactory.java @@ -19,6 +19,7 @@ import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.ConfigurationFactory; import org.apache.logging.log4j.core.config.ConfigurationSource; +/** Custom Log4J Configuration Factory for Besu */ public class BesuLoggingConfigurationFactory extends ConfigurationFactory { @Override diff --git a/besu/src/main/java/org/hyperledger/besu/cli/logging/XmlExtensionConfiguration.java b/besu/src/main/java/org/hyperledger/besu/cli/logging/XmlExtensionConfiguration.java index 69caa01a8..d2ae7071b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/logging/XmlExtensionConfiguration.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/logging/XmlExtensionConfiguration.java @@ -29,8 +29,15 @@ import org.apache.logging.log4j.core.layout.PatternLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** The Xml extension configuration for Logging framework. */ public class XmlExtensionConfiguration extends XmlConfiguration { + /** + * Instantiates a new Xml extension configuration. + * + * @param loggerContext the logger context + * @param configSource the Configuration Source + */ public XmlExtensionConfiguration( final LoggerContext loggerContext, final ConfigurationSource configSource) { super(loggerContext, configSource); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/OptionParser.java b/besu/src/main/java/org/hyperledger/besu/cli/options/OptionParser.java index 76d5b2695..73161742f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/OptionParser.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/OptionParser.java @@ -22,34 +22,77 @@ import com.google.common.base.Splitter; import com.google.common.collect.Range; import org.apache.tuweni.units.bigints.UInt256; +/** The Option parser. */ public class OptionParser { + /** + * Parse long range range. + * + * @param arg the arg + * @return the range + */ public static Range parseLongRange(final String arg) { checkArgument(arg.matches("-?\\d+\\.\\.-?\\d+")); final Iterator ends = Splitter.on("..").split(arg).iterator(); return Range.closed(parseLong(ends.next()), parseLong(ends.next())); } + /** + * Parse long from String. + * + * @param arg long value to parse from String + * @return the long + */ public static long parseLong(final String arg) { return Long.parseLong(arg, 10); } + /** + * Format Long values range. + * + * @param range the range + * @return the string + */ public static String format(final Range range) { return format(range.lowerEndpoint()) + ".." + format(range.upperEndpoint()); } + /** + * Format int to String. + * + * @param value the value + * @return the string + */ public static String format(final int value) { return Integer.toString(value, 10); } + /** + * Format long to String. + * + * @param value the value + * @return the string + */ public static String format(final long value) { return Long.toString(value, 10); } + /** + * Format float to string. + * + * @param value the value + * @return the string + */ public static String format(final float value) { return Float.toString(value); } + /** + * Format UInt256 to string. + * + * @param value the value + * @return the string + */ public static String format(final UInt256 value) { return value.toBigInteger().toString(10); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java index 1a97bb837..e3bbbe290 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java @@ -29,6 +29,7 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import picocli.CommandLine.Option; +/** The Data storage CLI options. */ public class DataStorageOptions implements CLIOptions { private static final String DATA_STORAGE_FORMAT = "--data-storage-format"; @@ -63,6 +64,11 @@ public class DataStorageOptions implements CLIOptions arity = "1") private final Boolean bonsaiUseSnapshots = DEFAULT_BONSAI_USE_SNAPSHOTS; + /** + * Create data storage options. + * + * @return the data storage options + */ public static DataStorageOptions create() { return new DataStorageOptions(); } @@ -87,6 +93,11 @@ public class DataStorageOptions implements CLIOptions bonsaiUseSnapshots.toString()); } + /** + * Normalize data storage format string. + * + * @return the normalized string + */ public String normalizeDataStorageFormat() { return StringUtils.capitalize(dataStorageFormat.toString().toLowerCase()); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java index bfd1ff800..10ffe4865 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java @@ -22,6 +22,7 @@ import java.util.List; import picocli.CommandLine; +/** The Ethstats CLI options. */ public class EthstatsOptions implements CLIOptions { private static final String ETHSTATS = "--ethstats"; @@ -44,6 +45,11 @@ public class EthstatsOptions implements CLIOptions { private EthstatsOptions() {} + /** + * Create ethstats options. + * + * @return the ethstats options + */ public static EthstatsOptions create() { return new EthstatsOptions(); } @@ -53,10 +59,20 @@ public class EthstatsOptions implements CLIOptions { return NetstatsUrl.fromParams(ethstatsUrl, ethstatsContact); } + /** + * Gets ethstats url. + * + * @return the ethstats url + */ public String getEthstatsUrl() { return ethstatsUrl; } + /** + * Gets ethstats contact. + * + * @return the ethstats contact + */ public String getEthstatsContact() { return ethstatsContact; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java index 4b7bb0051..4eba5b74c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java @@ -21,17 +21,30 @@ import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Spec; +/** The Logging level CLI option. */ public class LoggingLevelOption { + /** + * Create logging level option. + * + * @return the logging level option + */ public static LoggingLevelOption create() { return new LoggingLevelOption(); } private static final Set ACCEPTED_VALUES = Set.of("OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"); + /** The Picocli CommandSpec. Visible for testing. Injected by Picocli framework at runtime. */ @Spec CommandSpec spec; + private Level logLevel; + /** + * Sets log level. + * + * @param logLevel the log level + */ @CommandLine.Option( names = {"--logging", "-l"}, paramLabel = "", @@ -48,6 +61,11 @@ public class LoggingLevelOption { } } + /** + * Gets log level. + * + * @return the log level + */ public Level getLogLevel() { return logLevel; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java index 4125efa3e..42789627d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java @@ -20,8 +20,14 @@ import java.io.File; import picocli.CommandLine; +/** The Node private key file Cli option. */ public class NodePrivateKeyFileOption { + /** + * Create node private key file option. + * + * @return the node private key file option + */ public static NodePrivateKeyFileOption create() { return new NodePrivateKeyFileOption(); } @@ -33,6 +39,11 @@ public class NodePrivateKeyFileOption { "The node's private key file (default: a file named \"key\" in the Besu data directory)") private final File nodePrivateKeyFile = null; + /** + * Gets node private key file. + * + * @return the node private key file + */ public File getNodePrivateKeyFile() { return nodePrivateKeyFile; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PTLSConfigOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PTLSConfigOptions.java index 3ae6583b3..8c5fea8ba 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PTLSConfigOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PTLSConfigOptions.java @@ -30,6 +30,7 @@ import picocli.CommandLine; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; +/** The P2P TLS Config Cli Options. */ public class P2PTLSConfigOptions { @Option( names = {"--Xp2p-tls-enabled"}, @@ -95,6 +96,12 @@ public class P2PTLSConfigOptions { description = "Certificate revocation list for the P2P service.") private final Path p2pCrlFile = null; + /** + * Generate P2p tls configuration. + * + * @param commandLine the command line object to report exceptions + * @return the optional TLSConfiguration + */ public Optional p2pTLSConfiguration(final CommandLine commandLine) { if (!p2pTLSEnabled) { return Optional.empty(); @@ -128,6 +135,12 @@ public class P2PTLSConfigOptions { .build()); } + /** + * Check P2P Tls options dependencies. + * + * @param logger the logger + * @param commandLine the command line + */ public void checkP2PTLSOptionsDependencies(final Logger logger, final CommandLine commandLine) { CommandLineUtils.checkOptionDependencies( logger, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java index 5b90e9281..e164ec8fa 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java @@ -24,12 +24,15 @@ import java.util.List; import picocli.CommandLine; +/** The Chain pruning CLI options. */ public class ChainPruningOptions implements CLIOptions { private static final String CHAIN_PRUNING_ENABLED_FLAG = "--Xchain-pruning-enabled"; private static final String CHAIN_PRUNING_BLOCKS_RETAINED_FLAG = "--Xchain-pruning-blocks-retained"; private static final String CHAIN_PRUNING_FREQUENCY_FLAG = "--Xchain-pruning-frequency"; + /** The constant DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED. */ public static final long DEFAULT_CHAIN_DATA_PRUNING_MIN_BLOCKS_RETAINED = 7200; + /** The constant DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY. */ public static final int DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY = 256; @CommandLine.Option( @@ -57,14 +60,29 @@ public class ChainPruningOptions implements CLIOptions private final PositiveNumber chainDataPruningBlocksFrequency = PositiveNumber.fromInt(DEFAULT_CHAIN_DATA_PRUNING_FREQUENCY); + /** + * Create chain pruning options. + * + * @return the chain pruning options + */ public static ChainPruningOptions create() { return new ChainPruningOptions(); } + /** + * Gets chain data pruning enabled. + * + * @return the chain data pruning enabled + */ public Boolean getChainDataPruningEnabled() { return chainDataPruningEnabled; } + /** + * Gets chain data pruning blocks retained. + * + * @return the chain data pruning blocks retained + */ public Long getChainDataPruningBlocksRetained() { return chainDataPruningBlocksRetained; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java index 8926ea38d..8d65a3264 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java @@ -23,6 +23,7 @@ import java.util.List; import picocli.CommandLine; +/** The Dns CLI options. */ public class DnsOptions implements CLIOptions { private final String DNS_ENABLED = "--Xdns-enabled"; @@ -42,10 +43,21 @@ public class DnsOptions implements CLIOptions { arity = "1") private Boolean dnsUpdateEnabled = Boolean.FALSE; + /** + * Create dns options. + * + * @return the dns options + */ public static DnsOptions create() { return new DnsOptions(); } + /** + * From config dns options. + * + * @param enodeDnsConfiguration the enode dns configuration + * @return the dns options + */ public static DnsOptions fromConfig(final EnodeDnsConfiguration enodeDnsConfiguration) { final DnsOptions cliOptions = new DnsOptions(); cliOptions.dnsEnabled = enodeDnsConfiguration.dnsEnabled(); @@ -53,10 +65,20 @@ public class DnsOptions implements CLIOptions { return cliOptions; } + /** + * Gets dns enabled. + * + * @return the dns enabled + */ public Boolean getDnsEnabled() { return dnsEnabled; } + /** + * Gets dns update enabled. + * + * @return the dns update enabled + */ public Boolean getDnsUpdateEnabled() { return dnsUpdateEnabled; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java index 70fa369c8..1d5434ff0 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java @@ -24,6 +24,7 @@ import java.util.List; import picocli.CommandLine; +/** The Eth protocol CLI options. */ public class EthProtocolOptions implements CLIOptions { private static final String MAX_MESSAGE_SIZE_FLAG = "--Xeth-max-message-size"; private static final String MAX_GET_HEADERS_FLAG = "--Xewp-max-get-headers"; @@ -114,10 +115,21 @@ public class EthProtocolOptions implements CLIOptions private EthProtocolOptions() {} + /** + * Create eth protocol options. + * + * @return the eth protocol options + */ public static EthProtocolOptions create() { return new EthProtocolOptions(); } + /** + * From config eth protocol options. + * + * @param config the config + * @return the eth protocol options + */ public static EthProtocolOptions fromConfig(final EthProtocolConfiguration config) { final EthProtocolOptions options = create(); options.maxMessageSize = PositiveNumber.fromInt(config.getMaxMessageSize()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java index d5a4f8b79..7e787cf83 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java @@ -23,10 +23,17 @@ import java.util.List; import picocli.CommandLine; +/** The Evm CLI options. */ public class EvmOptions implements CLIOptions { + /** The constant JUMPDEST_CACHE_WEIGHT. */ public static final String JUMPDEST_CACHE_WEIGHT = "--Xevm-jumpdest-cache-weight-kb"; + /** + * Create evm options. + * + * @return the evm options + */ public static EvmOptions create() { return new EvmOptions(); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java index 580af54cd..d8b868ef9 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java @@ -21,13 +21,25 @@ import java.util.List; import picocli.CommandLine; +/** The Ipc CLI options. */ public class IpcOptions { private static final String DEFAULT_IPC_FILE = "besu.ipc"; + /** + * Create ipc options. + * + * @return the ipc options + */ public static IpcOptions create() { return new IpcOptions(); } + /** + * Gets default path. + * + * @param dataDir the data dir + * @return the default path + */ public static Path getDefaultPath(final Path dataDir) { return dataDir.resolve(DEFAULT_IPC_FILE); } @@ -57,14 +69,29 @@ public class IpcOptions { "Comma separated list of APIs to enable on JSON-RPC IPC service (default: ${DEFAULT-VALUE})") private final List rpcIpcApis = DEFAULT_RPC_APIS; + /** + * Whether IPC options are enabled. + * + * @return true for enabled, false otherwise. + */ public Boolean isEnabled() { return enabled; } + /** + * Gets ipc path. + * + * @return the ipc path + */ public Path getIpcPath() { return ipcPath; } + /** + * Gets rpc ipc apis. + * + * @return the rpc ipc apis + */ public List getRpcIpcApis() { return rpcIpcApis; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/LauncherOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/LauncherOptions.java index 7c01c1a89..17352f347 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/LauncherOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/LauncherOptions.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.cli.options.unstable; import net.consensys.quorum.mainnet.launcher.options.Options; import picocli.CommandLine; +/** The Launcher CLI options. */ public class LauncherOptions implements Options { private static final String LAUNCHER_OPTION_NAME = "--Xlauncher"; @@ -40,14 +41,29 @@ public class LauncherOptions implements Options { arity = "0..1") private Boolean isLauncherModeForced = Boolean.FALSE; + /** + * Create launcher options. + * + * @return the launcher options + */ public static LauncherOptions create() { return new LauncherOptions(); } + /** + * Is launcher mode enabled. + * + * @return true if enabled, false otherwise. + */ public boolean isLauncherMode() { return isLauncherMode; } + /** + * Is launcher mode forced enabled. + * + * @return true if enabled, false otherwise. + */ public boolean isLauncherModeForced() { return isLauncherModeForced; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MetricsCLIOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MetricsCLIOptions.java index 5e9fe5b0e..45270c808 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MetricsCLIOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/MetricsCLIOptions.java @@ -22,6 +22,7 @@ import java.util.List; import picocli.CommandLine; +/** The Metrics cli options. */ public class MetricsCLIOptions implements CLIOptions { private static final String TIMERS_ENABLED_FLAG = "--Xmetrics-timers-enabled"; private static final String IDLE_TIMEOUT_FLAG = "--Xmetrics-idle-timeout"; @@ -43,10 +44,21 @@ public class MetricsCLIOptions implements CLIOptions { private final String INITIATE_CONNECTIONS_FREQUENCY_FLAG = "--Xp2p-initiate-connections-frequency"; @@ -33,6 +34,7 @@ public class NetworkingOptions implements CLIOptions { private final String DNS_DISCOVERY_SERVER_OVERRIDE_FLAG = "--Xp2p-dns-discovery-server"; private final String DISCOVERY_PROTOCOL_V5_ENABLED = "--Xv5-discovery-enabled"; private final String P2P_PEER_LOWER_BOUND_FLAG = "--Xp2p-peer-lower-bound"; + /** The constant FILTER_ON_ENR_FORK_ID. */ public static final String FILTER_ON_ENR_FORK_ID = "--Xfilter-on-enr-fork-id"; @CommandLine.Option( @@ -85,10 +87,21 @@ public class NetworkingOptions implements CLIOptions { private NetworkingOptions() {} + /** + * Create networking options. + * + * @return the networking options + */ public static NetworkingOptions create() { return new NetworkingOptions(); } + /** + * Create networking options from Networking Configuration. + * + * @param networkingConfig the networking config + * @return the networking options + */ public static NetworkingOptions fromConfig(final NetworkingConfiguration networkingConfig) { final NetworkingOptions cliOptions = new NetworkingOptions(); cliOptions.checkMaintainedConnectionsFrequencySec = diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java index 76361c416..e3673a1ab 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PkiBlockCreationOptions.java @@ -29,14 +29,17 @@ import picocli.CommandLine; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; +/** The Pki block creation Cli options. */ public class PkiBlockCreationOptions { + /** The pki block creation enabled. */ @Option( names = {"--Xpki-block-creation-enabled"}, hidden = true, description = "Enable PKI integration (default: ${DEFAULT-VALUE})") Boolean enabled = false; + /** The Key store type. */ @Option( names = {"--Xpki-block-creation-keystore-type"}, hidden = true, @@ -45,6 +48,7 @@ public class PkiBlockCreationOptions { @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) String keyStoreType = PkiKeyStoreConfiguration.DEFAULT_KEYSTORE_TYPE; + /** The Key store file. */ @Option( names = {"--Xpki-block-creation-keystore-file"}, hidden = true, @@ -52,6 +56,7 @@ public class PkiBlockCreationOptions { description = "Keystore containing key/certificate for PKI Block Creation.") Path keyStoreFile = null; + /** The Key store password file. */ @Option( names = {"--Xpki-block-creation-keystore-password-file"}, hidden = true, @@ -60,6 +65,7 @@ public class PkiBlockCreationOptions { "File containing password to unlock keystore for PKI Integration. Required if PKI Block Creation is enabled.") Path keyStorePasswordFile = null; + /** The Certificate alias. */ @Option( names = {"--Xpki-block-creation-keystore-certificate-alias"}, hidden = true, @@ -69,6 +75,7 @@ public class PkiBlockCreationOptions { @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) String certificateAlias = PkiKeyStoreConfiguration.DEFAULT_CERTIFICATE_ALIAS; + /** The Trust store type. */ @Option( names = {"--Xpki-block-creation-truststore-type"}, hidden = true, @@ -77,6 +84,7 @@ public class PkiBlockCreationOptions { @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) String trustStoreType = PkiKeyStoreConfiguration.DEFAULT_KEYSTORE_TYPE; + /** The Trust store file. */ @Option( names = {"--Xpki-block-creation-truststore-file"}, hidden = true, @@ -84,6 +92,7 @@ public class PkiBlockCreationOptions { description = "Truststore containing trusted certificates for PKI Block Creation.") Path trustStoreFile = null; + /** The Trust store password file. */ @Option( names = {"--Xpki-block-creation-truststore-password-file"}, hidden = true, @@ -91,6 +100,7 @@ public class PkiBlockCreationOptions { description = "File containing password to unlock truststore for PKI Block Creation.") Path trustStorePasswordFile = null; + /** The Crl file. */ @Option( names = {"--Xpki-block-creation-crl-file"}, hidden = true, @@ -98,6 +108,12 @@ public class PkiBlockCreationOptions { description = "File with all CRLs for PKI Block Creation.") Path crlFile = null; + /** + * As domain config optional. + * + * @param commandLine the command line + * @return the optional + */ public Optional asDomainConfig(final CommandLine commandLine) { if (!enabled) { return Optional.empty(); @@ -127,6 +143,12 @@ public class PkiBlockCreationOptions { .build()); } + /** + * Check pki block creation options dependencies. + * + * @param logger the logger + * @param commandLine the command line + */ public void checkPkiBlockCreationOptionsDependencies( final Logger logger, final CommandLine commandLine) { CommandLineUtils.checkOptionDependencies( diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java index 4854c9324..212d810f9 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java @@ -16,8 +16,14 @@ package org.hyperledger.besu.cli.options.unstable; import static picocli.CommandLine.Option; +/** The Privacy plugin Cli options. */ public class PrivacyPluginOptions { + /** + * Create privacy plugin options. + * + * @return the privacy plugin options + */ public static PrivacyPluginOptions create() { return new PrivacyPluginOptions(); } @@ -29,6 +35,11 @@ public class PrivacyPluginOptions { hidden = true) private final Boolean isPrivacyPluginEnabled = false; + /** + * Is privacy plugin enabled boolean. + * + * @return the boolean + */ public boolean isPrivacyPluginEnabled() { return isPrivacyPluginEnabled; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java index 11a185efb..3cb23655a 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions; import picocli.CommandLine; +/** The Rpc Cli options. */ public class RPCOptions { @CommandLine.Option( @@ -34,14 +35,29 @@ public class RPCOptions { arity = "1") private final Long wsTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds(); + /** + * Create rpc options. + * + * @return the rpc options + */ public static RPCOptions create() { return new RPCOptions(); } + /** + * Gets http timeout sec. + * + * @return the http timeout sec + */ public Long getHttpTimeoutSec() { return httpTimeoutSec; } + /** + * Gets WebSocket timeout sec. + * + * @return the WebSocket timeout sec + */ public Long getWsTimeoutSec() { return wsTimeoutSec; } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java index 0492bd8ba..7c7e08742 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java @@ -27,6 +27,7 @@ import com.google.common.collect.Range; import org.apache.tuweni.units.bigints.UInt256; import picocli.CommandLine; +/** The Synchronizer Cli options. */ public class SynchronizerOptions implements CLIOptions { private static final String BLOCK_PROPAGATION_RANGE_FLAG = "--Xsynchronizer-block-propagation-range"; @@ -74,6 +75,11 @@ public class SynchronizerOptions implements CLIOptions