diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad6541f481..c4997b7ff96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ # Changelog ## [Unreleased] -- Added isLabelsObserved to LabelledGauge in plugin-api. Default implementation returns false. ### Breaking Changes - Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783) @@ -12,6 +11,7 @@ besu_blockchain_difficulty_total if you use these metrics you have to update your custom solution, to support the new name. ### Upcoming Breaking Changes +- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge` ### Additions and Improvements - Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755) @@ -21,6 +21,7 @@ if you use these metrics you have to update your custom solution, to support the - Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813) - Add a method to check if a metric category is enabled to the plugin API [#7832](https://github.com/hyperledger/besu/pull/7832) - Add account and state overrides to `eth_call` and `eth_estimateGas` [#7801](https://github.com/hyperledger/besu/pull/7801) +- Add a new metric collector for counters which get their value from suppliers [#7894](https://github.com/hyperledger/besu/pull/7894) - Prometheus Java Metrics library upgraded to version 1.3.3 [#7880](https://github.com/hyperledger/besu/pull/7880) ### Bug fixes 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 edb55a11265..ccd4363412d 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java @@ -14,12 +14,11 @@ */ package org.hyperledger.besu.controller; -import static org.hyperledger.besu.consensus.clique.CliqueHelpers.installCliqueBlockChoiceRule; - import org.hyperledger.besu.config.CliqueConfigOptions; import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueContext; import org.hyperledger.besu.consensus.clique.CliqueForksSchedulesFactory; +import org.hyperledger.besu.consensus.clique.CliqueHelpers; import org.hyperledger.besu.consensus.clique.CliqueMiningTracker; import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule; import org.hyperledger.besu.consensus.clique.blockcreation.CliqueBlockScheduler; @@ -167,7 +166,8 @@ protected CliqueContext createConsensusContext( blockchain, epochManager, blockInterface), epochManager, blockInterface); - installCliqueBlockChoiceRule(blockchain, cliqueContext); + CliqueHelpers.setCliqueContext(cliqueContext); + CliqueHelpers.installCliqueBlockChoiceRule(blockchain, cliqueContext); return cliqueContext; } diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java index a5771238d2a..b0869feb23c 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.consensus.clique; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.mainnet.DifficultyCalculator; @@ -39,12 +38,9 @@ public CliqueDifficultyCalculator(final Address localAddress) { } @Override - public BigInteger nextDifficulty( - final long time, final BlockHeader parent, final ProtocolContext context) { + public BigInteger nextDifficulty(final long time, final BlockHeader parent) { - final Address nextProposer = - CliqueHelpers.getProposerForBlockAfter( - parent, context.getConsensusContext(CliqueContext.class).getValidatorProvider()); + final Address nextProposer = CliqueHelpers.getProposerForBlockAfter(parent); return nextProposer.equals(localAddress) ? IN_TURN_DIFFICULTY : OUT_OF_TURN_DIFFICULTY; } } diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java index cba98a5a5eb..d64fe899a66 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java @@ -27,9 +27,20 @@ /** The Clique helpers. */ public class CliqueHelpers { + private static CliqueContext cliqueContext; + /** Default constructor. */ CliqueHelpers() {} + /** + * Set the clique consensus context + * + * @param cliqueContext the clique consensus context + */ + public static void setCliqueContext(final CliqueContext cliqueContext) { + CliqueHelpers.cliqueContext = cliqueContext; + } + /** * Gets proposer of block. * @@ -45,12 +56,11 @@ public static Address getProposerOfBlock(final BlockHeader header) { * Gets proposer for block after. * * @param parent the parent - * @param validatorProvider the validator provider * @return the proposer for block after */ - static Address getProposerForBlockAfter( - final BlockHeader parent, final ValidatorProvider validatorProvider) { - final CliqueProposerSelector proposerSelector = new CliqueProposerSelector(validatorProvider); + static Address getProposerForBlockAfter(final BlockHeader parent) { + final CliqueProposerSelector proposerSelector = + new CliqueProposerSelector(cliqueContext.getValidatorProvider()); return proposerSelector.selectProposerForNextBlock(parent); } diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java index d6362122835..8f350609dc8 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java @@ -42,10 +42,7 @@ public CliqueMiningTracker(final Address localAddress, final ProtocolContext pro * @return the boolean */ public boolean isProposerAfter(final BlockHeader header) { - final Address nextProposer = - CliqueHelpers.getProposerForBlockAfter( - header, - protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider()); + final Address nextProposer = CliqueHelpers.getProposerForBlockAfter(header); return localAddress.equals(nextProposer); } diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java index 2ceedb71893..a60fcc58125 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java @@ -44,8 +44,6 @@ import java.util.Optional; import java.util.function.Function; -import com.google.common.annotations.VisibleForTesting; - /** Defines the protocol behaviours for a blockchain using Clique. */ public class CliqueProtocolSchedule { @@ -63,7 +61,7 @@ public class CliqueProtocolSchedule { * @param privacyParameters the privacy parameters * @param isRevertReasonEnabled the is revert reason enabled * @param evmConfiguration the evm configuration - * @param miningConfiguration the mining parameters + * @param miningConfiguration the mining configuration * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -122,45 +120,6 @@ public static ProtocolSchedule create( .createProtocolSchedule(); } - /** - * Create protocol schedule. - * - * @param config the config - * @param forksSchedule the transitions - * @param nodeKey the node key - * @param isRevertReasonEnabled the is revert reason enabled - * @param evmConfiguration the evm configuration - * @param miningConfiguration the mining parameters - * @param badBlockManager the cache to use to keep invalid blocks - * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled - * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying - * calls - * @return the protocol schedule - */ - @VisibleForTesting - public static ProtocolSchedule create( - final GenesisConfigOptions config, - final ForksSchedule forksSchedule, - final NodeKey nodeKey, - final boolean isRevertReasonEnabled, - final EvmConfiguration evmConfiguration, - final MiningConfiguration miningConfiguration, - final BadBlockManager badBlockManager, - final boolean isParallelTxProcessingEnabled, - final MetricsSystem metricsSystem) { - return create( - config, - forksSchedule, - nodeKey, - PrivacyParameters.DEFAULT, - isRevertReasonEnabled, - evmConfiguration, - miningConfiguration, - badBlockManager, - isParallelTxProcessingEnabled, - metricsSystem); - } - private static ProtocolSpecBuilder applyCliqueSpecificModifications( final EpochManager epochManager, final long secondsBetweenBlocks, 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 a14b5187ef7..87c83b2cb08 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 @@ -38,10 +38,9 @@ public CliqueDifficultyValidationRule() {} public boolean validate( final BlockHeader header, final BlockHeader parent, final ProtocolContext protocolContext) { final Address actualBlockCreator = CliqueHelpers.getProposerOfBlock(header); - final CliqueDifficultyCalculator diffCalculator = new CliqueDifficultyCalculator(actualBlockCreator); - final BigInteger expectedDifficulty = diffCalculator.nextDifficulty(0, parent, protocolContext); + final BigInteger expectedDifficulty = diffCalculator.nextDifficulty(0, parent); final BigInteger actualDifficulty = header.getDifficulty().toBigInteger(); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java index 3c9da2520d9..74537b2ad1a 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java @@ -23,8 +23,6 @@ import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; @@ -43,9 +41,7 @@ public class CliqueDifficultyCalculatorTest { private Address localAddr; private final List
validatorList = Lists.newArrayList(); - private ProtocolContext cliqueProtocolContext; private BlockHeaderTestFixture blockHeaderBuilder; - private final CliqueBlockInterface blockInterface = new CliqueBlockInterface(); @BeforeEach public void setup() { @@ -56,9 +52,7 @@ public void setup() { final ValidatorProvider validatorProvider = mock(ValidatorProvider.class); when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList); - - final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface); - cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager()); + CliqueHelpers.setCliqueContext(new CliqueContext(validatorProvider, null, null)); blockHeaderBuilder = new BlockHeaderTestFixture(); } @@ -68,8 +62,7 @@ public void inTurnValidatorProducesDifficultyOfTwo() { final BlockHeader parentHeader = blockHeaderBuilder.number(1).buildHeader(); - assertThat(calculator.nextDifficulty(0, parentHeader, cliqueProtocolContext)) - .isEqualTo(BigInteger.valueOf(2)); + assertThat(calculator.nextDifficulty(0, parentHeader)).isEqualTo(BigInteger.valueOf(2)); } @Test @@ -78,7 +71,6 @@ public void outTurnValidatorProducesDifficultyOfOne() { final BlockHeader parentHeader = blockHeaderBuilder.number(2).buildHeader(); - assertThat(calculator.nextDifficulty(0, parentHeader, cliqueProtocolContext)) - .isEqualTo(BigInteger.valueOf(1)); + assertThat(calculator.nextDifficulty(0, parentHeader)).isEqualTo(BigInteger.valueOf(1)); } } diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java index 083604af6f0..47741206229 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MiningConfiguration; +import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -66,6 +67,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() { config, new ForksSchedule<>(List.of()), NODE_KEY, + PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, @@ -92,6 +94,7 @@ public void parametersAlignWithMainnetWithAdjustments() { GenesisConfigFile.DEFAULT.getConfigOptions(), forksSchedule, NODE_KEY, + PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, @@ -118,6 +121,7 @@ public void zeroEpochLengthThrowsException() { genesisConfig, new ForksSchedule<>(List.of()), NODE_KEY, + PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, @@ -140,6 +144,7 @@ public void negativeEpochLengthThrowsException() { genesisConfig, new ForksSchedule<>(List.of()), NODE_KEY, + PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, @@ -166,6 +171,7 @@ public void shouldValidateBaseFeeMarketTransition() { config, forksSchedule, NODE_KEY, + PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java index 12467cda4ee..0ece2823327 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java @@ -122,6 +122,7 @@ void setup() { new NoOpMetricsSystem()); final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface); + CliqueHelpers.setCliqueContext(cliqueContext); final Block genesis = GenesisState.fromConfig(GenesisConfigFile.mainnet(), protocolSchedule).getBlock(); @@ -149,7 +150,7 @@ public void proposerAddressCanBeExtractFromAConstructedBlock() { final Address coinbase = AddressHelpers.ofValue(1); - final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( @@ -178,7 +179,7 @@ public void insertsValidVoteIntoConstructedBlock() { when(voteProvider.getVoteAfterBlock(any(), any())) .thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1))); - final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( @@ -212,7 +213,7 @@ public void insertsNoVoteWhenAtEpoch() { when(mockVoteProvider.getVoteAfterBlock(any(), any())) .thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1))); - final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( @@ -255,7 +256,7 @@ private TransactionPool createTransactionPool() { return transactionPool; } - private static MiningConfiguration createMiningParameters( + private static MiningConfiguration createMiningConfiguration( final Bytes extraData, final Address coinbase) { final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.builder() diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java index 7000d145b6b..9c2bf04bce7 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java @@ -26,6 +26,7 @@ import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueContext; import org.hyperledger.besu.consensus.clique.CliqueExtraData; +import org.hyperledger.besu.consensus.clique.CliqueHelpers; import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule; import org.hyperledger.besu.consensus.common.EpochManager; import org.hyperledger.besu.consensus.common.ForksSchedule; @@ -98,6 +99,7 @@ public void setup() { when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList); final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface); + CliqueHelpers.setCliqueContext(cliqueContext); cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager()); cliqueProtocolSchedule = CliqueProtocolSchedule.create( @@ -119,7 +121,7 @@ public void setup() { public void extraDataCreatedOnEpochBlocksContainsValidators() { final Bytes vanityData = generateRandomVanityData(); - final MiningConfiguration miningConfiguration = createMiningParameters(vanityData); + final MiningConfiguration miningConfiguration = createMiningConfiguration(vanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -155,7 +157,7 @@ public void extraDataCreatedOnEpochBlocksContainsValidators() { public void extraDataForNonEpochBlocksDoesNotContainValidaors() { final Bytes vanityData = generateRandomVanityData(); - final MiningConfiguration miningConfiguration = createMiningParameters(vanityData); + final MiningConfiguration miningConfiguration = createMiningConfiguration(vanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -191,7 +193,7 @@ public void shouldUseLatestVanityData() { final Bytes initialVanityData = generateRandomVanityData(); final Bytes modifiedVanityData = generateRandomVanityData(); - final MiningConfiguration miningConfiguration = createMiningParameters(initialVanityData); + final MiningConfiguration miningConfiguration = createMiningConfiguration(initialVanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -255,7 +257,7 @@ private Bytes generateRandomVanityData() { return Bytes.wrap(vanityData); } - private static MiningConfiguration createMiningParameters(final Bytes vanityData) { + private static MiningConfiguration createMiningConfiguration(final Bytes vanityData) { return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java index 543d110ef45..fd39a46cfcf 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueContext; +import org.hyperledger.besu.consensus.clique.CliqueHelpers; import org.hyperledger.besu.consensus.clique.CliqueMiningTracker; import org.hyperledger.besu.consensus.clique.TestHelpers; import org.hyperledger.besu.consensus.common.validator.ValidatorProvider; @@ -258,6 +259,7 @@ private void setupCliqueContextAndBlockchain() { when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validators); final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface); + CliqueHelpers.setCliqueContext(cliqueContext); when(protocolContext.getConsensusContext(CliqueContext.class)).thenReturn(cliqueContext); when(protocolContext.getBlockchain()).thenReturn(blockChain); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java index d970d83d80e..d7e4d074091 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueContext; +import org.hyperledger.besu.consensus.clique.CliqueHelpers; import org.hyperledger.besu.consensus.clique.TestHelpers; import org.hyperledger.besu.consensus.common.validator.ValidatorProvider; import org.hyperledger.besu.crypto.KeyPair; @@ -58,6 +59,7 @@ public void setup() { when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList); final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface); + CliqueHelpers.setCliqueContext(cliqueContext); cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager()); blockHeaderBuilder = new BlockHeaderTestFixture(); } diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java index 29ec30d6679..f92b58bbfa6 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java @@ -133,7 +133,7 @@ private ProtocolSpecBuilder applyBftChanges( .blockBodyValidatorBuilder(MainnetBlockBodyValidator::new) .blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder()) .blockImporterBuilder(MainnetBlockImporter::new) - .difficultyCalculator((time, parent, protocolContext) -> BigInteger.ONE) + .difficultyCalculator((time, parent) -> BigInteger.ONE) .skipZeroBlockRewards(true) .blockHeaderFunctions(BftBlockHeaderFunctions.forOnchainBlock(bftExtraDataCodec)) .blockReward(Wei.of(configOptions.getBlockRewardWei())) diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java index a8c84d5a093..66e177efeef 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java @@ -129,7 +129,7 @@ private static ProtocolSpecBuilder applyParisSpecificModifications( gasCalculator, chainId.orElse(BigInteger.ZERO), EvmConfiguration.DEFAULT)) .blockHeaderValidatorBuilder(MergeProtocolSchedule::getBlockHeaderValidator) .blockReward(Wei.ZERO) - .difficultyCalculator((a, b, c) -> BigInteger.ZERO) + .difficultyCalculator((a, b) -> BigInteger.ZERO) .skipZeroBlockRewards(true) .isPoS(true) .name("Paris"); diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java index ba83f8aad9c..2fff61a8299 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java @@ -193,8 +193,7 @@ public void parametersAlignWithMainnetWithAdjustments() { private static void assertProofOfStakeConfigIsEnabled(final ProtocolSpec spec) { assertThat(spec.isPoS()).isTrue(); assertThat(spec.getEvm().getOperationsUnsafe()[0x44]).isInstanceOf(PrevRanDaoOperation.class); - assertThat(spec.getDifficultyCalculator().nextDifficulty(-1, null, null)) - .isEqualTo(BigInteger.ZERO); + assertThat(spec.getDifficultyCalculator().nextDifficulty(-1, null)).isEqualTo(BigInteger.ZERO); assertThat(spec.getBlockReward()).isEqualTo(Wei.ZERO); assertThat(spec.isSkipZeroBlockRewards()).isTrue(); assertThat(spec.getBlockProcessor()).isInstanceOf(MainnetBlockProcessor.class); 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 51cde269e05..c4a3f89aaa3 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 @@ -437,8 +437,7 @@ private ProcessableBlockHeader createPendingBlockHeader( newBlockNumber); final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator(); - final BigInteger difficulty = - difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext); + final BigInteger difficulty = difficultyCalculator.nextDifficulty(timestamp, parentHeader); final Wei baseFee = Optional.of(protocolSpec.getFeeMarket()) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyCalculators.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyCalculators.java index ceaf06e3530..692d3810c31 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyCalculators.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyCalculators.java @@ -34,6 +34,6 @@ public static boolean isFixedDifficultyInConfig(final GenesisConfigOptions confi public static DifficultyCalculator calculator(final GenesisConfigOptions config) { long difficulty = config.getEthashConfigOptions().getFixedDifficulty().getAsLong(); - return (time, parent, context) -> BigInteger.valueOf(difficulty); + return (time, parent) -> BigInteger.valueOf(difficulty); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java index 9a8f30d01f4..6e15eb87e09 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicDifficultyCalculators.java @@ -32,7 +32,7 @@ public abstract class ClassicDifficultyCalculators { private static final long DELAY = (CONTINUE_BLOCK - PAUSE_BLOCK) / EXPONENTIAL_DIFF_PERIOD; public static DifficultyCalculator DIFFICULTY_BOMB_PAUSED = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final BigInteger difficulty = ensureMinimumDifficulty( @@ -43,7 +43,7 @@ public abstract class ClassicDifficultyCalculators { }; public static DifficultyCalculator DIFFICULTY_BOMB_DELAYED = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final BigInteger difficulty = ensureMinimumDifficulty( @@ -55,7 +55,7 @@ public abstract class ClassicDifficultyCalculators { }; public static DifficultyCalculator DIFFICULTY_BOMB_REMOVED = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final BigInteger difficulty = ensureMinimumDifficulty( @@ -66,7 +66,7 @@ public abstract class ClassicDifficultyCalculators { }; public static DifficultyCalculator EIP100 = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final boolean hasOmmers = !parent.getOmmersHash().equals(Hash.EMPTY_LIST_HASH); final BigInteger difficulty = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculator.java index d03bede977d..408f83cb510 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculator.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; import java.math.BigInteger; @@ -28,8 +27,7 @@ public interface DifficultyCalculator { * * @param time the time the block was generated * @param parent the block's parent block header - * @param context the context in which the difficulty calculator should operate * @return the block difficulty */ - BigInteger nextDifficulty(long time, BlockHeader parent, ProtocolContext context); + BigInteger nextDifficulty(long time, BlockHeader parent); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java index 46f0a05e5dc..2129b10d5d0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java @@ -45,7 +45,7 @@ public abstract class MainnetDifficultyCalculators { private MainnetDifficultyCalculators() {} static final DifficultyCalculator FRONTIER = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final BigInteger adjust = parentDifficulty.divide(DIFFICULTY_BOUND_DIVISOR); BigInteger difficulty; @@ -60,7 +60,7 @@ private MainnetDifficultyCalculators() {} }; static final DifficultyCalculator HOMESTEAD = - (time, parent, protocolContext) -> { + (time, parent) -> { final BigInteger parentDifficulty = difficulty(parent.getDifficulty()); final BigInteger difficulty = ensureMinimumDifficulty( @@ -72,35 +72,28 @@ private MainnetDifficultyCalculators() {} }; static final DifficultyCalculator BYZANTIUM = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, BYZANTIUM_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, BYZANTIUM_FAKE_BLOCK_OFFSET); static final DifficultyCalculator CONSTANTINOPLE = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, CONSTANTINOPLE_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, CONSTANTINOPLE_FAKE_BLOCK_OFFSET); static final DifficultyCalculator MUIR_GLACIER = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, MUIR_GLACIER_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, MUIR_GLACIER_FAKE_BLOCK_OFFSET); // As per https://eips.ethereum.org/EIPS/eip-3554 static final DifficultyCalculator LONDON = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, LONDON_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, LONDON_FAKE_BLOCK_OFFSET); // As per https://eips.ethereum.org/EIPS/eip-4345 static final DifficultyCalculator ARROW_GLACIER = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, ARROW_GLACIER_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, ARROW_GLACIER_FAKE_BLOCK_OFFSET); // As per https://eips.ethereum.org/EIPS/eip-5133 static final DifficultyCalculator GRAY_GLACIER = - (time, parent, protocolContext) -> - calculateThawedDifficulty(time, parent, GRAY_GLACIER_FAKE_BLOCK_OFFSET); + (time, parent) -> calculateThawedDifficulty(time, parent, GRAY_GLACIER_FAKE_BLOCK_OFFSET); // Proof-of-Stake difficulty must not be altered - static final DifficultyCalculator PROOF_OF_STAKE_DIFFICULTY = - (time, parent, protocolContext) -> BigInteger.ZERO; + static final DifficultyCalculator PROOF_OF_STAKE_DIFFICULTY = (time, parent) -> BigInteger.ZERO; private static BigInteger calculateThawedDifficulty( final long time, final BlockHeader parent, final long fakeBlockOffset) { 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 5ff2129972f..c662c188644 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 @@ -532,9 +532,10 @@ public TransactionProcessingResult processTransaction( coinbaseCalculator.price(usedGas, transactionGasPrice, blockHeader.getBaseFee()); operationTracer.traceBeforeRewardTransaction(worldUpdater, transaction, coinbaseWeiDelta); - - final var coinbase = evmWorldUpdater.getOrCreate(miningBeneficiary); - coinbase.incrementBalance(coinbaseWeiDelta); + if (!coinbaseWeiDelta.isZero() || !clearEmptyAccounts) { + final var coinbase = evmWorldUpdater.getOrCreate(miningBeneficiary); + coinbase.incrementBalance(coinbaseWeiDelta); + } operationTracer.traceEndTransaction( evmWorldUpdater.updater(), 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 bcc4e213586..1eb4f044c2f 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 @@ -39,7 +39,7 @@ public boolean validate( final BigInteger actualDifficulty = new BigInteger(1, header.getDifficulty().toArray()); final BigInteger expectedDifficulty = - difficultyCalculator.nextDifficulty(header.getTimestamp(), parent, context); + difficultyCalculator.nextDifficulty(header.getTimestamp(), parent); if (actualDifficulty.compareTo(expectedDifficulty) != 0) { LOG.info( diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java index 02bb41feb90..9a6ddeaeb73 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java @@ -49,21 +49,21 @@ public void reportedDifficultyForAllBlocksIsAFixedValue() { schedule .getByBlockHeader(blockHeader(0)) .getDifficultyCalculator() - .nextDifficulty(1, parentHeader, null)) + .nextDifficulty(1, parentHeader)) .isEqualTo(FixedDifficultyCalculators.DEFAULT_DIFFICULTY); assertThat( schedule .getByBlockHeader(blockHeader(500)) .getDifficultyCalculator() - .nextDifficulty(1, parentHeader, null)) + .nextDifficulty(1, parentHeader)) .isEqualTo(FixedDifficultyCalculators.DEFAULT_DIFFICULTY); assertThat( schedule .getByBlockHeader(blockHeader(500_000)) .getDifficultyCalculator() - .nextDifficulty(1, parentHeader, null)) + .nextDifficulty(1, parentHeader)) .isEqualTo(FixedDifficultyCalculators.DEFAULT_DIFFICULTY); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java index d8d9f3777ea..c40da7210e2 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java @@ -108,7 +108,6 @@ void shouldWarmCoinbaseIfRequested() { .thenReturn(ValidationResult.valid()); when(transactionValidatorFactory.get().validateForSender(any(), any(), any())) .thenReturn(ValidationResult.valid()); - when(worldState.getOrCreate(any())).thenReturn(senderAccount); when(worldState.getOrCreateSenderAccount(any())).thenReturn(senderAccount); when(worldState.updater()).thenReturn(worldState); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/MonitoredExecutors.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/MonitoredExecutors.java index dba43282e5b..02514db1e7b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/MonitoredExecutors.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/MonitoredExecutors.java @@ -155,13 +155,13 @@ private static T newMonitoredExecutor( metricsSystem.createCounter( BesuMetricCategory.EXECUTORS, - metricName + "_completed_tasks", + metricName + "_completed_tasks_total", "Total number of tasks executed", executor::getCompletedTaskCount); metricsSystem.createCounter( BesuMetricCategory.EXECUTORS, - metricName + "_submitted_tasks", + metricName + "_submitted_tasks_total", "Total number of tasks executed", executor::getTaskCount); diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java index 25c0cd24841..5c571986698 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java @@ -224,8 +224,7 @@ public BlockHeader parentBlockHeader(final ProtocolSpec protocolSpec) { BlockHeaderBuilder.createDefault() .difficulty(Difficulty.fromHexOrDecimalString(parentDifficulty)) .number(number - 1) - .buildBlockHeader(), - null))); + .buildBlockHeader()))); } if (parentExcessBlobGas != null && parentBlobGasUsed != null) { builder.excessBlobGas(BlobGas.of(Long.decode(parentExcessBlobGas))); diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java index 3333f02e585..ea09a1eb983 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java @@ -181,7 +181,7 @@ private void testDifficulty( UInt256.fromHexString(value.get("currentDifficulty").asText()); final var spec = protocolSchedule.getByBlockHeader(testHeader); final var calculator = spec.getDifficultyCalculator(); - assertThat(UInt256.valueOf(calculator.nextDifficulty(currentTime, testHeader, null))) + assertThat(UInt256.valueOf(calculator.nextDifficulty(currentTime, testHeader))) .describedAs("File %s Test %s", testFile, entry.getKey()) .isEqualTo(currentDifficulty); } diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusMetricsSystem.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusMetricsSystem.java index f9b586b3bd7..f10a3b4bab1 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusMetricsSystem.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusMetricsSystem.java @@ -169,6 +169,19 @@ public LabelledMetric createSimpleLabelledTimer( }); } + @Override + public void createGauge( + final MetricCategory category, + final String name, + final String help, + final DoubleSupplier valueSupplier) { + if (isCategoryEnabled(category)) { + final var gauge = new PrometheusSuppliedGauge(category, name, help); + gauge.labels(valueSupplier); + registerCollector(category, gauge); + } + } + @Override public void trackExternalSummary( final MetricCategory category, @@ -184,15 +197,12 @@ public void trackExternalSummary( } @Override - public void createGauge( - final MetricCategory category, - final String name, - final String help, - final DoubleSupplier valueSupplier) { + public void createGuavaCacheCollector( + final MetricCategory category, final String name, final Cache cache) { if (isCategoryEnabled(category)) { - final var gauge = new PrometheusSuppliedGauge(category, name, help); - gauge.labels(valueSupplier); - registerCollector(category, gauge); + final var cacheCollector = + new PrometheusGuavaCache(category, guavaCacheCollectorContext, name, cache); + registerCollector(category, cacheCollector); } } @@ -226,16 +236,6 @@ public LabelledSuppliedMetric createLabelledSuppliedGauge( return NoOpMetricsSystem.getLabelledSuppliedMetric(labelNames.length); } - @Override - public void createGuavaCacheCollector( - final MetricCategory category, final String name, final Cache cache) { - if (isCategoryEnabled(category)) { - final var cacheCollector = - new PrometheusGuavaCache(category, guavaCacheCollectorContext, name, cache); - registerCollector(category, cacheCollector); - } - } - private void registerCollector( final MetricCategory category, final PrometheusCollector collector) { final Collection categoryCollectors = diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCounter.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCounter.java index 8b5976b657f..a443420f334 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCounter.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCounter.java @@ -27,7 +27,7 @@ import io.prometheus.metrics.model.snapshots.DataPointSnapshot; /** The Prometheus supplied counter. */ -public class PrometheusSuppliedCounter extends PrometheusSuppliedCollector { +public class PrometheusSuppliedCounter extends PrometheusSuppliedValueCollector { /** * Instantiates a new labelled Prometheus supplied counter. diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedGauge.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedGauge.java index 7179f013167..3fac206937f 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedGauge.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedGauge.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * Copyright contributors to 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 @@ -29,7 +29,8 @@ /** The Prometheus gauge. */ @SuppressWarnings("removal") -public class PrometheusSuppliedGauge extends PrometheusSuppliedCollector implements LabelledGauge { +public class PrometheusSuppliedGauge extends PrometheusSuppliedValueCollector + implements LabelledGauge { /** * Instantiates a new labelled Prometheus gauge. diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCollector.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedValueCollector.java similarity index 96% rename from metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCollector.java rename to metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedValueCollector.java index 3187843afca..5ef7fa4b20e 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedCollector.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusSuppliedValueCollector.java @@ -28,7 +28,7 @@ import io.prometheus.metrics.model.registry.PrometheusRegistry; import io.prometheus.metrics.model.snapshots.DataPointSnapshot; -abstract class PrometheusSuppliedCollector extends CategorizedPrometheusCollector +abstract class PrometheusSuppliedValueCollector extends CategorizedPrometheusCollector implements LabelledSuppliedMetric { /** The collector */ protected final Collector collector; @@ -36,7 +36,7 @@ abstract class PrometheusSuppliedCollector extends CategorizedPrometheusCollecto /** Map label values with the collector callback data */ protected final Map, CallbackData> labelledCallbackData = new ConcurrentHashMap<>(); - protected PrometheusSuppliedCollector( + protected PrometheusSuppliedValueCollector( final MetricCategory category, final String name, final String help,