Skip to content

Commit

Permalink
Merge millisecond blocks with empty blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <[email protected]>
  • Loading branch information
matthew1001 committed Sep 20, 2024
1 parent 62e4e24 commit c38970d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,28 @@ public synchronized boolean isRunning() {
*/
public synchronized void startTimer(
final ConsensusRoundIdentifier round, final BlockHeader chainHeadHeader) {
// cancelTimer();
//
// final long now = clock.millis();
// final long expiryTime;
cancelTimer();

final long expiryTime;

// Experimental option for test scenarios only. Not for production use.
// final long blockPeriodMilliseconds =
//
// forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodMilliseconds();
//
// if (blockPeriodMilliseconds > 0) {
// // Experimental mode for setting < 1 second block periods e.g. for CI/CD pipelines
// // running tests against Besu
// expiryTime = clock.millis() + blockPeriodMilliseconds;
// LOG.warn(
// "Test-mode only xblockperiodmilliseconds has been set to {} millisecond blocks. Do
// not use in a production system.",
// blockPeriodMilliseconds);
// } else {
// // absolute time when the timer is supposed to expire
// final int blockPeriodSeconds =
// forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodSeconds();
// final long minimumTimeBetweenBlocksMillis = blockPeriodSeconds * 1000L;
// expiryTime = chainHeadHeader.getTimestamp() * 1_000 + minimumTimeBetweenBlocksMillis;
// }

// absolute time when the timer is supposed to expire
final int currentBlockPeriodSeconds =
forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodSeconds();
final long minimumTimeBetweenBlocksMillis = currentBlockPeriodSeconds * 1000L;
final long expiryTime = chainHeadHeader.getTimestamp() * 1_000 + minimumTimeBetweenBlocksMillis;
final long blockPeriodMilliseconds =
forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodMilliseconds();

if (blockPeriodMilliseconds > 0) {
// Experimental mode for setting < 1 second block periods e.g. for CI/CD pipelines
// running tests against Besu
expiryTime = clock.millis() + blockPeriodMilliseconds;
LOG.warn(
"Test-mode only xblockperiodmilliseconds has been set to {} millisecond blocks. Do not use in a production system.",
blockPeriodMilliseconds);
} else {
// absolute time when the timer is supposed to expire
final int currentBlockPeriodSeconds =
forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodSeconds();
final long minimumTimeBetweenBlocksMillis = currentBlockPeriodSeconds * 1000L;
expiryTime = chainHeadHeader.getTimestamp() * 1_000 + minimumTimeBetweenBlocksMillis;
}

setBlockTimes(round);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,6 @@ public Block createBlock(final long headerTimeStampSeconds) {
return blockCreator.createBlock(headerTimeStampSeconds, this.parentHeader).getBlock();
}

/**
* Create and send proposal message.
*
* @param headerTimeStampSeconds the header time stamp seconds
*/
// public void createAndSendProposalMessage(final long headerTimeStampSeconds) {
// LOG.debug("Creating proposed block. round={}", roundState.getRoundIdentifier());
// final Block block =
// blockCreator.createBlock(headerTimeStampSeconds, this.parentHeader).getBlock();
//
// LOG.trace("Creating proposed block blockHeader={}", block.getHeader());
// updateStateWithProposalAndTransmit(block, emptyList(), emptyList());
// }

/**
* Start round with.
*
Expand Down

0 comments on commit c38970d

Please sign in to comment.