From 1568133fbcce24bd8618a62fdc8d9046b95ec6dc Mon Sep 17 00:00:00 2001 From: Leni Date: Sun, 23 Jun 2024 02:56:45 +0800 Subject: [PATCH 1/2] fix the synchronizer usage Signed-off-by: Leni --- .../common/bft/statemachine/BaseBftController.java | 10 +++++----- .../consensus/ibft/statemachine/IbftController.java | 6 +++--- .../consensus/qbft/statemachine/QbftController.java | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java index e35af1af646..c5b3cc9ce9b 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java @@ -44,7 +44,7 @@ public abstract class BaseBftController implements BftEventHandler { private final FutureMessageBuffer futureMessageBuffer; private final Gossiper gossiper; private final MessageTracker duplicateMessageTracker; - private final SynchronizerUpdater sychronizerUpdater; + private final SynchronizerUpdater synchronizerUpdater; private final AtomicBoolean started = new AtomicBoolean(false); @@ -56,7 +56,7 @@ public abstract class BaseBftController implements BftEventHandler { * @param gossiper the gossiper * @param duplicateMessageTracker the duplicate message tracker * @param futureMessageBuffer the future message buffer - * @param sychronizerUpdater the synchronizer updater + * @param synchronizerUpdater the synchronizer updater */ protected BaseBftController( final Blockchain blockchain, @@ -64,13 +64,13 @@ protected BaseBftController( final Gossiper gossiper, final MessageTracker duplicateMessageTracker, final FutureMessageBuffer futureMessageBuffer, - final SynchronizerUpdater sychronizerUpdater) { + final SynchronizerUpdater synchronizerUpdater) { this.blockchain = blockchain; this.bftFinalState = bftFinalState; this.futureMessageBuffer = futureMessageBuffer; this.gossiper = gossiper; this.duplicateMessageTracker = duplicateMessageTracker; - this.sychronizerUpdater = sychronizerUpdater; + this.synchronizerUpdater = synchronizerUpdater; } @Override @@ -221,7 +221,7 @@ private boolean processMessage(final BftMessage msg, final Message rawMsg) { futureMessageBuffer.addMessage(msgRoundIdentifier.getSequenceNumber(), rawMsg); // Notify the synchronizer the transmitting peer must have the parent block to the received // message's target height. - sychronizerUpdater.updatePeerChainState( + synchronizerUpdater.updatePeerChainState( msgRoundIdentifier.getSequenceNumber() - 1L, rawMsg.getConnection()); } else { LOG.trace( diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftController.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftController.java index c19bd9f1958..e2156bd7d6c 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftController.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftController.java @@ -46,7 +46,7 @@ public class IbftController extends BaseBftController { * @param gossiper the gossiper * @param duplicateMessageTracker the duplicate message tracker * @param futureMessageBuffer the future message buffer - * @param sychronizerUpdater the synchronizer updater + * @param synchronizerUpdater the synchronizer updater */ public IbftController( final Blockchain blockchain, @@ -55,7 +55,7 @@ public IbftController( final Gossiper gossiper, final MessageTracker duplicateMessageTracker, final FutureMessageBuffer futureMessageBuffer, - final SynchronizerUpdater sychronizerUpdater) { + final SynchronizerUpdater synchronizerUpdater) { super( blockchain, @@ -63,7 +63,7 @@ public IbftController( gossiper, duplicateMessageTracker, futureMessageBuffer, - sychronizerUpdater); + synchronizerUpdater); this.ibftBlockHeightManagerFactory = ibftBlockHeightManagerFactory; } diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java index bd2751ff321..57737542eaf 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java @@ -48,7 +48,7 @@ public class QbftController extends BaseBftController { * @param gossiper the gossiper * @param duplicateMessageTracker the duplicate message tracker * @param futureMessageBuffer the future message buffer - * @param sychronizerUpdater the synchronizer updater + * @param synchronizerUpdater the synchronizer updater * @param bftExtraDataCodec the bft extra data codec */ public QbftController( @@ -58,7 +58,7 @@ public QbftController( final Gossiper gossiper, final MessageTracker duplicateMessageTracker, final FutureMessageBuffer futureMessageBuffer, - final SynchronizerUpdater sychronizerUpdater, + final SynchronizerUpdater synchronizerUpdater, final BftExtraDataCodec bftExtraDataCodec) { super( @@ -67,7 +67,7 @@ public QbftController( gossiper, duplicateMessageTracker, futureMessageBuffer, - sychronizerUpdater); + synchronizerUpdater); this.qbftBlockHeightManagerFactory = qbftBlockHeightManagerFactory; this.bftExtraDataCodec = bftExtraDataCodec; } From 3636c1ecfdf3d9b1654eed0f2a02149c6c204474 Mon Sep 17 00:00:00 2001 From: Leni Date: Sun, 23 Jun 2024 02:58:53 +0800 Subject: [PATCH 2/2] fix Identifier usage Signed-off-by: Leni --- .../consensus/common/bft/events/BlockTimerExpiry.java | 4 ++-- .../common/bft/statemachine/BaseBftController.java | 8 ++++---- .../besu/consensus/common/bft/BlockTimerTest.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/events/BlockTimerExpiry.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/events/BlockTimerExpiry.java index 3027e0dca5d..d57e981efc4 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/events/BlockTimerExpiry.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/events/BlockTimerExpiry.java @@ -41,9 +41,9 @@ public BftEvents.Type getType() { /** * Gets round identifier. * - * @return the round indentifier + * @return the round Identifier */ - public ConsensusRoundIdentifier getRoundIndentifier() { + public ConsensusRoundIdentifier getRoundIdentifier() { return roundIdentifier; } diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java index c5b3cc9ce9b..58d579f28e1 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java @@ -162,14 +162,14 @@ public void handleNewBlockEvent(final NewChainHead newChainHead) { @Override public void handleBlockTimerExpiry(final BlockTimerExpiry blockTimerExpiry) { - final ConsensusRoundIdentifier roundIndentifier = blockTimerExpiry.getRoundIndentifier(); - if (isMsgForCurrentHeight(roundIndentifier)) { - getCurrentHeightManager().handleBlockTimerExpiry(roundIndentifier); + final ConsensusRoundIdentifier roundIdentifier = blockTimerExpiry.getRoundIdentifier(); + if (isMsgForCurrentHeight(roundIdentifier)) { + getCurrentHeightManager().handleBlockTimerExpiry(roundIdentifier); } else { LOG.trace( "Block timer event discarded as it is not for current block height chainHeight={} eventHeight={}", getCurrentHeightManager().getChainHeight(), - roundIndentifier.getSequenceNumber()); + roundIdentifier.getSequenceNumber()); } } diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java index 23026148114..70187a4d40d 100644 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java +++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java @@ -141,7 +141,7 @@ public void aBlockTimerExpiryEventIsAddedToTheQueueOnExpiry() throws Interrupted assertThat(eventQueue.size()).isEqualTo(1); final BftEvent queuedEvent = eventQueue.poll(0, TimeUnit.SECONDS); assertThat(queuedEvent).isInstanceOf(BlockTimerExpiry.class); - assertThat(((BlockTimerExpiry) queuedEvent).getRoundIndentifier()) + assertThat(((BlockTimerExpiry) queuedEvent).getRoundIdentifier()) .usingRecursiveComparison() .isEqualTo(round); } @@ -171,7 +171,7 @@ public void eventIsImmediatelyAddedToTheQueueIfAbsoluteExpiryIsEqualToNow() { verify(mockQueue).add(bftEventCaptor.capture()); assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue(); - assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier()) + assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIdentifier()) .usingRecursiveComparison() .isEqualTo(round); } @@ -201,7 +201,7 @@ public void eventIsImmediatelyAddedToTheQueueIfAbsoluteExpiryIsInThePast() { verify(mockQueue).add(bftEventCaptor.capture()); assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue(); - assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier()) + assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIdentifier()) .usingRecursiveComparison() .isEqualTo(round); }