Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
c57c2ac
Refactor mining options
fab-10 Oct 10, 2023
b408b64
Fix null pointer exception
fab-10 Oct 10, 2023
da79e09
fix another null pointer exception
fab-10 Oct 10, 2023
7684d7e
uncomment code
fab-10 Oct 10, 2023
78741da
Move miner options tests
fab-10 Oct 11, 2023
18bcce3
Unit test fixes
fab-10 Oct 12, 2023
59fbe8e
Removed the commented code
fab-10 Oct 12, 2023
8f14dd3
WIP
fab-10 Oct 13, 2023
2280e02
Merge branch 'main' into mining-options-refactor
fab-10 Oct 13, 2023
65bdabd
WIP
fab-10 Oct 13, 2023
e89a244
Remove not relevant for this feature
fab-10 Oct 16, 2023
46e0dc4
Revert "Remove not relevant for this feature"
fab-10 Oct 16, 2023
20e498b
Merge branch 'main' into mining-options-refactor
fab-10 Oct 16, 2023
0ea8553
Time limited transaction selection during block creation
fab-10 Oct 16, 2023
86b9a6e
Merge branch 'main' into mining-options-refactor
fab-10 Oct 17, 2023
2267bc7
Fix javadoc
fab-10 Oct 17, 2023
c6b56d2
Remove code not belonging to this PR
fab-10 Oct 17, 2023
477acf9
coinbase is an updatable parameter
fab-10 Oct 17, 2023
4626230
Move MiningOptions to upper package
fab-10 Oct 17, 2023
25b1522
Fix coinbase for *bft
fab-10 Oct 17, 2023
28a32af
Merge branch 'mining-options-refactor' into time-limited-block-creation
fab-10 Oct 17, 2023
ae775ae
Merge branch 'main' into mining-options-refactor
fab-10 Oct 18, 2023
ca5095d
Merge branch 'mining-options-refactor' into time-limited-block-creation
fab-10 Oct 18, 2023
06a7145
Fix test
fab-10 Oct 18, 2023
bc655bf
Introduce a block level and a tx level world state updater
fab-10 Oct 18, 2023
16315a4
Merge branch 'main' into mining-options-refactor
macfarla Oct 20, 2023
2700930
Merge branch 'mining-options-refactor' of github.com:fab-10/besu into…
fab-10 Oct 23, 2023
bf8eba4
Merge branch 'mining-options-refactor' into time-limited-block-creation
fab-10 Oct 23, 2023
4716d89
Fix test
fab-10 Oct 23, 2023
e55392b
Apply suggestions from code review
fab-10 Oct 23, 2023
fa534ba
Merge branch 'mining-options-refactor' into time-limited-block-creation
fab-10 Oct 23, 2023
8aef8ad
Option remaning and tests
fab-10 Oct 23, 2023
2698672
WIP
fab-10 Oct 23, 2023
bc8137f
Better handling of tx on timeout
fab-10 Oct 23, 2023
d710e5c
Merge branch 'main' into mining-options-refactor
fab-10 Oct 24, 2023
639af82
Update besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
fab-10 Oct 24, 2023
232caa6
Merge branch 'mining-options-refactor' of github.com:fab-10/besu into…
fab-10 Oct 24, 2023
878969d
Merge branch 'main' into mining-options-refactor
fab-10 Oct 24, 2023
700a06a
Merge branch 'mining-options-refactor' into time-limited-block-creation
fab-10 Oct 24, 2023
f3c4c3c
Better handling of not selected tx due to timeout
fab-10 Oct 24, 2023
2050178
[skip ci] Update CHANGELOG
fab-10 Oct 24, 2023
0de5b5a
Merge branch 'main' into time-limited-block-creation
fab-10 Oct 25, 2023
e9f76df
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Oct 25, 2023
92a0aa5
Introduce a timeout for the evaluation of a single tx, during block c…
fab-10 Oct 25, 2023
b1742be
Update API checksum
fab-10 Oct 25, 2023
90b05ea
Merge branch 'main' into time-limited-block-creation
fab-10 Oct 25, 2023
ea13bf0
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Oct 25, 2023
f6e63f4
Fix tests
fab-10 Oct 25, 2023
415adcf
Merge branch 'main' into time-limited-block-creation
fab-10 Oct 26, 2023
9b2e8cd
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Oct 26, 2023
7282a3c
By default, set --Xtxs-selection-per-tx-max-time to the value of --Xt…
fab-10 Oct 26, 2023
7f0f34d
Improvements and unit tests
fab-10 Oct 26, 2023
cb35fa9
[skip ci] Update CHANGELOG
fab-10 Oct 26, 2023
5a7af10
Check for txTimeout before so we discard the tx if a concurrent block…
fab-10 Oct 31, 2023
0e6b2bf
Merge branch 'main' into time-limited-block-creation
fab-10 Oct 31, 2023
5c5c954
Merge branch 'main' into time-limited-block-creation
fab-10 Nov 2, 2023
a8b859f
Apply suggestion from code review and javadoc
fab-10 Nov 2, 2023
cf8b239
Introduce a specific configuration for PoA networks
fab-10 Nov 2, 2023
5ce9aaa
Merge branch 'main' into time-limited-block-creation
fab-10 Nov 2, 2023
42548a0
javadoc
fab-10 Nov 2, 2023
f7650c9
More option tests
fab-10 Nov 2, 2023
ae9dbd1
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Nov 2, 2023
cfb9499
More renaming and tests
fab-10 Nov 3, 2023
8247a26
Merge branch 'main' into time-limited-block-creation
fab-10 Nov 3, 2023
b5fa6dd
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Nov 3, 2023
1cbd1e8
Update CHANGELOG
fab-10 Nov 3, 2023
ba5ee0a
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Nov 3, 2023
21717e8
complete renaming
fab-10 Nov 3, 2023
8fab043
One timeout per tx
fab-10 Nov 3, 2023
08e0be2
Merge branch 'main' into time-limited-block-creation
fab-10 Nov 6, 2023
c62a519
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Nov 6, 2023
1b2f62f
Introduce TxSelectionState to keep track of a single tx evaluation state
fab-10 Nov 6, 2023
a2d1ad7
Merge branch 'main' into time-limited-block-creation
fab-10 Nov 7, 2023
9d77a56
Merge branch 'time-limited-block-creation' into time-limited-tx-proce…
fab-10 Nov 7, 2023
7835f5c
Use a single object to synchronize and stop tx evaluation on block ti…
fab-10 Nov 8, 2023
4d5ed0c
Merge branch 'main' into time-limited-tx-processing-block-creation
fab-10 Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Add `yParity` to GraphQL and JSON-RPC for relevant querise. [6119](https://github.com/hyperledger/besu/pull/6119)
- Force tx replacement price bump to zero when zero base fee market is configured or `--min-gas-price` is set to 0. This allows for easier tx replacement in networks where there is not gas price. [#6079](https://github.com/hyperledger/besu/pull/6079)
- Introduce the possibility to limit the time spent selecting pending transactions during block creation, using the new experimental option `Xblock-txs-selection-max-time` on PoS and PoW networks (by default set to 5000ms) or `Xpoa-block-txs-selection-max-time` on PoA networks (by default 75% of the min block time) [#6044](https://github.com/hyperledger/besu/pull/6044)
- Introduce the possibility to limit the time spent evaluating a single pending transactions during block creation, using the new experimental option `Xblock-txs-selection-per-tx-max-time` (by default set to the value of block txs selection max time for your network) [#6089](https://github.com/hyperledger/besu/pull/6089)

### Bug fixes
- Upgrade netty to address CVE-2023-44487, CVE-2023-34462 [#6100](https://github.com/hyperledger/besu/pull/6100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ static class Unstable {
+ " To be only used on PoA networks, for other networks see Xblock-txs-selection-max-time."
+ " (default: ${DEFAULT-VALUE})")
private Percentage poaBlockTxsSelectionMaxTime = DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;

@CommandLine.Option(
hidden = true,
names = {"--Xblock-txs-selection-per-tx-max-time"},
description =
"Specifies the maximum time, in milliseconds, that could be spent selecting a single transaction to be included in the block."
+ " Must be positive and ≤ the max time allocated for the block txs selection."
+ " (default: will get the block txs selection max time as specified by --Xblock-txs-selection-max-time or --Xpoa-block-txs-selection-max-time)")
private Long blockTxsSelectionPerTxMaxTime;
}

private MiningOptions() {}
Expand Down Expand Up @@ -324,6 +333,11 @@ static MiningOptions fromConfig(final MiningParameters miningParameters) {

miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
miningParameters
.getUnstable()
.getConfiguredBlockTxsSelectionPerTxMaxTime()
.ifPresent(value -> miningOptions.unstableOptions.blockTxsSelectionPerTxMaxTime = value);

return miningOptions;
}

Expand All @@ -344,25 +358,31 @@ public MiningParameters toDomainObject() {
updatableInitValuesBuilder.coinbase(coinbase);
}

final var unstableParametersBuilder =
ImmutableMiningParameters.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive)
.maxOmmerDepth(unstableOptions.maxOmmersDepth)
.stratumExtranonce(unstableOptions.stratumExtranonce)
.posBlockCreationMaxTime(unstableOptions.posBlockCreationMaxTime)
.posBlockCreationRepetitionMinDuration(
unstableOptions.posBlockCreationRepetitionMinDuration)
.nonPoaBlockTxsSelectionMaxTime(unstableOptions.nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(unstableOptions.poaBlockTxsSelectionMaxTime);

if (unstableOptions.blockTxsSelectionPerTxMaxTime != null) {
unstableParametersBuilder.configuredBlockTxsSelectionPerTxMaxTime(
unstableOptions.blockTxsSelectionPerTxMaxTime);
}

final var miningParametersBuilder =
ImmutableMiningParameters.builder()
.mutableInitValues(updatableInitValuesBuilder.build())
.isStratumMiningEnabled(iStratumMiningEnabled)
.stratumNetworkInterface(stratumNetworkInterface)
.stratumPort(stratumPort)
.unstable(
ImmutableMiningParameters.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive)
.maxOmmerDepth(unstableOptions.maxOmmersDepth)
.stratumExtranonce(unstableOptions.stratumExtranonce)
.posBlockCreationMaxTime(unstableOptions.posBlockCreationMaxTime)
.posBlockCreationRepetitionMinDuration(
unstableOptions.posBlockCreationRepetitionMinDuration)
.nonPoaBlockTxsSelectionMaxTime(unstableOptions.nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(unstableOptions.poaBlockTxsSelectionMaxTime)
.build());
.unstable(unstableParametersBuilder.build());

return miningParametersBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -384,6 +386,48 @@ public void poaBlockTxsSelectionMaxTimeOnlyCompatibleWithPoaNetworks() {
"90");
}

@Test
public void txsSelectionPerTxMaxTimeDefaultValue() {
// by default, it takes the value of the block txs selection max time
internalTestSuccess(
miningParams ->
assertThat(miningParams.getUnstable().getBlockTxsSelectionPerTxMaxTime())
.isEqualTo(miningParams.getUnstable().getBlockTxsSelectionMaxTime())
.isEqualTo(DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME));
}

@Test
public void txsSelectionPerTxMaxTimeOption() {
internalTestSuccess(
miningParams ->
assertThat(miningParams.getUnstable().getBlockTxsSelectionPerTxMaxTime())
.isEqualTo(700L),
"--Xblock-txs-selection-per-tx-max-time",
"700");
}

@Test
public void txsSelectionPerTxMaxTimeOptionGetsTheValueOfTxsSelectionMaxTimeIfNotConfigured() {
// by default, it takes the value of the block txs selection max time
internalTestSuccess(
miningParams ->
assertThat(miningParams.getUnstable().getBlockTxsSelectionPerTxMaxTime())
.isEqualTo(miningParams.getUnstable().getBlockTxsSelectionMaxTime())
.isEqualTo(1000L),
"--Xblock-txs-selection-max-time",
"1000");
}

@Test
public void txsSelectionPerTxMaxTimeOutOfAllowedRange() {
internalTestFailure(
"blockTxsSelectionPerTxMaxTime (4000) is greater than the blockTxsSelectionMaxTime (3000)",
"--Xblock-txs-selection-max-time",
"3000",
"--Xblock-txs-selection-per-tx-max-time",
"4000");
}

@Override
protected MiningParameters createDefaultDomainObject() {
return MiningParameters.newDefault();
Expand Down Expand Up @@ -413,4 +457,9 @@ protected MiningOptions optionsFromDomainObject(final MiningParameters domainObj
protected MiningOptions getOptionsFromBesuCommand(final TestBesuCommand besuCommand) {
return besuCommand.getMiningOptions();
}

@Override
protected List<String> getFieldsWithComputedDefaults() {
return Arrays.asList("unstableOptions.blockTxsSelectionPerTxMaxTime");
}
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ allprojects {
importOrder 'org.hyperledger', 'java', ''
trimTrailingWhitespace()
endWithNewline()
toggleOffOn()
}
groovyGradle {
target '*.gradle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -182,6 +183,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
private final BadBlockManager badBlockManager = spy(new BadBlockManager());

@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() {
when(mergeContext.as(MergeContext.class)).thenReturn(mergeContext);
when(mergeContext.getTerminalTotalDifficulty())
Expand All @@ -206,7 +208,7 @@ public void setUp() {
genesisState.writeStateTo(mutable);
mutable.persist(null);

when(ethScheduler.scheduleBlockCreationTask(any()))
when(ethScheduler.scheduleBlockCreationTask(any(Runnable.class)))
.thenAnswer(
invocation -> {
final Runnable runnable = invocation.getArgument(0);
Expand All @@ -217,6 +219,17 @@ public void setUp() {
return blockCreationTask;
});

when(ethScheduler.scheduleBlockCreationTask(any(Supplier.class)))
.thenAnswer(
invocation -> {
final Supplier<?> supplier = invocation.getArgument(0);
if (!invocation.toString().contains("MergeCoordinator")) {
return CompletableFuture.supplyAsync(supplier);
}
blockCreationTask = CompletableFuture.supplyAsync((Supplier<Void>) supplier);
return blockCreationTask;
});

MergeConfigOptions.setMergeEnabled(true);

when(ethContext.getEthPeers().subscribeConnect(any())).thenReturn(1L);
Expand All @@ -234,6 +247,10 @@ public void setUp() {

this.transactionPool.setEnabled();

createMergeCoordinator(miningParameters);
}

private void createMergeCoordinator(final MiningParameters miningParameters) {
this.coordinator =
new MergeCoordinator(
protocolContext,
Expand Down Expand Up @@ -558,6 +575,7 @@ public void shouldStopRetryBlockCreationIfTimeExpired() throws InterruptedExcept
.from(miningParameters)
.unstable(Unstable.builder().posBlockCreationMaxTime(100).build())
.build();
createMergeCoordinator(miningParameters);
doAnswer(
invocation -> {
retries.incrementAndGet();
Expand Down Expand Up @@ -752,15 +770,7 @@ public void shouldUseExtraDataFromMiningParameters() {
.mutableInitValues(MutableInitValues.builder().extraData(extraData).build())
.build();

this.coordinator =
new MergeCoordinator(
protocolContext,
protocolSchedule,
ethScheduler,
transactionPool,
miningParameters,
backwardSyncContext,
Optional.empty());
createMergeCoordinator(miningParameters);

final PayloadIdentifier payloadId =
this.coordinator.preparePayload(
Expand Down
Loading