Skip to content

Commit

Permalink
Merge branch 'main' into qbft-snap
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Whitehead <[email protected]>
  • Loading branch information
matthew1001 authored Jul 1, 2024
2 parents 6ba69e1 + 08772b4 commit 14ee678
Show file tree
Hide file tree
Showing 69 changed files with 2,066 additions and 225 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Next Release

### Upcoming Breaking Changes
- Receipt compaction will be enabled by default in a future version of Besu. After this change it will not be possible to downgrade to the previous Besu version.
- PKI-backed QBFT will be removed in a future version of Besu. Other forms of QBFT will remain unchanged.
- --Xbonsai-limit-trie-logs-enabled is deprecated, use --bonsai-limit-trie-logs-enabled instead
- --Xbonsai-trie-logs-pruning-window-size is deprecated, use --bonsai-trie-logs-pruning-window-size instead
- `besu storage x-trie-log` subcommand is deprecated, use `besu storage trie-log` instead

### Breaking Changes
- `Xp2p-peer-lower-bound` has been removed. [#7247](https://github.com/hyperledger/besu/pull/7247)

Expand All @@ -16,6 +23,8 @@
- Add LUKSO as predefined network name [#7223](https://github.com/hyperledger/besu/pull/7223)
- Refactored how code, initcode, and max stack size are configured in forks. [#7245](https://github.com/hyperledger/besu/pull/7245)
- Nodes in a permissioned chain maintain (and retry) connections to bootnodes [#7257](https://github.com/hyperledger/besu/pull/7257)
- Promote experimental `besu storage x-trie-log` subcommand to production-ready [#7278](https://github.com/hyperledger/besu/pull/7278)
- Enhanced BFT round-change diagnostics [#7271](https://github.com/hyperledger/besu/pull/7271)
- `--Xsnapsync-bft-enabled` option enables experimental support for snap sync with IBFT/QBFT permissioned Bonsai-DB chains [#7140](https://github.com/hyperledger/besu/pull/7140)

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@

/** The Trie Log subcommand. */
@Command(
name = "x-trie-log",
name = "trie-log",
aliases = "x-trie-log",
description = "Manipulate trie logs",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
Expand Down
60 changes: 57 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,63 @@ allprojects {
options.addBooleanOption('Xdoclint/package:-org.hyperledger.besu.privacy.contracts.generated,' +
'-org.hyperledger.besu.tests.acceptance.*,' +
'-org.hyperledger.besu.tests.web3j.generated,' +
// TODO: these are temporary disabled (ethereum and sub modules), it should be removed in a future PR.
'-org.hyperledger.besu.ethereum.*,' +
'-org.hyperledger.besu.evmtool',
// TODO: these are temporary excluded from lint (ethereum sub modules), it should be removed in a future PR.
// ethereum api module
'-org.hyperledger.besu.ethereum.api.handlers,' +
'-org.hyperledger.besu.ethereum.api.jsonrpc,' +
'-org.hyperledger.besu.ethereum.api.jsonrpc.*,' +
'-org.hyperledger.besu.ethereum.api.query,' +
'-org.hyperledger.besu.ethereum.api.query.*,' +
'-org.hyperledger.besu.ethereum.api.tls,' +
'-org.hyperledger.besu.ethereum.api.util,' +
// ethereum blockcreation module
'-org.hyperledger.besu.ethereum.blockcreation,' +
'-org.hyperledger.besu.ethereum.blockcreation.*,' +
// ethereum core module
'-org.hyperledger.besu.ethereum.chain,' +
'-org.hyperledger.besu.ethereum.core,' +
'-org.hyperledger.besu.ethereum.core.*,' +
'-org.hyperledger.besu.ethereum.debug,' +
'-org.hyperledger.besu.ethereum.difficulty.fixed,' +
'-org.hyperledger.besu.ethereum.forkid,' +
'-org.hyperledger.besu.ethereum.mainnet,' +
'-org.hyperledger.besu.ethereum.mainnet.*,' +
'-org.hyperledger.besu.ethereum.privacy,' +
'-org.hyperledger.besu.ethereum.privacy.*,' +
'-org.hyperledger.besu.ethereum.processing,' +
'-org.hyperledger.besu.ethereum.proof,' +
'-org.hyperledger.besu.ethereum.storage,' +
'-org.hyperledger.besu.ethereum.storage.*,' +
'-org.hyperledger.besu.ethereum.transaction,' +
'-org.hyperledger.besu.ethereum.trie.*,' +
'-org.hyperledger.besu.ethereum.util,' +
'-org.hyperledger.besu.ethereum.vm,' +
'-org.hyperledger.besu.ethereum.worldstate,' +
// ethereum eth module
'-org.hyperledger.besu.ethereum.eth.*,' +
'-org.hyperledger.besu.ethereum.eth,' +
'-org.hyperledger.besu.consensus.merge,' +
// p2p module
'-org.hyperledger.besu.ethereum.p2p,' +
'-org.hyperledger.besu.ethereum.p2p.*,' +
// permissioning module
'-org.hyperledger.besu.ethereum.permissioning,' +
'-org.hyperledger.besu.ethereum.permissioning.*,' +
// referencetests module
'-org.hyperledger.besu.ethereum.referencetests,' +
// retesteth module
'-org.hyperledger.besu.ethereum.retesteth.methods,' +
'-org.hyperledger.besu.ethereum.retesteth,' +
//rlp module
'-org.hyperledger.besu.ethereum.rlp,' +
// stratum module
'-org.hyperledger.besu.ethereum.stratum,' +
// trie module
'-org.hyperledger.besu.ethereum.trie.*,' +
'-org.hyperledger.besu.ethereum.trie,' +
// verkle trie module
'-org.hyperledger.besu.ethereum.verkletrie,' +
'-org.hyperledger.besu.ethereum.verkletrie.*',
true)
options.addStringOption('Xmaxerrs','65535')
options.addStringOption('Xmaxwarns','65535')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Class for starting and keeping organised round timers */
public class RoundTimer {

private static final Logger LOG = LoggerFactory.getLogger(RoundTimer.class);

private final BftExecutors bftExecutors;
private Optional<ScheduledFuture<?>> currentTimerTask;
private final BftEventQueue queue;
Expand Down Expand Up @@ -71,6 +77,16 @@ public synchronized void startTimer(final ConsensusRoundIdentifier round) {

final ScheduledFuture<?> newTimerTask =
bftExecutors.scheduleTask(newTimerRunnable, expiryTime, TimeUnit.MILLISECONDS);

// Once we are up to round 2 start logging round expiries
if (round.getRoundNumber() >= 2) {
LOG.info(
"QBFT round {} expired. Moved to round {} which will expire in {} seconds",
round.getRoundNumber() - 1,
round.getRoundNumber(),
(expiryTime / 1000));
}

currentTimerTask = Optional.of(newTimerTask);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,26 @@ private <P extends Payload, M extends BftMessage<P>> void actionOrBufferMessage(
@Override
public void handleRoundChangePayload(final RoundChange message) {
final ConsensusRoundIdentifier targetRound = message.getRoundIdentifier();
LOG.trace("Received a RoundChange Payload for {}", targetRound);

LOG.debug(
"Round change from {}: block {}, round {}",
message.getAuthor(),
message.getRoundIdentifier().getSequenceNumber(),
message.getRoundIdentifier().getRoundNumber());

// Diagnostic logging (only logs anything if the chain has stalled)
roundChangeManager.storeAndLogRoundChangeSummary(message);

final MessageAge messageAge =
determineAgeOfPayload(message.getRoundIdentifier().getRoundNumber());
if (messageAge == MessageAge.PRIOR_ROUND) {
LOG.trace("Received RoundChange Payload for a prior round. targetRound={}", targetRound);
LOG.debug("Received RoundChange Payload for a prior round. targetRound={}", targetRound);
return;
}

final Optional<Collection<RoundChange>> result =
roundChangeManager.appendRoundChangeMessage(message);

if (result.isPresent()) {
LOG.debug(
"Received sufficient RoundChange messages to change round to targetRound={}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ private BaseQbftBlockHeightManager createFullBlockHeightManager(final BlockHeade
new RoundChangeManager(
BftHelpers.calculateRequiredValidatorQuorum(finalState.getValidators().size()),
messageValidatorFactory.createRoundChangeMessageValidator(
parentHeader.getNumber() + 1L, parentHeader)),
parentHeader.getNumber() + 1L, parentHeader),
finalState.getLocalAddress()),
roundFactory,
finalState.getClock(),
messageValidatorFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,51 @@ public Collection<RoundChange> createRoundChangeCertificate() {
@VisibleForTesting
final Map<ConsensusRoundIdentifier, RoundChangeStatus> roundChangeCache = Maps.newHashMap();

/** A summary of the latest round each validator is on, for diagnostic purposes only */
private final Map<Address, ConsensusRoundIdentifier> roundSummary = Maps.newHashMap();

private final long quorum;
private final RoundChangeMessageValidator roundChangeMessageValidator;
private final Address localAddress;

/**
* Instantiates a new Round change manager.
*
* @param quorum the quorum
* @param roundChangeMessageValidator the round change message validator
* @param localAddress this node's address
*/
public RoundChangeManager(
final long quorum, final RoundChangeMessageValidator roundChangeMessageValidator) {
final long quorum,
final RoundChangeMessageValidator roundChangeMessageValidator,
final Address localAddress) {
this.quorum = quorum;
this.roundChangeMessageValidator = roundChangeMessageValidator;
this.localAddress = localAddress;
}

/**
* Store the latest round for a node, and if chain is stalled log a summary of which round each
* address is on
*
* @param message the round-change message that has just been received
*/
public void storeAndLogRoundChangeSummary(final RoundChange message) {
roundSummary.put(message.getAuthor(), message.getRoundIdentifier());
if (roundChangeCache.keySet().stream()
.findFirst()
.orElse(new ConsensusRoundIdentifier(0, 0))
.getRoundNumber()
>= 2) {
LOG.info("BFT round summary (quorum = {})", quorum);
for (Map.Entry<Address, ConsensusRoundIdentifier> nextEntry : roundSummary.entrySet()) {
LOG.info(
"Address: {} Round: {} {}",
nextEntry.getKey(),
nextEntry.getValue().getRoundNumber(),
nextEntry.getKey().equals(localAddress) ? "(Local node)" : "");
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,125 @@

import org.immutables.value.Value;

/**
* The ApiConfiguration class provides configuration for the API. It includes default values for gas
* price, max logs range, gas cap, and other parameters.
*/
@Value.Immutable
@Value.Style(allParameters = true)
public abstract class ApiConfiguration {

/**
* The default lower bound coefficient for gas and priority fee. This value is used as the default
* lower bound when calculating the gas and priority fee.
*/
public static final long DEFAULT_LOWER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT = 0L;

/**
* The default upper bound coefficient for gas and priority fee. This value is used as the default
* upper bound when calculating the gas and priority fee.
*/
public static final long DEFAULT_UPPER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT = Long.MAX_VALUE;

/** Constructs a new ApiConfiguration with default values. */
protected ApiConfiguration() {}

/**
* Returns the number of blocks to consider for gas price calculations. Default value is 100.
*
* @return the number of blocks for gas price calculations
*/
@Value.Default
public long getGasPriceBlocks() {
return 100;
}

/**
* Returns the percentile to use for gas price calculations. Default value is 50.0.
*
* @return the percentile for gas price calculations
*/
@Value.Default
public double getGasPricePercentile() {
return 50.0d;
}

/**
* Returns the maximum gas price. Default value is 500 GWei.
*
* @return the maximum gas price
*/
@Value.Default
public Wei getGasPriceMax() {
return Wei.of(500_000_000_000L); // 500 GWei
}

/**
* Returns the fraction to use for gas price calculations. This is derived from the gas price
* percentile.
*
* @return the fraction for gas price calculations
*/
@Value.Derived
public double getGasPriceFraction() {
return getGasPricePercentile() / 100.0;
}

/**
* Returns the maximum range for logs. Default value is 5000.
*
* @return the maximum range for logs
*/
@Value.Default
public Long getMaxLogsRange() {
return 5000L;
}

/**
* Returns the gas cap. Default value is 0.
*
* @return the gas cap
*/
@Value.Default
public Long getGasCap() {
return 0L;
}

/**
* Returns whether gas and priority fee limiting is enabled. Default value is false.
*
* @return true if gas and priority fee limiting is enabled, false otherwise
*/
@Value.Default
public boolean isGasAndPriorityFeeLimitingEnabled() {
return false;
}

/**
* Returns the lower bound coefficient for gas and priority fee. Default value is 0.
*
* @return the lower bound coefficient for gas and priority fee
*/
@Value.Default
public Long getLowerBoundGasAndPriorityFeeCoefficient() {
return DEFAULT_LOWER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT;
}

/**
* Returns the upper bound coefficient for gas and priority fee. Default value is Long.MAX_VALUE.
*
* @return the upper bound coefficient for gas and priority fee
*/
@Value.Default
public Long getUpperBoundGasAndPriorityFeeCoefficient() {
return DEFAULT_UPPER_BOUND_GAS_AND_PRIORITY_FEE_COEFFICIENT;
}

/**
* Returns the maximum range for trace filter. Default value is 1000.
*
* @return the maximum range for trace filter
*/
@Value.Default
public Long getMaxTraceFilterRange() {
return 1000L;
Expand Down
Loading

0 comments on commit 14ee678

Please sign in to comment.