From ed1329cf848a9d7858d039a55add810da3c428b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20L=C3=B3pez=20Le=C3=B3n?= Date: Tue, 25 Jan 2022 20:14:54 -0300 Subject: [PATCH] Introduce SLF4J for logging (#3285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump SLF4J version Signed-off-by: Diego López León * Replace log4j2 API with SLF4j API Signed-off-by: Diego López León * Replace usage of LogManager#getFormatterLogger This is for keeping compatibility with SLF4J. If neccesary, a specific formatter can be created for the RlpBlockImporter class Signed-off-by: Diego López León * Unset the default logging value for the retesteth This is because it's not possible to resolve the root logger level into a Log4J2 field Signed-off-by: Diego López León * Prevent creation of Logger context outside SLF4J org.hyperledger.besu.cli.BesuCommand#setAllLevels was taken from https://github.com/apache/logging-log4j2/blob/rel%2F2.17.1/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L309 Signed-off-by: Diego López León * Add FATAL level deprecation message Signed-off-by: Diego López León * [Sonar] Fix java:S2139 Exceptions should be either logged or rethrown but not both Signed-off-by: Diego López León * [Sonar] Fix java:S3457 Printf-style format strings should be used correctly Signed-off-by: Diego López León * Add changelog Signed-off-by: Diego López León --- CHANGELOG.md | 1 + acceptance-tests/dsl/build.gradle | 3 - .../acceptance/dsl/AcceptanceTestBase.java | 6 +- .../dsl/condition/process/ExitedWithCode.java | 6 +- .../tests/acceptance/dsl/node/BesuNode.java | 6 +- .../dsl/node/ProcessBesuNodeRunner.java | 14 +-- .../dsl/node/ThreadBesuNodeRunner.java | 16 +-- .../acceptance/dsl/node/cluster/Cluster.java | 6 +- .../dsl/privacy/PrivacyCluster.java | 6 +- .../acceptance/dsl/privacy/PrivacyNode.java | 6 +- acceptance-tests/test-plugins/build.gradle | 4 +- .../plugins/BadCLIOptionsPlugin.java | 6 +- .../plugins/TestBesuEventsPlugin.java | 6 +- .../plugins/TestPermissioningPlugin.java | 6 +- .../acceptance/plugins/TestPicoCLIPlugin.java | 6 +- .../plugins/TestPrivacyServicePlugin.java | 6 +- .../TestPrivacyPluginPayloadProvider.java | 6 +- ...igningPrivateMarkerTransactionFactory.java | 7 +- besu/build.gradle | 5 +- .../main/java/org/hyperledger/besu/Besu.java | 15 +-- .../java/org/hyperledger/besu/Runner.java | 12 +- .../org/hyperledger/besu/RunnerBuilder.java | 6 +- .../besu/chainexport/BlockExporter.java | 6 +- .../besu/chainimport/JsonBlockImporter.java | 6 +- .../besu/chainimport/RlpBlockImporter.java | 8 +- .../org/hyperledger/besu/cli/BesuCommand.java | 23 ++-- .../logging/XmlExtensionConfiguration.java | 9 +- .../options/stable/LoggingLevelOption.java | 44 ++++++++ .../options/stable/P2PTLSConfigOptions.java | 2 +- .../unstable/PkiBlockCreationOptions.java | 2 +- .../cli/subcommands/PublicKeySubCommand.java | 6 +- .../cli/subcommands/RetestethSubCommand.java | 22 ++-- .../subcommands/blocks/BlocksSubCommand.java | 6 +- .../operator/GenerateBlockchainConfig.java | 6 +- .../subcommands/operator/RestoreState.java | 6 +- .../besu/cli/util/CommandLineUtils.java | 2 +- .../besu/controller/BesuController.java | 6 +- .../controller/BesuControllerBuilder.java | 6 +- .../CliqueBesuControllerBuilder.java | 6 +- .../controller/IbftBesuControllerBuilder.java | 6 +- .../IbftLegacyBesuControllerBuilder.java | 6 +- .../controller/QbftBesuControllerBuilder.java | 6 +- .../besu/services/BesuPluginContextImpl.java | 6 +- .../besu/services/PicoCLIOptionsImpl.java | 6 +- .../services/PrivacyPluginServiceImpl.java | 6 +- .../besu/cli/CommandLineUtilsTest.java | 2 +- .../besu/cli/CommandTestAbstract.java | 6 +- build.gradle | 2 +- config/build.gradle | 4 +- .../consensus/clique/CliqueExtraData.java | 6 +- .../CliqueMiningCoordinator.java | 7 +- .../CliqueDifficultyValidationRule.java | 6 +- .../CliqueExtraDataValidationRule.java | 6 +- .../CoinbaseHeaderValidationRule.java | 6 +- .../SignerRateLimitValidationRule.java | 6 +- .../VoteValidationRule.java | 6 +- .../common/MigratingMiningCoordinator.java | 7 +- .../consensus/common/bft/BftEventQueue.java | 6 +- .../consensus/common/bft/BftExecutors.java | 6 +- .../common/bft/BftExtraDataCodec.java | 6 +- .../consensus/common/bft/BftProcessor.java | 6 +- .../common/bft/EthSynchronizerUpdater.java | 7 +- .../common/bft/EventMultiplexer.java | 6 +- .../blockcreation/BftMiningCoordinator.java | 7 +- .../bft/blockcreation/ProposerSelector.java | 6 +- .../BftCoinbaseValidationRule.java | 6 +- .../BftCommitSealsValidationRule.java | 6 +- .../BftValidatorsValidationRule.java | 6 +- .../BftVanityDataValidationRule.java | 6 +- .../common/bft/network/ValidatorPeers.java | 6 +- .../bft/protocol/BftProtocolManager.java | 6 +- .../bft/statemachine/BaseBftController.java | 6 +- .../blockbased/VoteTallyUpdater.java | 6 +- .../methods/IbftDiscardValidatorVote.java | 6 +- .../methods/IbftGetValidatorsByBlockHash.java | 6 +- .../IbftGetValidatorsByBlockNumber.java | 6 +- .../methods/IbftProposeValidatorVote.java | 6 +- .../ibft/network/IbftMessageTransmitter.java | 6 +- .../statemachine/IbftBlockHeightManager.java | 6 +- .../ibft/statemachine/IbftRound.java | 23 ++-- .../ibft/statemachine/RoundChangeManager.java | 6 +- .../ibft/statemachine/RoundState.java | 6 +- .../FutureRoundProposalMessageValidator.java | 7 +- .../ibft/validation/MessageValidator.java | 6 +- .../ProposalBlockConsistencyValidator.java | 7 +- .../RoundChangeCertificateValidator.java | 6 +- .../RoundChangeMessageValidator.java | 6 +- .../RoundChangePayloadValidator.java | 6 +- .../ibft/validation/SignedDataValidator.java | 6 +- .../consensus/ibftlegacy/IbftExtraData.java | 6 +- .../IbftExtraDataValidationRule.java | 6 +- .../VoteValidationRule.java | 6 +- .../blockcreation/PkiQbftBlockCreator.java | 6 +- .../QbftValidatorsValidationRule.java | 6 +- .../methods/QbftDiscardValidatorVote.java | 6 +- .../methods/QbftGetValidatorsByBlockHash.java | 6 +- .../QbftGetValidatorsByBlockNumber.java | 6 +- .../methods/QbftProposeValidatorVote.java | 6 +- .../qbft/network/QbftMessageTransmitter.java | 6 +- ...PkiBlockCreationConfigurationProvider.java | 15 +-- .../statemachine/QbftBlockHeightManager.java | 6 +- .../qbft/statemachine/QbftRound.java | 23 ++-- .../qbft/statemachine/RoundChangeManager.java | 6 +- .../qbft/statemachine/RoundState.java | 6 +- .../qbft/validation/CommitValidator.java | 6 +- .../qbft/validation/MessageValidator.java | 6 +- .../qbft/validation/PrepareValidator.java | 6 +- .../validation/ProposalPayloadValidator.java | 6 +- .../qbft/validation/ProposalValidator.java | 6 +- .../RoundChangeMessageValidator.java | 6 +- .../RoundChangePayloadValidator.java | 6 +- .../ValidatorModeTransitionLogger.java | 6 +- container-tests/tests/build.gradle | 1 - crypto/build.gradle | 4 +- .../hyperledger/besu/crypto/KeyPairUtil.java | 6 +- .../hyperledger/besu/crypto/SECP256K1.java | 6 +- .../crypto/SignatureAlgorithmFactory.java | 6 +- enclave/build.gradle | 2 +- errorprone-checks/build.gradle | 3 +- .../PrivateStaticFinalLoggers.java | 5 +- ...rivateStaticFinalLoggersNegativeCases.java | 7 +- ...rivateStaticFinalLoggersPositiveCases.java | 6 +- ethereum/api/build.gradle | 5 +- .../api/graphql/GraphQLDataFetchers.java | 6 +- .../api/graphql/GraphQLHttpService.java | 6 +- .../api/jsonrpc/JsonResponseStreamer.java | 6 +- .../api/jsonrpc/JsonRpcHttpService.java | 6 +- .../authentication/AuthenticationUtils.java | 6 +- .../api/jsonrpc/health/LivenessCheck.java | 6 +- .../api/jsonrpc/health/ReadinessCheck.java | 6 +- .../internal/methods/AdminAddPeer.java | 6 +- .../internal/methods/AdminChangeLogLevel.java | 12 +- .../internal/methods/AdminRemovePeer.java | 6 +- .../internal/methods/DebugTraceBlock.java | 6 +- .../internal/methods/EthGetBlockByNumber.java | 6 +- .../jsonrpc/internal/methods/EthGetWork.java | 7 +- .../methods/EthSendRawTransaction.java | 6 +- .../internal/methods/EthSubmitWork.java | 7 +- .../methods/ExecutionEngineJsonRpcMethod.java | 6 +- .../internal/methods/PluginJsonRpcMethod.java | 6 +- .../methods/PluginsReloadConfiguration.java | 6 +- .../jsonrpc/internal/methods/TraceFilter.java | 6 +- .../methods/engine/EngineExecutePayload.java | 10 +- .../methods/engine/EngineGetPayload.java | 6 +- .../parameters/JsonCallParameter.java | 6 +- .../MultiTenancyRpcMethodDecorator.java | 7 +- .../eea/AbstractEeaSendRawTransaction.java | 8 +- .../priv/GoQuorumEthGetQuorumPayload.java | 7 +- .../GoQuorumSendRawPrivateTransaction.java | 11 +- .../GoQuorumStoreRawPrivateTransaction.java | 9 +- .../methods/priv/PrivCreatePrivacyGroup.java | 7 +- .../methods/priv/PrivDebugGetStateRoot.java | 10 +- .../methods/priv/PrivDeletePrivacyGroup.java | 6 +- .../priv/PrivDistributeRawTransaction.java | 8 +- .../methods/priv/PrivFindPrivacyGroup.java | 6 +- .../priv/PrivGetEeaTransactionCount.java | 6 +- .../priv/PrivGetPrivateTransaction.java | 7 +- .../methods/priv/PrivGetTransactionCount.java | 6 +- .../priv/PrivGetTransactionReceipt.java | 7 +- .../privx/PrivxFindFlexiblePrivacyGroup.java | 6 +- .../websocket/JsonResponseStreamer.java | 6 +- .../websocket/WebSocketRequestHandler.java | 6 +- .../jsonrpc/websocket/WebSocketService.java | 6 +- .../subscription/SubscriptionManager.java | 6 +- .../besu/ethereum/api/query/BackendQuery.java | 6 +- .../ethereum/api/query/BlockchainQueries.java | 13 +-- .../api/query/StateBackupService.java | 37 +++---- ...AutoTransactionLogBloomCachingService.java | 7 +- .../query/cache/LogBloomCacheMetadata.java | 6 +- .../cache/TransactionLogBloomCacher.java | 6 +- .../api/util/DomainObjectDecodeUtils.java | 4 - .../jsonrpc/AdminJsonRpcHttpServiceTest.java | 6 +- .../methods/AdminChangeLogLevelTest.java | 39 +++---- .../blockcreation/AbstractBlockCreator.java | 16 ++- .../blockcreation/AbstractMinerExecutor.java | 6 +- .../ethereum/blockcreation/BlockMiner.java | 6 +- .../BlockTransactionSelector.java | 6 +- .../blockcreation/PoWMiningCoordinator.java | 7 +- ethereum/core/build.gradle | 5 +- .../besu/ethereum/MainnetBlockValidator.java | 7 +- ...nsaiInMemoryWorldStateKeyValueStorage.java | 7 +- .../bonsai/BonsaiPersistedWorldState.java | 6 +- .../bonsai/BonsaiWorldStateArchive.java | 6 +- .../ethereum/chain/DefaultBlockchain.java | 46 ++++---- .../goquorum/GoQuorumBlockProcessor.java | 6 +- .../goquorum/GoQuorumPrivateStateUtil.java | 7 +- .../mainnet/AbstractBlockProcessor.java | 6 +- .../mainnet/BaseFeeBlockBodyValidator.java | 6 +- .../mainnet/BlockHeaderValidator.java | 6 +- .../mainnet/ClassicBlockProcessor.java | 6 +- .../FrontierTargetingGasLimitCalculator.java | 7 +- .../LondonTargetingGasLimitCalculator.java | 7 +- .../mainnet/MainnetBlockBodyValidator.java | 6 +- .../mainnet/MainnetBlockProcessor.java | 6 +- .../mainnet/MainnetTransactionProcessor.java | 10 +- .../besu/ethereum/mainnet/PoWSolver.java | 7 +- .../mainnet/PrivacyBlockProcessor.java | 6 +- .../mainnet/ProtocolScheduleBuilder.java | 6 +- .../mainnet/feemarket/LondonFeeMarket.java | 6 +- .../AncestryValidationRule.java | 6 +- ...rketBlockHeaderGasPriceValidationRule.java | 7 +- .../CalculatedDifficultyValidationRule.java | 7 +- .../ConstantFieldValidationRule.java | 7 +- .../ExtraDataMaxLengthValidationRule.java | 6 +- .../GasLimitRangeAndDeltaValidationRule.java | 7 +- .../GasUsageValidationRule.java | 6 +- .../ProofOfWorkValidationRule.java | 6 +- .../TimestampBoundedByFutureParameter.java | 7 +- .../TimestampMoreRecentThanParent.java | 6 +- .../FlexiblePrivacyPrecompiledContract.java | 7 +- .../PrivacyPluginPrecompiledContract.java | 6 +- .../privacy/PrivacyPrecompiledContract.java | 20 ++-- .../privacy/FlexiblePrivacyController.java | 18 +-- ...PrivateGroupRehydrationBlockProcessor.java | 7 +- .../privacy/PrivateStateGenesisAllocator.java | 6 +- .../privacy/PrivateStateRehydration.java | 6 +- .../ethereum/privacy/PrivateTransaction.java | 6 +- .../privacy/PrivateTransactionLocator.java | 9 +- .../privacy/PrivateTransactionProcessor.java | 6 +- .../privacy/PrivateTransactionValidator.java | 6 +- .../RestrictedDefaultPrivacyController.java | 20 ++-- .../PrivateMigrationBlockProcessor.java | 6 +- .../migration/PrivateStorageMigration.java | 6 +- .../PrivateStorageMigrationService.java | 6 +- .../ethereum/worldstate/MarkSweepPruner.java | 6 +- .../besu/ethereum/worldstate/Pruner.java | 8 +- ethereum/eth/build.gradle | 2 + .../besu/ethereum/eth/manager/EthPeer.java | 22 ++-- .../eth/manager/EthProtocolManager.java | 6 +- .../ethereum/eth/manager/EthScheduler.java | 6 +- .../ethereum/eth/manager/PeerReputation.java | 7 +- .../eth/manager/snap/SnapProtocolManager.java | 6 +- .../task/AbstractGetHeadersFromPeerTask.java | 6 +- .../manager/task/AbstractPeerRequestTask.java | 6 +- .../task/AbstractRetryingPeerTask.java | 6 +- .../manager/task/GetBlockFromPeerTask.java | 6 +- .../manager/task/GetBlockFromPeersTask.java | 6 +- .../manager/task/GetBodiesFromPeerTask.java | 6 +- .../task/GetHeadersFromPeerByHashTask.java | 6 +- .../task/GetHeadersFromPeerByNumberTask.java | 6 +- .../manager/task/GetNodeDataFromPeerTask.java | 6 +- .../GetPooledTransactionsFromPeerTask.java | 7 +- .../manager/task/GetReceiptsFromPeerTask.java | 6 +- .../task/RetryingGetBlockFromPeersTask.java | 6 +- .../eth/manager/task/WaitForPeerTask.java | 6 +- .../eth/manager/task/WaitForPeersTask.java | 6 +- .../AbstractPeerBlockValidator.java | 6 +- .../ClassicForkPeerValidator.java | 6 +- .../peervalidation/DaoForkPeerValidator.java | 6 +- .../peervalidation/PeerValidatorRunner.java | 6 +- .../RequiredBlocksPeerValidator.java | 6 +- .../ethereum/eth/sync/BlockBroadcaster.java | 6 +- .../eth/sync/BlockPropagationManager.java | 6 +- .../ethereum/eth/sync/ChainHeadTracker.java | 7 +- .../eth/sync/CheckpointHeaderFetcher.java | 6 +- .../eth/sync/CheckpointRangeSource.java | 6 +- .../eth/sync/DefaultSynchronizer.java | 6 +- .../eth/sync/DownloadHeadersStep.java | 6 +- .../eth/sync/PipelineChainDownloader.java | 6 +- .../ethereum/eth/sync/SyncTargetManager.java | 6 +- .../eth/sync/TrailingPeerLimiter.java | 7 +- .../sync/fastsync/FastDownloaderFactory.java | 6 +- .../sync/fastsync/FastImportBlocksStep.java | 6 +- .../eth/sync/fastsync/FastSyncActions.java | 6 +- .../eth/sync/fastsync/FastSyncDownloader.java | 6 +- .../sync/fastsync/FastSyncStateStorage.java | 6 +- .../sync/fastsync/FastSyncTargetManager.java | 6 +- .../sync/fastsync/PivotBlockConfirmer.java | 6 +- .../sync/fastsync/PivotBlockRetriever.java | 6 +- .../fastsync/worldstate/CompleteTaskStep.java | 6 +- .../worldstate/FastWorldDownloadState.java | 6 +- .../FastWorldStateDownloadProcess.java | 6 +- .../worldstate/FastWorldStateDownloader.java | 6 +- .../fastsync/worldstate/NodeDataRequest.java | 6 +- .../fastsync/worldstate/RequestDataStep.java | 6 +- .../sync/fullsync/FullImportBlockStep.java | 6 +- .../eth/sync/fullsync/FullSyncDownloader.java | 6 +- .../sync/fullsync/FullSyncTargetManager.java | 6 +- .../eth/sync/tasks/CompleteBlocksTask.java | 6 +- .../tasks/DetermineCommonAncestorTask.java | 6 +- .../tasks/DownloadHeaderSequenceTask.java | 6 +- .../sync/tasks/GetReceiptsForHeadersTask.java | 6 +- .../eth/sync/tasks/PersistBlockTask.java | 6 +- .../sync/worldstate/WorldDownloadState.java | 6 +- .../PendingTransactionsMessageProcessor.java | 7 +- .../eth/transactions/TransactionPool.java | 6 +- .../TransactionsMessageProcessor.java | 6 +- .../TransactionsMessageSender.java | 6 +- .../AbstractPendingTransactionsSorter.java | 7 +- .../BaseFeePendingTransactionsSorter.java | 6 +- .../eth/ForkIdBackwardCompatibilityTest.java | 6 +- .../ethereum/eth/manager/EIP2124Test.java | 6 +- .../ethereum/eth/transactions/TestNode.java | 6 +- .../eth/transactions/TestNodeList.java | 9 +- ethereum/ethstats/build.gradle | 4 +- .../besu/ethstats/EthStatsService.java | 6 +- .../besu/ethstats/util/NetstatsUrl.java | 4 +- ethereum/evmtool/build.gradle | 3 +- .../besu/evmtool/DataStoreModule.java | 6 +- .../besu/evmtool/EvmToolCommand.java | 17 +-- .../besu/evmtool/StateTestSubCommand.java | 15 +-- ethereum/p2p/build.gradle | 5 +- .../p2p/discovery/PeerDiscoveryAgent.java | 6 +- .../discovery/VertxPeerDiscoveryAgent.java | 6 +- .../internal/DiscoveryProtocolLogger.java | 6 +- .../internal/PeerDiscoveryController.java | 6 +- .../internal/RecursivePeerRefreshState.java | 6 +- .../p2p/network/DefaultP2PNetwork.java | 6 +- .../ethereum/p2p/network/NetworkRunner.java | 6 +- .../p2p/network/PeerReputationManager.java | 6 +- .../ethereum/p2p/peers/StaticNodesParser.java | 9 +- .../besu/ethereum/p2p/plain/PlainFramer.java | 6 +- .../ethereum/p2p/plain/PlainHandshaker.java | 6 +- .../besu/ethereum/p2p/rlpx/RlpxAgent.java | 6 +- .../connections/AbstractPeerConnection.java | 6 +- .../netty/AbstractHandshakeHandler.java | 6 +- .../rlpx/connections/netty/ApiHandler.java | 6 +- .../p2p/rlpx/connections/netty/DeFramer.java | 6 +- .../netty/HandshakeHandlerOutbound.java | 6 +- .../connections/netty/TLSContextFactory.java | 6 +- .../rlpx/connections/netty/WireKeepAlive.java | 6 +- .../ethereum/p2p/rlpx/framing/Framer.java | 6 +- .../rlpx/handshake/ecies/ECIESHandshaker.java | 6 +- .../internal/MockPeerDiscoveryAgent.java | 6 +- .../p2p/peers/StaticNodesParserTest.java | 2 +- .../netty/TLSContextFactoryTest.java | 6 +- ethereum/permissioning/build.gradle | 3 +- ...untLocalConfigPermissioningController.java | 15 ++- ...odeLocalConfigPermissioningController.java | 15 ++- .../NodePermissioningControllerFactory.java | 7 +- ...martContractV2PermissioningController.java | 7 +- .../permissioning/TomlConfigFileParser.java | 6 +- ...nSmartContractPermissioningController.java | 7 +- .../AccountPermissioningController.java | 6 +- ...AccountPermissioningControllerFactory.java | 13 +-- .../node/NodePermissioningController.java | 6 +- .../node/PeerPermissionsAdapter.java | 6 +- ...ocalConfigPermissioningControllerTest.java | 3 +- ...ocalConfigPermissioningControllerTest.java | 3 +- ethereum/retesteth/build.gradle | 5 +- .../ethereum/retesteth/RetestethContext.java | 10 +- .../retesteth/methods/TestImportRawBlock.java | 6 +- .../retesteth/methods/TestSetChainParams.java | 6 +- .../ethereum/stratum/GetWorkProtocol.java | 7 +- .../stratum/Stratum1EthProxyProtocol.java | 7 +- .../ethereum/stratum/Stratum1Protocol.java | 7 +- .../ethereum/stratum/StratumConnection.java | 7 +- .../besu/ethereum/stratum/StratumServer.java | 7 +- evm/build.gradle | 3 +- .../java/org/hyperledger/besu/evm/EVM.java | 7 +- .../contractvalidation/MaxCodeSizeRule.java | 6 +- .../contractvalidation/PrefixCodeRule.java | 6 +- .../AbstractAltBnPrecompiledContract.java | 6 +- .../AbstractBLS12PrecompiledContract.java | 6 +- .../AbstractPrecompiledContract.java | 6 +- .../BLAKE2BFPrecompileContract.java | 6 +- .../processor/ContractCreationProcessor.java | 6 +- .../evm/processor/MessageCallProcessor.java | 6 +- gradle/versions.gradle | 2 +- metrics/core/build.gradle | 4 +- .../besu/metrics/MetricsService.java | 5 +- .../besu/metrics/MetricsSystemFactory.java | 6 +- .../MetricsOtelGrpcPushService.java | 6 +- .../opentelemetry/OpenTelemetrySystem.java | 6 +- .../prometheus/MetricsHttpService.java | 6 +- .../prometheus/MetricsPushGatewayService.java | 8 +- metrics/rocksdb/build.gradle | 3 +- nat/build.gradle | 5 +- .../org/hyperledger/besu/nat/NatService.java | 6 +- .../besu/nat/core/AbstractNatManager.java | 6 +- .../besu/nat/docker/DockerNatManager.java | 6 +- .../nat/kubernetes/KubernetesNatManager.java | 6 +- .../upnp/BesuUpnpServiceConfiguration.java | 6 +- .../besu/nat/upnp/UpnpNatManager.java | 6 +- pki/build.gradle | 4 +- .../hyperledger/besu/pki/cms/CmsCreator.java | 5 - .../besu/pki/cms/CmsValidator.java | 8 +- .../pki/keystore/HardwareKeyStoreWrapper.java | 6 +- .../pki/keystore/SoftwareKeyStoreWrapper.java | 6 +- .../besu/pki/keystore/CryptoTestUtil.java | 6 +- plugins/rocksdb/build.gradle | 4 +- .../RocksDBKeyValuePrivacyStorageFactory.java | 10 +- .../RocksDBKeyValueStorageFactory.java | 9 +- .../rocksdb/RocksDBMetricsFactory.java | 6 +- .../storage/rocksdb/RocksDBPlugin.java | 6 +- .../storage/rocksdb/RocksDbKeyIterator.java | 6 +- .../services/storage/rocksdb/RocksDbUtil.java | 6 +- .../configuration/DatabaseMetadata.java | 6 +- .../RocksDBColumnarKeyValueStorage.java | 6 +- .../unsegmented/RocksDBKeyValueStorage.java | 6 +- .../unsegmented/RocksDBTransaction.java | 6 +- services/kvstore/build.gradle | 4 +- .../kvstore/InMemoryStoragePlugin.java | 6 +- services/pipeline/build.gradle | 4 +- .../pipeline/AsyncOperationProcessor.java | 6 +- .../besu/services/pipeline/Pipe.java | 6 +- .../besu/services/pipeline/Pipeline.java | 6 +- services/tasks/build.gradle | 4 +- .../tasks/FlatFileTaskCollection.java | 6 +- .../enclave/testutil/EnclaveKeyUtils.java | 6 +- .../enclave/testutil/TesseraTestHarness.java | 6 +- util/build.gradle | 6 +- .../besu/util/Log4j2ConfiguratorUtil.java | 104 ++++++++++++++++++ .../hyperledger/besu/util/Subscribers.java | 6 +- 404 files changed, 1501 insertions(+), 1393 deletions(-) create mode 100644 besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java create mode 100644 util/src/main/java/org/hyperledger/besu/util/Log4j2ConfiguratorUtil.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f97f6867c..fd96dff27d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Re-order external services (e.g JsonRpcHttpService) to start before blocks start processing [#3118](https://github.com/hyperledger/besu/pull/3118) - Stream JSON RPC responses to avoid creating big JSON strings in memory [#3076](https://github.com/hyperledger/besu/pull/3076) - Ethereum Classic Mystique Hard Fork [#3256](https://github.com/hyperledger/besu/pull/3256) +- Move into SLF4J as logging facade [#3285](https://github.com/hyperledger/besu/pull/3285) ### Bug Fixes - Make 'to' field optional in eth_call method according to the spec [#3177](https://github.com/hyperledger/besu/pull/3177) diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 30cf0d4a4a..a1805d8e52 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -33,9 +33,6 @@ dependencies { implementation 'io.reactivex.rxjava2:rxjava' implementation 'io.vertx:vertx-core' implementation 'junit:junit' - implementation 'org.apache.logging.log4j:log4j-api' - implementation 'org.apache.logging.log4j:log4j-core' - implementation 'org.apache.logging.log4j:log4j-slf4j-impl' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-io' implementation 'org.apache.tuweni:tuweni-units' diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index f79856d0fc..c02071f6ee 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -57,18 +57,18 @@ import java.math.BigInteger; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.ThreadContext; import org.junit.After; import org.junit.Rule; import org.junit.rules.TestName; import org.junit.rules.TestWatcher; import org.junit.runner.Description; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AcceptanceTestBase { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBase.class); protected final Accounts accounts; protected final AccountTransactions accountTransactions; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/process/ExitedWithCode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/process/ExitedWithCode.java index abceb8ed5b..0e28f0609e 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/process/ExitedWithCode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/process/ExitedWithCode.java @@ -22,12 +22,12 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ExitedWithCode implements Condition { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ExitedWithCode.class); private final int code; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index 295c3b7d2f..e6a7daeafc 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.tests.acceptance.dsl.node; import static java.util.Collections.unmodifiableList; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.apache.tuweni.io.file.Files.copyResource; import org.hyperledger.besu.cli.config.NetworkName; @@ -66,10 +65,11 @@ import java.util.concurrent.TimeUnit; import com.google.common.base.MoreObjects; import com.google.common.io.MoreFiles; import com.google.common.io.RecursiveDeleteOption; -import org.apache.logging.log4j.Logger; import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; import org.java_websocket.exceptions.WebsocketNotConnectedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.web3j.protocol.Web3jService; import org.web3j.protocol.core.JsonRpc2_0Web3j; import org.web3j.protocol.http.HttpService; @@ -81,7 +81,7 @@ import org.web3j.utils.Async; public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable { private static final String LOCALHOST = "127.0.0.1"; - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BesuNode.class); private final Path homeDirectory; private KeyPair keyPair; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index 5b22cff528..4d256559c7 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -46,15 +46,15 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.ThreadContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; public class ProcessBesuNodeRunner implements BesuNodeRunner { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProcessBesuNodeRunner.class); private static final Logger PROCESS_LOG = - LogManager.getLogger("org.hyperledger.besu.SubProcessLog"); + LoggerFactory.getLogger("org.hyperledger.besu.SubProcessLog"); private final Map besuProcesses = new HashMap<>(); private final ExecutorService outputProcessorExecutor = Executors.newCachedThreadPool(); @@ -410,7 +410,7 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner { waitForFile(dataDir, "besu.ports"); waitForFile(dataDir, "besu.networks"); } - ThreadContext.remove("node"); + MDC.remove("node"); } private boolean isNotAliveOrphan(final String name) { @@ -422,7 +422,7 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner { try (final BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(), UTF_8))) { - ThreadContext.put("node", node.getName()); + MDC.put("node", node.getName()); String line = in.readLine(); while (line != null) { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index fe4e66a29b..2aa90bb17b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -65,15 +65,15 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.ThreadContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; public class ThreadBesuNodeRunner implements BesuNodeRunner { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ThreadBesuNodeRunner.class); private final Map besuRunners = new HashMap<>(); private final Map besuPluginContextMap = new ConcurrentHashMap<>(); @@ -111,10 +111,10 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { @Override public void startNode(final BesuNode node) { - if (ThreadContext.containsKey("node")) { - LOG.error("ThreadContext node is already set to {}", ThreadContext.get("node")); + if (MDC.get("node") != null) { + LOG.error("ThreadContext node is already set to {}", MDC.get("node")); } - ThreadContext.put("node", node.getName()); + MDC.put("node", node.getName()); if (!node.getRunCommand().isEmpty()) { throw new UnsupportedOperationException("commands are not supported with thread runner"); @@ -229,7 +229,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { runner.startEthereumMainLoop(); besuRunners.put(node.getName(), runner); - ThreadContext.remove("node"); + MDC.remove("node"); } @Override diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java index 8a118a635e..c18c4be0cf 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java @@ -33,11 +33,11 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Cluster implements AutoCloseable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Cluster.class); private final Map nodes = new HashMap<>(); private final BesuNodeRunner besuNodeRunner; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java index 5dcf9ed284..c1f7d343f7 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyCluster.java @@ -30,11 +30,11 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivacyCluster { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyCluster.class); private final NetConditions net; private final BesuNodeRunner besuNodeRunner; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 9d0eb3fdd9..ed83e473e8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -57,14 +57,14 @@ import java.util.Optional; import java.util.stream.Collectors; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.awaitility.Awaitility; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testcontainers.containers.Network; public class PrivacyNode implements AutoCloseable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyNode.class); private static final int MAX_OPEN_FILES = 1024; private static final long CACHE_CAPACITY = 8388608; private static final int MAX_BACKGROUND_COMPACTIONS = 4; diff --git a/acceptance-tests/test-plugins/build.gradle b/acceptance-tests/test-plugins/build.gradle index 3720e02301..09d19912d3 100644 --- a/acceptance-tests/test-plugins/build.gradle +++ b/acceptance-tests/test-plugins/build.gradle @@ -1,5 +1,7 @@ dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':besu') implementation project(':crypto') implementation project(':datatypes') @@ -8,8 +10,6 @@ dependencies { implementation project(':plugin-api') implementation 'com.google.auto.service:auto-service' implementation 'info.picocli:picocli' - implementation 'org.apache.logging.log4j:log4j-api' - implementation 'org.apache.logging.log4j:log4j-core' testImplementation 'org.assertj:assertj-core' testImplementation 'junit:junit' diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java index e2534f2e1e..a3fe06c572 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java @@ -26,13 +26,13 @@ import java.io.IOException; import java.nio.file.Files; import com.google.auto.service.AutoService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Option; @AutoService(BesuPlugin.class) public class BadCLIOptionsPlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BadCLIOptionsPlugin.class); @Option(names = "--poorly-named-option") String poorlyNamedOption = "nothing"; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java index e2c9911712..44e728010c 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java @@ -28,12 +28,12 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import com.google.auto.service.AutoService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @AutoService(BesuPlugin.class) public class TestBesuEventsPlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class); private BesuContext context; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java index c41967d841..65c90a5ed1 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java @@ -21,13 +21,13 @@ import org.hyperledger.besu.plugin.services.PermissioningService; import org.hyperledger.besu.plugin.services.PicoCLIOptions; import com.google.auto.service.AutoService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Option; @AutoService(BesuPlugin.class) public class TestPermissioningPlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestPermissioningPlugin.class); private static final String aliceNode = "09b02f8a5fddd222ade4ea4528faefc399623af3f736be3c44f03e2df22fb792f3931a4d9573d333ca74343305762a753388c3422a86d98b713fc91c1ea04842"; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java index 0e87d16776..0db5281537 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java @@ -24,13 +24,13 @@ import java.nio.file.Files; import java.util.Collections; import com.google.auto.service.AutoService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Option; @AutoService(BesuPlugin.class) public class TestPicoCLIPlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestPicoCLIPlugin.class); @Option( names = {"--Xplugin-test-option"}, diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java index 42ffbbd69b..a441640b01 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java @@ -23,13 +23,13 @@ import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyPluginPa import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestSigningPrivateMarkerTransactionFactory; import com.google.auto.service.AutoService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Option; @AutoService(BesuPlugin.class) public class TestPrivacyServicePlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyServicePlugin.class); PrivacyPluginService pluginService; BesuContext context; diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java index 7f270b9052..f40d71b9c5 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java @@ -25,12 +25,12 @@ import org.hyperledger.besu.plugin.services.privacy.PrivacyPluginPayloadProvider import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestPrivacyPluginPayloadProvider implements PrivacyPluginPayloadProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyPluginPayloadProvider.class); private String prefix; public void setPluginPayloadPrefix(final String prefix) { diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java index ccdb7f9d1a..09e1eb0a44 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.tests.acceptance.plugins.privacy; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.datatypes.Address.extract; import org.hyperledger.besu.crypto.KeyPair; @@ -31,13 +30,15 @@ import org.hyperledger.besu.plugin.data.TransactionType; import org.hyperledger.besu.plugin.data.UnsignedPrivateMarkerTransaction; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestSigningPrivateMarkerTransactionFactory implements PrivateMarkerTransactionFactory { - private static final Logger LOG = getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(TestSigningPrivateMarkerTransactionFactory.class); KeyPair aliceFixedSigningKey; Address sender; diff --git a/besu/build.gradle b/besu/build.gradle index 30ecd377be..878e883e25 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -28,6 +28,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':config') implementation project(':pki') implementation project(':consensus:clique') @@ -56,6 +58,7 @@ dependencies { implementation project(':plugin-api') implementation project(':plugins:rocksdb') implementation project(':services:kvstore') + implementation project(':util') implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8' @@ -64,7 +67,6 @@ dependencies { implementation 'info.picocli:picocli' implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.logging.log4j:log4j-core' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-config' @@ -74,7 +76,6 @@ dependencies { implementation 'org.xerial.snappy:snappy-java' implementation 'net.consensys.services:quorum-mainnet-launcher' - runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl' runtimeOnly 'org.apache.logging.log4j:log4j-jul' runtimeOnly 'com.splunk.logging:splunk-library-javalogging' runtimeOnly 'org.fusesource.jansi:jansi' // for color logging in windows diff --git a/besu/src/main/java/org/hyperledger/besu/Besu.java b/besu/src/main/java/org/hyperledger/besu/Besu.java index 4760b2cc74..fcd3ada9b9 100644 --- a/besu/src/main/java/org/hyperledger/besu/Besu.java +++ b/besu/src/main/java/org/hyperledger/besu/Besu.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.chainexport.RlpBlockExporter; import org.hyperledger.besu.chainimport.JsonBlockImporter; import org.hyperledger.besu.chainimport.RlpBlockImporter; @@ -26,7 +24,8 @@ import org.hyperledger.besu.services.BesuPluginContextImpl; import io.netty.util.internal.logging.InternalLoggerFactory; import io.netty.util.internal.logging.Log4J2LoggerFactory; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.RunLast; public final class Besu { @@ -68,7 +67,7 @@ public final class Besu { "Could not set logging system property as the security manager prevented it:" + e.getMessage()); } - final Logger logger = getLogger(); + final Logger logger = LoggerFactory.getLogger(Besu.class); Thread.setDefaultUncaughtExceptionHandler(log4jExceptionHandler(logger)); Thread.currentThread().setUncaughtExceptionHandler(log4jExceptionHandler(logger)); @@ -76,8 +75,10 @@ public final class Besu { } private static Thread.UncaughtExceptionHandler log4jExceptionHandler(final Logger logger) { - return (thread, error) -> - logger.error( - () -> String.format("Uncaught exception in thread \"%s\"", thread.getName()), error); + return (thread, error) -> { + if (logger.isErrorEnabled()) { + logger.error(String.format("Uncaught exception in thread \"%s\"", thread.getName()), error); + } + }; } } diff --git a/besu/src/main/java/org/hyperledger/besu/Runner.java b/besu/src/main/java/org/hyperledger/besu/Runner.java index 57ca44c164..85981c1012 100644 --- a/besu/src/main/java/org/hyperledger/besu/Runner.java +++ b/besu/src/main/java/org/hyperledger/besu/Runner.java @@ -46,12 +46,12 @@ import java.util.concurrent.TimeoutException; import com.google.common.annotations.VisibleForTesting; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Runner implements AutoCloseable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Runner.class); private final Vertx vertx; private final CountDownLatch vertxShutdownLatch = new CountDownLatch(1); @@ -135,8 +135,7 @@ public class Runner implements AutoCloseable { writeBesuNetworksToFile(); writePidFile(); } catch (final Exception ex) { - LOG.error("Startup failed", ex); - throw new IllegalStateException(ex); + throw new IllegalStateException("Startup failed", ex); } } @@ -212,8 +211,7 @@ public class Runner implements AutoCloseable { Thread.currentThread().interrupt(); throw new IllegalStateException("Interrupted while waiting for service to start", e); } catch (final ExecutionException e) { - LOG.error("Service " + serviceName + " failed to start", e); - throw new IllegalStateException(e); + throw new IllegalStateException("Service " + serviceName + " failed to start", e); } catch (final TimeoutException e) { LOG.warn("Service {} is taking an unusually long time to start", serviceName); } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 362f988774..639396e74f 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -130,13 +130,13 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import graphql.GraphQL; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RunnerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RunnerBuilder.class); private Vertx vertx; private BesuController besuController; 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 e9403a2c38..9e33363777 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainexport/BlockExporter.java @@ -25,12 +25,12 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Besu Block Export Util. */ public abstract class BlockExporter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockExporter.class); private final Blockchain blockchain; protected BlockExporter(final Blockchain 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 9f1c2fce75..cdfa0985e4 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java @@ -40,13 +40,13 @@ import java.util.stream.Stream; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Tool for importing blocks with transactions from human-readable json. */ public class JsonBlockImporter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(JsonBlockImporter.class); private final ObjectMapper mapper; private final BesuController controller; 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 96d7229fc3..bf08121f4a 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/RlpBlockImporter.java @@ -45,12 +45,12 @@ import java.util.concurrent.atomic.AtomicReference; import com.google.common.base.MoreObjects; import com.google.common.base.Stopwatch; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Tool for importing rlp-encoded block data from files. */ public class RlpBlockImporter implements Closeable { - private static final Logger LOG = LogManager.getFormatterLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RlpBlockImporter.class); private final Semaphore blockBacklog = new Semaphore(2); @@ -237,7 +237,7 @@ public class RlpBlockImporter implements Closeable { final long elapseMicros = segmentTimer.elapsed(TimeUnit.MICROSECONDS); //noinspection PlaceholderCountMatchesArgumentCount LOG.info( - "Import at block %8d / %,14d gas %,11d micros / Mgps %7.3f segment %6.3f cumulative", + "Import at block {} / {} gas {} micros / Mgps {} segment {} cumulative", blockNum, segmentGas, elapseMicros, 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 64e6c7fe06..7e90a982b1 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -49,6 +49,7 @@ import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; import org.hyperledger.besu.cli.custom.RpcAuthFileValidator; import org.hyperledger.besu.cli.error.BesuExceptionHandler; import org.hyperledger.besu.cli.options.stable.EthstatsOptions; +import org.hyperledger.besu.cli.options.stable.LoggingLevelOption; import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption; import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions; import org.hyperledger.besu.cli.options.unstable.DataStorageOptions; @@ -172,6 +173,7 @@ import org.hyperledger.besu.services.RpcEndpointServiceImpl; import org.hyperledger.besu.services.SecurityModuleServiceImpl; import org.hyperledger.besu.services.StorageServiceImpl; import org.hyperledger.besu.services.kvstore.InMemoryStoragePlugin; +import org.hyperledger.besu.util.Log4j2ConfiguratorUtil; import org.hyperledger.besu.util.NetworkUtility; import org.hyperledger.besu.util.PermissioningConfigurationValidator; import org.hyperledger.besu.util.number.Fraction; @@ -225,11 +227,9 @@ import net.consensys.quorum.mainnet.launcher.config.ImmutableLauncherConfig; import net.consensys.quorum.mainnet.launcher.exception.LauncherException; import net.consensys.quorum.mainnet.launcher.util.ParseArgsHelper; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.config.Configurator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; import picocli.AutoComplete; import picocli.CommandLine; import picocli.CommandLine.AbstractParseResultHandler; @@ -285,6 +285,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private final EthstatsOptions ethstatsOptions = EthstatsOptions.create(); private final NodePrivateKeyFileOption nodePrivateKeyFileOption = NodePrivateKeyFileOption.create(); + private final LoggingLevelOption loggingLevelOption = LoggingLevelOption.create(); private final RunnerBuilder runnerBuilder; private final BesuController.Builder controllerBuilderFactory; @@ -828,12 +829,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { "Deprecated in favor of --host-allowlist. Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})") private final JsonRPCAllowlistHostsProperty hostsWhitelist = new JsonRPCAllowlistHostsProperty(); - @Option( - names = {"--logging", "-l"}, - paramLabel = "", - description = "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL") - private final Level logLevel = null; - @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) @Option( names = {"--color-enabled"}, @@ -1341,6 +1336,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private void handleStableOptions() { commandLine.addMixin("Ethstats", ethstatsOptions); commandLine.addMixin("Private key file", nodePrivateKeyFileOption); + commandLine.addMixin("Logging level", loggingLevelOption); } private void handleUnstableOptions() { @@ -1519,13 +1515,14 @@ public class BesuCommand implements DefaultCommandValues, Runnable { public void configureLogging(final boolean announce) { // To change the configuration if color was enabled/disabled - Configurator.reconfigure(); + Log4j2ConfiguratorUtil.reconfigure(); // set log level per CLI flags + final Level logLevel = loggingLevelOption.getLogLevel(); if (logLevel != null) { if (announce) { System.out.println("Setting logging level to " + logLevel.name()); } - Configurator.setAllLevels("", logLevel); + Log4j2ConfiguratorUtil.setAllLevels("", logLevel); } } @@ -2551,7 +2548,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { try { besuPluginContext.stopPlugins(); runner.close(); - LogManager.shutdown(); + Log4j2ConfiguratorUtil.shutdown(); } catch (final Exception e) { logger.error("Failed to stop Besu"); } @@ -2817,7 +2814,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { @VisibleForTesting Level getLogLevel() { - return logLevel; + return loggingLevelOption.getLogLevel(); } private class BesuCommandConfigurationService implements BesuConfiguration { 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 c578ad7356..69caa01a87 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 @@ -19,7 +19,6 @@ import org.hyperledger.besu.cli.BesuCommand; import java.io.IOException; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.appender.ConsoleAppender; import org.apache.logging.log4j.core.config.AbstractConfiguration; @@ -27,6 +26,8 @@ import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.ConfigurationSource; import org.apache.logging.log4j.core.config.xml.XmlConfiguration; import org.apache.logging.log4j.core.layout.PatternLayout; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class XmlExtensionConfiguration extends XmlConfiguration { @@ -57,11 +58,13 @@ public class XmlExtensionConfiguration extends XmlConfiguration { createConsoleAppender(); return refreshed; } catch (final IOException e) { - LogManager.getLogger().error("Failed to reload the Log4j2 Xml configuration file", e); + LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) + .error("Failed to reload the Log4j2 Xml configuration file", e); } } - LogManager.getLogger().warn("Cannot programmatically reconfigure loggers"); + LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) + .warn("Cannot programmatically reconfigure loggers"); return refreshedParent; } 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 new file mode 100644 index 0000000000..317e98705e --- /dev/null +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java @@ -0,0 +1,44 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.cli.options.stable; + +import org.apache.logging.log4j.Level; +import picocli.CommandLine; + +public class LoggingLevelOption { + + public static LoggingLevelOption create() { + return new LoggingLevelOption(); + } + + private Level logLevel; + + @CommandLine.Option( + names = {"--logging", "-l"}, + paramLabel = "", + description = "Logging verbosity levels: OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL") + public void setLogLevel(final Level logLevel) { + if (Level.FATAL.equals(logLevel)) { + System.out.println("FATAL level is deprecated"); + this.logLevel = Level.ERROR; + } else { + this.logLevel = logLevel; + } + } + + public Level getLogLevel() { + return logLevel; + } +} 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 e02f88d78f..3ae6583b3c 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 @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration import java.nio.file.Path; import java.util.Optional; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; import picocli.CommandLine; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; 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 9846eaa897..76361c416a 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 @@ -24,7 +24,7 @@ import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration; import java.nio.file.Path; import java.util.Optional; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; import picocli.CommandLine; import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java index 389a09aba6..ae54d8d6b4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java @@ -34,8 +34,8 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; @@ -51,7 +51,7 @@ import picocli.CommandLine.Spec; mixinStandardHelpOptions = true, subcommands = {ExportSubCommand.class, AddressSubCommand.class}) public class PublicKeySubCommand implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PublicKeySubCommand.class); public static final String COMMAND_NAME = "public-key"; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java index e9adee23e8..3a221dcc5b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java @@ -19,18 +19,20 @@ import static org.hyperledger.besu.cli.subcommands.RetestethSubCommand.COMMAND_N import org.hyperledger.besu.BesuInfo; import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; +import org.hyperledger.besu.cli.options.stable.LoggingLevelOption; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration; import org.hyperledger.besu.ethereum.retesteth.RetestethService; +import org.hyperledger.besu.util.Log4j2ConfiguratorUtil; import java.net.InetAddress; import java.nio.file.Path; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.config.Configurator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; @Command( @@ -40,7 +42,7 @@ import picocli.CommandLine.Option; @SuppressWarnings("unused") public class RetestethSubCommand implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RetestethSubCommand.class); public static final String COMMAND_NAME = "retesteth"; @@ -57,12 +59,7 @@ public class RetestethSubCommand implements Runnable { description = "The path to Besu data directory (default: ${DEFAULT-VALUE})") private final Path dataPath = DefaultCommandValues.getDefaultBesuDataPath(this); - @Option( - names = {"--logging", "-l"}, - paramLabel = "", - description = - "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL (default: ${DEFAULT-VALUE})") - private final Level logLevel = LogManager.getRootLogger().getLevel(); + @Mixin private LoggingLevelOption loggingLevelOption; @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. @Option( @@ -105,9 +102,10 @@ public class RetestethSubCommand implements Runnable { private void prepareLogging() { // set log level per CLI flags + final Level logLevel = loggingLevelOption.getLogLevel(); if (logLevel != null) { System.out.println("Setting logging level to " + logLevel.name()); - Configurator.setAllLevels("", logLevel); + Log4j2ConfiguratorUtil.setAllLevels("", logLevel); } } @@ -130,7 +128,7 @@ public class RetestethSubCommand implements Runnable { () -> { try { retestethService.close(); - LogManager.shutdown(); + Log4j2ConfiguratorUtil.shutdown(); } catch (final Exception e) { LOG.error("Failed to stop Besu Retesteth"); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java index 3d2f8613d2..9ddce315cb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java @@ -55,9 +55,9 @@ import java.util.function.Function; import java.util.function.Supplier; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.ExecutionException; @@ -76,7 +76,7 @@ import picocli.CommandLine.Spec; subcommands = {ImportSubCommand.class, ExportSubCommand.class}) public class BlocksSubCommand implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlocksSubCommand.class); public static final String COMMAND_NAME = "blocks"; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java index bacbd25199..b9a5e09ab4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java @@ -51,9 +51,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.io.Resources; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.ParentCommand; @@ -63,7 +63,7 @@ import picocli.CommandLine.ParentCommand; description = "Generates node keypairs and genesis file with RLP encoded extra data.", mixinStandardHelpOptions = true) class GenerateBlockchainConfig implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GenerateBlockchainConfig.class); private final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java index c49237d3ce..944f5d9c8c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java @@ -47,10 +47,10 @@ import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.ParentCommand; @@ -61,7 +61,7 @@ import picocli.CommandLine.ParentCommand; mixinStandardHelpOptions = true) public class RestoreState implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RestoreState.class); @Option( names = "--backup-path", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java index 0c905538da..d688e4307a 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; import picocli.CommandLine; public class CommandLineUtils { diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java index 6246710345..8411980221 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java @@ -41,11 +41,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BesuController implements java.io.Closeable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BesuController.class); public static final String DATABASE_PATH = "database"; public static final String CACHE_PATH = "caches"; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index cdd1f5e45c..9181f1aa11 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -83,11 +83,11 @@ import java.util.Map; import java.util.Optional; import java.util.OptionalLong; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class BesuControllerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BesuControllerBuilder.class); protected GenesisConfigFile genesisConfig; protected SynchronizerConfiguration syncConfig; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java index 8c6adfbc3b..1eec4654b4 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java @@ -40,12 +40,12 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CliqueBesuControllerBuilder extends BesuControllerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CliqueBesuControllerBuilder.class); private Address localAddress; private EpochManager epochManager; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java index 9f87beaa03..10fad6117e 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java @@ -81,12 +81,12 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftBesuControllerBuilder.class); private BftEventQueue bftEventQueue; private BftConfigOptions bftConfig; private ForksSchedule forksSchedule; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java index 138e4fe060..f10d11cf5d 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java @@ -47,12 +47,12 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftLegacyBesuControllerBuilder extends BesuControllerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftLegacyBesuControllerBuilder.class); private final BlockInterface blockInterface = new IbftLegacyBlockInterface(); @Override diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java index 35659f7ba5..bb9924e40e 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java @@ -92,12 +92,12 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftBesuControllerBuilder.class); private BftEventQueue bftEventQueue; private QbftConfigOptions qbftConfig; private ForksSchedule qbftForksSchedule; diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java index 620c2e7c44..5f8c4c87fe 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java @@ -42,12 +42,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BesuPluginContextImpl.class); private enum Lifecycle { UNINITIALIZED, diff --git a/besu/src/main/java/org/hyperledger/besu/services/PicoCLIOptionsImpl.java b/besu/src/main/java/org/hyperledger/besu/services/PicoCLIOptionsImpl.java index 5d4a0cb3cc..cd2b257782 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/PicoCLIOptionsImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/PicoCLIOptionsImpl.java @@ -16,15 +16,15 @@ package org.hyperledger.besu.services; import org.hyperledger.besu.plugin.services.PicoCLIOptions; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Model.OptionSpec; public class PicoCLIOptionsImpl implements PicoCLIOptions { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PicoCLIOptionsImpl.class); private final CommandLine commandLine; diff --git a/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java index ac6d29c821..17f5c4bcb6 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java @@ -20,11 +20,11 @@ import org.hyperledger.besu.plugin.services.privacy.PrivacyGroupGenesisProvider; import org.hyperledger.besu.plugin.services.privacy.PrivacyPluginPayloadProvider; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivacyPluginServiceImpl implements PrivacyPluginService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyPluginServiceImpl.class); private PrivacyPluginPayloadProvider privacyPluginPayloadProvider; private PrivateMarkerTransactionFactory privateMarkerTransactionFactory; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java index 9a2cb30a8a..863bbc16b2 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java @@ -27,12 +27,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.logging.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Option; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index f843cf86eb..a7f1c1e5d1 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -101,8 +101,6 @@ import java.util.function.Supplier; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.awaitility.Awaitility; @@ -115,6 +113,8 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine; import picocli.CommandLine.Help.Ansi; import picocli.CommandLine.Model.CommandSpec; @@ -123,7 +123,7 @@ import picocli.CommandLine.RunLast; @RunWith(MockitoJUnitRunner.class) public abstract class CommandTestAbstract { - private static final Logger TEST_LOGGER = LogManager.getLogger(); + private static final Logger TEST_LOGGER = LoggerFactory.getLogger(CommandTestAbstract.class); protected final ByteArrayOutputStream commandOutput = new ByteArrayOutputStream(); private final PrintStream outPrintStream = new PrintStream(commandOutput); diff --git a/build.gradle b/build.gradle index 22ac48f63a..ba4f7b18d8 100644 --- a/build.gradle +++ b/build.gradle @@ -457,7 +457,7 @@ subprojects { duplicateClassesStrategy = DuplicatesStrategy.WARN } - dependencies { jmh 'org.apache.logging.log4j:log4j-api' } + dependencies { jmh 'org.slf4j:slf4j-api' } } } diff --git a/config/build.gradle b/config/build.gradle index 04e1588b75..a0d2a7d2f3 100644 --- a/config/build.gradle +++ b/config/build.gradle @@ -28,16 +28,16 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':datatypes') implementation project(':util') implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'info.picocli:picocli' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-units' - runtimeOnly 'org.apache.logging.log4j:log4j-core' testImplementation project(':testutil') diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueExtraData.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueExtraData.java index 0ea4a341b4..a20af191ce 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueExtraData.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueExtraData.java @@ -29,16 +29,16 @@ import java.util.function.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Represents the data structure stored in the extraData field of the BlockHeader used when * operating under an Clique consensus mechanism. */ public class CliqueExtraData implements ParsedExtraData { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CliqueExtraData.class); public static final int EXTRA_VANITY_LENGTH = 32; private final Bytes vanityData; diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinator.java index de37855eeb..3d8f0e0a69 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinator.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinator.java @@ -14,19 +14,18 @@ */ package org.hyperledger.besu.consensus.clique.blockcreation; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.consensus.clique.CliqueMiningTracker; import org.hyperledger.besu.ethereum.blockcreation.AbstractMiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CliqueMiningCoordinator extends AbstractMiningCoordinator { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CliqueMiningCoordinator.class); private final CliqueMiningTracker miningTracker; diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java index 2283cc53af..a19f7db95f 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; import java.math.BigInteger; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CliqueDifficultyValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CliqueDifficultyValidationRule.class); @Override public boolean validate( diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueExtraDataValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueExtraDataValidationRule.java index 215ea03a6c..22439db264 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueExtraDataValidationRule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueExtraDataValidationRule.java @@ -26,12 +26,12 @@ import org.hyperledger.besu.ethereum.rlp.RLPException; import java.util.Collection; import com.google.common.collect.Iterables; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CliqueExtraDataValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CliqueExtraDataValidationRule.class); private final EpochManager epochManager; diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CoinbaseHeaderValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CoinbaseHeaderValidationRule.java index e85d45e78e..6173a1ffea 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CoinbaseHeaderValidationRule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CoinbaseHeaderValidationRule.java @@ -19,12 +19,12 @@ import org.hyperledger.besu.consensus.common.EpochManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CoinbaseHeaderValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CoinbaseHeaderValidationRule.class); private final EpochManager epochManager; diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/SignerRateLimitValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/SignerRateLimitValidationRule.java index 82839e2d28..d3265e2c85 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/SignerRateLimitValidationRule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/SignerRateLimitValidationRule.java @@ -20,12 +20,12 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SignerRateLimitValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SignerRateLimitValidationRule.class); @Override public boolean validate( diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/VoteValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/VoteValidationRule.java index 2f8362edaa..2c0cfa622b 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/VoteValidationRule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/VoteValidationRule.java @@ -18,12 +18,12 @@ import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class VoteValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(VoteValidationRule.class); /** * Responsible for ensuring the nonce is either auth or drop. diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingMiningCoordinator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingMiningCoordinator.java index fe8b0af640..d727434d50 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingMiningCoordinator.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingMiningCoordinator.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.consensus.common; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; @@ -30,12 +28,13 @@ import java.util.List; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MigratingMiningCoordinator implements MiningCoordinator, BlockAddedObserver { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MigratingMiningCoordinator.class); private final ForksSchedule miningCoordinatorSchedule; private final Blockchain blockchain; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftEventQueue.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftEventQueue.java index c212bf8bc8..36266c60e9 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftEventQueue.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftEventQueue.java @@ -21,14 +21,14 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Threadsafe queue that lets parts of the system inform the Bft infrastructure about events */ public class BftEventQueue { private final BlockingQueue queue = new LinkedBlockingQueue<>(); - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftEventQueue.class); private final int messageQueueLimit; public BftEventQueue(final int messageQueueLimit) { diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExecutors.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExecutors.java index 27db69eb91..02a9b73154 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExecutors.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExecutors.java @@ -25,8 +25,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BftExecutors { @@ -36,7 +36,7 @@ public class BftExecutors { STOPPED } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftExecutors.class); private final Duration shutdownTimeout = Duration.ofSeconds(30); private final MetricsSystem metricsSystem; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExtraDataCodec.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExtraDataCodec.java index 7280146a51..10ef53de76 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExtraDataCodec.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftExtraDataCodec.java @@ -16,9 +16,9 @@ package org.hyperledger.besu.consensus.common.bft; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class BftExtraDataCodec { @@ -28,7 +28,7 @@ public abstract class BftExtraDataCodec { EXCLUDE_COMMIT_SEALS_AND_ROUND_NUMBER } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftExtraDataCodec.class); public static int EXTRA_VANITY_LENGTH = 32; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java index 877314a951..a85b440cf6 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java @@ -20,13 +20,13 @@ import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Execution context for draining queued bft events and applying them to a maintained state */ public class BftProcessor implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftProcessor.class); private final BftEventQueue incomingQueue; private volatile boolean shutdown = false; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EthSynchronizerUpdater.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EthSynchronizerUpdater.java index b29d670ab6..a446ee32df 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EthSynchronizerUpdater.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EthSynchronizerUpdater.java @@ -14,17 +14,16 @@ */ package org.hyperledger.besu.consensus.common.bft; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthSynchronizerUpdater implements SynchronizerUpdater { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthSynchronizerUpdater.class); private final EthPeers ethPeers; public EthSynchronizerUpdater(final EthPeers ethPeers) { diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EventMultiplexer.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EventMultiplexer.java index d916538076..a7e91dff1e 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EventMultiplexer.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/EventMultiplexer.java @@ -21,12 +21,12 @@ import org.hyperledger.besu.consensus.common.bft.events.NewChainHead; import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; import org.hyperledger.besu.consensus.common.bft.statemachine.BftEventHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EventMultiplexer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EventMultiplexer.class); private final BftEventHandler eventHandler; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java index 00d4689b6a..218d54f429 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.consensus.common.bft.blockcreation; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.consensus.common.bft.BftEventQueue; import org.hyperledger.besu.consensus.common.bft.BftExecutors; import org.hyperledger.besu.consensus.common.bft.BftProcessor; @@ -35,8 +33,9 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BftMiningCoordinator implements MiningCoordinator, BlockAddedObserver { @@ -46,7 +45,7 @@ public class BftMiningCoordinator implements MiningCoordinator, BlockAddedObserv STOPPED } - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftMiningCoordinator.class); private final BftEventHandler eventHandler; private final BftProcessor bftProcessor; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/ProposerSelector.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/ProposerSelector.java index 177c3683be..3be18ea4ce 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/ProposerSelector.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/ProposerSelector.java @@ -30,8 +30,8 @@ import java.util.NavigableSet; import java.util.Optional; import java.util.TreeSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for determining which member of the validator pool should propose the next block @@ -44,7 +44,7 @@ import org.apache.logging.log4j.Logger; */ public class ProposerSelector { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProposerSelector.class); private final Blockchain blockchain; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCoinbaseValidationRule.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCoinbaseValidationRule.java index 3d62ea138f..36a222275c 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCoinbaseValidationRule.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCoinbaseValidationRule.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures that the coinbase (which corresponds to the block proposer) is included in the list of @@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger; */ public class BftCoinbaseValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOGGER = LogManager.getLogger(BftCoinbaseValidationRule.class); + private static final Logger LOGGER = LoggerFactory.getLogger(BftCoinbaseValidationRule.class); @Override public boolean validate( diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCommitSealsValidationRule.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCommitSealsValidationRule.java index 4c3758101a..78e4c8fe98 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCommitSealsValidationRule.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftCommitSealsValidationRule.java @@ -27,8 +27,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures the commit seals in the block header were created by known validators (as determined by @@ -38,7 +38,7 @@ import org.apache.logging.log4j.Logger; */ public class BftCommitSealsValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(BftCommitSealsValidationRule.class); @Override public boolean validate( diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftValidatorsValidationRule.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftValidatorsValidationRule.java index 53fefc8b74..1e0e57d555 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftValidatorsValidationRule.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftValidatorsValidationRule.java @@ -27,8 +27,8 @@ import java.util.NavigableSet; import java.util.TreeSet; import com.google.common.collect.Iterables; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures the Validators listed in the block header match that tracked in memory (which was in-turn @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; */ public class BftValidatorsValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(BftValidatorsValidationRule.class); @Override public boolean validate( diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftVanityDataValidationRule.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftVanityDataValidationRule.java index 03435252d2..831937bfe9 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftVanityDataValidationRule.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/headervalidationrules/BftVanityDataValidationRule.java @@ -21,12 +21,12 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BftVanityDataValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftVanityDataValidationRule.class); @Override public boolean validate( diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/network/ValidatorPeers.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/network/ValidatorPeers.java index 146ccfc480..7942315f62 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/network/ValidatorPeers.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/network/ValidatorPeers.java @@ -28,8 +28,8 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for tracking the network peers which have a connection to this node, then @@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger; */ public class ValidatorPeers implements ValidatorMulticaster, PeerConnectionTracker { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ValidatorPeers.class); // It's possible for multiple connections between peers to exist for brief periods, so map each // address to a set of connections diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/protocol/BftProtocolManager.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/protocol/BftProtocolManager.java index eca919e580..8cfdb1e384 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/protocol/BftProtocolManager.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/protocol/BftProtocolManager.java @@ -29,11 +29,11 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.Di import java.util.Arrays; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BftProtocolManager implements ProtocolManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BftProtocolManager.class); private final BftEventQueue bftEventQueue; private final PeerConnectionTracker peers; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java index 8c27c71468..c210adfcf8 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java @@ -32,12 +32,12 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class BaseBftController implements BftEventHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BaseBftController.class); private final Blockchain blockchain; private final BftFinalState bftFinalState; private final FutureMessageBuffer futureMessageBuffer; diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/VoteTallyUpdater.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/VoteTallyUpdater.java index 30342d0e9c..bae5540aad 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/VoteTallyUpdater.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/VoteTallyUpdater.java @@ -24,8 +24,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.Collection; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provides the logic to extract vote tally state from the blockchain and update it as blocks are @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; */ class VoteTallyUpdater { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(VoteTallyUpdater.class); private final EpochManager epochManager; private final BlockInterface blockInterface; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftDiscardValidatorVote.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftDiscardValidatorVote.java index 45696346a5..e45f707093 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftDiscardValidatorVote.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftDiscardValidatorVote.java @@ -24,11 +24,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftDiscardValidatorVote implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftDiscardValidatorVote.class); private final ValidatorProvider validatorProvider; public IbftDiscardValidatorVote(final ValidatorProvider validatorProvider) { diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java index 658629a63d..beaef23dbb 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java @@ -27,11 +27,11 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftGetValidatorsByBlockHash implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftGetValidatorsByBlockHash.class); private final Blockchain blockchain; private final BlockInterface blockInterface; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java index ab04a5bc2e..2bad849666 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java @@ -26,12 +26,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftGetValidatorsByBlockNumber.class); private final BlockInterface blockInterface; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftProposeValidatorVote.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftProposeValidatorVote.java index 0bbe1de4af..33f7044a58 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftProposeValidatorVote.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftProposeValidatorVote.java @@ -25,11 +25,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftProposeValidatorVote implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftProposeValidatorVote.class); private final ValidatorProvider validatorProvider; public IbftProposeValidatorVote(final ValidatorProvider validatorProvider) { diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/IbftMessageTransmitter.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/IbftMessageTransmitter.java index dd52e8b40a..09a9a82ab7 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/IbftMessageTransmitter.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/IbftMessageTransmitter.java @@ -34,12 +34,12 @@ import org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleExcepti import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftMessageTransmitter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftMessageTransmitter.class); private final MessageFactory messageFactory; private final ValidatorMulticaster multicaster; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManager.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManager.java index 4c2bf31103..f8d236b362 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManager.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManager.java @@ -45,8 +45,8 @@ import java.util.function.Consumer; import java.util.function.Function; import com.google.common.collect.Maps; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for starting/clearing Consensus rounds at a given block height. One of these is @@ -56,7 +56,7 @@ import org.apache.logging.log4j.Logger; */ public class IbftBlockHeightManager implements BaseIbftBlockHeightManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftBlockHeightManager.class); private final IbftRoundFactory roundFactory; private final RoundChangeManager roundChangeManager; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftRound.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftRound.java index 8ab9b2e3f1..62026f5478 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftRound.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftRound.java @@ -44,13 +44,12 @@ import org.hyperledger.besu.util.Subscribers; import java.util.Optional; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IbftRound { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftRound.class); private final Subscribers observers; private final RoundState roundState; @@ -249,11 +248,17 @@ public class IbftRound { final long blockNumber = blockToImport.getHeader().getNumber(); final BftExtraData extraData = bftExtraDataCodec.decode(blockToImport.getHeader()); - LOG.log( - getRoundIdentifier().getRoundNumber() > 0 ? Level.INFO : Level.DEBUG, - "Importing block to chain. round={}, hash={}", - getRoundIdentifier(), - blockToImport.getHash()); + if (getRoundIdentifier().getRoundNumber() > 0) { + LOG.info( + "Importing block to chain. round={}, hash={}", + getRoundIdentifier(), + blockToImport.getHash()); + } else { + LOG.debug( + "Importing block to chain. round={}, hash={}", + getRoundIdentifier(), + blockToImport.getHash()); + } LOG.trace("Importing block with extraData={}", extraData); final boolean result = blockImporter.importBlock(protocolContext, blockToImport, HeaderValidationMode.FULL); diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundChangeManager.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundChangeManager.java index 473b3ea314..a024c92e45 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundChangeManager.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundChangeManager.java @@ -25,8 +25,8 @@ import java.util.Optional; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for handling all RoundChange messages received for a given block height @@ -72,7 +72,7 @@ public class RoundChangeManager { } } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangeManager.class); @VisibleForTesting final Map roundChangeCache = Maps.newHashMap(); diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundState.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundState.java index 22aa9e3af8..872763d851 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundState.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/RoundState.java @@ -29,12 +29,12 @@ import java.util.Set; import java.util.stream.Collectors; import com.google.common.collect.Sets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; // Data items used to define how a round will operate public class RoundState { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundState.class); private final ConsensusRoundIdentifier roundIdentifier; private final MessageValidator validator; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/FutureRoundProposalMessageValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/FutureRoundProposalMessageValidator.java index acc62c021c..df29545663 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/FutureRoundProposalMessageValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/FutureRoundProposalMessageValidator.java @@ -17,15 +17,16 @@ package org.hyperledger.besu.consensus.ibft.validation; import org.hyperledger.besu.consensus.ibft.messagewrappers.Proposal; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* One of these will be created by the IbftBlockHeightManager and will exist for the life of the chainheight, and used to ensure supplied Proposals are suitable for starting a new round. */ public class FutureRoundProposalMessageValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(FutureRoundProposalMessageValidator.class); private final MessageValidatorFactory messageValidatorFactory; private final long chainHeight; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java index dd9ec15707..2d41e53aca 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/MessageValidator.java @@ -29,12 +29,12 @@ import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MessageValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MessageValidator.class); private final SignedDataValidator signedDataValidator; private final ProposalBlockConsistencyValidator proposalConsistencyValidator; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/ProposalBlockConsistencyValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/ProposalBlockConsistencyValidator.java index 5356eb9806..d2a58d3386 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/ProposalBlockConsistencyValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/ProposalBlockConsistencyValidator.java @@ -21,12 +21,13 @@ import org.hyperledger.besu.consensus.common.bft.payload.SignedData; import org.hyperledger.besu.consensus.ibft.payload.ProposalPayload; import org.hyperledger.besu.ethereum.core.Block; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ProposalBlockConsistencyValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(ProposalBlockConsistencyValidator.class); public boolean validateProposalMatchesBlock( final SignedData signedPayload, diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeCertificateValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeCertificateValidator.java index 598b96bc39..15448395e2 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeCertificateValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeCertificateValidator.java @@ -30,12 +30,12 @@ import org.hyperledger.besu.ethereum.core.Block; import java.util.Collection; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoundChangeCertificateValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangeCertificateValidator.class); private final Collection
validators; private final MessageValidatorForHeightFactory messageValidatorFactory; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidator.java index 2bf404b172..db254012e2 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangeMessageValidator.java @@ -17,12 +17,12 @@ package org.hyperledger.besu.consensus.ibft.validation; import org.hyperledger.besu.consensus.common.bft.BftBlockInterface; import org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoundChangeMessageValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangeMessageValidator.class); private final RoundChangePayloadValidator roundChangePayloadValidator; private final ProposalBlockConsistencyValidator proposalBlockConsistencyValidator; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangePayloadValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangePayloadValidator.java index d7aba9f027..3524af57df 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangePayloadValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/RoundChangePayloadValidator.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.datatypes.Address; import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoundChangePayloadValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangePayloadValidator.class); private final MessageValidatorForHeightFactory messageValidatorFactory; private final Collection
validators; diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/SignedDataValidator.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/SignedDataValidator.java index 56ad7b5fb8..f72a251adb 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/SignedDataValidator.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/validation/SignedDataValidator.java @@ -27,12 +27,12 @@ import org.hyperledger.besu.ethereum.core.Util; import java.util.Collection; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SignedDataValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SignedDataValidator.class); private final Collection
validators; private final Address expectedProposer; diff --git a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftExtraData.java b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftExtraData.java index b501424508..2df4a71418 100644 --- a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftExtraData.java +++ b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftExtraData.java @@ -31,16 +31,16 @@ import java.util.Collection; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Represents the data structure stored in the extraData field of the BlockHeader used when * operating under an IBFT consensus mechanism. */ public class IbftExtraData implements ParsedExtraData { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftExtraData.class); public static final int EXTRA_VANITY_LENGTH = 32; private static final Supplier SIGNATURE_ALGORITHM = diff --git a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRule.java b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRule.java index a01bd319a8..e98ae46b01 100644 --- a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRule.java +++ b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/IbftExtraDataValidationRule.java @@ -31,8 +31,8 @@ import java.util.NavigableSet; import java.util.TreeSet; import com.google.common.collect.Iterables; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures the byte content of the extraData field can be deserialised into an appropriate @@ -41,7 +41,7 @@ import org.apache.logging.log4j.Logger; */ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(IbftExtraDataValidationRule.class); private final boolean validateCommitSeals; private final long ceil2nBy3Block; diff --git a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/VoteValidationRule.java b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/VoteValidationRule.java index 0929968df8..42301a8334 100644 --- a/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/VoteValidationRule.java +++ b/consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/headervalidationrules/VoteValidationRule.java @@ -18,12 +18,12 @@ import org.hyperledger.besu.consensus.ibftlegacy.IbftLegacyBlockInterface; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class VoteValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(VoteValidationRule.class); /** * Responsible for ensuring the nonce is either auth or drop. diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/PkiQbftBlockCreator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/PkiQbftBlockCreator.java index 6a9b197f1a..fd59ab298b 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/PkiQbftBlockCreator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/PkiQbftBlockCreator.java @@ -34,12 +34,12 @@ import org.hyperledger.besu.pki.cms.CmsCreator; import java.util.List; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PkiQbftBlockCreator implements BlockCreator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PkiQbftBlockCreator.class); private final BlockCreator blockCreator; private final PkiQbftExtraDataCodec pkiQbftExtraDataCodec; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/headervalidationrules/QbftValidatorsValidationRule.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/headervalidationrules/QbftValidatorsValidationRule.java index 74d530bb1f..0316131bbf 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/headervalidationrules/QbftValidatorsValidationRule.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/headervalidationrules/QbftValidatorsValidationRule.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.AttachedBlockHeaderValidationRule; import org.hyperledger.besu.ethereum.rlp.RLPException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures the Validators listed in the block header match that tracked in memory (which was in-turn @@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger; */ public class QbftValidatorsValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(QbftValidatorsValidationRule.class); private final boolean extraDataValidatorsAndVoteMustBeEmpty; private final BftValidatorsValidationRule bftValidatorsValidationRule = new BftValidatorsValidationRule(); diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java index ac1474188a..d7fef808c2 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftDiscardValidatorVote.java @@ -24,11 +24,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftDiscardValidatorVote implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftDiscardValidatorVote.class); private final ValidatorProvider validatorProvider; public QbftDiscardValidatorVote(final ValidatorProvider validatorProvider) { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java index e2fa3e7022..6fdc6fad06 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java @@ -28,11 +28,11 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftGetValidatorsByBlockHash implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftGetValidatorsByBlockHash.class); private final Blockchain blockchain; private final ValidatorProvider validatorProvider; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockNumber.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockNumber.java index fb976c5520..820c44e8d1 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockNumber.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockNumber.java @@ -27,12 +27,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftGetValidatorsByBlockNumber.class); private final ValidatorProvider validatorProvider; public QbftGetValidatorsByBlockNumber( diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java index 8a63578e8a..6153fd10c7 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftProposeValidatorVote.java @@ -25,11 +25,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftProposeValidatorVote implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftProposeValidatorVote.class); private final ValidatorProvider validatorProvider; public QbftProposeValidatorVote(final ValidatorProvider validatorProvider) { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java index 39c577c051..9a2d9329c8 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java @@ -37,12 +37,12 @@ import org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleExcepti import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftMessageTransmitter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftMessageTransmitter.class); private final MessageFactory messageFactory; private final ValidatorMulticaster multicaster; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/pki/PkiBlockCreationConfigurationProvider.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/pki/PkiBlockCreationConfigurationProvider.java index 8d5e53e210..fcd2169105 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/pki/PkiBlockCreationConfigurationProvider.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/pki/PkiBlockCreationConfigurationProvider.java @@ -21,12 +21,13 @@ import org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration; import org.hyperledger.besu.pki.keystore.KeyStoreWrapper; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PkiBlockCreationConfigurationProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(PkiBlockCreationConfigurationProvider.class); private final KeyStoreWrapperProvider keyStoreWrapperProvider; @@ -51,9 +52,7 @@ public class PkiBlockCreationConfigurationProvider { null); LOG.info("Loaded PKI Block Creation KeyStore {}", pkiKeyStoreConfiguration.getKeyStorePath()); } catch (Exception e) { - final String message = "Error loading PKI Block Creation KeyStore"; - LOG.error(message, e); - throw new RuntimeException(message, e); + throw new IllegalStateException("Error loading PKI Block Creation KeyStore", e); } KeyStoreWrapper trustStore; @@ -67,9 +66,7 @@ public class PkiBlockCreationConfigurationProvider { LOG.info( "Loaded PKI Block Creation TrustStore {}", pkiKeyStoreConfiguration.getTrustStorePath()); } catch (Exception e) { - final String message = "Error loading PKI Block Creation TrustStore"; - LOG.error(message, e); - throw new RuntimeException(message, e); + throw new IllegalStateException("Error loading PKI Block Creation TrustStore", e); } return new PkiBlockCreationConfiguration( diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java index f58d93d032..9377211783 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java @@ -40,8 +40,8 @@ import java.util.function.Consumer; import java.util.function.Function; import com.google.common.collect.Maps; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for starting/clearing Consensus rounds at a given block height. One of these is @@ -51,7 +51,7 @@ import org.apache.logging.log4j.Logger; */ public class QbftBlockHeightManager implements BaseQbftBlockHeightManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftBlockHeightManager.class); private final QbftRoundFactory roundFactory; private final RoundChangeManager roundChangeManager; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java index 520bc40dbc..d77970f0e5 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java @@ -49,13 +49,12 @@ import org.hyperledger.besu.util.Subscribers; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QbftRound { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(QbftRound.class); private final Subscribers observers; protected final RoundState roundState; @@ -267,11 +266,17 @@ public class QbftRound { final long blockNumber = blockToImport.getHeader().getNumber(); final BftExtraData extraData = bftExtraDataCodec.decode(blockToImport.getHeader()); - LOG.log( - getRoundIdentifier().getRoundNumber() > 0 ? Level.INFO : Level.DEBUG, - "Importing proposed block to chain. round={}, hash={}", - getRoundIdentifier(), - blockToImport.getHash()); + if (getRoundIdentifier().getRoundNumber() > 0) { + LOG.info( + "Importing proposed block to chain. round={}, hash={}", + getRoundIdentifier(), + blockToImport.getHash()); + } else { + LOG.debug( + "Importing proposed block to chain. round={}, hash={}", + getRoundIdentifier(), + blockToImport.getHash()); + } LOG.trace("Importing proposed block with extraData={}", extraData); final boolean result = blockImporter.importBlock(protocolContext, blockToImport, HeaderValidationMode.FULL); diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java index 10b824907f..4d067fbbcb 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java @@ -25,8 +25,8 @@ import java.util.Optional; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for handling all RoundChange messages received for a given block height @@ -72,7 +72,7 @@ public class RoundChangeManager { } } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangeManager.class); @VisibleForTesting final Map roundChangeCache = Maps.newHashMap(); diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java index 72ba262141..5dbd6dfb3f 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java @@ -28,12 +28,12 @@ import java.util.Set; import java.util.stream.Collectors; import com.google.common.collect.Sets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; // Data items used to define how a round will operate public class RoundState { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundState.class); private final ConsensusRoundIdentifier roundIdentifier; private final MessageValidator validator; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java index 7044103e55..625777fd05 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java @@ -24,14 +24,14 @@ import org.hyperledger.besu.ethereum.core.Util; import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CommitValidator { private static final String ERROR_PREFIX = "Invalid Commit Message"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CommitValidator.class); private final Collection
validators; private final ConsensusRoundIdentifier targetRound; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java index 4dddc4eb09..225a563187 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java @@ -27,12 +27,12 @@ import org.hyperledger.besu.ethereum.core.Block; import java.util.Collection; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MessageValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MessageValidator.class); public static class SubsequentMessageValidator { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java index c5b0cf8c01..471536a8f9 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java @@ -23,14 +23,14 @@ import org.hyperledger.besu.datatypes.Hash; import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrepareValidator { private static final String ERROR_PREFIX = "Invalid Prepare Message"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrepareValidator.class); private final Collection
validators; private final ConsensusRoundIdentifier targetRound; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java index d75b4d1c73..55b6700501 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java @@ -35,14 +35,14 @@ import org.hyperledger.besu.pki.cms.CmsValidator; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ProposalPayloadValidator { private static final String ERROR_PREFIX = "Invalid Proposal Payload"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProposalPayloadValidator.class); private final Address expectedProposer; private final ConsensusRoundIdentifier targetRound; private final BlockValidator blockValidator; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java index 40e02ebfec..a086efc075 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java @@ -40,12 +40,12 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ProposalValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProposalValidator.class); private static final String ERROR_PREFIX = "Invalid Proposal Payload"; private final BlockValidator blockValidator; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java index 882563d57f..bd7b14a594 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java @@ -33,14 +33,14 @@ import java.util.Collection; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoundChangeMessageValidator { private static final String ERROR_PREFIX = "Invalid RoundChange Message"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangeMessageValidator.class); private final RoundChangePayloadValidator roundChangePayloadValidator; private final long quorumMessageCount; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java index 6827ce72f7..fdc3bc52ba 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java @@ -21,8 +21,8 @@ import org.hyperledger.besu.datatypes.Address; import java.util.Collection; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Note: This does not validate that the received payload is for a future round, only that it was @@ -32,7 +32,7 @@ import org.apache.logging.log4j.Logger; public class RoundChangePayloadValidator { private static final String ERROR_PREFIX = "Invalid RoundChange Payload"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RoundChangePayloadValidator.class); private final Collection
validators; private final long chainHeight; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java index 71037f1f00..92adb94367 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import java.util.function.Consumer; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ValidatorModeTransitionLogger { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ValidatorModeTransitionLogger.class); private final ForksSchedule forksSchedule; private final Consumer msgConsumer; diff --git a/container-tests/tests/build.gradle b/container-tests/tests/build.gradle index 0401e8c385..5b4a9dccc4 100644 --- a/container-tests/tests/build.gradle +++ b/container-tests/tests/build.gradle @@ -18,7 +18,6 @@ jar { enabled = false } dependencies { testImplementation 'junit:junit' - testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl' testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' testImplementation 'org.testcontainers:testcontainers' diff --git a/crypto/build.gradle b/crypto/build.gradle index 872697ae20..9ad4cb9b23 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -32,17 +32,15 @@ dependencies { api project(':util') api 'org.bouncycastle:bcprov-jdk15on' + api 'org.slf4j:slf4j-api' implementation 'com.google.guava:guava' implementation 'net.java.dev.jna:jna' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-units' implementation 'org.hyperledger.besu:secp256k1' implementation 'org.hyperledger.besu:secp256r1' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-core' diff --git a/crypto/src/main/java/org/hyperledger/besu/crypto/KeyPairUtil.java b/crypto/src/main/java/org/hyperledger/besu/crypto/KeyPairUtil.java index 890843d738..690b9a98bb 100644 --- a/crypto/src/main/java/org/hyperledger/besu/crypto/KeyPairUtil.java +++ b/crypto/src/main/java/org/hyperledger/besu/crypto/KeyPairUtil.java @@ -28,12 +28,12 @@ import java.util.List; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.io.Resources; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class KeyPairUtil { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(KeyPairUtil.class); private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); diff --git a/crypto/src/main/java/org/hyperledger/besu/crypto/SECP256K1.java b/crypto/src/main/java/org/hyperledger/besu/crypto/SECP256K1.java index 732a25db25..9d58745618 100644 --- a/crypto/src/main/java/org/hyperledger/besu/crypto/SECP256K1.java +++ b/crypto/src/main/java/org/hyperledger/besu/crypto/SECP256K1.java @@ -27,14 +27,14 @@ import java.util.Optional; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.bouncycastle.crypto.digests.SHA256Digest; import org.bouncycastle.crypto.signers.DSAKCalculator; import org.bouncycastle.crypto.signers.HMacDSAKCalculator; import org.bouncycastle.math.ec.custom.sec.SecP256K1Curve; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* * Adapted from the BitcoinJ ECKey (Apache 2 License) implementation: @@ -46,7 +46,7 @@ import org.bouncycastle.math.ec.custom.sec.SecP256K1Curve; */ public class SECP256K1 extends AbstractSECP256 { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SECP256K1.class); private boolean useNative; diff --git a/crypto/src/main/java/org/hyperledger/besu/crypto/SignatureAlgorithmFactory.java b/crypto/src/main/java/org/hyperledger/besu/crypto/SignatureAlgorithmFactory.java index 97197df760..1589dadca3 100644 --- a/crypto/src/main/java/org/hyperledger/besu/crypto/SignatureAlgorithmFactory.java +++ b/crypto/src/main/java/org/hyperledger/besu/crypto/SignatureAlgorithmFactory.java @@ -15,12 +15,12 @@ package org.hyperledger.besu.crypto; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SignatureAlgorithmFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SignatureAlgorithmFactory.class); private static SignatureAlgorithm instance = null; diff --git a/enclave/build.gradle b/enclave/build.gradle index d42cd64cfd..608b91df1a 100644 --- a/enclave/build.gradle +++ b/enclave/build.gradle @@ -1,13 +1,13 @@ dependencies { api project(':util') api project(':crypto') + api 'org.slf4j:slf4j-api' implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' implementation 'org.apache.tuweni:tuweni-net' - implementation 'org.apache.logging.log4j:log4j-api' runtimeOnly('org.bouncycastle:bcpkix-jdk15on') diff --git a/errorprone-checks/build.gradle b/errorprone-checks/build.gradle index a4279c3efd..f5325cbb94 100644 --- a/errorprone-checks/build.gradle +++ b/errorprone-checks/build.gradle @@ -25,6 +25,8 @@ sourceCompatibility = 11 targetCompatibility = 11 dependencies { + api 'org.slf4j:slf4j-api' + annotationProcessor 'com.google.auto.service:auto-service' implementation 'com.google.auto.service:auto-service' @@ -34,7 +36,6 @@ dependencies { testImplementation 'com.google.errorprone:error_prone_test_helpers' testImplementation 'junit:junit' - testImplementation 'org.apache.logging.log4j:log4j-api' testImplementation 'org.assertj:assertj-core' epJavac 'com.google.errorprone:error_prone_check_api' diff --git a/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java b/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java index ca75532e14..9a805fbf92 100644 --- a/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java +++ b/errorprone-checks/src/main/java/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggers.java @@ -45,8 +45,7 @@ import com.sun.tools.javac.code.Type; linkType = BugPattern.LinkType.NONE) public class PrivateStaticFinalLoggers extends BugChecker implements VariableTreeMatcher { - static final Supplier ORG_APACHE_LOGGING_LOG4J_LOGGER = - Suppliers.typeFromString("org.apache.logging.log4j.Logger"); + static final Supplier ORG_SLF4J_LOGGER = Suppliers.typeFromString("org.slf4j.Logger"); @Override public Description matchVariable(final VariableTree tree, final VisitorState state) { @@ -58,7 +57,7 @@ public class PrivateStaticFinalLoggers extends BugChecker implements VariableTre .containsAll(List.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL))) { return NO_MATCH; } - if (!isSubtype(getType(tree), ORG_APACHE_LOGGING_LOG4J_LOGGER.get(state), state)) { + if (!isSubtype(getType(tree), ORG_SLF4J_LOGGER.get(state), state)) { return NO_MATCH; } return buildDescription(tree) diff --git a/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersNegativeCases.java b/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersNegativeCases.java index 1b53c21209..99d8986ac7 100644 --- a/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersNegativeCases.java +++ b/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersNegativeCases.java @@ -15,10 +15,11 @@ package org.hyperledger.errorpronechecks; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStaticFinalLoggersNegativeCases { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(PrivateStaticFinalLoggersNegativeCases.class); } diff --git a/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersPositiveCases.java b/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersPositiveCases.java index 8cd8168924..cbe6c772d7 100644 --- a/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersPositiveCases.java +++ b/errorprone-checks/src/test/resources/org/hyperledger/errorpronechecks/PrivateStaticFinalLoggersPositiveCases.java @@ -15,11 +15,11 @@ package org.hyperledger.errorpronechecks; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStaticFinalLoggersPositiveCases { // BUG: Diagnostic contains: Logger classes should be private, static, and final. - private final Logger LOG = LogManager.getLogger(); + private final Logger LOG = LoggerFactory.getLogger(PrivateStaticFinalLoggersPositiveCases.class); } diff --git a/ethereum/api/build.gradle b/ethereum/api/build.gradle index 7d9d6ee741..c710267738 100644 --- a/ethereum/api/build.gradle +++ b/ethereum/api/build.gradle @@ -32,6 +32,9 @@ configurations { } dependencies { + api 'org.slf4j:slf4j-api' + api 'org.apache.logging.log4j:log4j-api' + implementation project(':config') implementation project(':consensus:merge') implementation project(':crypto') @@ -61,7 +64,6 @@ dependencies { implementation 'io.vertx:vertx-web' implementation 'io.vertx:vertx-codegen' implementation 'com.fasterxml.jackson.core:jackson-databind' - implementation 'org.apache.logging.log4j:log4j-core' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-net' implementation 'org.apache.tuweni:tuweni-toml' @@ -89,6 +91,7 @@ dependencies { testImplementation 'io.vertx:vertx-unit' testImplementation 'junit:junit' + testImplementation 'org.apache.logging.log4j:log4j-core' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-core' testImplementation 'io.vertx:vertx-web-client' diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java index 12b6a7849a..b2e66a86db 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java @@ -58,14 +58,14 @@ import java.util.stream.Collectors; import com.google.common.base.Preconditions; import graphql.schema.DataFetcher; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GraphQLDataFetchers { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GraphQLDataFetchers.class); private Optional goQuorumPrivacyParameters = Optional.empty(); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java index e0ca99e192..b758cce3ba 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java @@ -65,12 +65,12 @@ import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.handler.BodyHandler; import io.vertx.ext.web.handler.CorsHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GraphQLHttpService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GraphQLHttpService.class); private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0); private static final String APPLICATION_JSON = "application/json"; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonResponseStreamer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonResponseStreamer.java index 22d906909f..7b980944f3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonResponseStreamer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonResponseStreamer.java @@ -20,12 +20,12 @@ import java.util.concurrent.Semaphore; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpServerResponse; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class JsonResponseStreamer extends OutputStream { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(JsonResponseStreamer.class); private final HttpServerResponse response; private final Semaphore paused = new Semaphore(0); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java index 2e7018b356..ec1b8fd853 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java @@ -106,12 +106,12 @@ import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.handler.BodyHandler; import io.vertx.ext.web.handler.CorsHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class JsonRpcHttpService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(JsonRpcHttpService.class); private static final String SPAN_CONTEXT = "span_context"; private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtils.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtils.java index ec0f9cd731..f8e4f5167d 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtils.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/AuthenticationUtils.java @@ -23,11 +23,11 @@ import com.google.common.annotations.VisibleForTesting; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.auth.User; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AuthenticationUtils { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AuthenticationUtils.class); @VisibleForTesting public static boolean isPermitted( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/LivenessCheck.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/LivenessCheck.java index 9786790d50..13cf7242c5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/LivenessCheck.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/LivenessCheck.java @@ -14,11 +14,11 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.health; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LivenessCheck implements HealthService.HealthCheck { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(LivenessCheck.class); @Override public boolean isHealthy(final HealthService.ParamSource params) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/ReadinessCheck.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/ReadinessCheck.java index 9e7a807a2f..38952a4408 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/ReadinessCheck.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/health/ReadinessCheck.java @@ -18,11 +18,11 @@ import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.plugin.data.SyncStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ReadinessCheck implements HealthService.HealthCheck { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ReadinessCheck.class); private static final int DEFAULT_MINIMUM_PEERS = 1; private static final int DEFAULT_MAX_BLOCKS_BEHIND = 2; private final P2PNetwork p2pNetwork; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminAddPeer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminAddPeer.java index d4345ea710..a4a72755cb 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminAddPeer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminAddPeer.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.ethereum.p2p.peers.Peer; import org.hyperledger.besu.plugin.data.EnodeURL; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AdminAddPeer extends AdminModifyPeer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AdminAddPeer.class); public AdminAddPeer(final P2PNetwork peerNetwork) { super(peerNetwork); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java index b8492656ed..16ed3ecd7e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java @@ -21,18 +21,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; +import org.hyperledger.besu.util.Log4j2ConfiguratorUtil; import java.util.Arrays; import java.util.Optional; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.config.Configurator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AdminChangeLogLevel implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AdminChangeLogLevel.class); @Override public String getName() { @@ -57,7 +57,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod { } private void setLogLevel(final String logFilter, final Level logLevel) { - LOG.log(Level.OFF, "Setting {} logging level to {} ", logFilter, logLevel.name()); - Configurator.setAllLevels(logFilter, logLevel); + LOG.debug("Setting {} logging level to {} ", logFilter, logLevel.name()); + Log4j2ConfiguratorUtil.setAllLevels(logFilter, logLevel); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminRemovePeer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminRemovePeer.java index baaab66bb7..248024c398 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminRemovePeer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminRemovePeer.java @@ -22,12 +22,12 @@ import org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.plugin.data.EnodeURL; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AdminRemovePeer extends AdminModifyPeer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AdminRemovePeer.class); public AdminRemovePeer(final P2PNetwork peerNetwork) { super(peerNetwork); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java index fa7c9566b9..97892ebda9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java @@ -35,13 +35,13 @@ import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import java.util.Collection; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DebugTraceBlock implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DebugTraceBlock.class); private final Supplier blockTracerSupplier; private final BlockHeaderFunctions blockHeaderFunctions; private final BlockchainQueries blockchain; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumber.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumber.java index 83f76bd807..8ae7431f92 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumber.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumber.java @@ -28,14 +28,14 @@ import org.hyperledger.besu.ethereum.core.Synchronizer; import java.util.function.Supplier; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthGetBlockByNumber extends AbstractBlockParameterMethod { private final BlockResultFactory blockResult; private final boolean includeCoinbase; - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(EthGetBlockByNumber.class); private final Synchronizer synchronizer; public EthGetBlockByNumber( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java index 5d2b6b3ea9..4ab12d6e11 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; @@ -32,12 +30,13 @@ import org.hyperledger.besu.ethereum.mainnet.PoWSolverInputs; import java.util.Optional; import com.google.common.io.BaseEncoding; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthGetWork implements JsonRpcMethod { private final MiningCoordinator miner; - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthGetWork.class); private final EpochCalculator epochCalculator; public EthGetWork(final MiningCoordinator miner) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java index 678bd8d31c..847d019bb4 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java @@ -32,11 +32,11 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import java.util.function.Supplier; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthSendRawTransaction implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthSendRawTransaction.class); private final boolean sendEmptyHashOnInvalidBlock; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java index ecf380eb5d..95e4de2b64 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; @@ -29,13 +27,14 @@ import org.hyperledger.besu.ethereum.mainnet.PoWSolverInputs; import java.util.Optional; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthSubmitWork implements JsonRpcMethod { private final MiningCoordinator miner; - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthSubmitWork.class); public EthSubmitWork(final MiningCoordinator miner) { this.miner = miner; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java index 635e3193d1..267f2d9fd6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java @@ -25,8 +25,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class ExecutionEngineJsonRpcMethod implements JsonRpcMethod { public enum ExecutionStatus { @@ -45,7 +45,7 @@ public abstract class ExecutionEngineJsonRpcMethod implements JsonRpcMethod { } private final Vertx syncVertx; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ExecutionEngineJsonRpcMethod.class); protected final MergeContext mergeContext; protected final ProtocolContext protocolContext; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginJsonRpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginJsonRpcMethod.java index 9e3a61d728..d5a5c0a81c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginJsonRpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginJsonRpcMethod.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PluginJsonRpcMethod implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PluginJsonRpcMethod.class); private final String name; private final Function function; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java index 8905def578..15f3b63074 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/PluginsReloadConfiguration.java @@ -26,12 +26,12 @@ import org.hyperledger.besu.plugin.BesuPlugin; import java.util.Map; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PluginsReloadConfiguration implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PluginsReloadConfiguration.class); private final Map namedPlugins; public PluginsReloadConfiguration(final Map namedPlugins) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceFilter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceFilter.java index c8d8dfa9b5..90083a44c0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceFilter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceFilter.java @@ -37,12 +37,12 @@ import java.util.Optional; import java.util.function.Supplier; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TraceFilter extends TraceBlock { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TraceFilter.class); public TraceFilter( final Supplier blockTracerSupplier, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExecutePayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExecutePayload.java index 05dccb5fd6..41622a586c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExecutePayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExecutePayload.java @@ -45,14 +45,14 @@ import java.util.stream.Collectors; import io.vertx.core.Vertx; import io.vertx.core.json.Json; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EngineExecutePayload extends ExecutionEngineJsonRpcMethod { private static final Hash OMMERS_HASH_CONSTANT = Hash.EMPTY_LIST_HASH; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EngineExecutePayload.class); private static final BlockHeaderFunctions headerFunctions = new MainnetBlockHeaderFunctions(); private final MergeMiningCoordinator mergeCoordinator; @@ -86,7 +86,9 @@ public class EngineExecutePayload extends ExecutionEngineJsonRpcMethod { return respondWith(reqId, blockParam.getBlockHash(), VALID, null); } - LOG.trace("blockparam: {}", () -> Json.encodePrettily(blockParam)); + if (LOG.isTraceEnabled()) { + LOG.trace("blockparam: {}", Json.encodePrettily(blockParam)); + } final List transactions; try { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayload.java index db48632a0f..7bcd60e9ce 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayload.java @@ -29,13 +29,13 @@ import org.hyperledger.besu.ethereum.core.Block; import java.util.Optional; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EngineGetPayload extends ExecutionEngineJsonRpcMethod { private final BlockResultFactory blockResultFactory; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EngineGetPayload.class); public EngineGetPayload( final Vertx vertx, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java index 9ec9d48c01..4ffe81419e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java @@ -28,14 +28,14 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @JsonIgnoreProperties(ignoreUnknown = true) public class JsonCallParameter extends CallParameter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(JsonCallParameter.class); private final Optional strict; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java index 8f848520d0..09ae469dfd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/MultiTenancyRpcMethodDecorator.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; @@ -26,10 +24,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcUnauth import java.util.Optional; import io.vertx.ext.auth.User; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MultiTenancyRpcMethodDecorator implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MultiTenancyRpcMethodDecorator.class); private final JsonRpcMethod rpcMethod; public MultiTenancyRpcMethodDecorator(final JsonRpcMethod rpcMethod) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java index 560137f864..fc2624a272 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter.convertTransactionInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DECODE_ERROR; @@ -43,11 +42,12 @@ import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFact import java.util.Optional; import io.vertx.ext.auth.User; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractEeaSendRawTransaction.class); private final TransactionPool transactionPool; private final PrivacyIdProvider privacyIdProvider; private final PrivateMarkerTransactionFactory privateMarkerTransactionFactory; @@ -102,7 +102,7 @@ public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod { } catch (final JsonRpcErrorResponseException e) { return new JsonRpcErrorResponse(id, e.getJsonRpcError()); } catch (final IllegalArgumentException | RLPException e) { - LOG.error(e); + LOG.error("Unable to decode EEA raw transaction", e); return new JsonRpcErrorResponse(id, DECODE_ERROR); } catch (final Exception e) { return new JsonRpcErrorResponse(id, convertEnclaveInvalidReason(e.getMessage())); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumEthGetQuorumPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumEthGetQuorumPayload.java index 71d6ba700b..f7b2f7c9c7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumEthGetQuorumPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumEthGetQuorumPayload.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.enclave.EnclaveClientException; import org.hyperledger.besu.enclave.GoQuorumEnclave; import org.hyperledger.besu.enclave.types.GoQuorumReceiveResponse; @@ -27,12 +25,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GoQuorumEthGetQuorumPayload implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GoQuorumEthGetQuorumPayload.class); private final GoQuorumEnclave enclave; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumSendRawPrivateTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumSendRawPrivateTransaction.java index 9d2992e6c6..c2c3ed51e0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumSendRawPrivateTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumSendRawPrivateTransaction.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter.convertTransactionInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DECODE_ERROR; @@ -40,12 +39,14 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import java.math.BigInteger; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GoQuorumSendRawPrivateTransaction implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(GoQuorumSendRawPrivateTransaction.class); final TransactionPool transactionPool; private final PrivacyIdProvider privacyIdProvider; private final GoQuorumEnclave enclave; @@ -102,10 +103,10 @@ public class GoQuorumSendRawPrivateTransaction implements JsonRpcMethod { } catch (final JsonRpcErrorResponseException e) { return new JsonRpcErrorResponse(id, e.getJsonRpcError()); } catch (final IllegalArgumentException | RLPException e) { - LOG.error(e); + LOG.error("Unable to decode private transaction for send", e); return new JsonRpcErrorResponse(id, DECODE_ERROR); } catch (final Exception e) { - LOG.error(e); + LOG.error("Unexpected error", e); return new JsonRpcErrorResponse(id, convertEnclaveInvalidReason(e.getMessage())); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumStoreRawPrivateTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumStoreRawPrivateTransaction.java index 5e1dbf7d3a..97c946e2f8 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumStoreRawPrivateTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumStoreRawPrivateTransaction.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DECODE_ERROR; @@ -30,12 +29,14 @@ import org.hyperledger.besu.ethereum.rlp.RLPException; import java.util.Base64; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GoQuorumStoreRawPrivateTransaction implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(GoQuorumStoreRawPrivateTransaction.class); private final GoQuorumEnclave enclave; public GoQuorumStoreRawPrivateTransaction(final GoQuorumEnclave enclave) { @@ -61,7 +62,7 @@ public class GoQuorumStoreRawPrivateTransaction implements JsonRpcMethod { LOG.debug("retrieved lookupId from GoQuorum enclave " + enclaveLookupId); return new JsonRpcSuccessResponse(id, hexEncodeEnclaveKey(enclaveLookupId)); } catch (final IllegalArgumentException | RLPException e) { - LOG.error(e); + LOG.error("Unable to decode private transaction for store", e); return new JsonRpcErrorResponse(id, DECODE_ERROR); } catch (final Exception e) { return new JsonRpcErrorResponse(id, convertEnclaveInvalidReason(e.getMessage())); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java index 122f735f5c..3527c02ad5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; @@ -28,11 +26,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.privacy.PrivacyController; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivCreatePrivacyGroup implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivCreatePrivacyGroup.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRoot.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRoot.java index 96b1d112a0..e7f9ec8f10 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRoot.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDebugGetStateRoot.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_PRIVACY_GROUP_ERROR; import org.hyperledger.besu.enclave.EnclaveClientException; @@ -35,11 +34,12 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController; import java.util.Optional; import java.util.regex.Pattern; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivDebugGetStateRoot extends AbstractBlockParameterMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivDebugGetStateRoot.class); private final PrivacyIdProvider privacyIdProvider; private final PrivacyController privacyController; @@ -68,7 +68,9 @@ public class PrivDebugGetStateRoot extends AbstractBlockParameterMethod { final JsonRpcRequestContext requestContext, final long blockNumber) { final String privacyGroupId = requestContext.getRequiredParameter(0, String.class); final String privacyUserId = privacyIdProvider.getPrivacyUserId(requestContext.getUser()); - LOG.trace("Executing {}", this::getName); + if (LOG.isTraceEnabled()) { + LOG.trace("Executing {}", getName()); + } final Optional privacyGroup; try { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java index 7bbb2e3af1..ed9bab3c5a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDeletePrivacyGroup.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DELETE_PRIVACY_GROUP_ERROR; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; @@ -27,11 +26,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSucces import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivDeletePrivacyGroup implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivDeletePrivacyGroup.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java index b53a29ec8f..b225fbf467 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter.convertTransactionInvalidReason; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.DECODE_ERROR; @@ -43,12 +42,13 @@ import java.util.Base64; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivDistributeRawTransaction implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivDistributeRawTransaction.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; private final boolean flexiblePrivacyGroupsEnabled; @@ -130,7 +130,7 @@ public class PrivDistributeRawTransaction implements JsonRpcMethod { LOG.error("Unauthorized privacy multi-tenancy rpc request. {}", e.getMessage()); return new JsonRpcErrorResponse(id, ENCLAVE_ERROR); } catch (final IllegalArgumentException | RLPException e) { - LOG.error(e); + LOG.error("Unable to decode transaction for distribute"); return new JsonRpcErrorResponse(id, DECODE_ERROR); } catch (final Exception e) { return new JsonRpcErrorResponse(id, convertEnclaveInvalidReason(e.getMessage())); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java index bbd125f816..f146d9a2d5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivFindPrivacyGroup.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_PRIVACY_GROUP_ERROR; import org.hyperledger.besu.enclave.types.PrivacyGroup; @@ -31,11 +30,12 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController; import java.util.Arrays; import java.util.List; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivFindPrivacyGroup implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivFindPrivacyGroup.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java index 80e9a759bc..84c9486847 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetEeaTransactionCount.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.GET_PRIVATE_TRANSACTION_NONCE_ERROR; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY; @@ -36,13 +35,14 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivGetEeaTransactionCount implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivGetEeaTransactionCount.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java index 313c3dfc01..d260647c84 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivateTransaction.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.EnclaveClientException; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcEnclaveErrorConverter; @@ -34,11 +32,12 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import java.util.Optional; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivGetPrivateTransaction implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivGetPrivateTransaction.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java index 2d7d86e5ff..824daacfc9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionCount.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.GET_PRIVATE_TRANSACTION_NONCE_ERROR; import org.hyperledger.besu.datatypes.Address; @@ -30,11 +29,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivGetTransactionCount implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivGetTransactionCount.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java index 8e0b9749db..000983a0cc 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetTransactionReceipt.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.EnclaveClientException; @@ -38,13 +36,14 @@ import org.hyperledger.besu.ethereum.rlp.RLP; import java.util.Optional; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivGetTransactionReceipt implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivGetTransactionReceipt.class); private final PrivateStateStorage privateStateStorage; private final PrivacyController privacyController; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java index 7a0f37f7c9..263ed2ab48 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/privx/PrivxFindFlexiblePrivacyGroup.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.privx; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.FIND_FLEXIBLE_PRIVACY_GROUP_ERROR; import org.hyperledger.besu.enclave.types.PrivacyGroup; @@ -31,11 +30,12 @@ import org.hyperledger.besu.ethereum.privacy.PrivacyController; import java.util.Arrays; import graphql.com.google.common.collect.Lists; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivxFindFlexiblePrivacyGroup implements JsonRpcMethod { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivxFindFlexiblePrivacyGroup.class); private final PrivacyController privacyController; private final PrivacyIdProvider privacyIdProvider; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/JsonResponseStreamer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/JsonResponseStreamer.java index 0c06256c65..1b5f441e8a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/JsonResponseStreamer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/JsonResponseStreamer.java @@ -21,12 +21,12 @@ import java.util.concurrent.Semaphore; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.ServerWebSocket; import io.vertx.core.http.WebSocketFrame; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class JsonResponseStreamer extends OutputStream { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(JsonResponseStreamer.class); private static final Buffer EMPTY_BUFFER = Buffer.buffer(); private final ServerWebSocket response; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketRequestHandler.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketRequestHandler.java index 12138550ec..2c5008d86f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketRequestHandler.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketRequestHandler.java @@ -53,12 +53,12 @@ import io.vertx.core.json.Json; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.ext.auth.User; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class WebSocketRequestHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketRequestHandler.class); private static final ObjectWriter JSON_OBJECT_WRITER = new ObjectMapper() .registerModule(new Jdk8Module()) // Handle JDK8 Optionals (de)serialization diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java index 907faf0c78..b5130ae608 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java @@ -41,12 +41,12 @@ import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.handler.BodyHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class WebSocketService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketService.class); private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0); private static final String APPLICATION_JSON = "application/json"; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/SubscriptionManager.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/SubscriptionManager.java index 8e7c8b3aed..899a54cc53 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/SubscriptionManager.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/SubscriptionManager.java @@ -39,8 +39,8 @@ import java.util.stream.Collectors; import io.vertx.core.AbstractVerticle; import io.vertx.core.eventbus.Message; import io.vertx.core.json.Json; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The SubscriptionManager is responsible for managing subscriptions and sending messages to the @@ -48,7 +48,7 @@ import org.apache.logging.log4j.Logger; */ public class SubscriptionManager extends AbstractVerticle implements PrivateTransactionObserver { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SubscriptionManager.class); public static final String EVENTBUS_REMOVE_SUBSCRIPTIONS_ADDRESS = "SubscriptionManager::removeSubscriptions"; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BackendQuery.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BackendQuery.java index 6c6e152ad4..e3209c499d 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BackendQuery.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BackendQuery.java @@ -20,11 +20,11 @@ import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BackendQuery { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BackendQuery.class); public static T runIfAlive(final Callable task, final Supplier alive) throws Exception { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java index 9988b2ed03..2f220afb67 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java @@ -22,7 +22,6 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; -import org.hyperledger.besu.ethereum.api.handlers.RpcMethodTimeoutException; import org.hyperledger.besu.ethereum.api.query.cache.TransactionLogBloomCacher; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.TransactionLocation; @@ -54,13 +53,13 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.LongStream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BlockchainQueries { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockchainQueries.class); private final WorldStateArchive worldStateArchive; private final Blockchain blockchain; @@ -670,12 +669,8 @@ public class BlockchainQueries { currentStep = nextStep; } return result; - } catch (final RpcMethodTimeoutException e) { - LOG.error("Error retrieving matching logs", e); - throw e; } catch (final Exception e) { - LOG.error("Error retrieving matching logs", e); - throw new RuntimeException(e); + throw new IllegalStateException("Error retrieving matching logs", e); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/StateBackupService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/StateBackupService.java index 39d9add219..bf07e408cb 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/StateBackupService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/StateBackupService.java @@ -52,14 +52,14 @@ import java.util.function.Function; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class StateBackupService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(StateBackupService.class); private static final Bytes ACCOUNT_END_MARKER; static { @@ -180,24 +180,19 @@ public class StateBackupService { } private BackupStatus backup(final long block, final boolean compress) throws IOException { - try { - checkArgument( - block >= 0 && block <= blockchain.getChainHeadBlockNumber(), - "Backup Block must be within blockchain"); - backupStatus.targetBlock = block; - backupStatus.compressed = compress; - backupStatus.currentAccount = Bytes32.ZERO; - - backupChainData(); - backupLeaves(); - - writeManifest(); - - return backupStatus; - } catch (final Throwable t) { - LOG.error("Unexpected error", t); - throw t; - } + checkArgument( + block >= 0 && block <= blockchain.getChainHeadBlockNumber(), + "Backup Block must be within blockchain"); + backupStatus.targetBlock = block; + backupStatus.compressed = compress; + backupStatus.currentAccount = Bytes32.ZERO; + + backupChainData(); + backupLeaves(); + + writeManifest(); + + return backupStatus; } private void writeManifest() throws IOException { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/AutoTransactionLogBloomCachingService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/AutoTransactionLogBloomCachingService.java index 8b654aa41d..567298404b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/AutoTransactionLogBloomCachingService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/AutoTransactionLogBloomCachingService.java @@ -28,11 +28,12 @@ import java.util.Optional; import java.util.OptionalLong; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AutoTransactionLogBloomCachingService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(AutoTransactionLogBloomCachingService.class); private final Blockchain blockchain; private final TransactionLogBloomCacher transactionLogBloomCacher; private OptionalLong blockAddedSubscriptionId = OptionalLong.empty(); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/LogBloomCacheMetadata.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/LogBloomCacheMetadata.java index cef41947c6..0e3113dbc9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/LogBloomCacheMetadata.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/LogBloomCacheMetadata.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LogBloomCacheMetadata { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(LogBloomCacheMetadata.class); public static final int DEFAULT_VERSION = 2; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacher.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacher.java index 3fe3ab93a9..bc37504116 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacher.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacher.java @@ -43,12 +43,12 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import com.fasterxml.jackson.annotation.JsonGetter; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TransactionLogBloomCacher { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TransactionLogBloomCacher.class); private static final String NO_SPACE_LEFT_ON_DEVICE = "No space left on device"; public static final int BLOCKS_PER_BLOOM_CACHE = 100_000; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java index a51dc2497e..5d3d1bb752 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java @@ -20,12 +20,9 @@ import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; import org.hyperledger.besu.ethereum.rlp.RLPException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; public class DomainObjectDecodeUtils { - private static final Logger LOG = LogManager.getLogger(); public static Transaction decodeRawTransaction(final String rawTransaction) throws InvalidJsonRpcRequestException { @@ -34,7 +31,6 @@ public class DomainObjectDecodeUtils { final boolean isGoQuorumCompatibilityMode = GoQuorumOptions.getGoQuorumCompatibilityMode(); return TransactionDecoder.decodeOpaqueBytes(txnBytes, isGoQuorumCompatibilityMode); } catch (final IllegalArgumentException | RLPException e) { - LOG.debug(e); throw new InvalidJsonRpcRequestException("Invalid raw transaction hex", e); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java index 1404c0328e..37aa5cb459 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java @@ -35,14 +35,14 @@ import io.vertx.core.json.JsonObject; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.junit.BeforeClass; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AdminJsonRpcHttpServiceTest.class); @BeforeClass public static void setup() throws Exception { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevelTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevelTest.java index 7b4a2f6ed0..59b1c53b67 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevelTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevelTest.java @@ -24,12 +24,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.config.Configurator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(MockitoJUnitRunner.class) public class AdminChangeLogLevelTest { @@ -55,14 +56,14 @@ public class AdminChangeLogLevelTest { final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId()); - final Level levelBeforeJsonRpcRequest = LogManager.getLogger().getLevel(); + final Logger loggerBeforeJsonRpcRequest = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); final JsonRpcSuccessResponse actualResponse = (JsonRpcSuccessResponse) adminChangeLogLevel.response(request); - final Level levelAfterJsonRpcRequest = LogManager.getLogger().getLevel(); + final Logger loggerAfterJsonRpcRequest = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); - assertThat(levelBeforeJsonRpcRequest).isEqualByComparingTo(Level.INFO); - assertThat(levelAfterJsonRpcRequest).isEqualByComparingTo(Level.DEBUG); + assertThat(loggerBeforeJsonRpcRequest.isInfoEnabled()).isTrue(); + assertThat(loggerAfterJsonRpcRequest.isDebugEnabled()).isTrue(); } @Test @@ -74,20 +75,20 @@ public class AdminChangeLogLevelTest { final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId()); - final Level levelOfAllProjectBeforeJsonRpcRequest = LogManager.getLogger().getLevel(); - final Level levelWithSpecificPackageBeforeJsonRpcRequest = - LogManager.getLogger("com").getLevel(); + final Logger loggerOfAllProjectBeforeJsonRpcRequest = + LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + final Logger loggerWithSpecificPackageBeforeJsonRpcRequest = LoggerFactory.getLogger("com"); final JsonRpcSuccessResponse actualResponse = (JsonRpcSuccessResponse) adminChangeLogLevel.response(request); - final Level levelOfAllProjectAfterJsonRpcRequest = LogManager.getLogger().getLevel(); - final Level levelWithSpecificPackageAfterJsonRpcRequest = - LogManager.getLogger("com").getLevel(); + final Logger loggerOfAllProjectAfterJsonRpcRequest = + LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + final Logger loggerWithSpecificPackageAfterJsonRpcRequest = LoggerFactory.getLogger("com"); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); - assertThat(levelOfAllProjectBeforeJsonRpcRequest).isEqualByComparingTo(Level.INFO); - assertThat(levelOfAllProjectAfterJsonRpcRequest).isEqualByComparingTo(Level.INFO); - assertThat(levelWithSpecificPackageBeforeJsonRpcRequest).isEqualByComparingTo(Level.INFO); - assertThat(levelWithSpecificPackageAfterJsonRpcRequest).isEqualByComparingTo(Level.DEBUG); + assertThat(loggerOfAllProjectBeforeJsonRpcRequest.isInfoEnabled()).isTrue(); + assertThat(loggerOfAllProjectAfterJsonRpcRequest.isInfoEnabled()).isTrue(); + assertThat(loggerWithSpecificPackageBeforeJsonRpcRequest.isInfoEnabled()).isTrue(); + assertThat(loggerWithSpecificPackageAfterJsonRpcRequest.isDebugEnabled()).isTrue(); } @Test @@ -98,14 +99,14 @@ public class AdminChangeLogLevelTest { final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId()); - final Level levelBeforeJsonRpcRequest = LogManager.getLogger().getLevel(); + final Logger loggerBeforeJsonRpcRequest = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); final JsonRpcSuccessResponse actualResponse = (JsonRpcSuccessResponse) adminChangeLogLevel.response(request); - final Level levelAfterJsonRpcRequest = LogManager.getLogger().getLevel(); + final Logger loggerAfterJsonRpcRequest = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse); - assertThat(levelBeforeJsonRpcRequest).isEqualByComparingTo(Level.INFO); - assertThat(levelAfterJsonRpcRequest).isEqualByComparingTo(Level.DEBUG); + assertThat(loggerBeforeJsonRpcRequest.isInfoEnabled()).isTrue(); + assertThat(loggerAfterJsonRpcRequest.isDebugEnabled()).isTrue(); } @Test diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index 7f2a9fc7da..10907b6204 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -50,9 +50,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractBlockCreator implements AsyncBlockCreator { @@ -61,7 +61,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { Bytes get(final BlockHeader parent); } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractBlockCreator.class); protected final Address coinbase; protected final Supplier> targetGasLimitSupplier; @@ -186,15 +186,13 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { return new Block(blockHeader, new BlockBody(transactionResults.getTransactions(), ommers)); } catch (final SecurityModuleException ex) { - LOG.warn("Failed to create block signature.", ex); - throw ex; + throw new IllegalStateException("Failed to create block signature", ex); } catch (final CancellationException ex) { - LOG.trace("Attempt to create block was interrupted."); - throw ex; + throw new IllegalStateException("Attempt to create block was interrupted", ex); } catch (final Exception ex) { // TODO(tmm): How are we going to know this has exploded, and thus restart it? - LOG.trace("Block creation failed unexpectedly. Will restart on next block added to chain."); - throw ex; + throw new IllegalStateException( + "Block creation failed unexpectedly. Will restart on next block added to chain.", ex); } } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java index 306fc6ec39..1b1f05fa42 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java @@ -34,13 +34,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractMinerExecutor> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractMinerExecutor.class); private final ExecutorService executorService = Executors.newCachedThreadPool(); protected final ProtocolContext protocolContext; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockMiner.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockMiner.java index 495a742fd5..b761cda1a9 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockMiner.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockMiner.java @@ -30,8 +30,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import com.google.common.base.Stopwatch; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for creating a block, and importing it to the blockchain. This is specifically a @@ -45,7 +45,7 @@ import org.apache.logging.log4j.Logger; */ public class BlockMiner implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockMiner.class); protected final Function blockCreatorFactory; protected final M minerBlockCreator; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java index 2d453646f3..50031b00ad 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java @@ -41,9 +41,9 @@ import java.util.concurrent.CancellationException; import java.util.function.Supplier; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for extracting transactions from PendingTransactions and determining if the @@ -66,7 +66,7 @@ import org.apache.tuweni.bytes.Bytes; * not cleared between executions of buildTransactionListForBlock(). */ public class BlockTransactionSelector { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockTransactionSelector.class); private final Wei minTransactionGasPrice; private final Double minBlockOccupancyRatio; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java index 2e17b81121..1c94bb7821 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.blockcreation; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; import org.hyperledger.besu.ethereum.chain.Blockchain; @@ -30,7 +28,8 @@ import java.util.concurrent.TimeUnit; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for determining when a block mining operation should be started/stopped, then @@ -39,7 +38,7 @@ import org.apache.logging.log4j.Logger; public class PoWMiningCoordinator extends AbstractMiningCoordinator implements BlockAddedObserver { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PoWMiningCoordinator.class); private final PoWMinerExecutor executor; diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index 34d3bf1096..ef6c58441e 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -38,6 +38,8 @@ sourceSets { } dependencies { + api 'org.slf4j:slf4j-api' + annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess' implementation project(':config') @@ -56,7 +58,6 @@ dependencies { implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.vertx:vertx-core' implementation 'net.java.dev.jna:jna' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-concurrent' implementation 'org.apache.tuweni:tuweni-units' @@ -67,8 +68,6 @@ dependencies { annotationProcessor 'org.immutables:value' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation project(path: ':config', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:api') testImplementation project(path: ':ethereum:referencetests') diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java index 531d5cc6c7..fc0c14cb84 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; @@ -33,11 +31,12 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MainnetBlockValidator implements BlockValidator { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MainnetBlockValidator.class); protected final BlockHeaderValidator blockHeaderValidator; protected final BlockBodyValidator blockBodyValidator; protected final BlockProcessor blockProcessor; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldStateKeyValueStorage.java index d3f7e5d79a..f539b899da 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldStateKeyValueStorage.java @@ -18,13 +18,14 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BonsaiInMemoryWorldStateKeyValueStorage extends BonsaiWorldStateKeyValueStorage implements WorldStateStorage { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(BonsaiInMemoryWorldStateKeyValueStorage.class); public BonsaiInMemoryWorldStateKeyValueStorage( final KeyValueStorage accountStorage, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java index 72b9a9e148..04a383a022 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java @@ -38,15 +38,15 @@ import java.util.function.Function; import java.util.stream.Stream; import javax.annotation.Nonnull; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BonsaiPersistedWorldState implements MutableWorldState, BonsaiWorldView { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BonsaiPersistedWorldState.class); protected final BonsaiWorldStateKeyValueStorage worldStateStorage; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java index 447cfdbdb4..3f10fd96db 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java @@ -34,15 +34,15 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BonsaiWorldStateArchive implements WorldStateArchive { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateArchive.class); private static final long RETAINED_LAYERS = 512; // at least 256 + typical rollbacks diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchain.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchain.java index ffb2f92c9a..194fa9c8e4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchain.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchain.java @@ -49,11 +49,11 @@ import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import com.google.common.collect.Streams; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DefaultBlockchain implements MutableBlockchain { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DefaultBlockchain.class); protected final BlockchainStorage blockchainStorage; private final Subscribers blockAddedObservers = Subscribers.create(); @@ -452,28 +452,28 @@ public class DefaultBlockchain implements MutableBlockchain { final BlockWithReceipts newChainHeadWithReceipts, final BlockWithReceipts oldChainWithReceipts, final BlockWithReceipts commonAncestorWithReceipts) { - if (newChainHeadWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber() - > reorgLoggingThreshold - || oldChainWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber() - > reorgLoggingThreshold) { + if ((newChainHeadWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber() + > reorgLoggingThreshold + || oldChainWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber() + > reorgLoggingThreshold) + && LOG.isWarnEnabled()) { LOG.warn( "Chain Reorganization +{} new / -{} old\n{}", - () -> newChainHeadWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber(), - () -> oldChainWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber(), - () -> - Streams.zip( - Stream.of("Old", "New", "Ancestor"), - Stream.of( - oldChainWithReceipts, - newChainHeadWithReceipts, - commonAncestorWithReceipts) - .map( - blockWithReceipts -> - String.format( - "hash: %s, height: %s", - blockWithReceipts.getHash(), blockWithReceipts.getNumber())), - (label, values) -> String.format("%10s - %s", label, values)) - .collect(joining("\n"))); + newChainHeadWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber(), + oldChainWithReceipts.getNumber() - commonAncestorWithReceipts.getNumber(), + Streams.zip( + Stream.of("Old", "New", "Ancestor"), + Stream.of( + oldChainWithReceipts, + newChainHeadWithReceipts, + commonAncestorWithReceipts) + .map( + blockWithReceipts -> + String.format( + "hash: %s, height: %s", + blockWithReceipts.getHash(), blockWithReceipts.getNumber())), + (label, values) -> String.format("%10s - %s", label, values)) + .collect(joining("\n"))); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java index a33107b884..13647af9e1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java @@ -47,13 +47,13 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GoQuorumBlockProcessor extends MainnetBlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GoQuorumBlockProcessor.class); private final GoQuorumEnclave goQuorumEnclave; private final GoQuorumPrivateStorage goQuorumPrivateStorage; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumPrivateStateUtil.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumPrivateStateUtil.java index 2ce5ea2aea..45e5ca3742 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumPrivateStateUtil.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumPrivateStateUtil.java @@ -15,8 +15,6 @@ package org.hyperledger.besu.ethereum.goquorum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters; @@ -25,10 +23,11 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import java.util.Optional; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GoQuorumPrivateStateUtil { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GoQuorumPrivateStateUtil.class); public static MutableWorldState getPrivateWorldStateAtBlock( final Optional goQuorumPrivacyParameters, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 75a2f4af37..f4b02fcee5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -36,8 +36,8 @@ import java.util.Collections; import java.util.List; import com.google.common.collect.ImmutableList; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractBlockProcessor implements BlockProcessor { @@ -51,7 +51,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { long gasUsed); } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractBlockProcessor.class); static final int MAX_GENERATION = 6; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java index aefeaf5856..9d8683f708 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java @@ -26,11 +26,11 @@ import java.util.List; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BaseFeeBlockBodyValidator extends MainnetBlockBodyValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BaseFeeBlockBodyValidator.class); public BaseFeeBlockBodyValidator(final ProtocolSchedule protocolSchedule) { super(protocolSchedule); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockHeaderValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockHeaderValidator.java index 77bc33232d..16b4119980 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockHeaderValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockHeaderValidator.java @@ -23,12 +23,12 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BlockHeaderValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockHeaderValidator.class); private final List rules; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java index 3840612362..3434e856e0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java @@ -24,12 +24,12 @@ import java.math.BigInteger; import java.util.List; import java.util.OptionalLong; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ClassicBlockProcessor extends AbstractBlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ClassicBlockProcessor.class); private static final long DEFAULT_ERA_LENGTH = 5_000_000L; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierTargetingGasLimitCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierTargetingGasLimitCalculator.java index 1443035f6b..49295e3946 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierTargetingGasLimitCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierTargetingGasLimitCalculator.java @@ -16,12 +16,13 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.ethereum.GasLimitCalculator; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FrontierTargetingGasLimitCalculator extends AbstractGasLimitSpecification implements GasLimitCalculator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(FrontierTargetingGasLimitCalculator.class); private final long maxConstantAdjustmentIncrement; public FrontierTargetingGasLimitCalculator() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonTargetingGasLimitCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonTargetingGasLimitCalculator.java index f50dadbcb9..6e03a2523e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonTargetingGasLimitCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonTargetingGasLimitCalculator.java @@ -16,11 +16,12 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LondonTargetingGasLimitCalculator extends FrontierTargetingGasLimitCalculator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(LondonTargetingGasLimitCalculator.class); private final long londonForkBlock; private final BaseFeeMarket feeMarket; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java index 55272aa0a7..5494766066 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java @@ -26,13 +26,13 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MainnetBlockBodyValidator implements BlockBodyValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MainnetBlockBodyValidator.class); private static final int MAX_OMMERS = 2; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java index 9ff3562bba..65ebbbe4a7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java @@ -25,12 +25,12 @@ import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MainnetBlockProcessor extends AbstractBlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MainnetBlockProcessor.class); public MainnetBlockProcessor( final MainnetTransactionProcessor transactionProcessor, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java index b8725061b8..a988ecf11b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java @@ -56,14 +56,14 @@ import java.util.Set; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MainnetTransactionProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MainnetTransactionProcessor.class); protected final GasCalculator gasCalculator; @@ -404,8 +404,8 @@ public class MainnetTransactionProcessor { if (LOG.isTraceEnabled()) { LOG.trace( "Gas used by transaction: {}, by message call/contract creation: {}", - () -> Gas.of(transaction.getGasLimit()).minus(initialFrame.getRemainingGas()), - () -> gasAvailable.minus(initialFrame.getRemainingGas())); + Gas.of(transaction.getGasLimit()).minus(initialFrame.getRemainingGas()), + gasAvailable.minus(initialFrame.getRemainingGas())); } // Refund the sender by what we should and pay the miner fee (note that we're doing them one diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java index b0c0f2e4d1..af9327bea8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.chain.PoWObserver; import org.hyperledger.besu.util.Subscribers; @@ -25,15 +23,16 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import com.google.common.base.Stopwatch; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.concurrent.ExpiringMap; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PoWSolver { private final int maxOmmerDepth; - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PoWSolver.class); private final long powJobTimeToLive; public static class PoWSolverJob { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java index 75532c66e1..bbd454ffbb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java @@ -40,14 +40,14 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivacyBlockProcessor implements BlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyBlockProcessor.class); private final BlockProcessor blockProcessor; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java index f83b80db69..a802ee21de 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java @@ -28,8 +28,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ProtocolScheduleBuilder { @@ -61,7 +61,7 @@ public class ProtocolScheduleBuilder { } } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProtocolScheduleBuilder.class); private final GenesisConfigOptions config; private final ProtocolSpecAdapters protocolSpecAdapters; private final Optional defaultChainId; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index 2a057cf9db..0725d564fc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -23,16 +23,16 @@ import org.hyperledger.besu.ethereum.core.feemarket.TransactionPriceCalculator; import java.util.Optional; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.units.bigints.UInt256s; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LondonFeeMarket implements BaseFeeMarket { static final Wei DEFAULT_BASEFEE_INITIAL_VALUE = GenesisConfigFile.BASEFEE_AT_GENESIS_DEFAULT_VALUE; static final long DEFAULT_BASEFEE_MAX_CHANGE_DENOMINATOR = 8L; static final long DEFAULT_SLACK_COEFFICIENT = 2L; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(LondonFeeMarket.class); private final Wei baseFeeInitialValue; private final long londonForkBlockNumber; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/AncestryValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/AncestryValidationRule.java index 6dc9d922bd..3f128313e5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/AncestryValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/AncestryValidationRule.java @@ -17,15 +17,15 @@ package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Ensures the hash of the parent block matches that specified in the parent hash of the proposed * header. */ public class AncestryValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AncestryValidationRule.class); @Override public boolean validate(final BlockHeader header, final BlockHeader parent) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRule.java index d4b00c1459..8e1b4315f1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRule.java @@ -22,12 +22,13 @@ import org.hyperledger.besu.ethereum.core.feemarket.FeeMarketException; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BaseFeeMarketBlockHeaderGasPriceValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(BaseFeeMarketBlockHeaderGasPriceValidationRule.class); private final BaseFeeMarket baseFeeMarket; public BaseFeeMarketBlockHeaderGasPriceValidationRule(final BaseFeeMarket baseFeeMarket) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/CalculatedDifficultyValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/CalculatedDifficultyValidationRule.java index 9a93260fe2..01847bd077 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/CalculatedDifficultyValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/CalculatedDifficultyValidationRule.java @@ -21,11 +21,12 @@ import org.hyperledger.besu.ethereum.mainnet.DifficultyCalculator; import java.math.BigInteger; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CalculatedDifficultyValidationRule implements AttachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(CalculatedDifficultyValidationRule.class); private final DifficultyCalculator difficultyCalculator; public CalculatedDifficultyValidationRule(final DifficultyCalculator difficultyCalculator) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ConstantFieldValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ConstantFieldValidationRule.java index 4f1bfc38c8..c2de1293d5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ConstantFieldValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ConstantFieldValidationRule.java @@ -14,17 +14,16 @@ */ package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; import java.util.function.Function; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConstantFieldValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ConstantFieldValidationRule.class); private final T expectedValue; private final Function accessor; private final String fieldName; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ExtraDataMaxLengthValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ExtraDataMaxLengthValidationRule.java index 5f7e6428f2..438d5e426a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ExtraDataMaxLengthValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ExtraDataMaxLengthValidationRule.java @@ -17,9 +17,9 @@ package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for ensuring the extra data fields in the header contain the appropriate number of @@ -27,7 +27,7 @@ import org.apache.tuweni.bytes.Bytes; */ public class ExtraDataMaxLengthValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ExtraDataMaxLengthValidationRule.class); private final long maxExtraDataBytes; public ExtraDataMaxLengthValidationRule(final long maxExtraDataBytes) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitRangeAndDeltaValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitRangeAndDeltaValidationRule.java index d1180526fe..752fd69e64 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitRangeAndDeltaValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitRangeAndDeltaValidationRule.java @@ -21,8 +21,8 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for ensuring the gasLimit specified in the supplied block header is within bounds as @@ -32,7 +32,8 @@ import org.apache.logging.log4j.Logger; public class GasLimitRangeAndDeltaValidationRule extends AbstractGasLimitSpecification implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(GasLimitRangeAndDeltaValidationRule.class); + private static final Logger LOG = + LoggerFactory.getLogger(GasLimitRangeAndDeltaValidationRule.class); private final Optional baseFeeMarket; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasUsageValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasUsageValidationRule.java index 7140e1a7d7..1756349d71 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasUsageValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasUsageValidationRule.java @@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Validates the gas used in executing the block (defined by the supplied header) is less than or @@ -26,7 +26,7 @@ import org.apache.logging.log4j.Logger; */ public class GasUsageValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GasUsageValidationRule.class); public GasUsageValidationRule() {} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRule.java index 01985740ea..2d2e66cb81 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRule.java @@ -28,13 +28,13 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import java.math.BigInteger; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class ProofOfWorkValidationRule implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ProofOfWorkValidationRule.class); private static final BigInteger ETHASH_TARGET_UPPER_BOUND = BigInteger.valueOf(2).pow(256); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampBoundedByFutureParameter.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampBoundedByFutureParameter.java index 68b5ae94cc..c5271b67ea 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampBoundedByFutureParameter.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampBoundedByFutureParameter.java @@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for ensuring the timestamp of a block is not more than "acceptableClockDriftSeconds' @@ -28,7 +28,8 @@ import org.apache.logging.log4j.Logger; */ public class TimestampBoundedByFutureParameter implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(TimestampBoundedByFutureParameter.class); private final long acceptableClockDriftSeconds; public TimestampBoundedByFutureParameter(final long acceptableClockDriftSeconds) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampMoreRecentThanParent.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampMoreRecentThanParent.java index 08ce0173b3..6aa7e5479e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampMoreRecentThanParent.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/TimestampMoreRecentThanParent.java @@ -19,13 +19,13 @@ import static com.google.common.base.Preconditions.checkArgument; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Responsible for ensuring the timestamp of a block is newer than its parent. */ public class TimestampMoreRecentThanParent implements DetachedBlockHeaderValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TimestampMoreRecentThanParent.class); private final long minimumSecondsSinceParent; public TimestampMoreRecentThanParent(final long minimumSecondsSinceParent) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java index 39c6c0e213..8a2201c52f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/FlexiblePrivacyPrecompiledContract.java @@ -52,14 +52,15 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FlexiblePrivacyPrecompiledContract extends PrivacyPrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(FlexiblePrivacyPrecompiledContract.class); private final Subscribers privateTransactionEventObservers = Subscribers.create(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java index 9f0f50e29a..a11f75af70 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java @@ -28,13 +28,13 @@ import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivacyPluginPrecompiledContract extends PrivacyPrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyPluginPrecompiledContract.class); private final PrivacyParameters privacyParameters; public PrivacyPluginPrecompiledContract( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java index 52f4688e87..b0e4195d0f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java @@ -51,10 +51,10 @@ import org.hyperledger.besu.plugin.data.Hash; import java.util.Base64; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { private final Enclave enclave; @@ -63,7 +63,7 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { private final PrivateStateGenesisAllocator privateStateGenesisAllocator; PrivateTransactionProcessor privateTransactionProcessor; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivacyPrecompiledContract.class); public PrivacyPrecompiledContract( final GasCalculator gasCalculator, @@ -147,11 +147,10 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { // This exception is thrown when the privacy group can not be found return Bytes.EMPTY; } catch (final EnclaveServerException e) { - LOG.error("Enclave is responding with an error, perhaps it has a misconfiguration?", e); - throw e; + throw new IllegalStateException( + "Enclave is responding with an error, perhaps it has a misconfiguration?", e); } catch (final EnclaveIOException e) { - LOG.error("Can not communicate with enclave, is it up?", e); - throw e; + throw new IllegalStateException("Can not communicate with enclave, is it up?", e); } LOG.debug("Processing private transaction {} in privacy group {}", pmtHash, privacyGroupId); @@ -256,11 +255,10 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { try { receiveResponse = enclave.receive(key); } catch (final EnclaveServerException e) { - LOG.error("Enclave is responding with an error, perhaps it has a misconfiguration?", e); - throw e; + throw new IllegalStateException( + "Enclave is responding with an error, perhaps it has a misconfiguration?", e); } catch (final EnclaveIOException e) { - LOG.error("Can not communicate with enclave is it up?", e); - throw e; + throw new IllegalStateException("Can not communicate with enclave is it up?", e); } return receiveResponse; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java index e6bea4535d..7c28d6e8a3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/FlexiblePrivacyController.java @@ -46,15 +46,15 @@ import java.util.List; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FlexiblePrivacyController extends AbstractRestrictedPrivacyController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FlexiblePrivacyController.class); private FlexiblePrivacyGroupContract flexiblePrivacyGroupContract; @@ -103,15 +103,9 @@ public class FlexiblePrivacyController extends AbstractRestrictedPrivacyControll final PrivateTransaction privateTransaction, final String privacyUserId, final Optional privacyGroup) { - final String firstPart; - try { - LOG.trace("Storing private transaction in enclave"); - final SendResponse sendResponse = sendRequest(privateTransaction, privacyGroup); - firstPart = sendResponse.getKey(); - } catch (final Exception e) { - LOG.error("Failed to store private transaction in enclave", e); - throw e; - } + LOG.trace("Storing private transaction in enclave"); + final SendResponse sendResponse = sendRequest(privateTransaction, privacyGroup); + final String firstPart = sendResponse.getKey(); final Optional optionalSecondPart = buildAndSendAddPayload( privateTransaction, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java index 955461ef41..a4ee631a01 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java @@ -44,13 +44,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateGroupRehydrationBlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(PrivateGroupRehydrationBlockProcessor.class); static final int MAX_GENERATION = 6; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java index db91fbc454..1ce016b098 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java @@ -28,14 +28,14 @@ import org.hyperledger.besu.plugin.services.privacy.PrivacyGroupGenesisProvider; import java.math.BigInteger; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStateGenesisAllocator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateStateGenesisAllocator.class); private final Boolean isFlexiblePrivacyEnabled; private final PrivacyGroupGenesisProvider privacyGroupGenesisProvider; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java index 05edb3d4e7..c7093c671b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateRehydration.java @@ -32,14 +32,14 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStateRehydration { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateStateRehydration.class); private final PrivateStateStorage privateStateStorage; private final Blockchain blockchain; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransaction.java index 68e2eda417..c108d27626 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransaction.java @@ -44,15 +44,15 @@ import java.util.Optional; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** An operation submitted by an external actor to be applied to the system. */ public class PrivateTransaction implements org.hyperledger.besu.plugin.data.PrivateTransaction { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateTransaction.class); // Used for transactions that are not tied to a specific chain // (i.e. does not have a chain id associated with it). diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocator.java index 454240321a..f6b951dbbd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionLocator.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.privacy; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.logging.log4j.LogManager.getLogger; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.Enclave; @@ -35,13 +34,14 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateTransactionLocator { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateTransactionLocator.class); private final Blockchain blockchain; private final Enclave enclave; @@ -155,8 +155,7 @@ public class PrivateTransactionLocator { privateTransaction = PrivateTransaction.readFrom(input); } } catch (final RLPException e) { - LOG.debug("Error de-serializing private transaction from enclave", e); - throw e; + throw new IllegalStateException("Error de-serializing private transaction from enclave", e); } return new TransactionFromEnclave(privateTransaction, receiveResponse.getPrivacyGroupId()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java index 8a1dd7dc1d..6ea2f1e160 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java @@ -44,13 +44,13 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateTransactionProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateTransactionProcessor.class); private final GasCalculator gasCalculator; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java index 70d5120f7c..2be5dc5dae 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java @@ -20,12 +20,12 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import java.math.BigInteger; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateTransactionValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateTransactionValidator.class); private final Optional chainId; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java index 17cf2903a9..2a00d58f4a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java @@ -28,13 +28,14 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RestrictedDefaultPrivacyController extends AbstractRestrictedPrivacyController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(RestrictedDefaultPrivacyController.class); public RestrictedDefaultPrivacyController( final Blockchain blockchain, @@ -79,15 +80,10 @@ public class RestrictedDefaultPrivacyController extends AbstractRestrictedPrivac final PrivateTransaction privateTransaction, final String privacyUserId, final Optional maybePrivacyGroup) { - try { - LOG.trace("Storing private transaction in enclave"); - final SendResponse sendResponse = - sendRequest(privateTransaction, privacyUserId, maybePrivacyGroup); - return sendResponse.getKey(); - } catch (final Exception e) { - LOG.error("Failed to store private transaction in enclave", e); - throw e; - } + LOG.trace("Storing private transaction in enclave"); + final SendResponse sendResponse = + sendRequest(privateTransaction, privacyUserId, maybePrivacyGroup); + return sendResponse.getKey(); } @Override diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java index b7b3fabbc7..bac2a9bfe5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java @@ -35,12 +35,12 @@ import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateMigrationBlockProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateMigrationBlockProcessor.class); static final int MAX_GENERATION = 6; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigration.java index 39823e91c9..a0f0f41612 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigration.java @@ -36,13 +36,13 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStorageMigration { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateStorageMigration.class); private final Blockchain blockchain; private final Address privacyPrecompileAddress; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationService.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationService.java index 9b2c7c4365..3eba73fc0a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationService.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationService.java @@ -21,12 +21,12 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrivateStorageMigrationService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrivateStorageMigrationService.class); private final PrivateStateStorage privateStateStorage; private final boolean migrationFlag; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java index e5ae3d2eff..1fac0298b0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java @@ -42,14 +42,14 @@ import java.util.function.Function; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MarkSweepPruner { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MarkSweepPruner.class); private static final byte[] IN_USE = Bytes.of(1).toArrayUnsafe(); private static final int DEFAULT_OPS_PER_TRANSACTION = 10_000; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java index 84e816b28b..04949b55e1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java @@ -30,12 +30,12 @@ import java.util.concurrent.atomic.AtomicReference; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Pruner { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Pruner.class); private final MarkSweepPruner pruningStrategy; private final Blockchain blockchain; @@ -165,7 +165,7 @@ public class Pruner { try { executorService.execute(action); } catch (final MerkleTrieException mte) { - LOG.fatal( + LOG.error( "An unrecoverable error occurred while pruning. The database directory must be deleted and resynced.", mte); System.exit(1); diff --git a/ethereum/eth/build.gradle b/ethereum/eth/build.gradle index 9dd6acdaf5..37c335767c 100644 --- a/ethereum/eth/build.gradle +++ b/ethereum/eth/build.gradle @@ -34,6 +34,8 @@ task testJar(type: Jar) { } dependencies { + api 'org.slf4j:slf4j-api' + annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess' implementation project(':config') implementation project(':datatypes') diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java index 5aedb769c1..a0ce294816 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java @@ -56,12 +56,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthPeer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthPeer.class); private static final int MAX_OUTSTANDING_REQUESTS = 5; @@ -226,14 +226,14 @@ public class EthPeer { "Permissioning blocked sending of message code {} to {}", messageData.getCode(), connection.getRemoteEnode()); - LOG.debug( - "Permissioning blocked by providers {}", - () -> - permissioningProviders.stream() - .filter( - p -> - !p.isMessagePermitted( - connection.getRemoteEnode(), messageData.getCode()))); + if (LOG.isDebugEnabled()) { + LOG.debug( + "Permissioning blocked by providers {}", + permissioningProviders.stream() + .filter( + p -> + !p.isMessagePermitted(connection.getRemoteEnode(), messageData.getCode()))); + } return null; } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java index d72f0d69dd..716f426edf 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java @@ -50,12 +50,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthProtocolManager.class); private final EthScheduler scheduler; private final CountDownLatch shutdown; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java index b834f4472e..12ed0044d7 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java @@ -37,11 +37,11 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EthScheduler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthScheduler.class); private final Duration defaultTimeout = Duration.ofSeconds(5); private final AtomicBoolean stopped = new AtomicBoolean(false); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/PeerReputation.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/PeerReputation.java index 060c902d51..2955c713ed 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/PeerReputation.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/PeerReputation.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.eth.manager; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason; import java.util.Map; @@ -27,10 +25,11 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PeerReputation { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerReputation.class); private static final int TIMEOUT_THRESHOLD = 3; private static final int USELESS_RESPONSE_THRESHOLD = 5; static final long USELESS_RESPONSE_WINDOW_IN_MILLIS = diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java index 2f4a12726d..b6873a7680 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java @@ -36,11 +36,11 @@ import java.util.Map; import java.util.Optional; import com.google.common.collect.ImmutableList; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SnapProtocolManager implements ProtocolManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SnapProtocolManager.class); private final List peerValidators; private final List supportedCapabilities; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java index 1a6104e5dc..c32eff3372 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractGetHeadersFromPeerTask.java @@ -31,14 +31,14 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Retrieves a sequence of headers from a peer. */ public abstract class AbstractGetHeadersFromPeerTask extends AbstractPeerRequestTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractGetHeadersFromPeerTask.class); private final ProtocolSchedule protocolSchedule; protected final int count; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractPeerRequestTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractPeerRequestTask.java index fe6b5e856e..fa364b4044 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractPeerRequestTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractPeerRequestTask.java @@ -31,11 +31,11 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractPeerRequestTask extends AbstractPeerTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractPeerRequestTask.class); private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(5); private Duration timeout = DEFAULT_TIMEOUT; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractRetryingPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractRetryingPeerTask.java index 75ce70a9d2..51146e7de6 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractRetryingPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/AbstractRetryingPeerTask.java @@ -29,8 +29,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; import java.util.function.Predicate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A task that will retry a fixed number of times before completing the associated CompletableFuture @@ -41,7 +41,7 @@ import org.apache.logging.log4j.Logger; */ public abstract class AbstractRetryingPeerTask extends AbstractEthTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractRetryingPeerTask.class); private final EthContext ethContext; private final int maxRetries; private final Predicate isEmptyResponse; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java index 1680539f87..92bc33a848 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java @@ -27,13 +27,13 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Downloads a block from a peer. Will complete exceptionally if block cannot be downloaded. */ public class GetBlockFromPeerTask extends AbstractPeerTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetBlockFromPeerTask.class); private final ProtocolSchedule protocolSchedule; private final Optional hash; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeersTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeersTask.java index d94ed4e93f..89a95e01fa 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeersTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeersTask.java @@ -25,12 +25,12 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Downloads a block from a peer. Will complete exceptionally if block cannot be downloaded. */ public class GetBlockFromPeersTask extends AbstractEthTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetBlockFromPeersTask.class); private final List peers; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java index d0cf46408e..e3fcce09e2 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java @@ -40,13 +40,13 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Requests bodies from a peer by header, matches up headers to bodies, and returns blocks. */ public class GetBodiesFromPeerTask extends AbstractPeerRequestTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetBodiesFromPeerTask.class); private final ProtocolSchedule protocolSchedule; private final List headers; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByHashTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByHashTask.java index 3847da19c1..dcdfc4e8be 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByHashTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByHashTask.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Retrieves a sequence of headers from a peer. */ public class GetHeadersFromPeerByHashTask extends AbstractGetHeadersFromPeerTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetHeadersFromPeerByHashTask.class); private final Hash referenceHash; private final long minimumRequiredBlockNumber; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByNumberTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByNumberTask.java index ff20aefc81..3022796828 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByNumberTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetHeadersFromPeerByNumberTask.java @@ -21,12 +21,12 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Retrieves a sequence of headers from a peer. */ public class GetHeadersFromPeerByNumberTask extends AbstractGetHeadersFromPeerTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetHeadersFromPeerByNumberTask.class); private final long blockNumber; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetNodeDataFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetNodeDataFromPeerTask.java index 461dcca31a..c5d0163228 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetNodeDataFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetNodeDataFromPeerTask.java @@ -33,13 +33,13 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GetNodeDataFromPeerTask extends AbstractPeerRequestTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetNodeDataFromPeerTask.class); private final Set hashes; private final long pivotBlockNumber; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetPooledTransactionsFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetPooledTransactionsFromPeerTask.java index 753da27597..cc84183bd2 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetPooledTransactionsFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetPooledTransactionsFromPeerTask.java @@ -30,12 +30,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GetPooledTransactionsFromPeerTask extends AbstractPeerRequestTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(GetPooledTransactionsFromPeerTask.class); private final List hashes; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetReceiptsFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetReceiptsFromPeerTask.java index 0d21049827..dace85a202 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetReceiptsFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetReceiptsFromPeerTask.java @@ -36,12 +36,12 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GetReceiptsFromPeerTask extends AbstractPeerRequestTask>> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetReceiptsFromPeerTask.class); private final Collection blockHeaders; private final Map> headersByReceiptsRoot = new HashMap<>(); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/RetryingGetBlockFromPeersTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/RetryingGetBlockFromPeersTask.java index ed95417950..8fdf06f643 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/RetryingGetBlockFromPeersTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/RetryingGetBlockFromPeersTask.java @@ -27,15 +27,15 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RetryingGetBlockFromPeersTask extends AbstractRetryingPeerTask> { private static final int DEFAULT_MAX_RETRIES = 5; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RetryingGetBlockFromPeersTask.class); private final ProtocolSchedule protocolSchedule; private final Optional blockHash; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeerTask.java index 0234f41ab7..44ced57e7b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeerTask.java @@ -18,12 +18,12 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Wait for a single new peer to connect. */ public class WaitForPeerTask extends AbstractEthTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WaitForPeerTask.class); private final EthContext ethContext; private volatile Long peerListenerId; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeersTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeersTask.java index 628b1f3cab..f70b82f186 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeersTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/WaitForPeersTask.java @@ -18,12 +18,12 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Waits for some number of peers to connect. */ public class WaitForPeersTask extends AbstractEthTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WaitForPeersTask.class); private final int targetPeerCount; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/AbstractPeerBlockValidator.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/AbstractPeerBlockValidator.java index 85062282a3..3e452b0c47 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/AbstractPeerBlockValidator.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/AbstractPeerBlockValidator.java @@ -30,11 +30,11 @@ import java.time.Duration; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; abstract class AbstractPeerBlockValidator implements PeerValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractPeerBlockValidator.class); static long DEFAULT_CHAIN_HEIGHT_ESTIMATION_BUFFER = 10L; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/ClassicForkPeerValidator.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/ClassicForkPeerValidator.java index 0d585c40f3..2958ec8e55 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/ClassicForkPeerValidator.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/ClassicForkPeerValidator.java @@ -20,11 +20,11 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ClassicForkPeerValidator extends AbstractPeerBlockValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ClassicForkPeerValidator.class); ClassicForkPeerValidator( final ProtocolSchedule protocolSchedule, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidator.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidator.java index 9585daaecb..d038ad0e9a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidator.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidator.java @@ -20,11 +20,11 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DaoForkPeerValidator extends AbstractPeerBlockValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DaoForkPeerValidator.class); DaoForkPeerValidator( final ProtocolSchedule protocolSchedule, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/PeerValidatorRunner.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/PeerValidatorRunner.java index 01635f98c7..7e8fdf3418 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/PeerValidatorRunner.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/PeerValidatorRunner.java @@ -19,11 +19,11 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import java.time.Duration; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PeerValidatorRunner { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerValidatorRunner.class); protected final EthContext ethContext; private final PeerValidator peerValidator; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidator.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidator.java index 92cc48b920..aae28f1a39 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidator.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidator.java @@ -22,11 +22,11 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RequiredBlocksPeerValidator extends AbstractPeerBlockValidator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RequiredBlocksPeerValidator.class); private final Hash hash; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockBroadcaster.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockBroadcaster.java index 75b96ed7ea..1bf55b01f8 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockBroadcaster.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockBroadcaster.java @@ -21,11 +21,11 @@ import org.hyperledger.besu.ethereum.eth.messages.NewBlockMessage; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection; import org.hyperledger.besu.util.Subscribers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BlockBroadcaster { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockBroadcaster.class); private final EthContext ethContext; private final Subscribers blockPropagatedSubscribers = diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java index 8d23faba46..cc83b5856d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java @@ -58,12 +58,12 @@ import java.util.stream.Collectors; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import com.google.common.collect.Range; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BlockPropagationManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BlockPropagationManager.class); private final SynchronizerConfiguration config; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTracker.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTracker.java index 0ef602c4e7..66a45afec3 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTracker.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTracker.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.eth.sync; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -29,11 +27,12 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.function.Supplier; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ChainHeadTracker implements ConnectCallback { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ChainHeadTracker.class); private final EthContext ethContext; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcher.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcher.java index e3c8f596fb..3f395d62c5 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcher.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcher.java @@ -31,11 +31,11 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CheckpointHeaderFetcher { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CheckpointHeaderFetcher.class); private final SynchronizerConfiguration syncConfig; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointRangeSource.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointRangeSource.java index 6b30c3fc4f..523d8b71f3 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointRangeSource.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointRangeSource.java @@ -32,11 +32,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CheckpointRangeSource implements Iterator { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CheckpointRangeSource.class); private static final Duration RETRY_DELAY_DURATION = Duration.ofSeconds(2); private final CheckpointHeaderFetcher checkpointFetcher; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java index 553e08e697..59440e65d4 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java @@ -40,12 +40,12 @@ import java.time.Clock; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DefaultSynchronizer implements Synchronizer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DefaultSynchronizer.class); private final Optional maybePruner; private final SyncState syncState; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStep.java index 9c1500af85..1759d0b84d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStep.java @@ -32,12 +32,12 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DownloadHeadersStep implements Function> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DownloadHeadersStep.class); private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java index 7c8400507e..99a3209966 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java @@ -37,11 +37,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PipelineChainDownloader implements ChainDownloader { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PipelineChainDownloader.class); static final Duration PAUSE_AFTER_ERROR_DURATION = Duration.ofSeconds(2); private final SyncState syncState; private final SyncTargetManager syncTargetManager; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java index 4a8f6f2c19..dc8cd6d027 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java @@ -29,12 +29,12 @@ import java.time.Duration; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class SyncTargetManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SyncTargetManager.class); private final SynchronizerConfiguration config; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/TrailingPeerLimiter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/TrailingPeerLimiter.java index 5807e90eab..d1301459c7 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/TrailingPeerLimiter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/TrailingPeerLimiter.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.eth.sync; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; import org.hyperledger.besu.ethereum.eth.manager.EthPeer; @@ -27,11 +25,12 @@ import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TrailingPeerLimiter implements BlockAddedObserver { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TrailingPeerLimiter.class); private static final Comparator BY_CHAIN_HEIGHT = Comparator.comparing(peer -> peer.chainState().getEstimatedHeight()); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastDownloaderFactory.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastDownloaderFactory.java index a764f58dd6..a5f731bfb1 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastDownloaderFactory.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastDownloaderFactory.java @@ -39,14 +39,14 @@ import java.time.Clock; import java.util.Optional; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastDownloaderFactory { private static final String FAST_SYNC_FOLDER = "fastsync"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastDownloaderFactory.class); public static Optional create( final SynchronizerConfiguration syncConfig, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java index 30600f991b..9b029dd412 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java @@ -26,11 +26,11 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastImportBlocksStep implements Consumer> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastImportBlocksStep.class); private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; private final ValidationPolicy headerValidationPolicy; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActions.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActions.java index 8c2c1c0870..1183617f24 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActions.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActions.java @@ -37,12 +37,12 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastSyncActions { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastSyncActions.class); private final SynchronizerConfiguration syncConfig; private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java index 499f5c0550..100f89c30a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java @@ -36,14 +36,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import com.google.common.io.MoreFiles; import com.google.common.io.RecursiveDeleteOption; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastSyncDownloader { private static final Duration FAST_SYNC_RETRY_DELAY = Duration.ofSeconds(5); - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastSyncDownloader.class); private final FastSyncActions fastSyncActions; private final WorldStateStorage worldStateStorage; private final WorldStateDownloader worldStateDownloader; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncStateStorage.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncStateStorage.java index 9a98d2b0e6..253e246616 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncStateStorage.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncStateStorage.java @@ -24,9 +24,9 @@ import java.io.IOException; import java.nio.file.Path; import com.google.common.io.Files; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Supports persisting fast sync state to disk to enable resuming after a restart. @@ -37,7 +37,7 @@ import org.apache.tuweni.bytes.Bytes; * block header we want to continue with that pivot block so the world state downloaded matches up. */ public class FastSyncStateStorage { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastSyncStateStorage.class); private static final String PIVOT_BLOCK_HEADER_FILENAME = "pivotBlockHeader.rlp"; private final File pivotBlockHeaderFile; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java index ec6d1ce662..e1d0310fe7 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class FastSyncTargetManager extends SyncTargetManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastSyncTargetManager.class); private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmer.java index a61950f5b7..1253dbb17c 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmer.java @@ -36,9 +36,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This task will query {@code numberOfPeersToQuery} peers for a particular block number. If any @@ -47,7 +47,7 @@ import org.apache.tuweni.bytes.Bytes; * distinct peers all return matching block headers for the specified block number. */ class PivotBlockConfirmer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PivotBlockConfirmer.class); private final EthContext ethContext; private final MetricsSystem metricsSystem; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java index b9339f7853..7bddc2ea46 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java @@ -26,8 +26,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This task attempts to find a non-controversial pivot block by confirming the pivot block number @@ -38,7 +38,7 @@ import org.apache.logging.log4j.Logger; */ public class PivotBlockRetriever { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PivotBlockRetriever.class); public static final int MAX_QUERY_RETRIES_PER_PEER = 3; private static final int DEFAULT_MAX_PIVOT_BLOCK_RESETS = 250; private static final int SUSPICIOUS_NUMBER_OF_RETRIES = 5; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/CompleteTaskStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/CompleteTaskStep.java index 40cacf2c3b..863617420a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/CompleteTaskStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/CompleteTaskStep.java @@ -25,11 +25,11 @@ import org.hyperledger.besu.services.tasks.Task; import java.util.function.LongSupplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CompleteTaskStep { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CompleteTaskStep.class); private static final int DISPLAY_PROGRESS_STEP = 100000; private final WorldStateStorage worldStateStorage; private final RunnableCounter completedRequestsCounter; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadState.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadState.java index baaece79e0..e82eda69a6 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadState.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadState.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.services.tasks.InMemoryTasksPriorityQueues; import java.time.Clock; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastWorldDownloadState extends WorldDownloadState { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastWorldDownloadState.class); public FastWorldDownloadState( final InMemoryTasksPriorityQueues pendingRequests, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloadProcess.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloadProcess.java index bd4390235d..1b27a23b1f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloadProcess.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloadProcess.java @@ -35,11 +35,11 @@ import org.hyperledger.besu.util.ExceptionUtils; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastWorldStateDownloadProcess implements WorldStateDownloadProcess { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastWorldStateDownloadProcess.class); private final Pipeline> fetchDataPipeline; private final Pipeline> completionPipeline; private final WritePipe> requestsToComplete; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloader.java index 3f12b1a538..bf47dfcdc8 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloader.java @@ -32,12 +32,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.util.function.IntSupplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FastWorldStateDownloader implements WorldStateDownloader { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FastWorldStateDownloader.class); private final long minMillisBeforeStalling; private final Clock clock; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/NodeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/NodeDataRequest.java index cfdaa0dd64..2ff8429316 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/NodeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/NodeDataRequest.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.eth.sync.fastsync.worldstate; import static com.google.common.base.Preconditions.checkNotNull; -import static org.apache.logging.log4j.LogManager.getLogger; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloaderException; @@ -28,11 +27,12 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class NodeDataRequest implements TasksPriorityProvider { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(NodeDataRequest.class); public static final int MAX_CHILDREN = 16; private final RequestType requestType; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/RequestDataStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/RequestDataStep.java index e4e85793be..e4325b967f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/RequestDataStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/RequestDataStep.java @@ -34,12 +34,12 @@ import java.util.concurrent.TimeoutException; import java.util.function.BiFunction; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RequestDataStep { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RequestDataStep.class); private final BiFunction, Long, EthTask>> getNodeDataTaskFactory; public RequestDataStep(final EthContext ethContext, final MetricsSystem metricsSystem) { diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullImportBlockStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullImportBlockStep.java index bc841a746f..5c478beead 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullImportBlockStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullImportBlockStep.java @@ -25,11 +25,11 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import java.time.Instant; import java.util.function.Consumer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FullImportBlockStep implements Consumer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FullImportBlockStep.class); private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloader.java index e716573ee5..cdcbf861ae 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloader.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FullSyncDownloader { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FullSyncDownloader.class); private final ChainDownloader chainDownloader; private final SynchronizerConfiguration syncConfig; private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java index 021d1988f6..02ad6832ab 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java @@ -31,12 +31,12 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.Optional; import java.util.concurrent.CompletableFuture; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class FullSyncTargetManager extends SyncTargetManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FullSyncTargetManager.class); private final ProtocolContext protocolContext; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index 0682916264..f9d5ed6532 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -38,15 +38,15 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Given a set of headers, "completes" them by repeatedly requesting additional data (bodies) needed * to create the blocks that correspond to the supplied headers. */ public class CompleteBlocksTask extends AbstractRetryingPeerTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CompleteBlocksTask.class); private static final int MIN_SIZE_INCOMPLETE_LIST = 1; private static final int DEFAULT_RETRIES = 3; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java index 23f95a973f..91aa6e5ff8 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTask.java @@ -30,8 +30,8 @@ import java.util.OptionalInt; import java.util.concurrent.CompletableFuture; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Finds the common ancestor with the given peer. It is assumed that the peer will at least share @@ -40,7 +40,7 @@ import org.apache.logging.log4j.Logger; * cases this node's genesis block will be returned. */ public class DetermineCommonAncestorTask extends AbstractEthTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DetermineCommonAncestorTask.class); private final EthContext ethContext; private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java index 416bbfad28..588809d437 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DownloadHeaderSequenceTask.java @@ -45,15 +45,15 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import com.google.common.primitives.Ints; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Retrieves a sequence of headers, sending out requests repeatedly until all headers are fulfilled. * Validates headers as they are received. */ public class DownloadHeaderSequenceTask extends AbstractRetryingPeerTask> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DownloadHeaderSequenceTask.class); private static final int DEFAULT_RETRIES = 3; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java index 41f9278c77..a44b6495f4 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java @@ -35,13 +35,13 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Given a set of headers, repeatedly requests the receipts for those blocks. */ public class GetReceiptsForHeadersTask extends AbstractRetryingPeerTask>> { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetReceiptsForHeadersTask.class); private static final int DEFAULT_RETRIES = 3; private final EthContext ethContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTask.java index 205f9888a5..86e1aead48 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTask.java @@ -33,12 +33,12 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PersistBlockTask extends AbstractEthTask { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PersistBlockTask.class); private final ProtocolSchedule protocolSchedule; private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldDownloadState.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldDownloadState.java index 6bcafff308..87dba23aa2 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldDownloadState.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldDownloadState.java @@ -31,12 +31,12 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class WorldDownloadState { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WorldDownloadState.class); private boolean downloadWasResumed; protected final InMemoryTasksPriorityQueues pendingRequests; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionsMessageProcessor.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionsMessageProcessor.java index e4b75e9715..ac7767a88f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionsMessageProcessor.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionsMessageProcessor.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.eth.transactions; import static java.time.Instant.now; -import static org.apache.logging.log4j.LogManager.getLogger; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -33,14 +32,16 @@ import java.time.Duration; import java.time.Instant; import java.util.concurrent.ConcurrentHashMap; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PendingTransactionsMessageProcessor { private static final int SKIPPED_MESSAGES_LOGGING_THRESHOLD = 1000; private static final long SYNC_TOLERANCE = 100L; - private static final Logger LOG = getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(PendingTransactionsMessageProcessor.class); private final ConcurrentHashMap scheduledTasks; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index f412e8fd80..937384bb20 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.eth.transactions; import static java.util.Collections.singletonList; import static java.util.Optional.ofNullable; -import static org.apache.logging.log4j.LogManager.getLogger; import static org.hyperledger.besu.ethereum.eth.transactions.sorter.AbstractPendingTransactionsSorter.TransactionAddedStatus.ADDED; import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE; @@ -51,7 +50,8 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Maintains the set of pending transactions received from JSON-RPC or other nodes. Transactions are @@ -62,7 +62,7 @@ import org.apache.logging.log4j.Logger; */ public class TransactionPool implements BlockAddedObserver { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TransactionPool.class); private static final long SYNC_TOLERANCE = 100L; private static final String REMOTE = "remote"; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageProcessor.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageProcessor.java index 5fdb5d4088..4bb7139839 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageProcessor.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageProcessor.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.eth.transactions; import static java.time.Instant.now; -import static org.apache.logging.log4j.LogManager.getLogger; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.manager.EthPeer; @@ -31,12 +30,13 @@ import java.util.List; import java.util.Set; import com.google.common.collect.Sets; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class TransactionsMessageProcessor { private static final int SKIPPED_MESSAGES_LOGGING_THRESHOLD = 1000; - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TransactionsMessageProcessor.class); private final PeerTransactionTracker transactionTracker; private final TransactionPool transactionPool; private final Counter totalSkippedTransactionsMessageCounter; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageSender.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageSender.java index a0e6eacc41..c122c5cb51 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageSender.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionsMessageSender.java @@ -22,11 +22,11 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection.PeerNot import java.util.Set; import java.util.stream.StreamSupport; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class TransactionsMessageSender { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TransactionsMessageSender.class); private final PeerTransactionTracker transactionTracker; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java index 5d3856ea9f..98443d2098 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java @@ -55,8 +55,8 @@ import java.util.stream.Collectors; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.EvictingQueue; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Holds the current set of pending transactions with the ability to iterate them based on priority @@ -65,7 +65,8 @@ import org.apache.logging.log4j.Logger; *

This class is safe for use across multiple threads. */ public abstract class AbstractPendingTransactionsSorter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(AbstractPendingTransactionsSorter.class); protected final int maxTransactionRetentionHours; protected final Clock clock; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java index acb83f0955..cc03be4afc 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java @@ -36,8 +36,8 @@ import java.util.TreeSet; import java.util.function.Supplier; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Holds the current set of pending transactions with the ability to iterate them based on priority @@ -47,7 +47,7 @@ import org.apache.logging.log4j.Logger; */ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransactionsSorter { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BaseFeePendingTransactionsSorter.class); private Optional baseFee; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdBackwardCompatibilityTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdBackwardCompatibilityTest.java index a369bec89d..7331c69b39 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdBackwardCompatibilityTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdBackwardCompatibilityTest.java @@ -25,16 +25,16 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(Parameterized.class) public class ForkIdBackwardCompatibilityTest { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ForkIdBackwardCompatibilityTest.class); private final String name; private final String genesisHash; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java index 861f4b006e..6b5dbaa644 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java @@ -31,17 +31,17 @@ import java.util.Collection; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(Parameterized.class) public class EIP2124Test { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EIP2124Test.class); @Parameters(name = "{index}: {0}") public static Collection data() { diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java index 81e019af65..f0ec99fc02 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java @@ -69,13 +69,13 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestNode implements Closeable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestNode.class); private static final MetricsSystem metricsSystem = new NoOpMetricsSystem(); protected final NodeKey nodeKey; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNodeList.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNodeList.java index 88b04d2728..46b9274ee4 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNodeList.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNodeList.java @@ -17,7 +17,6 @@ package org.hyperledger.besu.ethereum.eth.transactions; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static java.lang.String.format; -import static org.apache.logging.log4j.util.Strings.join; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.eth.transactions.TestNode.shortId; @@ -40,13 +39,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestNodeList implements Closeable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestNodeList.class); protected final List nodes = new ArrayList<>(); private final Duration MSG_WAIT = Duration.ofSeconds(2); @@ -246,7 +245,7 @@ public class TestNodeList implements Closeable { connStr.add("Connection: " + localString + " to " + peerString); } } - LOG.info("TestNodeList Connections:\n" + join(connStr, '\n')); + LOG.info("TestNodeList Connections: {}", connStr); } @Override diff --git a/ethereum/ethstats/build.gradle b/ethereum/ethstats/build.gradle index 14d5ad6bff..90c67063cd 100644 --- a/ethereum/ethstats/build.gradle +++ b/ethereum/ethstats/build.gradle @@ -28,11 +28,11 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' implementation 'com.squareup.okhttp3:okhttp' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'io.vertx:vertx-core' implementation 'org.apache.tuweni:tuweni-bytes' @@ -51,8 +51,6 @@ dependencies { annotationProcessor "org.immutables:value" implementation "org.immutables:value-annotations" - runtimeOnly 'org.apache.logging.log4j:log4j-core' - // test dependencies. testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') diff --git a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java index 16374dfa9d..784115b2af 100644 --- a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java +++ b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/EthStatsService.java @@ -75,8 +75,8 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpClientOptions; import io.vertx.core.http.WebSocket; import io.vertx.core.http.WebSocketConnectOptions; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class describes the behaviour of the EthStats service. This class is used to report pending @@ -84,7 +84,7 @@ import org.apache.logging.log4j.Logger; */ public class EthStatsService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EthStatsService.class); private static final Duration SEND_REPORT_DELAY = Duration.ofSeconds(5); private static final int HISTORY_RANGE = 50; diff --git a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/util/NetstatsUrl.java b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/util/NetstatsUrl.java index 7c30c7c8d3..305c50420c 100644 --- a/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/util/NetstatsUrl.java +++ b/ethereum/ethstats/src/main/java/org/hyperledger/besu/ethstats/util/NetstatsUrl.java @@ -20,8 +20,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.google.common.primitives.Ints; -import org.apache.logging.log4j.LogManager; import org.immutables.value.Value; +import org.slf4j.LoggerFactory; @Value.Immutable public interface NetstatsUrl { @@ -54,7 +54,7 @@ public interface NetstatsUrl { } } catch (IllegalArgumentException e) { - LogManager.getLogger().error(e.getMessage()); + LoggerFactory.getLogger(NetstatsUrl.class).error(e.getMessage()); } throw new IllegalArgumentException( "Invalid netstats URL syntax. Netstats URL should have the following format 'nodename:secret@host:port'."); diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index f1bf448574..ab67f1fc25 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -31,6 +31,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':besu') implementation project(':config') implementation project(':crypto') @@ -54,7 +56,6 @@ dependencies { implementation 'com.google.guava:guava' implementation 'info.picocli:picocli' implementation 'io.vertx:vertx-core' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.logging.log4j:log4j-core' annotationProcessor 'com.google.dagger:dagger-compiler' diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/DataStoreModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/DataStoreModule.java index c4b334526e..7a1b639a19 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/DataStoreModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/DataStoreModule.java @@ -37,14 +37,14 @@ import javax.inject.Singleton; import com.google.common.base.Suppliers; import dagger.Module; import dagger.Provides; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({"CloseableProvides"}) @Module(includes = GenesisFileModule.class) public class DataStoreModule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DataStoreModule.class); private final Supplier rocksDBFactory = Suppliers.memoize( () -> diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java index ff3335cf72..0ba1adb9d2 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java @@ -37,6 +37,7 @@ import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; import org.hyperledger.besu.evm.processor.MessageCallProcessor; import org.hyperledger.besu.evm.tracing.OperationTracer; import org.hyperledger.besu.evm.tracing.StandardJsonTracer; +import org.hyperledger.besu.util.Log4j2ConfiguratorUtil; import java.io.File; import java.io.IOException; @@ -51,10 +52,9 @@ import java.util.Optional; import com.google.common.base.Stopwatch; import io.vertx.core.json.JsonObject; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.config.Configurator; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @@ -75,7 +75,7 @@ import picocli.CommandLine.Option; subcommands = {StateTestSubCommand.class}) public class EvmToolCommand implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EvmToolCommand.class); @Option( names = {"--code"}, @@ -203,12 +203,13 @@ public class EvmToolCommand implements Runnable { .blockHeaderFunctions(new MainnetBlockHeaderFunctions()) .buildBlockHeader(); - Configurator.setAllLevels("", repeat == 0 ? Level.INFO : Level.OFF); + Log4j2ConfiguratorUtil.setAllLevels("", repeat == 0 ? Level.INFO : Level.OFF); int repeat = this.repeat; - Configurator.setLevel( + Log4j2ConfiguratorUtil.setLevel( "org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", Level.OFF); final ProtocolSpec protocolSpec = component.getProtocolSpec().apply(0); - Configurator.setLevel("org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", null); + Log4j2ConfiguratorUtil.setLevel( + "org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", null); final PrecompileContractRegistry precompileContractRegistry = protocolSpec.getPrecompileContractRegistry(); final EVM evm = protocolSpec.getEvm(); @@ -313,7 +314,7 @@ public class EvmToolCommand implements Runnable { } while (repeat-- > 0); } catch (final IOException e) { - LOG.fatal(e); + LOG.error("Unable to create Genesis module", e); } } } diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java index 2ad1f84a00..917c27be9a 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java @@ -41,6 +41,7 @@ import org.hyperledger.besu.evm.tracing.StandardJsonTracer; import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.evmtool.exception.UnsupportedForkException; +import org.hyperledger.besu.util.Log4j2ConfiguratorUtil; import java.io.BufferedReader; import java.io.File; @@ -59,10 +60,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Stopwatch; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.config.Configurator; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; @@ -74,7 +74,7 @@ import picocli.CommandLine.ParentCommand; mixinStandardHelpOptions = true, versionProvider = VersionProvider.class) public class StateTestSubCommand implements Runnable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(StateTestSubCommand.class); public static final String COMMAND_NAME = "state-test"; @@ -138,7 +138,7 @@ public class StateTestSubCommand implements Runnable { } } } catch (final IOException e) { - LOG.fatal(e); + LOG.error("Unable to read state file", e); } } @@ -152,10 +152,11 @@ public class StateTestSubCommand implements Runnable { } private void traceTestSpecs(final String test, final List specs) { - Configurator.setLevel( + Log4j2ConfiguratorUtil.setLevel( "org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", Level.OFF); final var referenceTestProtocolSchedules = ReferenceTestProtocolSchedules.create(); - Configurator.setLevel("org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", null); + Log4j2ConfiguratorUtil.setLevel( + "org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder", null); final OperationTracer tracer = // You should have picked Mercy. parentCommand.showJsonResults diff --git a/ethereum/p2p/build.gradle b/ethereum/p2p/build.gradle index 6d216d81a1..132f98ffd0 100644 --- a/ethereum/p2p/build.gradle +++ b/ethereum/p2p/build.gradle @@ -28,6 +28,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':crypto') implementation project(':datatypes') implementation project(':ethereum:core') @@ -40,7 +42,6 @@ dependencies { implementation 'dnsjava:dnsjava' implementation 'io.prometheus:simpleclient' implementation 'io.vertx:vertx-core' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-crypto' implementation('org.apache.tuweni:tuweni-devp2p') { @@ -59,8 +60,6 @@ dependencies { implementation "org.immutables:value-annotations" implementation 'tech.pegasys.discovery:discovery' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - // test dependencies. testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java index a7e449a9ac..0d053d450a 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java @@ -59,21 +59,21 @@ import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Suppliers; import com.google.common.net.InetAddresses; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt64; import org.ethereum.beacon.discovery.schema.EnrField; import org.ethereum.beacon.discovery.schema.IdentitySchema; import org.ethereum.beacon.discovery.schema.NodeRecord; import org.ethereum.beacon.discovery.schema.NodeRecordFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The peer discovery agent is the network component that sends and receives peer discovery messages * via UDP. */ public abstract class PeerDiscoveryAgent { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerDiscoveryAgent.class); private static final String SEQ_NO_STORE_KEY = "local-enr-seqno"; private static final com.google.common.base.Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java index fa011453b2..bb03e0075a 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/VertxPeerDiscoveryAgent.java @@ -48,12 +48,12 @@ import io.vertx.core.Vertx; import io.vertx.core.datagram.DatagramPacket; import io.vertx.core.datagram.DatagramSocket; import io.vertx.core.datagram.DatagramSocketOptions; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class VertxPeerDiscoveryAgent extends PeerDiscoveryAgent { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(VertxPeerDiscoveryAgent.class); private final Vertx vertx; /* The vert.x UDP socket. */ diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/DiscoveryProtocolLogger.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/DiscoveryProtocolLogger.java index badc05f48a..5510354a5d 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/DiscoveryProtocolLogger.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/DiscoveryProtocolLogger.java @@ -20,12 +20,12 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.Counter; import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DiscoveryProtocolLogger { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DiscoveryProtocolLogger.class); private final LabelledMetric outgoingMessageCounter; private final LabelledMetric incomingMessageCounter; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java index a18f68f8d4..9ed33d51b4 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java @@ -55,10 +55,10 @@ import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.ethereum.beacon.discovery.schema.NodeRecord; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This component is the entrypoint for managing the lifecycle of peers. @@ -104,7 +104,7 @@ import org.ethereum.beacon.discovery.schema.NodeRecord; * condition, the peer will be physically dropped (eliminated) from the table. */ public class PeerDiscoveryController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerDiscoveryController.class); private static final long REFRESH_CHECK_INTERVAL_MILLIS = MILLISECONDS.convert(30, SECONDS); private static final int PEER_REFRESH_ROUND_TIMEOUT_IN_SECONDS = 5; protected final TimerUtil timerUtil; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/RecursivePeerRefreshState.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/RecursivePeerRefreshState.java index 821aec8c9d..62105b2686 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/RecursivePeerRefreshState.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/RecursivePeerRefreshState.java @@ -28,12 +28,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RecursivePeerRefreshState { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RecursivePeerRefreshState.class); private static final int MAX_CONCURRENT_REQUESTS = 3; private Bytes target; private final PeerDiscoveryPermissions peerPermissions; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java index 15776add31..6214b07206 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java @@ -75,12 +75,12 @@ import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.devp2p.EthereumNodeRecord; import org.apache.tuweni.discovery.DNSDaemon; import org.apache.tuweni.discovery.DNSDaemonListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The peer network service (defunct PeerNetworkingService) is the entrypoint to the peer-to-peer @@ -124,7 +124,7 @@ import org.apache.tuweni.discovery.DNSDaemonListener; */ public class DefaultP2PNetwork implements P2PNetwork { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DefaultP2PNetwork.class); private final ScheduledExecutorService peerConnectionScheduler = Executors.newSingleThreadScheduledExecutor(); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/NetworkRunner.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/NetworkRunner.java index 8049ca3962..9799309213 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/NetworkRunner.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/NetworkRunner.java @@ -32,11 +32,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NetworkRunner implements AutoCloseable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(NetworkRunner.class); private final CountDownLatch shutdown = new CountDownLatch(1); private final AtomicBoolean started = new AtomicBoolean(false); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManager.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManager.java index 76848f8973..daa31c97e7 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManager.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManager.java @@ -22,11 +22,11 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.Di import java.util.Set; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PeerReputationManager implements DisconnectCallback { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerReputationManager.class); private static final Set locallyTriggeredDisconnectReasons = ImmutableSet.of( DisconnectReason.BREACH_OF_PROTOCOL, DisconnectReason.INCOMPATIBLE_P2P_PROTOCOL_VERSION); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParser.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParser.java index bc86c8ed9b..ed5ad92f40 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParser.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParser.java @@ -30,12 +30,12 @@ import java.util.stream.Collectors; import io.vertx.core.json.DecodeException; import io.vertx.core.json.JsonArray; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class StaticNodesParser { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(StaticNodesParser.class); public static Set fromPath( final Path path, final EnodeDnsConfiguration enodeDnsConfiguration) @@ -79,8 +79,7 @@ public class StaticNodesParser { enode.isListening(), "Static node must be configured with a valid listening port."); return enode; } catch (IllegalArgumentException ex) { - LOG.info("Illegal static enode supplied ({}). {}", input, ex.getMessage()); - throw ex; + throw new IllegalArgumentException("Illegal static enode supplied (" + input + ")", ex); } } } diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainFramer.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainFramer.java index 87d31bb37d..dfab204302 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainFramer.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainFramer.java @@ -22,11 +22,11 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage; import io.netty.buffer.ByteBuf; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PlainFramer extends Framer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PlainFramer.class); public PlainFramer() { LOG.trace("Initialising PlainFramer"); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainHandshaker.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainHandshaker.java index 67343dcbab..94dc1de380 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainHandshaker.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/plain/PlainHandshaker.java @@ -28,13 +28,13 @@ import java.util.concurrent.atomic.AtomicReference; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PlainHandshaker implements Handshaker { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PlainHandshaker.class); private final AtomicReference status = new AtomicReference<>(Handshaker.HandshakeStatus.UNINITIALIZED); diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java index 470c60cdac..43b5e68c69 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/RlpxAgent.java @@ -55,12 +55,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RlpxAgent { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RlpxAgent.class); private final LocalNode localNode; private final PeerConnectionEvents connectionEvents; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java index f93891d7e2..96545c474f 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java @@ -35,11 +35,11 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import com.google.common.base.MoreObjects; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractPeerConnection implements PeerConnection { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractPeerConnection.class); private final Peer peer; private final PeerInfo peerInfo; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/AbstractHandshakeHandler.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/AbstractHandshakeHandler.java index 3782c18ad9..38b5408b84 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/AbstractHandshakeHandler.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/AbstractHandshakeHandler.java @@ -37,13 +37,13 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.MessageToByteEncoder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; abstract class AbstractHandshakeHandler extends SimpleChannelInboundHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractHandshakeHandler.class); protected final Handshaker handshaker; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/ApiHandler.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/ApiHandler.java index de4b306911..39dbfb2d8b 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/ApiHandler.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/ApiHandler.java @@ -27,12 +27,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class ApiHandler extends SimpleChannelInboundHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ApiHandler.class); private final CapabilityMultiplexer multiplexer; private final AtomicBoolean waitingForPong; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java index fb7699ec77..aa61f31d5f 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java @@ -52,12 +52,12 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.DecoderException; import io.netty.handler.timeout.IdleStateHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class DeFramer extends ByteToMessageDecoder { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DeFramer.class); private final CompletableFuture connectFuture; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/HandshakeHandlerOutbound.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/HandshakeHandlerOutbound.java index aed5b86150..4f970627e8 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/HandshakeHandlerOutbound.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/HandshakeHandlerOutbound.java @@ -32,12 +32,12 @@ import java.util.concurrent.CompletableFuture; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class HandshakeHandlerOutbound extends AbstractHandshakeHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(HandshakeHandlerOutbound.class); private final ByteBuf first; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactory.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactory.java index 9e36bdb18a..d3d6c6e280 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactory.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactory.java @@ -40,12 +40,12 @@ import io.netty.handler.ssl.ClientAuth; import io.netty.handler.ssl.IdentityCipherSuiteFilter; import io.netty.handler.ssl.JdkSslContext; import io.netty.handler.ssl.SslContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TLSContextFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TLSContextFactory.class); private static final String[] ALLOWED_PROTOCOLS = {"TLSv1.3"}; private static final String KEYMANAGER_FACTORY_ALGORITHM = "PKIX"; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/WireKeepAlive.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/WireKeepAlive.java index b366c29a32..38c566d844 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/WireKeepAlive.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/WireKeepAlive.java @@ -25,11 +25,11 @@ import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleStateEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class WireKeepAlive extends ChannelDuplexHandler { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(WireKeepAlive.class); private final AtomicBoolean waitingForPong; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java index 87c6914a81..2e9cad6dfe 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java @@ -32,8 +32,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.errorprone.annotations.FormatMethod; import io.netty.buffer.ByteBuf; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.MutableBytes; import org.bouncycastle.crypto.BlockCipher; @@ -42,6 +40,8 @@ import org.bouncycastle.crypto.engines.AESEngine; import org.bouncycastle.crypto.modes.SICBlockCipher; import org.bouncycastle.crypto.params.KeyParameter; import org.bouncycastle.crypto.params.ParametersWithIV; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This component is responsible for reading and composing RLPx protocol frames, conformant to the @@ -57,7 +57,7 @@ import org.bouncycastle.crypto.params.ParametersWithIV; * @see RLPx framing */ public class Framer { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Framer.class); private static final int LENGTH_HEADER_DATA = 16; private static final int LENGTH_MAC = 16; diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/handshake/ecies/ECIESHandshaker.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/handshake/ecies/ECIESHandshaker.java index 66a43bbb1d..5282ed62b0 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/handshake/ecies/ECIESHandshaker.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/handshake/ecies/ECIESHandshaker.java @@ -36,11 +36,11 @@ import java.util.concurrent.atomic.AtomicReference; import com.google.common.annotations.VisibleForTesting; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.bouncycastle.crypto.InvalidCipherTextException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An Elliptic Curve Integrated Encryption Scheme implementation, following the handshake ceremony @@ -51,7 +51,7 @@ import org.bouncycastle.crypto.InvalidCipherTextException; */ public class ECIESHandshaker implements Handshaker { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ECIESHandshaker.class); private static final SecureRandom RANDOM = SecureRandomProvider.publicSecureRandom(); static final int SIGNATURE_LENGTH = 65; diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java index d290869c54..e0b55997c9 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java @@ -33,12 +33,12 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MockPeerDiscoveryAgent extends PeerDiscoveryAgent { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MockPeerDiscoveryAgent.class); // The set of known agents operating on the network private final Map agentNetwork; diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParserTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParserTest.java index 5baf375c0a..022582dfdf 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParserTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/StaticNodesParserTest.java @@ -169,7 +169,7 @@ public class StaticNodesParserTest { StaticNodesParser.fromPath( invalidFile.toPath(), EnodeDnsConfiguration.DEFAULT_CONFIG)) .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Static node must be configured with a valid listening port"); + .hasRootCauseMessage("Static node must be configured with a valid listening port."); } @Test diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactoryTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactoryTest.java index d50682fdee..eacdbe6337 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactoryTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/TLSContextFactoryTest.java @@ -45,13 +45,13 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @RunWith(Parameterized.class) public class TLSContextFactoryTest { @@ -79,7 +79,7 @@ public class TLSContextFactoryTest { private static final String partner2client2rvkJKSTruststore = "/keys/partner2client2rvk/truststore.jks"; - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TLSContextFactoryTest.class); private static final int MAX_NUMBER_MESSAGES = 10; diff --git a/ethereum/permissioning/build.gradle b/ethereum/permissioning/build.gradle index 8514c65b6f..2c8497a17f 100644 --- a/ethereum/permissioning/build.gradle +++ b/ethereum/permissioning/build.gradle @@ -28,6 +28,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':crypto') implementation project(':datatypes') implementation project(':ethereum:core') @@ -38,7 +40,6 @@ dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-toml' implementation 'org.apache.tuweni:tuweni-units' diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java index 70123e88e9..c62ed9d6b0 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java @@ -31,13 +31,14 @@ import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountLocalConfigPermissioningController implements TransactionPermissioningProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(AccountLocalConfigPermissioningController.class); private static final int ACCOUNT_BYTES_SIZE = 20; private LocalPermissioningConfiguration configuration; @@ -216,13 +217,11 @@ public class AccountLocalConfigPermissioningController implements TransactionPer readAccountsFromConfig(updatedConfig); configuration = updatedConfig; } catch (Exception e) { - LOG.warn( - "Error reloading permissions file. In-memory accounts allowlist will be reverted to previous valid configuration. " - + "Details: {}", - e.getMessage()); accountAllowlist.clear(); accountAllowlist.addAll(currentAccountsList); - throw new RuntimeException(e); + throw new IllegalStateException( + "Error reloading permissions file. In-memory accounts allowlist will be reverted to previous valid configuration", + e); } } diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java index 4454d0659a..ec66ea51ef 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java @@ -36,13 +36,14 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NodeLocalConfigPermissioningController implements NodeConnectionPermissioningProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(NodeLocalConfigPermissioningController.class); private LocalPermissioningConfiguration configuration; private final List fixedNodes; @@ -264,13 +265,11 @@ public class NodeLocalConfigPermissioningController implements NodeConnectionPer createNodeAllowlistModifiedEventAfterReload(currentAccountsList, nodesAllowlist); } catch (Exception e) { - LOG.warn( - "Error reloading permissions file. In-memory nodes allowlist will be reverted to previous valid configuration. " - + "Details: {}", - e.getMessage()); nodesAllowlist.clear(); nodesAllowlist.addAll(currentAccountsList); - throw new RuntimeException(e); + throw new IllegalStateException( + "Error reloading permissions file. In-memory nodes allowlist will be reverted to previous valid configuration", + e); } } diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java index 609ae6dab9..eeddcc1e7b 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java @@ -31,13 +31,14 @@ import java.util.List; import java.util.Optional; import com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NodePermissioningControllerFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(NodePermissioningControllerFactory.class); public NodePermissioningController create( final PermissioningConfiguration permissioningConfiguration, diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningController.java index 250aa61e31..486f61333b 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningController.java @@ -25,10 +25,10 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.List; import com.google.common.net.InetAddresses; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeEncoder; import org.web3j.abi.datatypes.Bool; @@ -41,7 +41,8 @@ import org.web3j.abi.datatypes.Function; public class NodeSmartContractV2PermissioningController extends AbstractNodeSmartContractPermissioningController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(NodeSmartContractV2PermissioningController.class); public static final Bytes TRUE_RESPONSE = Bytes.fromHexString(TypeEncoder.encode(new Bool(true))); public static final Bytes FALSE_RESPONSE = diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TomlConfigFileParser.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TomlConfigFileParser.java index 543f033a8d..5c8f63e198 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TomlConfigFileParser.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TomlConfigFileParser.java @@ -21,15 +21,15 @@ import java.io.FileNotFoundException; import java.util.stream.Collectors; import com.google.common.io.Resources; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.toml.Toml; import org.apache.tuweni.toml.TomlParseError; import org.apache.tuweni.toml.TomlParseResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TomlConfigFileParser { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TomlConfigFileParser.class); private static TomlParseResult checkConfigurationValidity( final TomlParseResult result, final String toml) throws Exception { diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningController.java index 60f08a251b..f8ee921668 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningController.java @@ -30,11 +30,11 @@ import org.hyperledger.besu.plugin.services.metrics.Counter; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.BaseUInt256Value; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Controller that can read from a smart contract that exposes the permissioning call @@ -43,7 +43,8 @@ import org.apache.tuweni.units.bigints.BaseUInt256Value; public class TransactionSmartContractPermissioningController implements TransactionPermissioningProvider { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(TransactionSmartContractPermissioningController.class); private final Address contractAddress; private final TransactionSimulator transactionSimulator; diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java index bd4390464f..cc8f323639 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningController.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.ethereum.permissioning.TransactionSmartContractPermi import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountPermissioningController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AccountPermissioningController.class); private final Optional accountLocalConfigPermissioningController; diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java index 7a168cee79..bed0a42b8b 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java @@ -33,13 +33,14 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountPermissioningControllerFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(AccountPermissioningControllerFactory.class); public static Optional create( final PermissioningConfiguration permissioningConfiguration, @@ -164,10 +165,8 @@ public class AccountPermissioningControllerFactory { // We don't care about the validation result. All we need it to ensure the check doesn't fail transactionSmartContractPermissioningController.isPermitted(transaction); } catch (Exception e) { - final String msg = - "Error validating onchain account permissioning smart contract configuration"; - LOG.error(msg + ":", e); - throw new IllegalStateException(msg, e); + throw new IllegalStateException( + "Error validating onchain account permissioning smart contract configuration", e); } } } diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java index d45af445fb..2ca141e54d 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningController.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.util.Subscribers; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NodePermissioningController { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(NodePermissioningController.class); private final Optional syncStatusNodePermissioningProvider; private Optional insufficientPeersPermissioningProvider = diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/PeerPermissionsAdapter.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/PeerPermissionsAdapter.java index 28711de759..6c87827cb6 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/PeerPermissionsAdapter.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/PeerPermissionsAdapter.java @@ -25,11 +25,11 @@ import org.hyperledger.besu.plugin.data.EnodeURL; import java.util.List; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PeerPermissionsAdapter extends PeerPermissions { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PeerPermissionsAdapter.class); private final NodePermissioningController nodePermissioningController; private final List bootnodes; diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java index 2095660e50..963d30498a 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java @@ -299,7 +299,8 @@ public class AccountLocalConfigPermissioningControllerTest { assertThat(thrown) .isInstanceOf(RuntimeException.class) - .hasMessageContaining("Unable to read permissioning TOML config file"); + .hasRootCauseMessage( + "Unable to read permissioning TOML config file : foo Configuration file does not exist: foo"); assertThat(controller.getAccountAllowlist()) .containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java index 1d76bc8d55..0c10c61b62 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java @@ -378,7 +378,8 @@ public class NodeLocalConfigPermissioningControllerTest { assertThat(thrown) .isInstanceOf(RuntimeException.class) - .hasMessageContaining("Unable to read permissioning TOML config file"); + .hasRootCauseMessage( + "Unable to read permissioning TOML config file : foo Configuration file does not exist: foo"); assertThat(controller.getNodesAllowlist()).containsExactly(expectedEnodeURI); } diff --git a/ethereum/retesteth/build.gradle b/ethereum/retesteth/build.gradle index 98b977576f..fa5907ec3c 100644 --- a/ethereum/retesteth/build.gradle +++ b/ethereum/retesteth/build.gradle @@ -26,6 +26,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':config') implementation project(':datatypes') implementation project(':ethereum:api') @@ -45,13 +47,10 @@ dependencies { implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' implementation 'com.fasterxml.jackson.core:jackson-databind' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-units' testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-core' - - runtimeOnly 'org.apache.logging.log4j:log4j-core' } diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java index d4e3e8d40e..cc744773a4 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java @@ -67,14 +67,14 @@ import java.util.Optional; import java.util.concurrent.locks.ReentrantLock; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RetestethContext { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RetestethContext.class); private static final PoWHasher NO_WORK_HASHER = (final long nonce, final long number, EpochCalculator epochCalc, final Bytes headerHash) -> new PoWSolution(nonce, Hash.ZERO, UInt256.ZERO, Hash.ZERO); @@ -209,7 +209,9 @@ public class RetestethContext { Wei.ZERO, transactionPoolConfiguration); - LOG.trace("Genesis Block {} ", genesisState::getBlock); + if (LOG.isTraceEnabled()) { + LOG.trace("Genesis Block {} ", genesisState.getBlock()); + } return true; } diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java index 897719ecc3..6289b76c95 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java @@ -29,12 +29,12 @@ import org.hyperledger.besu.ethereum.rlp.RLPException; import java.util.Collections; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestImportRawBlock implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestImportRawBlock.class); public static final String METHOD_NAME = "test_importRawBlock"; diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java index f68f9182b6..8578a47e63 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java @@ -27,12 +27,12 @@ import java.util.Map; import java.util.Optional; import io.vertx.core.json.JsonObject; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestSetChainParams implements JsonRpcMethod { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TestSetChainParams.class); public static final String METHOD_NAME = "test_setChainParams"; private final RetestethContext context; diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java index 12de06c65b..3c5b7daa14 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.stratum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; @@ -31,12 +29,13 @@ import java.util.function.Function; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Protocol using JSON-RPC HTTP methods to provide getWork/submitWork methods. */ public class GetWorkProtocol implements StratumProtocol { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(GetWorkProtocol.class); private static final ObjectMapper mapper = new ObjectMapper(); private static final String CRLF = "\r\n"; diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java index ebaf0302e9..834fe68097 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.stratum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; @@ -35,8 +33,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper; import com.google.common.io.BaseEncoding; import io.vertx.core.json.DecodeException; import io.vertx.core.json.JsonObject; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implementation of the stratum1+tcp protocol. @@ -44,7 +43,7 @@ import org.apache.tuweni.bytes.Bytes; *

This protocol allows miners to submit EthHash solutions over a persistent TCP connection. */ public class Stratum1EthProxyProtocol implements StratumProtocol { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Stratum1EthProxyProtocol.class); private static final JsonMapper mapper = new JsonMapper(); private final MiningCoordinator miningCoordinator; diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java index 111d080bbd..6df9d7dcf7 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.stratum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; @@ -39,8 +37,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.json.JsonMapper; import io.vertx.core.json.DecodeException; import io.vertx.core.json.JsonObject; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implementation of the stratum+tcp protocol. @@ -48,7 +47,7 @@ import org.apache.tuweni.bytes.Bytes; *

This protocol allows miners to submit EthHash solutions over a persistent TCP connection. */ public class Stratum1Protocol implements StratumProtocol { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Stratum1Protocol.class); private static final JsonMapper mapper = new JsonMapper(); private static final String STRATUM_1 = "EthereumStratum/1.0.0"; diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java index d5c7a4427b..f83a51ff79 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.stratum; -import static org.apache.logging.log4j.LogManager.getLogger; - import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.function.Consumer; @@ -24,14 +22,15 @@ import java.util.regex.Pattern; import com.google.common.base.Splitter; import io.vertx.core.buffer.Buffer; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Persistent TCP connection using a variant of the Stratum protocol, connecting the client to * miners. */ final class StratumConnection { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(StratumConnection.class); private String incompleteMessage = ""; private boolean httpDetected = false; diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java index fad16d7785..e9873eec31 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.ethereum.stratum; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.PoWObserver; import org.hyperledger.besu.ethereum.mainnet.EthHash; @@ -38,8 +36,9 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.net.NetServer; import io.vertx.core.net.NetServerOptions; import io.vertx.core.net.NetSocket; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * TCP server allowing miners to connect to the client over persistent TCP connections, using the @@ -47,7 +46,7 @@ import org.apache.tuweni.units.bigints.UInt256; */ public class StratumServer implements PoWObserver { - private static final Logger logger = getLogger(); + private static final Logger logger = LoggerFactory.getLogger(StratumServer.class); private final Vertx vertx; private final int port; diff --git a/evm/build.gradle b/evm/build.gradle index 635fe1442a..eb9e27baa1 100644 --- a/evm/build.gradle +++ b/evm/build.gradle @@ -30,6 +30,8 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':crypto') implementation project(':datatypes') implementation project(':ethereum:rlp') @@ -37,7 +39,6 @@ dependencies { compileOnly 'com.fasterxml.jackson.core:jackson-databind' implementation 'org.apache.tuweni:tuweni-bytes' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.hyperledger.besu:bls12-381' implementation 'net.java.dev.jna:jna' implementation 'com.github.ben-manes.caffeine:caffeine' diff --git a/evm/src/main/java/org/hyperledger/besu/evm/EVM.java b/evm/src/main/java/org/hyperledger/besu/evm/EVM.java index 726d992f2b..dbc312af8b 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/EVM.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/EVM.java @@ -14,8 +14,6 @@ */ package org.hyperledger.besu.evm; -import static org.apache.logging.log4j.LogManager.getLogger; - import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; import org.hyperledger.besu.evm.frame.MessageFrame; @@ -36,11 +34,12 @@ import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EVM { - private static final Logger LOG = getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EVM.class); protected static final OperationResult OVERFLOW_RESPONSE = new OperationResult( diff --git a/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java index 6d2671cba7..3d71ec6a3e 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java @@ -16,12 +16,12 @@ package org.hyperledger.besu.evm.contractvalidation; import org.hyperledger.besu.evm.frame.MessageFrame; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MaxCodeSizeRule implements ContractValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MaxCodeSizeRule.class); private final int maxCodeSize; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java index b31b26989f..ba0842cf5e 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java @@ -16,12 +16,12 @@ package org.hyperledger.besu.evm.contractvalidation; import org.hyperledger.besu.evm.frame.MessageFrame; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PrefixCodeRule implements ContractValidationRule { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(PrefixCodeRule.class); private final byte FORMAT_RESERVED = (byte) 0xEF; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java index 945e5d07ad..20ae8a8e37 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java @@ -22,13 +22,13 @@ import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import com.sun.jna.ptr.IntByReference; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractAltBnPrecompiledContract extends AbstractPrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractAltBnPrecompiledContract.class); // use the native library implementation, if it is available static boolean useNative = LibEthPairings.ENABLED; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java index b420c6075a..3869ff88cf 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java @@ -23,13 +23,13 @@ import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import javax.annotation.Nonnull; import com.sun.jna.ptr.IntByReference; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractBLS12PrecompiledContract implements PrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractBLS12PrecompiledContract.class); static final int[] DISCOUNT_TABLE = new int[] { diff --git a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java index c0051a29e0..665e5bbfa1 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java @@ -18,15 +18,15 @@ import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.evm.gascalculator.GasCalculator; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Skeleton class for {@link PrecompiledContract} implementations. */ @SuppressWarnings("unused") public abstract class AbstractPrecompiledContract implements PrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractPrecompiledContract.class); private final GasCalculator gasCalculator; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java index 38151cd8e2..cc0dc1a5d4 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java @@ -24,14 +24,14 @@ import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; // https://github.com/keep-network/go-ethereum/pull/4 public class BLAKE2BFPrecompileContract extends AbstractPrecompiledContract { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BLAKE2BFPrecompileContract.class); public BLAKE2BFPrecompileContract(final GasCalculator gasCalculator) { super("BLAKE2f", gasCalculator); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java index 4c83223041..a31a4d907e 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java @@ -31,14 +31,14 @@ import java.util.List; import java.util.Optional; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** A contract creation message processor. */ public class ContractCreationProcessor extends AbstractMessageProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(ContractCreationProcessor.class); private final boolean requireCodeDepositToSucceed; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java index 962a93804b..2f8ce3799d 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java @@ -31,12 +31,12 @@ import java.util.Objects; import java.util.Optional; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MessageCallProcessor extends AbstractMessageProcessor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MessageCallProcessor.class); private final PrecompileContractRegistry precompiles; diff --git a/gradle/versions.gradle b/gradle/versions.gradle index e9f2f72805..4915bce5b8 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -160,7 +160,7 @@ dependencyManagement { dependency 'org.rocksdb:rocksdbjni:6.15.2' - dependency 'org.slf4j:slf4j-log4j12:1.7.26' + dependency 'org.slf4j:slf4j-api:1.7.25' dependency 'org.springframework.security:spring-security-crypto:5.6.1' diff --git a/metrics/core/build.gradle b/metrics/core/build.gradle index b85a1b9a0a..1b53b496bc 100644 --- a/metrics/core/build.gradle +++ b/metrics/core/build.gradle @@ -36,6 +36,7 @@ publishing { dependencies { implementation project(':plugin-api') + api 'org.slf4j:slf4j-api' implementation 'com.google.guava:guava' implementation 'io.grpc:grpc-netty' @@ -57,9 +58,6 @@ dependencies { implementation 'io.prometheus:simpleclient_pushgateway' implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' - implementation 'org.apache.logging.log4j:log4j-api' - - runtimeOnly 'org.apache.logging.log4j:log4j-core' // test dependencies. testImplementation project(':util') diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsService.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsService.java index 82f5fa887e..625fc323a8 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsService.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsService.java @@ -25,7 +25,7 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import io.vertx.core.Vertx; -import org.apache.logging.log4j.LogManager; +import org.slf4j.LoggerFactory; /** * Service responsible for exposing metrics to the outside, either through a port and network @@ -37,7 +37,8 @@ public interface MetricsService { final Vertx vertx, final MetricsConfiguration configuration, final MetricsSystem metricsSystem) { - LogManager.getLogger().trace("Creating metrics service {}", configuration.getProtocol()); + LoggerFactory.getLogger(MetricsService.class) + .trace("Creating metrics service {}", configuration.getProtocol()); if (configuration.getProtocol() == MetricsProtocol.PROMETHEUS) { if (configuration.isEnabled()) { return Optional.of(new MetricsHttpService(vertx, configuration, metricsSystem)); diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsSystemFactory.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsSystemFactory.java index 872ad3ab22..f8449c497b 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsSystemFactory.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsSystemFactory.java @@ -22,13 +22,13 @@ import org.hyperledger.besu.metrics.opentelemetry.OpenTelemetrySystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Creates a new metric system based on configuration. */ public class MetricsSystemFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MetricsSystemFactory.class); private MetricsSystemFactory() {} diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/MetricsOtelGrpcPushService.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/MetricsOtelGrpcPushService.java index 0a86922033..75487d639f 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/MetricsOtelGrpcPushService.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/MetricsOtelGrpcPushService.java @@ -31,12 +31,12 @@ import io.opentelemetry.sdk.metrics.export.IntervalMetricReaderBuilder; import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.SpanProcessor; import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MetricsOtelGrpcPushService implements MetricsService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MetricsOtelGrpcPushService.class); private final MetricsConfiguration configuration; private final OpenTelemetrySystem metricsSystem; diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/OpenTelemetrySystem.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/OpenTelemetrySystem.java index b0f0ebb896..e3d3d2bae5 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/OpenTelemetrySystem.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/opentelemetry/OpenTelemetrySystem.java @@ -55,13 +55,13 @@ import io.opentelemetry.sdk.metrics.data.MetricDataType; import io.opentelemetry.sdk.metrics.data.PointData; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Metrics system relying on the native OpenTelemetry format. */ public class OpenTelemetrySystem implements ObservableMetricsSystem { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(OpenTelemetrySystem.class); private static final String TYPE_LABEL_KEY = "type"; private static final String AREA_LABEL_KEY = "area"; diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java index 08f16717bb..f471d15c2a 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java @@ -43,11 +43,11 @@ import io.vertx.core.http.HttpServerOptions; import io.vertx.core.http.HttpServerResponse; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MetricsHttpService implements MetricsService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MetricsHttpService.class); private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0); diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsPushGatewayService.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsPushGatewayService.java index 871deaebb9..9f5d81aabe 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsPushGatewayService.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsPushGatewayService.java @@ -27,11 +27,11 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import io.prometheus.client.exporter.PushGateway; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MetricsPushGatewayService implements MetricsService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(MetricsPushGatewayService.class); private PushGateway pushGateway; private ScheduledExecutorService scheduledExecutorService; @@ -92,7 +92,7 @@ public class MetricsPushGatewayService implements MetricsService { } resultFuture.complete(null); } catch (final InterruptedException e) { - LOG.error(e); + LOG.error("Unable to shutdown push metrics service gracefully", e); resultFuture.completeExceptionally(e); } return resultFuture; diff --git a/metrics/rocksdb/build.gradle b/metrics/rocksdb/build.gradle index 91a274de62..292909565d 100644 --- a/metrics/rocksdb/build.gradle +++ b/metrics/rocksdb/build.gradle @@ -34,11 +34,12 @@ publishing { } dependencies { + api 'org.slf4j:slf4j-api' + implementation project(':metrics:core') implementation project(':plugin-api') implementation 'com.google.guava:guava' implementation 'io.prometheus:simpleclient' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.rocksdb:rocksdbjni' } diff --git a/nat/build.gradle b/nat/build.gradle index a5967c6374..ff55f17098 100644 --- a/nat/build.gradle +++ b/nat/build.gradle @@ -28,15 +28,14 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation 'com.google.guava:guava' implementation 'com.squareup.okhttp3:okhttp' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.jupnp:org.jupnp' implementation 'org.jupnp:org.jupnp.support' implementation 'io.kubernetes:client-java' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - // test dependencies. testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') diff --git a/nat/src/main/java/org/hyperledger/besu/nat/NatService.java b/nat/src/main/java/org/hyperledger/besu/nat/NatService.java index 8f4554a14b..cd997d40f3 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/NatService.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/NatService.java @@ -25,13 +25,13 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Utility class to help interacting with various {@link NatManager}. */ public class NatService { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(NatService.class); private static final boolean DEFAULT_FALLBACK_STATUS = true; diff --git a/nat/src/main/java/org/hyperledger/besu/nat/core/AbstractNatManager.java b/nat/src/main/java/org/hyperledger/besu/nat/core/AbstractNatManager.java index 3be667cb21..dc40be4212 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/core/AbstractNatManager.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/core/AbstractNatManager.java @@ -33,11 +33,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractNatManager implements NatManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AbstractNatManager.class); protected final NatMethod natMethod; diff --git a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerNatManager.java b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerNatManager.java index fb26690b52..90f59b97ce 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerNatManager.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerNatManager.java @@ -29,15 +29,15 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class describes the behaviour of the Docker NAT manager. Docker Nat manager add support for * Docker’s NAT implementation when Besu is being run from a Docker container */ public class DockerNatManager extends AbstractNatManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DockerNatManager.class); private static final String PORT_MAPPING_TAG = "HOST_PORT_"; diff --git a/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java b/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java index 5828335f45..7b1165772c 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java @@ -39,15 +39,15 @@ import io.kubernetes.client.openapi.models.V1Service; import io.kubernetes.client.util.ClientBuilder; import io.kubernetes.client.util.KubeConfig; import io.kubernetes.client.util.authenticators.GCPAuthenticator; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class describes the behaviour of the Kubernetes NAT manager. Kubernetes Nat manager add * support for Kubernetes’s NAT implementation when Besu is being run from a Kubernetes cluster */ public class KubernetesNatManager extends AbstractNatManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(KubernetesNatManager.class); public static final String DEFAULT_BESU_SERVICE_NAME_FILTER = "besu"; diff --git a/nat/src/main/java/org/hyperledger/besu/nat/upnp/BesuUpnpServiceConfiguration.java b/nat/src/main/java/org/hyperledger/besu/nat/upnp/BesuUpnpServiceConfiguration.java index 69713fe53d..dd099a78d9 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/upnp/BesuUpnpServiceConfiguration.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/upnp/BesuUpnpServiceConfiguration.java @@ -20,8 +20,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.jupnp.DefaultUpnpServiceConfiguration; import org.jupnp.UpnpServiceConfiguration; import org.jupnp.binding.xml.DeviceDescriptorBinder; @@ -50,9 +48,11 @@ import org.jupnp.transport.spi.NetworkAddressFactory; import org.jupnp.transport.spi.SOAPActionProcessor; import org.jupnp.transport.spi.StreamClient; import org.jupnp.transport.spi.StreamServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class BesuUpnpServiceConfiguration implements UpnpServiceConfiguration { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(BesuUpnpServiceConfiguration.class); private final ThreadPoolExecutor executorService; private final DeviceDescriptorBinder deviceDescriptorBinderUDA10; diff --git a/nat/src/main/java/org/hyperledger/besu/nat/upnp/UpnpNatManager.java b/nat/src/main/java/org/hyperledger/besu/nat/upnp/UpnpNatManager.java index 750843f99b..22cc1ce13f 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/upnp/UpnpNatManager.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/upnp/UpnpNatManager.java @@ -34,8 +34,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.jupnp.UpnpService; import org.jupnp.UpnpServiceImpl; import org.jupnp.model.action.ActionInvocation; @@ -51,13 +49,15 @@ import org.jupnp.support.igd.callback.GetExternalIP; import org.jupnp.support.igd.callback.PortMappingAdd; import org.jupnp.support.igd.callback.PortMappingDelete; import org.jupnp.support.model.PortMapping; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Manages underlying UPnP library "jupnp" and provides abstractions for asynchronously interacting * with the NAT environment through UPnP. */ public class UpnpNatManager extends AbstractNatManager { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(UpnpNatManager.class); static final String SERVICE_TYPE_WAN_IP_CONNECTION = "WANIPConnection"; diff --git a/pki/build.gradle b/pki/build.gradle index 11c1545188..7315ec225d 100644 --- a/pki/build.gradle +++ b/pki/build.gradle @@ -28,15 +28,15 @@ jar { } dependencies { + api 'org.slf4j:slf4j-api' + implementation 'com.google.guava:guava' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.bouncycastle:bcpkix-jdk15on' testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-core' - testImplementation 'org.apache.logging.log4j:log4j-core' } configurations { testArtifacts } diff --git a/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsCreator.java b/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsCreator.java index 0dcd6bf93a..e34b361b06 100644 --- a/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsCreator.java +++ b/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsCreator.java @@ -23,8 +23,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.bouncycastle.cert.jcajce.JcaCertStore; import org.bouncycastle.cms.CMSProcessableByteArray; @@ -47,8 +45,6 @@ public class CmsCreator { } } - private static final Logger LOGGER = LogManager.getLogger(); - private final String certificateAlias; private final KeyStoreWrapper keyStore; @@ -100,7 +96,6 @@ public class CmsCreator { return Bytes.wrap(cmsSignedData.getEncoded()); } catch (final Exception e) { - LOGGER.error("Error creating CMS data", e); throw new RuntimeException("Error creating CMS data", e); } } diff --git a/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsValidator.java b/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsValidator.java index 8d36fbc15c..429bc1dad7 100644 --- a/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsValidator.java +++ b/pki/src/main/java/org/hyperledger/besu/pki/cms/CmsValidator.java @@ -30,8 +30,6 @@ import java.util.Collection; import java.util.EnumSet; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.bouncycastle.cert.X509CertificateHolder; import org.bouncycastle.cert.jcajce.JcaCertStoreBuilder; @@ -43,6 +41,8 @@ import org.bouncycastle.cms.SignerInformation; import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.Store; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CmsValidator { @@ -52,7 +52,7 @@ public class CmsValidator { } } - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(CmsValidator.class); private final KeyStoreWrapper truststore; @@ -93,7 +93,6 @@ public class CmsValidator { return true; } catch (final Exception e) { - LOGGER.error("Error validating CMS data", e); throw new RuntimeException("Error validating CMS data", e); } } @@ -117,7 +116,6 @@ public class CmsValidator { return new JcaX509CertificateConverter().getCertificate(certificateHolder); } catch (final Exception e) { - LOGGER.error("Error retrieving signer certificate from CMS data", e); throw new RuntimeException("Error retrieving signer certificate from CMS data", e); } } diff --git a/pki/src/main/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreWrapper.java b/pki/src/main/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreWrapper.java index 405e235cb4..2c7e63b21e 100644 --- a/pki/src/main/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreWrapper.java +++ b/pki/src/main/java/org/hyperledger/besu/pki/keystore/HardwareKeyStoreWrapper.java @@ -31,8 +31,8 @@ import java.util.Properties; import java.util.stream.Stream; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Creates an instance of this class which is backed by a PKCS#11 keystore, such as a software @@ -41,7 +41,7 @@ import org.apache.logging.log4j.Logger; */ public class HardwareKeyStoreWrapper extends AbstractKeyStoreWrapper { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(HardwareKeyStoreWrapper.class); private static final String pkcs11Provider = "SunPKCS11"; diff --git a/pki/src/main/java/org/hyperledger/besu/pki/keystore/SoftwareKeyStoreWrapper.java b/pki/src/main/java/org/hyperledger/besu/pki/keystore/SoftwareKeyStoreWrapper.java index 40664b5772..f2b48d96c8 100644 --- a/pki/src/main/java/org/hyperledger/besu/pki/keystore/SoftwareKeyStoreWrapper.java +++ b/pki/src/main/java/org/hyperledger/besu/pki/keystore/SoftwareKeyStoreWrapper.java @@ -29,12 +29,12 @@ import java.util.HashMap; import java.util.Map; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SoftwareKeyStoreWrapper extends AbstractKeyStoreWrapper { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(SoftwareKeyStoreWrapper.class); private final KeyStore keystore; private final transient char[] keystorePassword; diff --git a/pki/src/test/java/org/hyperledger/besu/pki/keystore/CryptoTestUtil.java b/pki/src/test/java/org/hyperledger/besu/pki/keystore/CryptoTestUtil.java index a030bf54a2..4176cac0fa 100644 --- a/pki/src/test/java/org/hyperledger/besu/pki/keystore/CryptoTestUtil.java +++ b/pki/src/test/java/org/hyperledger/besu/pki/keystore/CryptoTestUtil.java @@ -18,12 +18,12 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CryptoTestUtil { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(CryptoTestUtil.class); private CryptoTestUtil() {} diff --git a/plugins/rocksdb/build.gradle b/plugins/rocksdb/build.gradle index 0ab1005e6a..4463813ede 100644 --- a/plugins/rocksdb/build.gradle +++ b/plugins/rocksdb/build.gradle @@ -33,6 +33,7 @@ publishing { dependencies { api project(':plugin-api') + api 'org.slf4j:slf4j-api' implementation project(':metrics:core') implementation project(':metrics:rocksdb') @@ -43,12 +44,9 @@ dependencies { implementation 'info.picocli:picocli' implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.prometheus:simpleclient' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.rocksdb:rocksdbjni' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation project(':testutil') testImplementation 'junit:junit' diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValuePrivacyStorageFactory.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValuePrivacyStorageFactory.java index b368e50830..845b1d1431 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValuePrivacyStorageFactory.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValuePrivacyStorageFactory.java @@ -27,15 +27,16 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Takes a public storage factory and enables creating independently versioned privacy storage * objects which have the same features as the supported public storage factory */ public class RocksDBKeyValuePrivacyStorageFactory implements PrivacyKeyValueStorageFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = + LoggerFactory.getLogger(RocksDBKeyValuePrivacyStorageFactory.class); private static final int DEFAULT_VERSION = 1; private static final Set SUPPORTED_VERSIONS = Set.of(0, 1); @@ -62,8 +63,7 @@ public class RocksDBKeyValuePrivacyStorageFactory implements PrivacyKeyValueStor try { databaseVersion = readDatabaseVersion(commonConfiguration); } catch (final IOException e) { - LOG.error("Failed to retrieve the RocksDB database meta version: {}", e.getMessage()); - throw new StorageException(e.getMessage(), e); + throw new StorageException("Failed to retrieve the RocksDB database meta version", e); } } diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java index c4e9abf69e..274f88c998 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java @@ -39,12 +39,12 @@ import java.util.Set; import java.util.stream.Collectors; import com.google.common.base.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDBKeyValueStorageFactory.class); private static final int DEFAULT_VERSION = 1; private static final Set SUPPORTED_VERSIONS = Set.of(0, 1, 2); private static final String NAME = "rocksdb"; @@ -145,8 +145,7 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory { try { databaseVersion = readDatabaseVersion(commonConfiguration); } catch (final IOException e) { - LOG.error("Failed to retrieve the RocksDB database meta version: {}", e.getMessage()); - throw new StorageException(e.getMessage(), e); + throw new StorageException("Failed to retrieve the RocksDB database meta version", e); } isSegmentIsolationSupported = databaseVersion >= 1; rocksDBConfiguration = diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBMetricsFactory.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBMetricsFactory.java index 2371c32aae..0a6490c9a2 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBMetricsFactory.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBMetricsFactory.java @@ -23,11 +23,11 @@ import org.hyperledger.besu.plugin.services.metrics.MetricCategory; import org.hyperledger.besu.plugin.services.metrics.OperationTimer; import org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBConfiguration; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.rocksdb.OptimisticTransactionDB; import org.rocksdb.RocksDBException; import org.rocksdb.Statistics; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBMetricsFactory { @@ -40,7 +40,7 @@ public class RocksDBMetricsFactory { BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB, BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB_STATS); - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDBMetricsFactory.class); private final MetricCategory rocksDbMetricCategory; private final MetricCategory statsDbMetricCategory; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBPlugin.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBPlugin.java index e99c09ecd5..bc9231a10f 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBPlugin.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBPlugin.java @@ -28,12 +28,12 @@ import java.util.Optional; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBPlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDBPlugin.class); private static final String NAME = "rocksdb"; private final RocksDBCLIOptions options; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbKeyIterator.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbKeyIterator.java index 98064a6819..23e1cbcd0f 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbKeyIterator.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbKeyIterator.java @@ -25,13 +25,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.rocksdb.RocksDBException; import org.rocksdb.RocksIterator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDbKeyIterator implements Iterator, AutoCloseable { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDbKeyIterator.class); private final RocksIterator rocksIterator; private final AtomicBoolean closed = new AtomicBoolean(false); diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbUtil.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbUtil.java index 168fa13a2c..677b42bba2 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbUtil.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDbUtil.java @@ -16,12 +16,12 @@ package org.hyperledger.besu.plugin.services.storage.rocksdb; import org.hyperledger.besu.util.InvalidConfigurationException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.rocksdb.RocksDB; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDbUtil { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDbUtil.class); private RocksDbUtil() {} diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java index 63214c7cbb..ca47653074 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/configuration/DatabaseMetadata.java @@ -27,11 +27,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DatabaseMetadata { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(DatabaseMetadata.class); private static final String METADATA_FILENAME = "DATABASE_METADATA.json"; private static final ObjectMapper MAPPER = new ObjectMapper(); diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java index 6dd35b96ab..81e9866934 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java @@ -41,8 +41,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.rocksdb.BlockBasedTableConfig; import org.rocksdb.ColumnFamilyDescriptor; @@ -58,6 +56,8 @@ import org.rocksdb.Statistics; import org.rocksdb.Status; import org.rocksdb.TransactionDBOptions; import org.rocksdb.WriteOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBColumnarKeyValueStorage implements SegmentedKeyValueStorage { @@ -66,7 +66,7 @@ public class RocksDBColumnarKeyValueStorage RocksDbUtil.loadNativeLibrary(); } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDBColumnarKeyValueStorage.class); private static final String DEFAULT_COLUMN = "default"; private static final String NO_SPACE_LEFT_ON_DEVICE = "No space left on device"; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBKeyValueStorage.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBKeyValueStorage.java index 4dc86fe821..22d79cf2d6 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBKeyValueStorage.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBKeyValueStorage.java @@ -34,8 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.rocksdb.BlockBasedTableConfig; import org.rocksdb.LRUCache; import org.rocksdb.OptimisticTransactionDB; @@ -45,6 +43,8 @@ import org.rocksdb.RocksIterator; import org.rocksdb.Statistics; import org.rocksdb.Status; import org.rocksdb.WriteOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBKeyValueStorage implements KeyValueStorage { @@ -52,7 +52,7 @@ public class RocksDBKeyValueStorage implements KeyValueStorage { RocksDbUtil.loadNativeLibrary(); } - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(RocksDBKeyValueStorage.class); private final Options options; private final OptimisticTransactionDB db; diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBTransaction.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBTransaction.java index 7fac1abc6d..57dfdf8062 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBTransaction.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBTransaction.java @@ -19,14 +19,14 @@ import org.hyperledger.besu.plugin.services.metrics.OperationTimer; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBMetrics; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.rocksdb.RocksDBException; import org.rocksdb.Transaction; import org.rocksdb.WriteOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RocksDBTransaction implements KeyValueStorageTransaction { - private static final Logger logger = LogManager.getLogger(); + private static final Logger logger = LoggerFactory.getLogger(RocksDBTransaction.class); private static final String NO_SPACE_LEFT_ON_DEVICE = "No space left on device"; private final RocksDBMetrics metrics; diff --git a/services/kvstore/build.gradle b/services/kvstore/build.gradle index faf2d99b20..6001470f06 100644 --- a/services/kvstore/build.gradle +++ b/services/kvstore/build.gradle @@ -30,18 +30,16 @@ jar { dependencies { api project(':plugin-api') api project(':util') + api 'org.slf4j:slf4j-api' implementation project(':metrics:core') implementation project(':metrics:rocksdb') implementation 'com.google.guava:guava' implementation 'io.prometheus:simpleclient' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.rocksdb:rocksdbjni' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation project(':testutil') testImplementation 'junit:junit' diff --git a/services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/InMemoryStoragePlugin.java b/services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/InMemoryStoragePlugin.java index 6d23db335a..7d479f954d 100644 --- a/services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/InMemoryStoragePlugin.java +++ b/services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/InMemoryStoragePlugin.java @@ -27,12 +27,12 @@ import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier; import java.util.HashMap; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class InMemoryStoragePlugin implements BesuPlugin { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(InMemoryStoragePlugin.class); private BesuContext context; private MemoryKeyValueStorageFactory factory; private MemoryKeyValueStorageFactory privacyFactory; diff --git a/services/pipeline/build.gradle b/services/pipeline/build.gradle index 7b208ee4a8..517061c1b7 100644 --- a/services/pipeline/build.gradle +++ b/services/pipeline/build.gradle @@ -29,15 +29,13 @@ jar { dependencies { api project(':util') + api 'org.slf4j:slf4j-api' implementation project(':metrics:core') implementation project(':plugin-api') implementation 'io.opentelemetry:opentelemetry-api' implementation 'com.google.guava:guava' - implementation 'org.apache.logging.log4j:log4j-api' - - runtimeOnly 'org.apache.logging.log4j:log4j-core' testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' diff --git a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessor.java b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessor.java index 4bdeb645d6..bcccb94d07 100644 --- a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessor.java +++ b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessor.java @@ -25,11 +25,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class AsyncOperationProcessor implements Processor { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(AsyncOperationProcessor.class); private final Function> processor; private final List> inProgress; private CompletableFuture nextOutputAvailableFuture = completedFuture(null); diff --git a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java index e3615c931b..5e117d6e56 100644 --- a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java +++ b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipe.java @@ -22,8 +22,8 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Forms the connection between two pipeline stages. A pipe is essentially a blocking queue with the @@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger; * @param the type of item that flows through the pipe. */ public class Pipe implements ReadPipe, WritePipe { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Pipe.class); private final BlockingQueue queue; private final Counter inputCounter; private final Counter outputCounter; diff --git a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipeline.java b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipeline.java index 94fd4b49a4..04fb530a14 100644 --- a/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipeline.java +++ b/services/pipeline/src/main/java/org/hyperledger/besu/services/pipeline/Pipeline.java @@ -32,11 +32,11 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.api.trace.Tracer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Pipeline { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Pipeline.class); private final Pipe inputPipe; private final Collection stages; private final Collection> pipes; diff --git a/services/tasks/build.gradle b/services/tasks/build.gradle index 93ab36e87a..fa7ab66cf6 100644 --- a/services/tasks/build.gradle +++ b/services/tasks/build.gradle @@ -30,6 +30,7 @@ jar { dependencies { api project(':plugin-api') api project(':util') + api 'org.slf4j:slf4j-api' compileOnly 'org.openjdk.jmh:jmh-generator-annprocess' @@ -37,11 +38,8 @@ dependencies { implementation 'com.google.guava:guava' implementation 'io.vertx:vertx-core' - implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.tuweni:tuweni-bytes' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' } diff --git a/services/tasks/src/main/java/org/hyperledger/besu/services/tasks/FlatFileTaskCollection.java b/services/tasks/src/main/java/org/hyperledger/besu/services/tasks/FlatFileTaskCollection.java index dba504fe8c..579d418550 100644 --- a/services/tasks/src/main/java/org/hyperledger/besu/services/tasks/FlatFileTaskCollection.java +++ b/services/tasks/src/main/java/org/hyperledger/besu/services/tasks/FlatFileTaskCollection.java @@ -26,12 +26,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class FlatFileTaskCollection implements TaskCollection { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(FlatFileTaskCollection.class); private static final long DEFAULT_FILE_ROLL_SIZE_BYTES = 1024 * 1024 * 10; // 10Mb static final String FILENAME_PREFIX = "tasks"; private final Set> outstandingTasks = new HashSet<>(); diff --git a/testutil/src/main/java/org/hyperledger/enclave/testutil/EnclaveKeyUtils.java b/testutil/src/main/java/org/hyperledger/enclave/testutil/EnclaveKeyUtils.java index 38199f5611..be1323c5e8 100644 --- a/testutil/src/main/java/org/hyperledger/enclave/testutil/EnclaveKeyUtils.java +++ b/testutil/src/main/java/org/hyperledger/enclave/testutil/EnclaveKeyUtils.java @@ -26,12 +26,12 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.util.Base64; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EnclaveKeyUtils { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(EnclaveKeyUtils.class); /** * Utility method to load the enclave public key. Possible input values are the names of the *.pub diff --git a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java b/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java index 460ea3fec5..4d50f285eb 100644 --- a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java +++ b/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java @@ -31,16 +31,16 @@ import java.util.stream.Collectors; import com.google.common.base.Charsets; import io.vertx.core.json.JsonArray; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.assertj.core.util.Files; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.MountableFile; public class TesseraTestHarness implements EnclaveTestHarness { - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(TesseraTestHarness.class); private final EnclaveConfiguration enclaveConfiguration; diff --git a/util/build.gradle b/util/build.gradle index d39d3dcf70..6abf9eb221 100644 --- a/util/build.gradle +++ b/util/build.gradle @@ -28,18 +28,18 @@ jar { } dependencies { - api 'org.apache.logging.log4j:log4j-api' + api 'org.slf4j:slf4j-api' implementation project(':plugin-api') implementation 'com.google.guava:guava' implementation 'io.vertx:vertx-core' + implementation 'org.apache.logging.log4j:log4j-core' + implementation 'org.apache.logging.log4j:log4j-slf4j-impl' implementation 'org.apache.tuweni:tuweni-bytes' implementation 'org.apache.tuweni:tuweni-units' implementation 'org.xerial.snappy:snappy-java' - runtimeOnly 'org.apache.logging.log4j:log4j-core' - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-core' diff --git a/util/src/main/java/org/hyperledger/besu/util/Log4j2ConfiguratorUtil.java b/util/src/main/java/org/hyperledger/besu/util/Log4j2ConfiguratorUtil.java new file mode 100644 index 0000000000..b6876c5cb2 --- /dev/null +++ b/util/src/main/java/org/hyperledger/besu/util/Log4j2ConfiguratorUtil.java @@ -0,0 +1,104 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.util; + +import java.util.Map; +import java.util.Set; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.LoggerConfig; +import org.apache.logging.log4j.util.Strings; +import org.apache.logging.slf4j.Log4jLoggerFactory; +import org.slf4j.LoggerFactory; + +public class Log4j2ConfiguratorUtil { + + private Log4j2ConfiguratorUtil() {} + + public static void setAllLevels(final String parentLogger, final Level level) { + // 1) get logger config + // 2) if exact match, use it, if not, create it. + // 3) set level on logger config + // 4) update child logger configs with level + // 5) update loggers + final LoggerContext loggerContext = getLoggerContext(); + final Configuration config = loggerContext.getConfiguration(); + boolean set = setLevel(parentLogger, level, config); + for (final Map.Entry entry : config.getLoggers().entrySet()) { + if (entry.getKey().startsWith(parentLogger)) { + set |= setLevel(entry.getValue(), level); + } + } + if (set) { + loggerContext.updateLoggers(); + } + } + + public static void setLevel(final String loggerName, final Level level) { + final LoggerContext loggerContext = getLoggerContext(); + if (Strings.isEmpty(loggerName)) { + setRootLevel(loggerContext, level); + } else if (setLevel(loggerName, level, loggerContext.getConfiguration())) { + loggerContext.updateLoggers(); + } + } + + private static boolean setLevel( + final String loggerName, final Level level, final Configuration config) { + boolean set; + LoggerConfig loggerConfig = config.getLoggerConfig(loggerName); + if (!loggerName.equals(loggerConfig.getName())) { + loggerConfig = new LoggerConfig(loggerName, level, true); + config.addLogger(loggerName, loggerConfig); + loggerConfig.setLevel(level); + set = true; + } else { + set = setLevel(loggerConfig, level); + } + return set; + } + + private static boolean setLevel(final LoggerConfig loggerConfig, final Level level) { + final boolean set = !loggerConfig.getLevel().equals(level); + if (set) { + loggerConfig.setLevel(level); + } + return set; + } + + private static void setRootLevel(final LoggerContext loggerContext, final Level level) { + final LoggerConfig loggerConfig = loggerContext.getConfiguration().getRootLogger(); + if (!loggerConfig.getLevel().equals(level)) { + loggerConfig.setLevel(level); + loggerContext.updateLoggers(); + } + } + + public static void reconfigure() { + getLoggerContext().reconfigure(); + } + + private static LoggerContext getLoggerContext() { + final Set loggerContexts = + ((Log4jLoggerFactory) LoggerFactory.getILoggerFactory()).getLoggerContexts(); + return (LoggerContext) loggerContexts.iterator().next(); + } + + public static void shutdown() { + getLoggerContext().terminate(); + } +} diff --git a/util/src/main/java/org/hyperledger/besu/util/Subscribers.java b/util/src/main/java/org/hyperledger/besu/util/Subscribers.java index d54fa640f3..1aad7a07bf 100644 --- a/util/src/main/java/org/hyperledger/besu/util/Subscribers.java +++ b/util/src/main/java/org/hyperledger/besu/util/Subscribers.java @@ -20,8 +20,8 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Tracks subscribers that should be notified when some event occurred. This class is safe to use @@ -45,7 +45,7 @@ import org.apache.logging.log4j.Logger; */ public class Subscribers { private static final Subscribers NONE = new EmptySubscribers<>(); - private static final Logger LOG = LogManager.getLogger(); + private static final Logger LOG = LoggerFactory.getLogger(Subscribers.class); private final AtomicLong subscriberId = new AtomicLong(); private final Map subscribers = new ConcurrentHashMap<>();