Skip to content
/ besu Public
forked from hyperledger/besu

Commit

Permalink
Mining Parameters Metrics (hyperledger#6587)
Browse files Browse the repository at this point in the history
* mining parameter metrics

Signed-off-by: Brindrajsinh-Chauhan <brindrajsinh@gmail.com>

* update changelog

Signed-off-by: Brindrajsinh-Chauhan <brindrajsinh@gmail.com>

* remove unwanted code

Signed-off-by: Brindrajsinh-Chauhan <brindrajsinh@gmail.com>

---------

Signed-off-by: Brindrajsinh-Chauhan <brindrajsinh@gmail.com>
Signed-off-by: amsmota <antonio.mota@citi.com>
  • Loading branch information
Brindrajsinh-Chauhan authored and amsmota committed Apr 16, 2024
1 parent 5adad6a commit bc7d525
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- New `eth_blobBaseFee`JSON-RPC method [#6581](https://github.com/hyperledger/besu/pull/6581)
- Upgrade reference tests to version 13.1 [#6574](https://github.com/hyperledger/besu/pull/6574)
- Extend `BesuConfiguration` service [#6584](https://github.com/hyperledger/besu/pull/6584)
- Add `ethereum_min_gas_price` and `ethereum_min_priority_fee` metrics to track runtime values of `min-gas-price` and `min-priority-fee` [#6587](https://github.com/hyperledger/besu/pull/6587)

### Bug fixes
- Fix the way an advertised host configured with `--p2p-host` is treated when communicating with the originator of a PING packet [#6225](https://github.com/hyperledger/besu/pull/6225)
Expand Down
6 changes: 6 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.MiningParametersMetrics;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
Expand Down Expand Up @@ -2128,6 +2129,7 @@ private MiningParameters getMiningParameters() {
miningOptions.setGenesisBlockPeriodSeconds(
getGenesisBlockPeriodSeconds(getActualGenesisConfigOptions()));
miningParameters = miningOptions.toDomainObject();
initMiningParametersMetrics(miningParameters);
}
return miningParameters;
}
Expand All @@ -2139,6 +2141,10 @@ private DataStorageConfiguration getDataStorageConfiguration() {
return dataStorageConfiguration;
}

private void initMiningParametersMetrics(final MiningParameters miningParameters) {
new MiningParametersMetrics(getMetricsSystem(), miningParameters);
}

private OptionalInt getGenesisBlockPeriodSeconds(
final GenesisConfigOptions genesisConfigOptions) {
if (genesisConfigOptions.isClique()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core;

import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;

public class MiningParametersMetrics {
public static final String MIN_GAS_PRICE_GAUGE = "min_gas_price";
public static final String MIN_PRIORITY_FEE_GAUGE = "min_priority_fee";

public MiningParametersMetrics(
final MetricsSystem metricsSystem, final MiningParameters miningParameters) {

metricsSystem.createGauge(
BesuMetricCategory.ETHEREUM,
MIN_GAS_PRICE_GAUGE,
"Gauge to measure the runtime value of min-gas-price",
() -> miningParameters.getMinTransactionGasPrice().toBigInteger().doubleValue());

metricsSystem.createGauge(
BesuMetricCategory.ETHEREUM,
MIN_PRIORITY_FEE_GAUGE,
"Gauge to measure the runtime value of min-priority-fee",
() -> miningParameters.getMinPriorityFeePerGas().toBigInteger().doubleValue());
}
}

0 comments on commit bc7d525

Please sign in to comment.