Search in sources :

Example 1 with ValidatorPeer

use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.

the class ReceivedFutureProposalTest method proposalWithPrepareCertificateResultsInNewRoundStartingWithExpectedBlock.

@Test
public void proposalWithPrepareCertificateResultsInNewRoundStartingWithExpectedBlock() {
    final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
    final Block reproposedBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
    final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
    final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
    final List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
    final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
    nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares, reproposedBlock);
    peers.verifyMessagesReceived(localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Block(org.hyperledger.besu.ethereum.core.Block) IntegrationTestHelpers.createValidPreparedCertificate(org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate) PreparedCertificate(org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate) Test(org.junit.jupiter.api.Test)

Example 2 with ValidatorPeer

use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.

the class ReceivedFutureProposalTest method futureProposalWithInsufficientPreparesDoesNotTriggerNextRound.

@Test
public void futureProposalWithInsufficientPreparesDoesNotTriggerNextRound() {
    final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
    final Block reproposedBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
    final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
    final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
    final List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
    final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
    nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares.subList(0, 2), reproposedBlock);
    peers.verifyNoMessagesReceived();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Block(org.hyperledger.besu.ethereum.core.Block) IntegrationTestHelpers.createValidPreparedCertificate(org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate) PreparedCertificate(org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate) Test(org.junit.jupiter.api.Test)

Example 3 with ValidatorPeer

use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.

the class ReceivedFutureProposalTest method proposalWithEmptyPrepareCertificatesOfferNewBlock.

@Test
public void proposalWithEmptyPrepareCertificatesOfferNewBlock() {
    final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(targetRound);
    final ValidatorPeer nextProposer = context.roundSpecificPeers(targetRound).getProposer();
    final Block blockToPropose = context.createBlockForProposalFromChainHead(15, nextProposer.getNodeAddress());
    nextProposer.injectProposalForFutureRound(targetRound, roundChanges, Collections.emptyList(), blockToPropose);
    final Prepare expectedPrepare = localNodeMessageFactory.createPrepare(targetRound, blockToPropose.getHash());
    peers.verifyMessagesReceived(expectedPrepare);
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Block(org.hyperledger.besu.ethereum.core.Block) Prepare(org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare) Test(org.junit.jupiter.api.Test)

Example 4 with ValidatorPeer

use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.

the class ReceivedFutureProposalTest method futureProposalWithInvalidPrepareDoesNotTriggerNextRound.

@Test
public void futureProposalWithInvalidPrepareDoesNotTriggerNextRound() {
    final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
    final Block reproposedBlock = context.createBlockForProposalFromChainHead(15);
    final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
    final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
    List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
    prepares = prepares.stream().filter(p -> !p.getAuthor().equals(peers.getFirstNonProposer().getNodeAddress())).collect(Collectors.toList());
    final SignedData<PreparePayload> invalidPrepare = peers.getFirstNonProposer().getMessageFactory().createPrepare(nextRoundId, initialBlock.getHash()).getSignedPayload();
    prepares.add(invalidPrepare);
    final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
    nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares, reproposedBlock);
    peers.verifyNoMessagesReceived();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) PreparePayload(org.hyperledger.besu.consensus.qbft.payload.PreparePayload) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Block(org.hyperledger.besu.ethereum.core.Block) IntegrationTestHelpers.createValidPreparedCertificate(org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate) PreparedCertificate(org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate) Test(org.junit.jupiter.api.Test)

Example 5 with ValidatorPeer

use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.

the class SpuriousBehaviourTest method nonValidatorsCannotTriggerResponses.

@Test
public void nonValidatorsCannotTriggerResponses() {
    final NodeKey nonValidatorNodeKey = NodeKeyUtils.generate();
    final NodeParams nonValidatorParams = new NodeParams(Util.publicKeyToAddress(nonValidatorNodeKey.getPublicKey()), nonValidatorNodeKey);
    final ValidatorPeer nonvalidator = new ValidatorPeer(nonValidatorParams, new MessageFactory(nonValidatorParams.getNodeKey()), context.getEventMultiplexer());
    nonvalidator.injectProposal(new ConsensusRoundIdentifier(1, 0), proposedBlock);
    peers.verifyNoMessagesReceived();
}
Also used : ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) MessageFactory(org.hyperledger.besu.consensus.qbft.payload.MessageFactory) NodeKey(org.hyperledger.besu.crypto.NodeKey) NodeParams(org.hyperledger.besu.consensus.common.bft.inttest.NodeParams) Test(org.junit.jupiter.api.Test)

Aggregations

ValidatorPeer (org.hyperledger.besu.consensus.qbft.support.ValidatorPeer)12 Test (org.junit.jupiter.api.Test)11 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)10 SignedData (org.hyperledger.besu.consensus.common.bft.payload.SignedData)7 Block (org.hyperledger.besu.ethereum.core.Block)7 PreparedCertificate (org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate)4 IntegrationTestHelpers.createValidPreparedCertificate (org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate)4 MessageFactory (org.hyperledger.besu.consensus.qbft.payload.MessageFactory)2 RoundSpecificPeers (org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers)2 NewChainHead (org.hyperledger.besu.consensus.common.bft.events.NewChainHead)1 NodeParams (org.hyperledger.besu.consensus.common.bft.inttest.NodeParams)1 Commit (org.hyperledger.besu.consensus.qbft.messagewrappers.Commit)1 Prepare (org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare)1 Proposal (org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal)1 PreparePayload (org.hyperledger.besu.consensus.qbft.payload.PreparePayload)1 NodeKey (org.hyperledger.besu.crypto.NodeKey)1 SECPSignature (org.hyperledger.besu.crypto.SECPSignature)1