Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 committed Oct 23, 2023
1 parent 2700930 commit e55392b
Show file tree
Hide file tree
Showing 28 changed files with 102 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
Expand Down Expand Up @@ -58,8 +58,8 @@ public class BesuNodeConfigurationBuilder {
private Optional<Path> dataPath = Optional.empty();
private MiningParameters miningParameters =
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.mutableInitValues(
MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.build();

private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
Expand Down Expand Up @@ -306,8 +306,8 @@ public BesuNode createNodeWithMultiTenantedPrivacy(

final MiningParameters miningParameters =
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
.minTransactionGasPrice(Wei.ZERO)
.coinbase(AddressHelpers.ofValue(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
Expand Down Expand Up @@ -62,8 +62,8 @@ public void shouldMineOnSingleNodeWithFreeGas_Berlin() throws Exception {
final BesuNode minerNode = nodeFactory.createNode(besu, "miner1");
final MiningParameters zeroGasMiningParams =
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
.minTransactionGasPrice(Wei.ZERO)
.coinbase(AddressHelpers.ofValue(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,6 @@ public void run() {

// Need to create vertx after cmdline has been parsed, such that metricsSystem is configurable
vertx = createVertx(createVertxOptions(metricsSystem.get()));
miningParameters = getMiningParameters();

validateOptions();
configure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
package org.hyperledger.besu.cli.options;

import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_EXTRA_DATA;
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_MAX_OMMERS_DEPTH;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POW_JOB_TTL;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
import static org.hyperledger.besu.ethereum.core.MiningParameters.UpdatableInitValues.DEFAULT_EXTRA_DATA;
import static org.hyperledger.besu.ethereum.core.MiningParameters.UpdatableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
import static org.hyperledger.besu.ethereum.core.MiningParameters.UpdatableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;

import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;

import java.util.List;
Expand Down Expand Up @@ -262,7 +262,7 @@ static MiningOptions fromConfig(final MiningParameters miningParameters) {
@Override
public MiningParameters toDomainObject() {
final var updatableInitValuesBuilder =
UpdatableInitValues.builder()
MutableInitValues.builder()
.isMiningEnabled(isMiningEnabled)
.extraData(extraData)
.minTransactionGasPrice(minTransactionGasPrice)
Expand All @@ -277,7 +277,7 @@ public MiningParameters toDomainObject() {

final var miningParametersBuilder =
ImmutableMiningParameters.builder()
.updatableInitValues(updatableInitValuesBuilder.build())
.mutableInitValues(updatableInitValuesBuilder.build())
.isStratumMiningEnabled(iStratumMiningEnabled)
.stratumNetworkInterface(stratumNetworkInterface)
.stratumPort(stratumPort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.metrics.MetricsService;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
Expand Down Expand Up @@ -270,8 +270,8 @@ private MiningParameters getMiningParameters() {
final Address coinbase = Address.ZERO;
final Bytes extraData = Bytes.EMPTY;
return ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.nonceGenerator(new IncrementingNonceGenerator(0))
.extraData(extraData)
.minTransactionGasPrice(minTransactionGasPrice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ protected MiningCoordinator createMiningCoordinator(

final Address localAddress = Util.publicKeyToAddress(nodeKey.getPublicKey());
final BftProtocolSchedule bftProtocolSchedule = (BftProtocolSchedule) protocolSchedule;
miningParameters.setCoinbase(localAddress);
final BftBlockCreatorFactory<?> blockCreatorFactory =
new BftBlockCreatorFactory<>(
transactionPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
Expand Down Expand Up @@ -423,8 +423,8 @@ protected BesuController createController(final GenesisConfigFile genesisConfigF
.networkId(BigInteger.valueOf(10))
.miningParameters(
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
.minTransactionGasPrice(Wei.ZERO)
.build())
Expand Down
10 changes: 5 additions & 5 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
Expand Down Expand Up @@ -903,8 +903,8 @@ public void envVariableOverridesValueFromConfigFile() {
verify(mockControllerBuilder)
.miningParameters(
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.coinbase(Address.fromHexString(expectedCoinbase))
.build())
.build());
Expand All @@ -920,8 +920,8 @@ public void cliOptionOverridesEnvVariableAndConfig() {
verify(mockControllerBuilder)
.miningParameters(
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.coinbase(Address.fromHexString(expectedCoinbase))
.build())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;

import java.io.IOException;
Expand Down Expand Up @@ -316,8 +316,8 @@ protected MiningParameters createDefaultDomainObject() {
@Override
protected MiningParameters createCustomizedDomainObject() {
return ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
.extraData(Bytes.fromHexString("0xabc321"))
.minBlockOccupancyRatio(0.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
Expand Down Expand Up @@ -122,7 +122,7 @@ public void assertPoWIsNotMiningPreMerge() {
public void assertPowMiningPreMerge() {
miningParameters =
ImmutableMiningParameters.builder()
.updatableInitValues(UpdatableInitValues.builder().isMiningEnabled(true).build())
.mutableInitValues(MutableInitValues.builder().isMiningEnabled(true).build())
.build();
var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder);
assertThat(transCoordinator.isMiningBeforeMerge()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
Expand Down Expand Up @@ -157,8 +157,8 @@ public void setUp() {
new NoOpMetricsSystem(),
syncState,
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder().minTransactionGasPrice(Wei.ZERO).build())
.mutableInitValues(
MutableInitValues.builder().minTransactionGasPrice(Wei.ZERO).build())
.build(),
txPoolConfig,
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
Expand Down Expand Up @@ -244,8 +245,8 @@ private static MiningParameters createMiningParameters(
final Bytes extraData, final Address coinbase) {
final MiningParameters miningParameters =
ImmutableMiningParameters.builder()
.updatableInitValues(
ImmutableMiningParameters.UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(extraData)
.targetGasLimit(10_000_000L)
.minTransactionGasPrice(Wei.ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
Expand Down Expand Up @@ -236,8 +236,8 @@ private Bytes generateRandomVanityData() {

private static MiningParameters createMiningParameters(final Bytes vanityData) {
return ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(vanityData)
.minTransactionGasPrice(Wei.ZERO)
.coinbase(AddressHelpers.ofValue(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
Expand Down Expand Up @@ -307,8 +307,8 @@ private static ControllerAndState createControllerAndFinalState(

final MiningParameters miningParams =
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
.minTransactionGasPrice(Wei.ZERO)
.extraData(Bytes.wrap("Ibft Int tests".getBytes(UTF_8)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.UpdatableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
Expand Down Expand Up @@ -154,8 +154,8 @@ public BlockHeaderValidator.Builder createBlockHeaderRuleset(

final MiningParameters miningParameters =
ImmutableMiningParameters.builder()
.updatableInitValues(
UpdatableInitValues.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(
bftExtraDataEncoder.encode(
new BftExtraData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
* to fill 100% of the block.
*/
private static final double TRY_FILL_BLOCK = 1.0;

private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L;
/** The Mining parameters. */
protected final MiningParameters miningParameters;
/** The Merge block creator factory. */
Expand Down Expand Up @@ -122,7 +124,7 @@ public MergeCoordinator(
miningParams.setCoinbase(Address.ZERO);
}
if (miningParams.getTargetGasLimit().isEmpty()) {
miningParams.setTargetGasLimit(30000000L);
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);

Expand Down Expand Up @@ -168,7 +170,7 @@ public MergeCoordinator(
this.mergeContext = protocolContext.getConsensusContext(MergeContext.class);
this.backwardSyncContext = backwardSyncContext;
if (miningParams.getTargetGasLimit().isEmpty()) {
miningParams.setTargetGasLimit(30000000L);
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
this.miningParameters = miningParams;
Expand Down
Loading

0 comments on commit e55392b

Please sign in to comment.