mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 15:37:54 -05:00
Dev/test option for short BFT block periods (#7588)
* Dev mode for short BFT block periods Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactoring Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix comment Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor to make BFT block milliseconds an experimental QBFT config option Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update Json BFT config options Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
This commit is contained in:
@@ -37,6 +37,13 @@ public interface BftConfigOptions {
|
||||
*/
|
||||
int getBlockPeriodSeconds();
|
||||
|
||||
/**
|
||||
* Gets block period milliseconds. For TESTING only. If set then blockperiodseconds is ignored.
|
||||
*
|
||||
* @return the block period milliseconds
|
||||
*/
|
||||
long getBlockPeriodMilliseconds();
|
||||
|
||||
/**
|
||||
* Gets request timeout seconds.
|
||||
*
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
@@ -40,6 +41,9 @@ public class BftFork implements Fork {
|
||||
/** The constant BLOCK_PERIOD_SECONDS_KEY. */
|
||||
public static final String BLOCK_PERIOD_SECONDS_KEY = "blockperiodseconds";
|
||||
|
||||
/** The constant BLOCK_PERIOD_MILLISECONDS_KEY. */
|
||||
public static final String BLOCK_PERIOD_MILLISECONDS_KEY = "xblockperiodmilliseconds";
|
||||
|
||||
/** The constant BLOCK_REWARD_KEY. */
|
||||
public static final String BLOCK_REWARD_KEY = "blockreward";
|
||||
|
||||
@@ -82,6 +86,15 @@ public class BftFork implements Fork {
|
||||
return JsonUtil.getPositiveInt(forkConfigRoot, BLOCK_PERIOD_SECONDS_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block period milliseconds. Experimental for test scenarios only.
|
||||
*
|
||||
* @return the block period milliseconds
|
||||
*/
|
||||
public OptionalLong getBlockPeriodMilliseconds() {
|
||||
return JsonUtil.getLong(forkConfigRoot, BLOCK_PERIOD_MILLISECONDS_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block reward wei.
|
||||
*
|
||||
|
||||
@@ -34,6 +34,7 @@ public class JsonBftConfigOptions implements BftConfigOptions {
|
||||
|
||||
private static final long DEFAULT_EPOCH_LENGTH = 30_000;
|
||||
private static final int DEFAULT_BLOCK_PERIOD_SECONDS = 1;
|
||||
private static final int DEFAULT_BLOCK_PERIOD_MILLISECONDS = 0; // Experimental for test only
|
||||
private static final int DEFAULT_ROUND_EXPIRY_SECONDS = 1;
|
||||
// In a healthy network this can be very small. This default limit will allow for suitable
|
||||
// protection for on a typical 20 node validator network with multiple rounds
|
||||
@@ -66,6 +67,12 @@ public class JsonBftConfigOptions implements BftConfigOptions {
|
||||
bftConfigRoot, "blockperiodseconds", DEFAULT_BLOCK_PERIOD_SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBlockPeriodMilliseconds() {
|
||||
return JsonUtil.getLong(
|
||||
bftConfigRoot, "xblockperiodmilliseconds", DEFAULT_BLOCK_PERIOD_MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequestTimeoutSeconds() {
|
||||
return JsonUtil.getInt(bftConfigRoot, "requesttimeoutseconds", DEFAULT_ROUND_EXPIRY_SECONDS);
|
||||
@@ -133,6 +140,9 @@ public class JsonBftConfigOptions implements BftConfigOptions {
|
||||
if (bftConfigRoot.has("blockperiodseconds")) {
|
||||
builder.put("blockPeriodSeconds", getBlockPeriodSeconds());
|
||||
}
|
||||
if (bftConfigRoot.has("xblockperiodmilliseconds")) {
|
||||
builder.put("xBlockPeriodMilliSeconds", getBlockPeriodMilliseconds());
|
||||
}
|
||||
if (bftConfigRoot.has("requesttimeoutseconds")) {
|
||||
builder.put("requestTimeoutSeconds", getRequestTimeoutSeconds());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user