[MINOR] Normalize references to Logger (#28)

* normalize references to Logger

* stanrdize on getLogger()
S. Matthew English 6 years ago committed by GitHub
parent 393ce95af4
commit 671adffac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/CliqueVoteTallyUpdater.java
  2. 12
      consensus/clique/src/main/java/net/consensys/pantheon/consensus/clique/headervalidationrules/CliqueExtraDataValidationRule.java
  3. 4
      consensus/common/src/main/java/net/consensys/pantheon/consensus/common/headervalidationrules/VoteValidationRule.java
  4. 4
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/IbftEventQueue.java
  5. 4
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/IbftProcessor.java
  6. 7
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/VoteTallyUpdater.java
  7. 2
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/blockcreation/IbftBlockCreator.java
  8. 4
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/blockcreation/ProposerSelector.java
  9. 14
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/headervalidationrules/IbftExtraDataValidationRule.java
  10. 2
      consensus/ibft/src/main/java/net/consensys/pantheon/consensus/ibft/protocol/IbftProtocolManager.java
  11. 4
      crypto/src/main/java/net/consensys/pantheon/crypto/PersonalisationString.java
  12. 11
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/AbstractBlockCreator.java
  13. 3
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/blockcreation/BlockTransactionSelector.java
  14. 4
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/BlockHeaderValidator.java
  15. 2
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/EthHashCacheFactory.java
  16. 22
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/MainnetBlockBodyValidator.java
  17. 6
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/MainnetBlockProcessor.java
  18. 16
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/MainnetContractCreationProcessor.java
  19. 17
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/MainnetMessageCallProcessor.java
  20. 18
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/MainnetTransactionProcessor.java
  21. 6
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/AncestryValidationRule.java
  22. 4
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/CalculatedDifficultyValidationRule.java
  23. 4
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/ExtraDataMaxLengthValidationRule.java
  24. 7
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/GasLimitRangeAndDeltaValidationRule.java
  25. 4
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/GasUsageValidationRule.java
  26. 8
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRule.java
  27. 6
      ethereum/core/src/main/java/net/consensys/pantheon/ethereum/mainnet/headervalidationrules/TimestampValidationRule.java
  28. 10
      ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java
  29. 4
      ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/internal/methods/EthSendRawTransaction.java
  30. 10
      ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/websocket/WebSocketRequestHandler.java
  31. 14
      ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/websocket/WebSocketService.java
  32. 10
      ethereum/jsonrpc/src/main/java/net/consensys/pantheon/ethereum/jsonrpc/websocket/subscription/SubscriptionManager.java
  33. 16
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/NetworkRunner.java
  34. 2
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java
  35. 2
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/discovery/internal/PeerDiscoveryController.java
  36. 14
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/ApiHandler.java
  37. 4
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/Callbacks.java
  38. 2
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/DeFramer.java
  39. 4
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/HandshakeHandlerOutbound.java
  40. 16
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java
  41. 8
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/NettyPeerConnection.java
  42. 6
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/netty/WireKeepAlive.java
  43. 4
      ethereum/p2p/src/main/java/net/consensys/pantheon/ethereum/p2p/wire/Capability.java
  44. 12
      pantheon/src/main/java/net/consensys/pantheon/Runner.java
  45. 4
      pantheon/src/main/java/net/consensys/pantheon/cli/ExportPublicKeySubCommand.java
  46. 4
      pantheon/src/main/java/net/consensys/pantheon/cli/ImportBlockchainSubCommand.java
  47. 4
      pantheon/src/main/java/net/consensys/pantheon/cli/ImportSubCommand.java
  48. 2
      pantheon/src/main/java/net/consensys/pantheon/cli/PantheonCommand.java
  49. 10
      pantheon/src/main/java/net/consensys/pantheon/controller/KeyPairUtil.java
  50. 6
      pantheon/src/test/java/net/consensys/pantheon/cli/CommandTestAbstract.java
  51. 6
      services/kvstore/src/main/java/net/consensys/pantheon/services/kvstore/RocksDbKeyValueStorage.java

@ -16,7 +16,7 @@ import org.apache.logging.log4j.Logger;
public class CliqueVoteTallyUpdater {
private static final Logger LOGGER = getLogger();
private static final Logger LOG = getLogger();
public static final Address NO_VOTE_SUBJECT = Address.wrap(BytesValue.wrap(new byte[20]));
private final EpochManager epochManager;
@ -28,7 +28,7 @@ public class CliqueVoteTallyUpdater {
public VoteTally buildVoteTallyFromBlockchain(final Blockchain blockchain) {
final long chainHeadBlockNumber = blockchain.getChainHeadBlockNumber();
final long epochBlockNumber = epochManager.getLastEpochBlock(chainHeadBlockNumber);
LOGGER.info("Loading validator voting state starting from block {}", epochBlockNumber);
LOG.info("Loading validator voting state starting from block {}", epochBlockNumber);
final BlockHeader epochBlock = blockchain.getBlockHeader(epochBlockNumber).get();
final List<Address> initialValidators =
CliqueExtraData.decode(epochBlock.getExtraData()).getValidators();

@ -20,7 +20,7 @@ import org.apache.logging.log4j.Logger;
public class CliqueExtraDataValidationRule
implements AttachedBlockHeaderValidationRule<CliqueContext> {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
private final EpochManager epochManager;
@ -53,10 +53,10 @@ public class CliqueExtraDataValidationRule
return extraDataIsValid(storedValidators, header);
} catch (final RLPException ex) {
LOGGER.trace("ExtraData field was unable to be deserialised into an Clique Struct.", ex);
LOG.trace("ExtraData field was unable to be deserialised into an Clique Struct.", ex);
return false;
} catch (final IllegalArgumentException ex) {
LOGGER.trace("Failed to verify extra data", ex);
LOG.trace("Failed to verify extra data", ex);
return false;
}
}
@ -68,13 +68,13 @@ public class CliqueExtraDataValidationRule
final Address proposer = CliqueBlockHashing.recoverProposerAddress(header, cliqueExtraData);
if (!expectedValidators.contains(proposer)) {
LOGGER.trace("Proposer sealing block is not a member of the validators.");
LOG.trace("Proposer sealing block is not a member of the validators.");
return false;
}
if (epochManager.isEpochBlock(header.getNumber())) {
if (!Iterables.elementsEqual(cliqueExtraData.getValidators(), expectedValidators)) {
LOGGER.trace(
LOG.trace(
"Incorrect validators. Expected {} but got {}.",
expectedValidators,
cliqueExtraData.getValidators());
@ -82,7 +82,7 @@ public class CliqueExtraDataValidationRule
}
} else {
if (!cliqueExtraData.getValidators().isEmpty()) {
LOGGER.trace("Validator list on non-epoch blocks must be empty.");
LOG.trace("Validator list on non-epoch blocks must be empty.");
return false;
}
}

@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger;
public class VoteValidationRule implements DetachedBlockHeaderValidationRule {
private static final Logger LOGGER = LogManager.getLogger(VoteValidationRule.class);
private static final Logger LOG = LogManager.getLogger();
/**
* Responsible for ensuring the nonce is either auth or drop.
@ -22,7 +22,7 @@ public class VoteValidationRule implements DetachedBlockHeaderValidationRule {
public boolean validate(final BlockHeader header, final BlockHeader parent) {
final long nonce = header.getNonce();
if (!VoteType.fromNonce(nonce).isPresent()) {
LOGGER.trace("Nonce value ({}) is neither auth or drop.", nonce);
LOG.trace("Nonce value ({}) is neither auth or drop.", nonce);
return false;
}
return true;

@ -13,7 +13,7 @@ public class IbftEventQueue {
private final BlockingQueue<IbftEvent> queue = new LinkedBlockingQueue<>();
private static final int MAX_QUEUE_SIZE = 1000;
private static final Logger LOGGER = LogManager.getLogger(IbftEventQueue.class);
private static final Logger LOG = LogManager.getLogger();
/**
* Put an Ibft event onto the queue
@ -22,7 +22,7 @@ public class IbftEventQueue {
*/
public void add(final IbftEvent event) {
if (queue.size() > MAX_QUEUE_SIZE) {
LOGGER.warn("Queue size exceeded trying to add new ibft event {}", event.toString());
LOG.warn("Queue size exceeded trying to add new ibft event {}", event.toString());
} else {
queue.add(event);
}

@ -11,7 +11,7 @@ import org.apache.logging.log4j.Logger;
/** Execution context for draining queued ibft events and applying them to a maintained state */
public class IbftProcessor implements Runnable {
private static final Logger LOGGER = LogManager.getLogger(IbftEventQueue.class);
private static final Logger LOG = LogManager.getLogger();
private final IbftEventQueue incomingQueue;
private final ScheduledExecutorService roundTimerExecutor;
@ -73,7 +73,7 @@ public class IbftProcessor implements Runnable {
try {
stateMachine.processEvent(ibftEvent, roundTimer);
} catch (final Exception e) {
LOGGER.error(
LOG.error(
"State machine threw exception while processing event {" + ibftEvent + "}", e);
}
});

@ -1,7 +1,5 @@
package net.consensys.pantheon.consensus.ibft;
import static org.apache.logging.log4j.LogManager.getLogger;
import net.consensys.pantheon.consensus.common.EpochManager;
import net.consensys.pantheon.consensus.common.VoteTally;
import net.consensys.pantheon.consensus.common.VoteType;
@ -12,6 +10,7 @@ import net.consensys.pantheon.util.bytes.BytesValue;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
@ -20,7 +19,7 @@ import org.apache.logging.log4j.Logger;
*/
public class VoteTallyUpdater {
private static final Logger LOGGER = getLogger(VoteTallyUpdater.class);
private static final Logger LOG = LogManager.getLogger();
private static final Address NO_VOTE_SUBJECT = Address.wrap(BytesValue.wrap(new byte[20]));
private final EpochManager epochManager;
@ -38,7 +37,7 @@ public class VoteTallyUpdater {
public VoteTally buildVoteTallyFromBlockchain(final Blockchain blockchain) {
final long chainHeadBlockNumber = blockchain.getChainHeadBlockNumber();
final long epochBlockNumber = epochManager.getLastEpochBlock(chainHeadBlockNumber);
LOGGER.info("Loading validator voting state starting from block {}", epochBlockNumber);
LOG.info("Loading validator voting state starting from block {}", epochBlockNumber);
final BlockHeader epochBlock = blockchain.getBlockHeader(epochBlockNumber).get();
final List<Address> initialValidators =
IbftExtraData.decode(epochBlock.getExtraData()).getValidators();

@ -32,7 +32,7 @@ import org.apache.logging.log4j.Logger;
*/
public class IbftBlockCreator extends AbstractBlockCreator<IbftContext> {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
private final KeyPair nodeKeys;
private final ProtocolSchedule<IbftContext> protocolSchedule;

@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger;
*/
public class ProposerSelector {
private static final Logger LOGGER = LogManager.getLogger(ProposerSelector.class);
private static final Logger LOG = LogManager.getLogger();
private final Blockchain blockchain;
@ -143,7 +143,7 @@ public class ProposerSelector {
final IbftExtraData extraData = IbftExtraData.decode(blockHeader.getExtraData());
return IbftBlockHashing.recoverProposerAddress(blockHeader, extraData);
} else {
LOGGER.trace("Unable to determine proposer for requested block");
LOG.trace("Unable to determine proposer for requested block");
throw new RuntimeException("Unable to determine past proposer");
}
}

@ -26,7 +26,7 @@ import org.apache.logging.log4j.Logger;
*/
public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidationRule<IbftContext> {
private static final Logger LOGGER = LogManager.getLogger(IbftExtraDataValidationRule.class);
private static final Logger LOG = LogManager.getLogger();
private final boolean validateCommitSeals;
@ -66,7 +66,7 @@ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidatio
final Collection<Address> storedValidators = validatorProvider.getCurrentValidators();
if (!storedValidators.contains(proposer)) {
LOGGER.trace("Proposer sealing block is not a member of the validators.");
LOG.trace("Proposer sealing block is not a member of the validators.");
return false;
}
@ -79,7 +79,7 @@ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidatio
}
if (!Iterables.elementsEqual(ibftExtraData.getValidators(), storedValidators)) {
LOGGER.trace(
LOG.trace(
"Incorrect validators. Expected {} but got {}.",
storedValidators,
ibftExtraData.getValidators());
@ -87,10 +87,10 @@ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidatio
}
} catch (final RLPException ex) {
LOGGER.trace("ExtraData field was unable to be deserialised into an IBFT Struct.", ex);
LOG.trace("ExtraData field was unable to be deserialised into an IBFT Struct.", ex);
return false;
} catch (final IllegalArgumentException ex) {
LOGGER.trace("Failed to verify extra data", ex);
LOG.trace("Failed to verify extra data", ex);
return false;
}
@ -102,7 +102,7 @@ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidatio
final int minimumSealsRequired = calculateRequiredValidatorQuorum(storedValidators.size());
if (committers.size() < minimumSealsRequired) {
LOGGER.trace(
LOG.trace(
"Insufficient committers to seal block. (Required {}, received {})",
minimumSealsRequired,
committers.size());
@ -110,7 +110,7 @@ public class IbftExtraDataValidationRule implements AttachedBlockHeaderValidatio
}
if (!storedValidators.containsAll(committers)) {
LOGGER.trace("Not all committers are in the locally maintained validator list.");
LOG.trace("Not all committers are in the locally maintained validator list.");
return false;
}

@ -18,7 +18,7 @@ import org.apache.logging.log4j.Logger;
public class IbftProtocolManager implements ProtocolManager {
private final IbftEventQueue ibftEventQueue;
private final Logger LOGGER = LogManager.getLogger(IbftProtocolManager.class);
private final Logger LOG = LogManager.getLogger();
/**
* Constructor for the ibft protocol manager

@ -14,7 +14,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class PersonalisationString {
private static final Logger LOGGER = LogManager.getLogger(PersonalisationString.class);
private static final Logger LOG = LogManager.getLogger(PersonalisationString.class);
private static final byte[] NETWORK_MACS = networkHardwareAddresses();
public static byte[] getPersonalizationString() {
@ -42,7 +42,7 @@ public class PersonalisationString {
}
}
} catch (SocketException | BufferOverflowException e) {
LOGGER.warn(
LOG.warn(
"Failed to obtain network hardware address for use in random number personalisation string, "
+ "continuing without this piece of random information",
e);

@ -39,7 +39,7 @@ public abstract class AbstractBlockCreator<C> implements AsyncBlockCreator {
BytesValue get(final BlockHeader parent);
}
private static final Logger LOGGER = LogManager.getLogger(AbstractBlockCreator.class);
private static final Logger LOG = LogManager.getLogger();
protected final Address coinbase;
@ -117,7 +117,7 @@ public abstract class AbstractBlockCreator<C> implements AsyncBlockCreator {
protocolSchedule.getByBlockNumber(processableBlockHeader.getNumber()).getBlockReward();
if (!rewardBeneficiary(disposableWorldState, processableBlockHeader, ommers, blockReward)) {
LOGGER.trace("Failed to apply mining reward, exiting.");
LOG.trace("Failed to apply mining reward, exiting.");
throw new RuntimeException("Failed to apply mining reward.");
}
@ -147,12 +147,11 @@ public abstract class AbstractBlockCreator<C> implements AsyncBlockCreator {
return new Block(blockHeader, new BlockBody(transactionResults.getTransactions(), ommers));
} catch (final CancellationException ex) {
LOGGER.trace("Attempt to create block was interrupted.");
LOG.trace("Attempt to create block was interrupted.");
throw ex;
} catch (final Exception ex) {
// TODO(tmm): How are we going to know this has exploded, and thus restart it?
LOGGER.trace(
"Block creation failed unexpectedly. Will restart on next block added to chain.");
LOG.trace("Block creation failed unexpectedly. Will restart on next block added to chain.");
throw ex;
}
}
@ -245,7 +244,7 @@ public abstract class AbstractBlockCreator<C> implements AsyncBlockCreator {
beneficiary.incrementBalance(coinbaseReward);
for (final BlockHeader ommerHeader : ommers) {
if (ommerHeader.getNumber() - header.getNumber() > MAX_GENERATION) {
LOGGER.trace(
LOG.trace(
"Block processing error: ommer block number {} more than {} generations current block number {}",
ommerHeader.getNumber(),
MAX_GENERATION,

@ -10,7 +10,6 @@ import net.consensys.pantheon.ethereum.core.Transaction;
import net.consensys.pantheon.ethereum.core.TransactionReceipt;
import net.consensys.pantheon.ethereum.core.Wei;
import net.consensys.pantheon.ethereum.core.WorldUpdater;
import net.consensys.pantheon.ethereum.mainnet.MainnetBlockProcessor;
import net.consensys.pantheon.ethereum.mainnet.MainnetBlockProcessor.TransactionReceiptFactory;
import net.consensys.pantheon.ethereum.mainnet.TransactionProcessor;
@ -44,7 +43,7 @@ import org.apache.logging.log4j.Logger;
*/
public class BlockTransactionSelector {
private static final Logger LOGGER = LogManager.getLogger(MainnetBlockProcessor.class);
private static final Logger LOG = LogManager.getLogger();
private final Wei minTransactionGasPrice;
private static final double MIN_BLOCK_OCCUPANCY_RATIO = 0.8;

@ -13,7 +13,7 @@ import org.apache.logging.log4j.Logger;
public class BlockHeaderValidator<C> {
private static final Logger LOGGER = LogManager.getLogger(BlockHeaderValidator.class);
private static final Logger LOG = LogManager.getLogger();
private final List<Rule<C>> rules;
@ -69,7 +69,7 @@ public class BlockHeaderValidator<C> {
final Optional<BlockHeader> parent =
context.getBlockchain().getBlockHeader(header.getParentHash());
if (!parent.isPresent()) {
LOGGER.trace("Invalid block header: cannot determine parent header");
LOG.trace("Invalid block header: cannot determine parent header");
}
return parent;
}

@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger;
public class EthHashCacheFactory {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
public static class EthHashDescriptor {
private final long datasetSize;

@ -18,7 +18,7 @@ import org.apache.logging.log4j.Logger;
public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static final Logger LOGGER = LogManager.getLogger(MainnetBlockBodyValidator.class);
private static final Logger LOG = LogManager.getLogger();
private static final int MAX_OMMERS = 2;
@ -84,7 +84,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateTransactionsRoot(final Bytes32 expected, final Bytes32 actual) {
if (!expected.equals(actual)) {
LOGGER.warn(
LOG.warn(
"Invalid block: transaction root mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -95,7 +95,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateLogsBloom(
final LogsBloomFilter expected, final LogsBloomFilter actual) {
if (!expected.equals(actual)) {
LOGGER.warn(
LOG.warn(
"Invalid block: logs bloom filter mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -105,7 +105,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateGasUsed(final long expected, final long actual) {
if (expected != actual) {
LOGGER.warn("Invalid block: gas used mismatch (expected={}, actual={})", expected, actual);
LOG.warn("Invalid block: gas used mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -114,8 +114,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateReceiptsRoot(final Bytes32 expected, final Bytes32 actual) {
if (!expected.equals(actual)) {
LOGGER.warn(
"Invalid block: receipts root mismatch (expected={}, actual={})", expected, actual);
LOG.warn("Invalid block: receipts root mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -124,7 +123,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateStateRoot(final Bytes32 expected, final Bytes32 actual) {
if (!expected.equals(actual)) {
LOGGER.warn("Invalid block: state root mismatch (expected={}, actual={})", expected, actual);
LOG.warn("Invalid block: state root mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -149,7 +148,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private static boolean validateOmmersHash(final Bytes32 expected, final Bytes32 actual) {
if (!expected.equals(actual)) {
LOGGER.warn("Invalid block: ommers hash mismatch (expected={}, actual={})", expected, actual);
LOG.warn("Invalid block: ommers hash mismatch (expected={}, actual={})", expected, actual);
return false;
}
@ -159,19 +158,18 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
private boolean validateOmmers(
final ProtocolContext<C> context, final BlockHeader header, final List<BlockHeader> ommers) {
if (ommers.size() > MAX_OMMERS) {
LOGGER.warn(
"Invalid block: ommer count {} exceeds ommer limit {}", ommers.size(), MAX_OMMERS);
LOG.warn("Invalid block: ommer count {} exceeds ommer limit {}", ommers.size(), MAX_OMMERS);
return false;
}
if (!areOmmersUnique(ommers)) {
LOGGER.warn("Invalid block: ommers are not unique");
LOG.warn("Invalid block: ommers are not unique");
return false;
}
for (final BlockHeader ommer : ommers) {
if (!isOmmerValid(context, header, ommer)) {
LOGGER.warn("Invalid block: ommer is invalid");
LOG.warn("Invalid block: ommer is invalid");
return false;
}
}

@ -28,7 +28,7 @@ public class MainnetBlockProcessor implements BlockProcessor {
TransactionProcessor.Result result, WorldState worldState, long gasUsed);
}
private static final Logger LOGGER = LogManager.getLogger(MainnetBlockProcessor.class);
private static final Logger LOG = LogManager.getLogger();
private static final int MAX_GENERATION = 6;
@ -99,7 +99,7 @@ public class MainnetBlockProcessor implements BlockProcessor {
final long remainingGasBudget = blockHeader.getGasLimit() - gasUsed;
if (Long.compareUnsigned(transaction.getGasLimit(), remainingGasBudget) > 0) {
LOGGER.warn(
LOG.warn(
"Transaction processing error: transaction gas limit {} exceeds available block budget remaining {}",
transaction.getGasLimit(),
remainingGasBudget);
@ -149,7 +149,7 @@ public class MainnetBlockProcessor implements BlockProcessor {
coinbase.incrementBalance(coinbaseReward);
for (final BlockHeader ommerHeader : ommers) {
if (ommerHeader.getNumber() - header.getNumber() > MAX_GENERATION) {
LOGGER.warn(
LOG.warn(
"Block processing error: ommer block number {} more than {} generations current block number {}",
ommerHeader.getNumber(),
MAX_GENERATION,

@ -18,7 +18,7 @@ import org.apache.logging.log4j.Logger;
/** A contract creation message processor. */
public class MainnetContractCreationProcessor extends AbstractMessageProcessor {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
private final boolean requireCodeDepositToSucceed;
@ -69,8 +69,8 @@ public class MainnetContractCreationProcessor extends AbstractMessageProcessor {
@Override
public void start(final MessageFrame frame) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Executing contract-creation");
if (LOG.isTraceEnabled()) {
LOG.trace("Executing contract-creation");
}
final MutableAccount sender = frame.getWorldState().getMutable(frame.getSenderAddress());
@ -82,7 +82,7 @@ public class MainnetContractCreationProcessor extends AbstractMessageProcessor {
// incorrectly include this even in early hard forks.
final MutableAccount contract = frame.getWorldState().getOrCreate(frame.getContractAddress());
if (accountExists(contract)) {
LOGGER.trace(
LOG.trace(
"Contract creation error: account as already been created for address {}",
frame.getContractAddress());
frame.setState(MessageFrame.State.EXCEPTIONAL_HALT);
@ -100,21 +100,21 @@ public class MainnetContractCreationProcessor extends AbstractMessageProcessor {
final Gas depositFee = gasCalculator.codeDepositGasCost(contractCode.size());
if (frame.getRemainingGas().compareTo(depositFee) < 0) {
LOGGER.trace(
LOG.trace(
"Not enough gas to pay the code deposit fee for {}: "
+ "remaining gas = {} < {} = deposit fee",
frame.getContractAddress(),
frame.getRemainingGas(),
depositFee);
if (requireCodeDepositToSucceed) {
LOGGER.trace("Contract creation error: insufficient funds for code deposit");
LOG.trace("Contract creation error: insufficient funds for code deposit");
frame.setState(MessageFrame.State.EXCEPTIONAL_HALT);
} else {
frame.setState(MessageFrame.State.COMPLETED_SUCCESS);
}
} else {
if (contractCode.size() > codeSizeLimit) {
LOGGER.trace(
LOG.trace(
"Contract creation error: code size {} exceeds code size limit {}",
contractCode.size(),
codeSizeLimit);
@ -126,7 +126,7 @@ public class MainnetContractCreationProcessor extends AbstractMessageProcessor {
final MutableAccount contract =
frame.getWorldState().getOrCreate(frame.getContractAddress());
contract.setCode(contractCode);
LOGGER.trace(
LOG.trace(
"Successful creation of contract {} with code of size {} (Gas remaining: {})",
frame.getContractAddress(),
contractCode.size(),

@ -15,7 +15,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
private final PrecompileContractRegistry precompiles;
@ -34,7 +34,7 @@ public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
@Override
public void start(final MessageFrame frame) {
LOGGER.trace("Executing message-call");
LOG.trace("Executing message-call");
transferValue(frame);
@ -49,7 +49,7 @@ public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
@Override
protected void codeSuccess(final MessageFrame frame) {
LOGGER.trace(
LOG.trace(
"Successful message call of {} to {} (Gas remaining: {})",
frame.getSenderAddress(),
frame.getRecipientAddress(),
@ -71,12 +71,12 @@ public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
frame.getWorldState().getOrCreate(frame.getRecipientAddress());
if (frame.getRecipientAddress().equals(frame.getSenderAddress())) {
LOGGER.trace("Message call of {} to itself: no fund transferred", frame.getSenderAddress());
LOG.trace("Message call of {} to itself: no fund transferred", frame.getSenderAddress());
} else {
final Wei prevSenderBalance = senderAccount.decrementBalance(frame.getValue());
final Wei prevRecipientBalance = recipientAccount.incrementBalance(frame.getValue());
LOGGER.trace(
LOG.trace(
"Transferred value {} for message call from {} ({} -> {}) to {} ({} -> {})",
frame.getValue(),
frame.getSenderAddress(),
@ -96,7 +96,7 @@ public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
private void executePrecompile(final PrecompiledContract contract, final MessageFrame frame) {
final Gas gasRequirement = contract.gasRequirement(frame.getInputData());
if (frame.getRemainingGas().compareTo(gasRequirement) < 0) {
LOGGER.trace(
LOG.trace(
"Not enough gas available for pre-compiled contract code {}: requiring "
+ "{} but only {} gas available",
contract,
@ -108,14 +108,13 @@ public class MainnetMessageCallProcessor extends AbstractMessageProcessor {
final BytesValue output = contract.compute(frame.getInputData());
if (output != null) {
frame.setOutputData(output);
LOGGER.trace(
LOG.trace(
"Precompiled contract {} successfully executed (gas consumed: {})",
contract,
gasRequirement);
frame.setState(MessageFrame.State.COMPLETED_SUCCESS);
} else {
LOGGER.trace(
"Precompiled contract {} failed (gas consumed: {})", contract, gasRequirement);
LOG.trace("Precompiled contract {} failed (gas consumed: {})", contract, gasRequirement);
frame.setState(MessageFrame.State.EXCEPTIONAL_HALT);
}
}

@ -26,7 +26,7 @@ import org.apache.logging.log4j.Logger;
public class MainnetTransactionProcessor implements TransactionProcessor {
private static final Logger LOGGER = LogManager.getLogger(MainnetTransactionProcessor.class);
private static final Logger LOG = LogManager.getLogger();
private final GasCalculator gasCalculator;
@ -130,7 +130,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
final Transaction transaction,
final Address miningBenficiary,
final OperationTracer operationTracer) {
LOGGER.trace("Starting execution of {}", transaction);
LOG.trace("Starting execution of {}", transaction);
ValidationResult<TransactionInvalidReason> validationResult =
transactionValidator.validate(transaction);
@ -138,7 +138,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
// compare against a sender account (because the transaction may not
// be signed correctly to extract the sender).
if (!validationResult.isValid()) {
LOGGER.warn("Invalid transaction: {}", validationResult.getErrorMessage());
LOG.warn("Invalid transaction: {}", validationResult.getErrorMessage());
return Result.invalid(validationResult);
}
@ -147,17 +147,17 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
validationResult =
transactionValidator.validateForSender(transaction, sender, OptionalLong.empty());
if (!validationResult.isValid()) {
LOGGER.warn("Invalid transaction: {}", validationResult.getErrorMessage());
LOG.warn("Invalid transaction: {}", validationResult.getErrorMessage());
return Result.invalid(validationResult);
}
final long previousNonce = sender.incrementNonce();
LOGGER.trace(
LOG.trace(
"Incremented sender {} nonce ({} -> {})", senderAddress, previousNonce, sender.getNonce());
final Wei upfrontGasCost = transaction.getUpfrontGasCost();
final Wei previousBalance = sender.decrementBalance(upfrontGasCost);
LOGGER.trace(
LOG.trace(
"Deducted sender {} upfront gas cost {} ({} -> {})",
senderAddress,
upfrontGasCost,
@ -166,7 +166,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
final Gas intrinsicGas = gasCalculator.transactionIntrinsicGasCost(transaction);
final Gas gasAvailable = Gas.of(transaction.getGasLimit()).minus(intrinsicGas);
LOGGER.trace(
LOG.trace(
"Gas available for execution {} = {} - {} (limit - intrinsic)",
gasAvailable,
transaction.getGasLimit(),
@ -236,8 +236,8 @@ public class MainnetTransactionProcessor implements TransactionProcessor {
worldUpdater.commit();
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(
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()));

@ -11,12 +11,12 @@ import org.apache.logging.log4j.Logger;
* header.
*/
public class AncestryValidationRule implements DetachedBlockHeaderValidationRule {
private final Logger LOGGER = LogManager.getLogger(AncestryValidationRule.class);
private final Logger LOG = LogManager.getLogger(AncestryValidationRule.class);
@Override
public boolean validate(final BlockHeader header, final BlockHeader parent) {
if (!header.getParentHash().equals(parent.getHash())) {
LOGGER.trace(
LOG.trace(
"Invalid parent block header. Parent hash {} does not match "
+ "supplied parent header {}.",
header.getParentHash(),
@ -25,7 +25,7 @@ public class AncestryValidationRule implements DetachedBlockHeaderValidationRule
}
if (header.getNumber() != (parent.getNumber() + 1)) {
LOGGER.trace(
LOG.trace(
"Invalid block header: number {} is not one more than parent number {}",
header.getNumber(),
parent.getNumber());

@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class CalculatedDifficultyValidationRule<C> implements AttachedBlockHeaderValidationRule<C> {
private final Logger LOGGER = LogManager.getLogger(CalculatedDifficultyValidationRule.class);
private final Logger LOG = LogManager.getLogger(CalculatedDifficultyValidationRule.class);
private final DifficultyCalculator<C> difficultyCalculator;
public CalculatedDifficultyValidationRule(final DifficultyCalculator<C> difficultyCalculator) {
@ -27,7 +27,7 @@ public class CalculatedDifficultyValidationRule<C> implements AttachedBlockHeade
difficultyCalculator.nextDifficulty(header.getTimestamp(), parent, context);
if (actualDifficulty.compareTo(expectedDifficulty) != 0) {
LOGGER.trace(
LOG.trace(
"Invalid block header: difficulty {} does not equal expected difficulty {}",
actualDifficulty,
expectedDifficulty);

@ -13,7 +13,7 @@ import org.apache.logging.log4j.Logger;
*/
public class ExtraDataMaxLengthValidationRule implements DetachedBlockHeaderValidationRule {
private final Logger LOGGER = LogManager.getLogger(ExtraDataMaxLengthValidationRule.class);
private final Logger LOG = LogManager.getLogger(ExtraDataMaxLengthValidationRule.class);
private final long maxExtraDataBytes;
public ExtraDataMaxLengthValidationRule(final long maxExtraDataBytes) {
@ -27,7 +27,7 @@ public class ExtraDataMaxLengthValidationRule implements DetachedBlockHeaderVali
private boolean validateExtraData(final BytesValue extraData) {
if (extraData.size() > maxExtraDataBytes) {
LOGGER.trace(
LOG.trace(
"Invalid block header: extra data field length {} is greater {}",
extraData.size(),
maxExtraDataBytes);

@ -15,8 +15,7 @@ import org.apache.logging.log4j.Logger;
*/
public class GasLimitRangeAndDeltaValidationRule implements DetachedBlockHeaderValidationRule {
private static final Logger LOGGER =
LogManager.getLogger(GasLimitRangeAndDeltaValidationRule.class);
private static final Logger LOG = LogManager.getLogger(GasLimitRangeAndDeltaValidationRule.class);
private static final int GASLIMIT_BOUND_DIVISOR = 1024;
private final long minGasLimit;
private final long maxGasLimit;
@ -37,7 +36,7 @@ public class GasLimitRangeAndDeltaValidationRule implements DetachedBlockHeaderV
final long gasLimit = header.getGasLimit();
if ((gasLimit < minGasLimit) || (gasLimit > maxGasLimit)) {
LOGGER.trace(
LOG.trace(
"Header gasLimit = {}, outside range {} --> {}", gasLimit, minGasLimit, maxGasLimit);
return false;
}
@ -46,7 +45,7 @@ public class GasLimitRangeAndDeltaValidationRule implements DetachedBlockHeaderV
final long difference = Math.abs(parentGasLimit - gasLimit);
final long bounds = Long.divideUnsigned(parentGasLimit, GASLIMIT_BOUND_DIVISOR);
if (Long.compareUnsigned(difference, bounds) >= 0) {
LOGGER.trace(
LOG.trace(
"Invalid block header: gas limit delta {} is out of bounds of {}", gasLimit, bounds);
return false;
}

@ -12,12 +12,12 @@ import org.apache.logging.log4j.Logger;
*/
public class GasUsageValidationRule implements DetachedBlockHeaderValidationRule {
private final Logger LOGGER = LogManager.getLogger(GasUsageValidationRule.class);
private final Logger LOG = LogManager.getLogger(GasUsageValidationRule.class);
@Override
public boolean validate(final BlockHeader header, final BlockHeader parent) {
if (header.getGasUsed() > header.getGasLimit()) {
LOGGER.trace(
LOG.trace(
"Invalid block header: gas used {} exceeds gas limit {}",
header.getGasUsed(),
header.getGasLimit());

@ -21,7 +21,7 @@ import org.apache.logging.log4j.Logger;
public final class ProofOfWorkValidationRule implements DetachedBlockHeaderValidationRule {
private static final Logger LOGGER = LogManager.getLogger(ProofOfWorkValidationRule.class);
private static final Logger LOG = LogManager.getLogger(ProofOfWorkValidationRule.class);
private static final int SERIALIZED_HASH_SIZE = 33;
@ -60,7 +60,7 @@ public final class ProofOfWorkValidationRule implements DetachedBlockHeaderValid
HASHER.hash(hashBuffer, header.getNonce(), header.getNumber(), keccak256.digest());
if (header.getDifficulty().isZero()) {
LOGGER.trace("Rejecting header because difficulty is 0");
LOG.trace("Rejecting header because difficulty is 0");
return false;
}
final BigInteger difficulty =
@ -69,7 +69,7 @@ public final class ProofOfWorkValidationRule implements DetachedBlockHeaderValid
final UInt256 result = UInt256.wrap(Bytes32.wrap(hashBuffer, 32));
if (result.compareTo(target) > 0) {
LOGGER.warn(
LOG.warn(
"Invalid block header: the EthHash result {} was greater than the target {}.\n"
+ "Failing header:\n{}",
result,
@ -81,7 +81,7 @@ public final class ProofOfWorkValidationRule implements DetachedBlockHeaderValid
final Hash mixedHash =
Hash.wrap(Bytes32.leftPad(BytesValue.wrap(hashBuffer).slice(0, Bytes32.SIZE)));
if (!header.getMixHash().equals(mixedHash)) {
LOGGER.warn(
LOG.warn(
"Invalid block header: header mixed hash {} does not equal calculated mixed hash {}.\n"
+ "Failing header:\n{}",
header.getMixHash(),

@ -16,7 +16,7 @@ import org.apache.logging.log4j.Logger;
*/
public class TimestampValidationRule implements DetachedBlockHeaderValidationRule {
private final Logger LOGGER = LogManager.getLogger(TimestampValidationRule.class);
private final Logger LOG = LogManager.getLogger(TimestampValidationRule.class);
private final long acceptableClockDriftSeconds;
private final long minimumSecondsSinceParent;
@ -42,7 +42,7 @@ public class TimestampValidationRule implements DetachedBlockHeaderValidationRul
private boolean validateHeaderSufficientlyAheadOfParent(
final long timestamp, final long parentTimestamp) {
if ((timestamp - minimumSecondsSinceParent) < parentTimestamp) {
LOGGER.trace(
LOG.trace(
"Invalid block header: timestamp {} is not sufficiently newer than parent timestamp {}",
timestamp,
parentTimestamp);
@ -57,7 +57,7 @@ public class TimestampValidationRule implements DetachedBlockHeaderValidationRul
TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
+ acceptableClockDriftSeconds;
if (Long.compareUnsigned(timestamp, timestampMargin) > 0) {
LOGGER.trace(
LOG.trace(
"Invalid block header: timestamp {} is greater than the timestamp margin {}",
timestamp,
timestampMargin);

@ -45,7 +45,7 @@ import org.apache.logging.log4j.Logger;
public class JsonRpcHttpService {
private static final Logger LOGGER = LogManager.getLogger(JsonRpcHttpService.class);
private static final Logger LOG = LogManager.getLogger();
private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0);
private static final String APPLICATION_JSON = "application/json";
@ -76,7 +76,7 @@ public class JsonRpcHttpService {
}
public CompletableFuture<?> start() {
LOGGER.info("Starting JsonRPC service on {}:{}", config.getHost(), config.getPort());
LOG.info("Starting JsonRPC service on {}:{}", config.getHost(), config.getPort());
// Create the HTTP server and a router object.
httpServer =
vertx.createHttpServer(
@ -105,7 +105,7 @@ public class JsonRpcHttpService {
res -> {
if (!res.failed()) {
resultFuture.complete(null);
LOGGER.info(
LOG.info(
"JsonRPC service started and listening on {}:{}",
config.getHost(),
httpServer.actualPort());
@ -298,7 +298,7 @@ public class JsonRpcHttpService {
return NO_RESPONSE;
}
LOGGER.info("JSON-RPC request -> {}", request.getMethod());
LOG.info("JSON-RPC request -> {}", request.getMethod());
// Find method handler
final JsonRpcMethod method = jsonRpcMethods.get(request.getMethod());
if (method == null) {
@ -309,7 +309,7 @@ public class JsonRpcHttpService {
try {
return method.response(request);
} catch (final InvalidJsonRpcParameters e) {
LOGGER.debug(e);
LOG.debug(e);
return errorResponse(id, JsonRpcError.INVALID_PARAMS);
}
}

@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger;
public class EthSendRawTransaction implements JsonRpcMethod {
private static final Logger LOGGER = LogManager.getLogger(EthSendRawTransaction.class);
private static final Logger LOG = LogManager.getLogger();
private final TransactionPool transactionPool;
private final JsonRpcParameter parameters;
@ -66,7 +66,7 @@ public class EthSendRawTransaction implements JsonRpcMethod {
try {
return Transaction.readFrom(RLP.input(BytesValue.fromHexString(hash)));
} catch (IllegalArgumentException | RLPException e) {
LOGGER.debug(e);
LOG.debug(e);
throw new InvalidJsonRpcRequestException("Invalid raw transaction hex", e);
}
}

@ -15,7 +15,7 @@ import org.apache.logging.log4j.Logger;
public class WebSocketRequestHandler {
private static final Logger LOGGER = LogManager.getLogger(WebSocketRequestHandler.class);
private static final Logger LOG = LogManager.getLogger();
private final Vertx vertx;
private final Map<String, JsonRpcMethod> methods;
@ -32,23 +32,23 @@ public class WebSocketRequestHandler {
try {
request = buffer.toJsonObject().mapTo(WebSocketRpcRequest.class);
} catch (IllegalArgumentException | DecodeException e) {
LOGGER.debug("Error mapping json to WebSocketRpcRequest", e);
LOG.debug("Error mapping json to WebSocketRpcRequest", e);
future.complete(JsonRpcError.INVALID_REQUEST);
return;
}
if (!methods.containsKey(request.getMethod())) {
future.complete(JsonRpcError.METHOD_NOT_FOUND);
LOGGER.debug("Can't find method {}", request.getMethod());
LOG.debug("Can't find method {}", request.getMethod());
return;
}
final JsonRpcMethod method = methods.get(request.getMethod());
try {
LOGGER.info("WS-RPC request -> {}", request.getMethod());
LOG.info("WS-RPC request -> {}", request.getMethod());
request.setConnectionId(id);
future.complete(method.response(request));
} catch (final Exception e) {
LOGGER.error(JsonRpcError.INTERNAL_ERROR.getMessage(), e);
LOG.error(JsonRpcError.INTERNAL_ERROR.getMessage(), e);
future.complete(JsonRpcError.INTERNAL_ERROR);
}
},

@ -17,7 +17,7 @@ import org.apache.logging.log4j.Logger;
public class WebSocketService {
private static final Logger LOGGER = LogManager.getLogger(WebSocketService.class);
private static final Logger LOG = LogManager.getLogger();
private static final InetSocketAddress EMPTY_SOCKET_ADDRESS = new InetSocketAddress("0.0.0.0", 0);
@ -37,7 +37,7 @@ public class WebSocketService {
}
public CompletableFuture<?> start() {
LOGGER.info(
LOG.info(
"Starting Websocket service on {}:{}", configuration.getHost(), configuration.getPort());
final CompletableFuture<?> resultFuture = new CompletableFuture<>();
@ -60,11 +60,11 @@ public class WebSocketService {
final SocketAddress socketAddress = websocket.remoteAddress();
final String connectionId = websocket.textHandlerID();
LOGGER.debug("Websocket Connected ({})", socketAddressAsString(socketAddress));
LOG.debug("Websocket Connected ({})", socketAddressAsString(socketAddress));
websocket.handler(
buffer -> {
LOGGER.debug(
LOG.debug(
"Received Websocket request {} ({})",
buffer.toString(),
socketAddressAsString(socketAddress));
@ -74,7 +74,7 @@ public class WebSocketService {
websocket.closeHandler(
v -> {
LOGGER.debug("Websocket Disconnected ({})", socketAddressAsString(socketAddress));
LOG.debug("Websocket Disconnected ({})", socketAddressAsString(socketAddress));
vertx
.eventBus()
.publish(SubscriptionManager.EVENTBUS_REMOVE_SUBSCRIPTIONS_ADDRESS, connectionId);
@ -82,7 +82,7 @@ public class WebSocketService {
websocket.exceptionHandler(
t -> {
LOGGER.debug(
LOG.debug(
"Unrecoverable error on Websocket: {} ({})",
t.getMessage(),
socketAddressAsString(socketAddress));
@ -95,7 +95,7 @@ public class WebSocketService {
return res -> {
if (res.succeeded()) {
LOGGER.info(
LOG.info(
"Websocket service started and listening on {}:{}",
configuration.getHost(),
httpServer.actualPort());

@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger;
*/
public class SubscriptionManager extends AbstractVerticle {
private static final Logger LOGGER = LogManager.getLogger(SubscriptionManager.class);
private static final Logger LOG = LogManager.getLogger();
public static final String EVENTBUS_REMOVE_SUBSCRIPTIONS_ADDRESS =
"SubscriptionManager::removeSubscriptions";
@ -47,7 +47,7 @@ public class SubscriptionManager extends AbstractVerticle {
}
public Long subscribe(final SubscribeRequest request) {
LOGGER.info("Subscribe request {}", request);
LOG.info("Subscribe request {}", request);
final long subscriptionId = subscriptionCounter.incrementAndGet();
final Subscription subscription = subscriptionBuilder.build(subscriptionId, request);
@ -70,7 +70,7 @@ public class SubscriptionManager extends AbstractVerticle {
}
public boolean unsubscribe(final UnsubscribeRequest request) {
LOGGER.debug("Unsubscribe request subscriptionId = {}", request.getSubscriptionId());
LOG.debug("Unsubscribe request subscriptionId = {}", request.getSubscriptionId());
if (!subscriptions.containsKey(request.getSubscriptionId())) {
throw new SubscriptionNotFoundException(request.getSubscriptionId());
@ -102,10 +102,10 @@ public class SubscriptionManager extends AbstractVerticle {
void removeSubscriptions(final Message<String> message) {
final String connectionId = message.body();
if (connectionId == null || "".equals(connectionId)) {
LOGGER.warn("Received invalid connectionId ({}). No subscriptions removed.");
LOG.warn("Received invalid connectionId ({}). No subscriptions removed.");
}
LOGGER.debug("Removing subscription for connectionId = {}", connectionId);
LOG.debug("Removing subscription for connectionId = {}", connectionId);
final List<Long> subscriptionIds =
Lists.newArrayList(

@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class NetworkRunner implements AutoCloseable {
private static final Logger LOGGER = LogManager.getLogger(NetworkRunner.class);
private static final Logger LOG = LogManager.getLogger();
private final CountDownLatch shutdown = new CountDownLatch(1);;
private final AtomicBoolean started = new AtomicBoolean(false);
@ -59,17 +59,17 @@ public class NetworkRunner implements AutoCloseable {
public void start() {
if (started.compareAndSet(false, true)) {
LOGGER.info("Starting Network.");
LOG.info("Starting Network.");
setupHandlers();
networkExecutor.submit(network);
} else {
LOGGER.error("Attempted to start already running network.");
LOG.error("Attempted to start already running network.");
}
}
public void stop() {
if (stopped.compareAndSet(false, true)) {
LOGGER.info("Stopping Network.");
LOG.info("Stopping Network.");
network.stop();
for (final ProtocolManager protocolManager : protocolManagers) {
protocolManager.stop();
@ -77,7 +77,7 @@ public class NetworkRunner implements AutoCloseable {
networkExecutor.shutdown();
shutdown.countDown();
} else {
LOGGER.error("Attempted to stop already stopped network.");
LOG.error("Attempted to stop already stopped network.");
}
}
@ -88,11 +88,11 @@ public class NetworkRunner implements AutoCloseable {
protocolManager.awaitStop();
}
if (!networkExecutor.awaitTermination(2L, TimeUnit.MINUTES)) {
LOGGER.error("Network executor did not shutdown cleanly.");
LOG.error("Network executor did not shutdown cleanly.");
networkExecutor.shutdownNow();
networkExecutor.awaitTermination(2L, TimeUnit.MINUTES);
}
LOGGER.info("Network stopped.");
LOG.info("Network stopped.");
}
private void setupHandlers() {
@ -108,7 +108,7 @@ public class NetworkRunner implements AutoCloseable {
final int code = message.getData().getCode();
if (!protocol.isValidMessageCode(cap.getVersion(), code)) {
// Handle invalid messsages by disconnecting
LOGGER.info(
LOG.info(
"Invalid message code ({}-{}, {}) received from peer, disconnecting from:",
cap.getName(),
cap.getVersion(),

@ -78,7 +78,7 @@ import org.apache.logging.log4j.Logger;
* </ol>
*/
public class PeerDiscoveryAgent implements DisconnectCallback {
private static final Logger LOG = LogManager.getLogger(PeerDiscoveryAgent.class);
private static final Logger LOG = LogManager.getLogger();
// The devp2p specification says only accept packets up to 1280, but some
// clients ignore that, so we add in a little extra padding.

@ -79,7 +79,7 @@ import org.apache.logging.log4j.Logger;
*/
public class PeerDiscoveryController {
private static final Logger LOG = LogManager.getLogger(PeerDiscoveryController.class);
private static final Logger LOG = LogManager.getLogger();
private static final long REFRESH_CHECK_INTERVAL_MILLIS = MILLISECONDS.convert(30, SECONDS);
private final Vertx vertx;
private final PeerTable peerTable;

@ -18,7 +18,7 @@ import org.apache.logging.log4j.Logger;
final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
private static final Logger LOGGER = LogManager.getLogger(ApiHandler.class);
private static final Logger LOG = LogManager.getLogger();
private final CapabilityMultiplexer multiplexer;
private final AtomicBoolean waitingForPong;
@ -49,7 +49,7 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
if (demultiplexed.getCapability() == null) {
switch (message.getCode()) {
case WireMessageCodes.PING:
LOGGER.debug("Received Wire PING");
LOG.debug("Received Wire PING");
try {
connection.send(null, PongMessage.get());
} catch (final PeerNotConnected peerNotConnected) {
@ -57,7 +57,7 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
}
break;
case WireMessageCodes.PONG:
LOGGER.debug("Received Wire PONG");
LOG.debug("Received Wire PONG");
waitingForPong.set(false);
break;
case WireMessageCodes.DISCONNECT:
@ -65,18 +65,18 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
DisconnectReason reason = null;
try {
reason = disconnect.getReason();
LOGGER.info(
LOG.info(
"Received Wire DISCONNECT ({}) from peer: {}",
reason.name(),
connection.getPeer().getClientId());
} catch (final RLPException e) {
// It seems pretty common to get disconnect messages with no reason, which results in an
// rlp parsing error
LOGGER.warn(
LOG.warn(
"Received Wire DISCONNECT, but unable to parse reason. Peer: {}",
connection.getPeer().getClientId());
} catch (final Exception e) {
LOGGER.error(
LOG.error(
"Received Wire DISCONNECT, but unable to parse reason. Peer: {}",
connection.getPeer().getClientId(),
e);
@ -91,7 +91,7 @@ final class ApiHandler extends SimpleChannelInboundHandler<MessageData> {
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable) {
LOGGER.error("Error:", throwable);
LOG.error("Error:", throwable);
callbacks.invokeDisconnect(connection, DisconnectReason.TCP_SUBSYSTEM_ERROR, false);
ctx.close();
}

@ -16,7 +16,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Callbacks {
private static final Logger LOGGER = LogManager.getLogger(Callbacks.class);
private static final Logger LOG = LogManager.getLogger();
private static final Subscribers<Consumer<Message>> NO_SUBSCRIBERS = new Subscribers<>();
private final Map<Capability, Subscribers<Consumer<Message>>> callbacks;
@ -48,7 +48,7 @@ public class Callbacks {
try {
consumer.accept(fullMessage);
} catch (final Throwable t) {
LOGGER.error("Error in callback:", t);
LOG.error("Error in callback:", t);
}
});
}

@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger;
final class DeFramer extends ByteToMessageDecoder {
private static final Logger LOG = LogManager.getLogger(DeFramer.class);
private static final Logger LOG = LogManager.getLogger();
private final CompletableFuture<PeerConnection> connectFuture;

@ -18,7 +18,7 @@ import org.apache.logging.log4j.Logger;
public final class HandshakeHandlerOutbound extends AbstractHandshakeHandler {
private static final Logger LOGGER = LogManager.getLogger(HandshakeHandlerOutbound.class);
private static final Logger LOG = LogManager.getLogger();
private final ByteBuf first;
@ -53,7 +53,7 @@ public final class HandshakeHandlerOutbound extends AbstractHandshakeHandler {
.addListener(
f -> {
if (f.isSuccess()) {
LOGGER.debug(
LOG.debug(
"Wrote initial crypto handshake message to {}.", ctx.channel().remoteAddress());
}
});

@ -87,7 +87,7 @@ import org.apache.logging.log4j.Logger;
*/
public final class NettyP2PNetwork implements P2PNetwork {
private static final Logger LOGGER = LogManager.getLogger(NettyP2PNetwork.class);
private static final Logger LOG = LogManager.getLogger();
private static final int TIMEOUT_SECONDS = 30;
final Map<Capability, Subscribers<Consumer<Message>>> protocolCallbacks =
@ -173,7 +173,7 @@ public final class NettyP2PNetwork implements P2PNetwork {
supportedCapabilities,
socketAddress.getPort(),
this.keyPair.getPublicKey().getEncodedBytes());
LOGGER.info("P2PNetwork started and listening on {}", socketAddress);
LOG.info("P2PNetwork started and listening on {}", socketAddress);
latch.countDown();
});
@ -209,7 +209,7 @@ public final class NettyP2PNetwork implements P2PNetwork {
connection -> {
// Reject incoming connections if we've reached our limit
if (connections.size() >= maxPeers) {
LOGGER.info(
LOG.info(
"Disconnecting incoming connection because connection limit of {} has been reached: {}",
maxPeers,
connection.getPeer().getNodeId());
@ -223,7 +223,7 @@ public final class NettyP2PNetwork implements P2PNetwork {
}
onConnectionEstablished(connection);
LOGGER.info(
LOG.info(
"Successfully accepted connection from {}", connection.getPeer().getNodeId());
logConnections();
});
@ -242,7 +242,7 @@ public final class NettyP2PNetwork implements P2PNetwork {
@Override
public CompletableFuture<PeerConnection> connect(final Peer peer) {
LOGGER.trace("Initiating connection to peer: {}", peer.getId());
LOG.trace("Initiating connection to peer: {}", peer.getId());
final CompletableFuture<PeerConnection> connectionFuture = new CompletableFuture<>();
final Endpoint endpoint = peer.getEndpoint();
pendingConnections.incrementAndGet();
@ -290,9 +290,9 @@ public final class NettyP2PNetwork implements P2PNetwork {
pendingConnections.decrementAndGet();
if (t == null) {
onConnectionEstablished(connection);
LOGGER.info("Connection established to peer: {}", peer.getId());
LOG.info("Connection established to peer: {}", peer.getId());
} else {
LOGGER.warn("Failed to connect to peer {}: {}", peer.getId(), t);
LOG.warn("Failed to connect to peer {}: {}", peer.getId(), t);
}
logConnections();
});
@ -300,7 +300,7 @@ public final class NettyP2PNetwork implements P2PNetwork {
}
private void logConnections() {
LOGGER.info(
LOG.info(
"Connections: {} pending, {} active connections.",
pendingConnections.get(),
connections.size());

@ -27,7 +27,7 @@ import org.apache.logging.log4j.Logger;
final class NettyPeerConnection implements PeerConnection {
private static final Logger LOGGER = LogManager.getLogger(NettyPeerConnection.class);
private static final Logger LOG = LogManager.getLogger();
private final ChannelHandlerContext ctx;
private final PeerInfo peerInfo;
@ -74,7 +74,7 @@ final class NettyPeerConnection implements PeerConnection {
}
}
LOGGER.debug("Writing {} to {} via protocol {}", message, peerInfo, capability);
LOG.debug("Writing {} to {} via protocol {}", message, peerInfo, capability);
ctx.channel().writeAndFlush(new OutboundMessage(capability, message));
}
@ -96,7 +96,7 @@ final class NettyPeerConnection implements PeerConnection {
@Override
public void terminateConnection(final DisconnectReason reason, final boolean peerInitiated) {
if (disconnectDispatched.compareAndSet(false, true)) {
LOGGER.info("Disconnected ({}) from {}", reason, peerInfo);
LOG.info("Disconnected ({}) from {}", reason, peerInfo);
callbacks.invokeDisconnect(this, reason, peerInitiated);
disconnected.set(true);
}
@ -108,7 +108,7 @@ final class NettyPeerConnection implements PeerConnection {
@Override
public void disconnect(final DisconnectReason reason) {
if (disconnectDispatched.compareAndSet(false, true)) {
LOGGER.info("Disconnecting ({}) from {}", reason, peerInfo);
LOG.info("Disconnecting ({}) from {}", reason, peerInfo);
callbacks.invokeDisconnect(this, reason, false);
try {
send(null, DisconnectMessage.create(reason));

@ -15,7 +15,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
final class WireKeepAlive extends ChannelDuplexHandler {
private static final Logger LOGGER = LogManager.getLogger(WireKeepAlive.class);
private static final Logger LOG = LogManager.getLogger();
private final AtomicBoolean waitingForPong;
@ -37,12 +37,12 @@ final class WireKeepAlive extends ChannelDuplexHandler {
if (waitingForPong.get()) {
// We are still waiting for a response from our last pong, disconnect with timeout error
LOGGER.info("Wire PONG never received, disconnecting from peer.");
LOG.info("Wire PONG never received, disconnecting from peer.");
connection.disconnect(DisconnectReason.TIMEOUT);
return;
}
LOGGER.debug("Idle connection detected, sending Wire PING to peer.");
LOG.debug("Idle connection detected, sending Wire PING to peer.");
connection.send(null, PingMessage.get());
waitingForPong.set(true);
}

@ -20,7 +20,7 @@ import org.apache.logging.log4j.Logger;
* format</a>
*/
public class Capability {
private static final Logger LOGGER = LogManager.getLogger(Capability.class);
private static final Logger LOG = LogManager.getLogger();
private final String name;
private final int version;
@ -28,7 +28,7 @@ public class Capability {
// Quorum reports IBFT as "istanbul", breaking wire protocol conventions.
// As such, this check cannot prevent connection.
if (name.length() != 3) {
LOGGER.warn("Capability name '{}' is too long", name);
LOG.warn("Capability name '{}' is too long", name);
}
this.name = name;
this.version = version;

@ -22,7 +22,7 @@ public class Runner implements AutoCloseable {
static final String KEY_PATH = "key";
private static final Logger LOGGER = LogManager.getLogger(Runner.class);
private static final Logger LOG = LogManager.getLogger();
private final Vertx vertx;
@ -53,19 +53,19 @@ public class Runner implements AutoCloseable {
public void execute() {
try {
LOGGER.info("Starting Ethereum main loop ... ");
LOG.info("Starting Ethereum main loop ... ");
networkRunner.start();
pantheonController.getSynchronizer().start();
jsonRpc.ifPresent(service -> service.start().join());
websocketRpc.ifPresent(service -> service.start().join());
LOGGER.info("Ethereum main loop is up.");
LOG.info("Ethereum main loop is up.");
writePantheonPortsToFile();
networkRunner.awaitStop();
} catch (final InterruptedException e) {
LOGGER.debug("Interrupted, exiting", e);
LOG.debug("Interrupted, exiting", e);
Thread.currentThread().interrupt();
} catch (final Exception ex) {
LOGGER.error("Exception in main loop:", ex);
LOG.error("Exception in main loop:", ex);
throw new IllegalStateException(ex);
}
}
@ -111,7 +111,7 @@ public class Runner implements AutoCloseable {
fileOutputStream,
"This file contains the ports used by the running instance of Pantheon. This file will be deleted after the node is shutdown.");
} catch (final Exception e) {
LOGGER.warn("Error writing ports file", e);
LOG.warn("Error writing ports file", e);
}
}

@ -27,7 +27,7 @@ import picocli.CommandLine.ParentCommand;
)
class ExportPublicKeySubCommand implements Runnable {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
@Parameters(arity = "1..1", paramLabel = "PATH", description = "File to write public key to")
private final File publicKeyExportFile = null;
@ -49,7 +49,7 @@ class ExportPublicKeySubCommand implements Runnable {
try (BufferedWriter fileWriter = Files.newBufferedWriter(path, UTF_8)) {
fileWriter.write(keyPair.getPublicKey().toString());
} catch (final IOException e) {
LOGGER.error("An error occurred while trying to write the public key", e);
LOG.error("An error occurred while trying to write the public key", e);
}
}
}

@ -23,7 +23,7 @@ import picocli.CommandLine.ParentCommand;
)
class ImportBlockchainSubCommand implements Runnable {
private static final Logger LOGGER = LogManager.getLogger(ImportBlockchainSubCommand.class);
private static final Logger LOG = LogManager.getLogger();
@ParentCommand
private PantheonCommand parentCommand; // Picocli injects reference to parent command
@ -76,7 +76,7 @@ class ImportBlockchainSubCommand implements Runnable {
@Override
public void run() {
LOGGER.info("Runs import sub command with blocksImportPath : {}", blocksImportPath);
LOG.info("Runs import sub command with blocksImportPath : {}", blocksImportPath);
checkNotNull(parentCommand);

@ -22,7 +22,7 @@ import picocli.CommandLine.ParentCommand;
mixinStandardHelpOptions = true
)
class ImportSubCommand implements Runnable {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
@ParentCommand
private PantheonCommand parentCommand; // Picocli injects reference to parent command
@ -38,7 +38,7 @@ class ImportSubCommand implements Runnable {
@Override
public void run() {
LOGGER.info("Runs import sub command with blocksImportPath : {}", blocksImportPath);
LOG.info("Runs import sub command with blocksImportPath : {}", blocksImportPath);
checkNotNull(parentCommand);
checkNotNull(blockImporter);

@ -61,7 +61,7 @@ import picocli.CommandLine.ParameterException;
footer = "Pantheon is licensed under the Apache License 2.0"
)
public class PantheonCommand implements Runnable {
private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOG = LogManager.getLogger();
private static final int DEFAULT_MAX_PEERS = 25;

@ -1,29 +1,27 @@
package net.consensys.pantheon.controller;
import static org.apache.logging.log4j.LogManager.getLogger;
import net.consensys.pantheon.crypto.SECP256K1;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class KeyPairUtil {
private static final Logger LOGGER = getLogger();
private static final Logger LOG = LogManager.getLogger();
public static SECP256K1.KeyPair loadKeyPair(final Path home) throws IOException {
final File keyFile = home.resolve("key").toFile();
final SECP256K1.KeyPair key;
if (keyFile.exists()) {
key = SECP256K1.KeyPair.load(keyFile);
LOGGER.info(
"Loaded key {} from {}", key.getPublicKey().toString(), keyFile.getAbsolutePath());
LOG.info("Loaded key {} from {}", key.getPublicKey().toString(), keyFile.getAbsolutePath());
} else {
key = SECP256K1.KeyPair.generate();
key.getPrivateKey().store(keyFile);
LOGGER.info(
LOG.info(
"Generated new key key {} and stored it to {}",
key.getPublicKey().toString(),
keyFile.getAbsolutePath());

@ -37,7 +37,7 @@ import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
public abstract class CommandTestAbstract {
private final Logger LOGGER = LogManager.getLogger();
private final Logger LOG = LogManager.getLogger();
final ByteArrayOutputStream commandOutput = new ByteArrayOutputStream();
private final PrintStream outPrintStream = new PrintStream(commandOutput);
@ -74,8 +74,8 @@ public abstract class CommandTestAbstract {
// Display outputs for debug purpose
@After
public void displayOutput() {
LOGGER.info("Standard output {}", commandOutput.toString());
LOGGER.info("Standard error {}", commandErrorOutput.toString());
LOG.info("Standard output {}", commandOutput.toString());
LOG.info("Standard error {}", commandErrorOutput.toString());
}
void parseCommand(final String... args) {

@ -25,7 +25,7 @@ import org.rocksdb.WriteOptions;
public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
private static final Logger logger = LogManager.getLogger(RocksDbKeyValueStorage.class);
private static final Logger LOG = LogManager.getLogger();
private final Options options;
private final TransactionDBOptions txOptions;
@ -106,7 +106,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
private void throwIfClosed() {
if (closed.get()) {
logger.error("Attempting to use a closed RocksDbKeyValueStorage");
LOG.error("Attempting to use a closed RocksDbKeyValueStorage");
throw new IllegalStateException("Storage has been closed");
}
}
@ -140,7 +140,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
try {
rocksIt.status();
} catch (final RocksDBException e) {
logger.error("RocksDbEntryIterator encountered a problem while iterating.", e);
LOG.error("RocksDbEntryIterator encountered a problem while iterating.", e);
}
if (!hasNext()) {
throw new NoSuchElementException();

Loading…
Cancel
Save