QBFT out of early access (#3475)

* QBFT out of early access
* Fixing typo IBFT -> QBFT (fixes #3452)

Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
pull/3476/head
Lucas Saldanha 3 years ago committed by GitHub
parent d48ad35e99
commit fb70ba4535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/IntegrationTestHelpers.java
  3. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  4. 4
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftGossip.java
  5. 2
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java
  6. 62
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftControllerTest.java

@ -14,6 +14,7 @@
- Add header validation rules needed to validate The Merge blocks [#3454](https://github.com/hyperledger/besu/pull/3454)
- Add core components: controller builder, protocol scheduler, coordinator, block creator and processor. [#3461](https://github.com/hyperledger/besu/pull/3461)
- Execution specific RPC endpoint [#2914](https://github.com/hyperledger/besu/issues/2914), [#3350](https://github.com/hyperledger/besu/pull/3350)
- QBFT consensus algorithm is production ready
### Bug Fixes

@ -32,12 +32,12 @@ public class IntegrationTestHelpers {
public static SignedData<CommitPayload> createSignedCommitPayload(
final ConsensusRoundIdentifier roundId, final Block block, final NodeKey nodeKey) {
final QbftExtraDataCodec ibftExtraDataEncoder = new QbftExtraDataCodec();
final QbftExtraDataCodec qbftExtraDataEncoder = new QbftExtraDataCodec();
final Block commitBlock = createCommitBlockFromProposalBlock(block, roundId.getRoundNumber());
final SECPSignature commitSeal =
nodeKey.sign(
new BftBlockHashing(ibftExtraDataEncoder)
new BftBlockHashing(qbftExtraDataEncoder)
.calculateDataHashForCommittedSeal(commitBlock.getHeader()));
final MessageFactory messageFactory = new MessageFactory(nodeKey);

@ -448,7 +448,7 @@ public class TestContextBuilder {
final Address localAddress = Util.publicKeyToAddress(nodeKey.getPublicKey());
final BftBlockCreatorFactory blockCreatorFactory =
new QbftBlockCreatorFactory(
pendingTransactions, // changed from IbftBesuController
pendingTransactions, // changed from QbftBesuController
protocolContext,
protocolSchedule,
miningParams,
@ -512,7 +512,7 @@ public class TestContextBuilder {
BFT_EXTRA_DATA_ENCODER);
final EventMultiplexer eventMultiplexer = new EventMultiplexer(qbftController);
//////////////////////////// END IBFT BesuController ////////////////////////////
//////////////////////////// END QBFT BesuController ////////////////////////////
return new ControllerAndState(
bftExecutors,

@ -31,7 +31,7 @@ import java.util.List;
import com.google.common.collect.Lists;
/** Class responsible for rebroadcasting IBFT messages to known validators */
/** Class responsible for rebroadcasting QBFT messages to known validators */
public class QbftGossip implements Gossiper {
private final ValidatorMulticaster multicaster;
@ -74,7 +74,7 @@ public class QbftGossip implements Gossiper {
break;
default:
throw new IllegalArgumentException(
"Received message does not conform to any recognised IBFT message structure.");
"Received message does not conform to any recognised QBFT message structure.");
}
final List<Address> excludeAddressesList =
Lists.newArrayList(

@ -154,7 +154,7 @@ public class QbftBlockHeightManagerTest {
setupContextWithBftExtraDataEncoder(
QbftContext.class, validators, new QbftExtraDataCodec()));
// Ensure the created IbftRound has the valid ConsensusRoundIdentifier;
// Ensure the created QbftRound has the valid ConsensusRoundIdentifier;
when(roundFactory.createNewRound(any(), anyInt()))
.thenAnswer(
invocation -> {

@ -96,7 +96,7 @@ public class QbftControllerTest {
private final ConsensusRoundIdentifier futureRoundIdentifier = new ConsensusRoundIdentifier(5, 0);
private final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(4, 0);
private final ConsensusRoundIdentifier pastRoundIdentifier = new ConsensusRoundIdentifier(3, 0);
@Mock private QbftGossip ibftGossip;
@Mock private QbftGossip qbftGossip;
@Mock private FutureMessageBuffer futureMessageBuffer;
private QbftController qbftController;
@ -119,13 +119,13 @@ public class QbftControllerTest {
when(messageTracker.hasSeenMessage(any())).thenReturn(false);
}
private void constructIbftController() {
private void constructQbftController() {
qbftController =
new QbftController(
blockChain,
bftFinalState,
blockHeightManagerFactory,
ibftGossip,
qbftGossip,
messageTracker,
futureMessageBuffer,
mock(EthSynchronizerUpdater.class),
@ -134,7 +134,7 @@ public class QbftControllerTest {
@Test
public void createsNewBlockHeightManagerWhenStarted() {
constructIbftController();
constructQbftController();
verify(blockHeightManagerFactory, never()).create(chainHeadBlockHeader);
qbftController.start();
@ -155,7 +155,7 @@ public class QbftControllerTest {
when(blockHeightManager.getChainHeight()).thenReturn(5L);
when(futureMessageBuffer.retrieveMessagesForHeight(5L)).thenReturn(height2Msgs);
constructIbftController();
constructQbftController();
qbftController.start();
verify(futureMessageBuffer).retrieveMessagesForHeight(5L);
@ -164,11 +164,11 @@ public class QbftControllerTest {
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verify(blockHeightManager, never()).handleProposalPayload(proposal);
verify(blockHeightManager).handlePreparePayload(prepare);
verify(ibftGossip).send(prepareMessage);
verify(qbftGossip).send(prepareMessage);
verify(blockHeightManager).handleCommitPayload(commit);
verify(ibftGossip).send(commitMessage);
verify(qbftGossip).send(commitMessage);
verify(blockHeightManager).handleRoundChangePayload(roundChange);
verify(ibftGossip).send(roundChangeMessage);
verify(qbftGossip).send(roundChangeMessage);
}
@Test
@ -184,7 +184,7 @@ public class QbftControllerTest {
.thenReturn(emptyList());
when(blockHeightManager.getChainHeight()).thenReturn(5L);
constructIbftController();
constructQbftController();
qbftController.start();
final NewChainHead newChainHead = new NewChainHead(nextBlock);
qbftController.handleNewBlockEvent(newChainHead);
@ -193,18 +193,18 @@ public class QbftControllerTest {
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verify(futureMessageBuffer, times(2)).retrieveMessagesForHeight(5L);
verify(blockHeightManager).handleProposalPayload(proposal);
verify(ibftGossip).send(proposalMessage);
verify(qbftGossip).send(proposalMessage);
verify(blockHeightManager).handlePreparePayload(prepare);
verify(ibftGossip).send(prepareMessage);
verify(qbftGossip).send(prepareMessage);
verify(blockHeightManager).handleCommitPayload(commit);
verify(ibftGossip).send(commitMessage);
verify(qbftGossip).send(commitMessage);
verify(blockHeightManager).handleRoundChangePayload(roundChange);
verify(ibftGossip).send(roundChangeMessage);
verify(qbftGossip).send(roundChangeMessage);
}
@Test
public void newBlockForCurrentOrPreviousHeightTriggersNoChange() {
constructIbftController();
constructQbftController();
qbftController.start();
long chainHeadHeight = chainHeadBlockHeader.getNumber();
when(nextBlock.getNumber()).thenReturn(chainHeadHeight);
@ -223,7 +223,7 @@ public class QbftControllerTest {
public void handlesRoundExpiry() {
final RoundExpiry roundExpiry = new RoundExpiry(roundIdentifier);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleRoundExpiry(roundExpiry);
@ -234,7 +234,7 @@ public class QbftControllerTest {
public void handlesBlockTimerExpiry() {
final BlockTimerExpiry blockTimerExpiry = new BlockTimerExpiry(roundIdentifier);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleBlockTimerExpiry(blockTimerExpiry);
@ -244,13 +244,13 @@ public class QbftControllerTest {
@Test
public void proposalForCurrentHeightIsPassedToBlockHeightManager() {
setupProposal(roundIdentifier, validator);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(proposalMessage));
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
verify(blockHeightManager).handleProposalPayload(proposal);
verify(ibftGossip).send(proposalMessage);
verify(qbftGossip).send(proposalMessage);
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verifyNoMoreInteractions(blockHeightManager);
}
@ -258,13 +258,13 @@ public class QbftControllerTest {
@Test
public void prepareForCurrentHeightIsPassedToBlockHeightManager() {
setupPrepare(roundIdentifier, validator);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(prepareMessage));
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
verify(blockHeightManager).handlePreparePayload(prepare);
verify(ibftGossip).send(prepareMessage);
verify(qbftGossip).send(prepareMessage);
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verifyNoMoreInteractions(blockHeightManager);
}
@ -272,13 +272,13 @@ public class QbftControllerTest {
@Test
public void commitForCurrentHeightIsPassedToBlockHeightManager() {
setupCommit(roundIdentifier, validator);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(commitMessage));
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
verify(blockHeightManager).handleCommitPayload(commit);
verify(ibftGossip).send(commitMessage);
verify(qbftGossip).send(commitMessage);
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verifyNoMoreInteractions(blockHeightManager);
}
@ -286,13 +286,13 @@ public class QbftControllerTest {
@Test
public void roundChangeForCurrentHeightIsPassedToBlockHeightManager() {
setupRoundChange(roundIdentifier, validator);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(roundChangeMessage));
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
verify(blockHeightManager).handleRoundChangePayload(roundChange);
verify(ibftGossip).send(roundChangeMessage);
verify(qbftGossip).send(roundChangeMessage);
verify(blockHeightManager, atLeastOnce()).getChainHeight();
verifyNoMoreInteractions(blockHeightManager);
}
@ -324,7 +324,7 @@ public class QbftControllerTest {
@Test
public void roundExpiryForPastHeightIsDiscarded() {
final RoundExpiry roundExpiry = new RoundExpiry(pastRoundIdentifier);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleRoundExpiry(roundExpiry);
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
@ -334,7 +334,7 @@ public class QbftControllerTest {
@Test
public void blockTimerForPastHeightIsDiscarded() {
final BlockTimerExpiry blockTimerExpiry = new BlockTimerExpiry(pastRoundIdentifier);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleBlockTimerExpiry(blockTimerExpiry);
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
@ -401,7 +401,7 @@ public class QbftControllerTest {
public void uniqueMessagesAreAddedAsSeen() {
when(messageTracker.hasSeenMessage(proposalMessageData)).thenReturn(false);
setupProposal(roundIdentifier, validator);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(proposalMessage));
@ -411,7 +411,7 @@ public class QbftControllerTest {
@Test
public void messagesWhichAreAboveHeightManagerButBelowBlockChainLengthAreDiscarded() {
// NOTE: for this to occur, the system would need to be synchronising - i.e. blockchain is
// moving up faster than ibft loop is handling NewBlock messages
// moving up faster than qbft loop is handling NewBlock messages
final long blockchainLength = 10L;
final long blockHeightManagerTargettingBlock = 6L;
final long messageHeight = 8L;
@ -422,7 +422,7 @@ public class QbftControllerTest {
when(blockHeightManagerFactory.create(any())).thenReturn(blockHeightManager);
when(blockHeightManager.getChainHeight()).thenReturn(blockHeightManagerTargettingBlock);
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(proposalMessage));
verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
@ -430,7 +430,7 @@ public class QbftControllerTest {
}
private void verifyNotHandledAndNoFutureMsgs(final BftReceivedMessageEvent msg) {
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(msg);
@ -440,7 +440,7 @@ public class QbftControllerTest {
}
private void verifyHasFutureMessages(final long msgHeight, final Message message) {
constructIbftController();
constructQbftController();
qbftController.start();
qbftController.handleMessageEvent(new BftReceivedMessageEvent(message));

Loading…
Cancel
Save