Skip to content

Commit 1b335ad

Browse files
Mining Parameters Metrics (#6587)
* 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>
1 parent 5adad6a commit 1b335ad

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
- New `eth_blobBaseFee`JSON-RPC method [#6581](https://github.com/hyperledger/besu/pull/6581)
4747
- Upgrade reference tests to version 13.1 [#6574](https://github.com/hyperledger/besu/pull/6574)
4848
- Extend `BesuConfiguration` service [#6584](https://github.com/hyperledger/besu/pull/6584)
49+
- 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)
4950

5051
### Bug fixes
5152
- 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)

besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
119119
import org.hyperledger.besu.ethereum.chain.Blockchain;
120120
import org.hyperledger.besu.ethereum.core.MiningParameters;
121+
import org.hyperledger.besu.ethereum.core.MiningParametersMetrics;
121122
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
122123
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
123124
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@@ -2128,6 +2129,7 @@ private MiningParameters getMiningParameters() {
21282129
miningOptions.setGenesisBlockPeriodSeconds(
21292130
getGenesisBlockPeriodSeconds(getActualGenesisConfigOptions()));
21302131
miningParameters = miningOptions.toDomainObject();
2132+
initMiningParametersMetrics(miningParameters);
21312133
}
21322134
return miningParameters;
21332135
}
@@ -2139,6 +2141,10 @@ private DataStorageConfiguration getDataStorageConfiguration() {
21392141
return dataStorageConfiguration;
21402142
}
21412143

2144+
private void initMiningParametersMetrics(final MiningParameters miningParameters) {
2145+
new MiningParametersMetrics(getMetricsSystem(), miningParameters);
2146+
}
2147+
21422148
private OptionalInt getGenesisBlockPeriodSeconds(
21432149
final GenesisConfigOptions genesisConfigOptions) {
21442150
if (genesisConfigOptions.isClique()) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Hyperledger Besu Contributors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*
13+
* SPDX-License-Identifier: Apache-2.0
14+
*/
15+
package org.hyperledger.besu.ethereum.core;
16+
17+
import org.hyperledger.besu.metrics.BesuMetricCategory;
18+
import org.hyperledger.besu.plugin.services.MetricsSystem;
19+
20+
public class MiningParametersMetrics {
21+
public static final String MIN_GAS_PRICE_GAUGE = "min_gas_price";
22+
public static final String MIN_PRIORITY_FEE_GAUGE = "min_priority_fee";
23+
24+
public MiningParametersMetrics(
25+
final MetricsSystem metricsSystem, final MiningParameters miningParameters) {
26+
27+
metricsSystem.createGauge(
28+
BesuMetricCategory.ETHEREUM,
29+
MIN_GAS_PRICE_GAUGE,
30+
"Gauge to measure the runtime value of min-gas-price",
31+
() -> miningParameters.getMinTransactionGasPrice().toBigInteger().doubleValue());
32+
33+
metricsSystem.createGauge(
34+
BesuMetricCategory.ETHEREUM,
35+
MIN_PRIORITY_FEE_GAUGE,
36+
"Gauge to measure the runtime value of min-priority-fee",
37+
() -> miningParameters.getMinPriorityFeePerGas().toBigInteger().doubleValue());
38+
}
39+
}

0 commit comments

Comments
 (0)