Search in sources :

Example 1 with ValidatorPeer

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

the class ReceivedFutureProposalTest method proposalMessageForPriorRoundIsNotActioned.

@Test
public void proposalMessageForPriorRoundIsNotActioned() {
    // first move to a future round, then inject a proposal for a prior round, local node
    // should send no messages.
    final ConsensusRoundIdentifier futureRound = new ConsensusRoundIdentifier(1, 2);
    peers.roundChange(futureRound);
    final ConsensusRoundIdentifier interimRound = new ConsensusRoundIdentifier(1, 1);
    final List<SignedData<RoundChangePayload>> roundChangePayloads = peers.createSignedRoundChangePayload(interimRound);
    final ValidatorPeer interimRoundProposer = context.roundSpecificPeers(interimRound).getProposer();
    interimRoundProposer.injectProposalForFutureRound(interimRound, new RoundChangeCertificate(roundChangePayloads), context.createBlockForProposalFromChainHead(1, 30));
    peers.verifyNoMessagesReceived();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.ibft.support.ValidatorPeer) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) RoundChangeCertificate(org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate) Test(org.junit.jupiter.api.Test)

Example 2 with ValidatorPeer

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

the class ReceivedFutureProposalTest method receiveRoundStateIsNotLostIfASecondProposalMessageIsReceivedForCurrentRound.

@Test
public void receiveRoundStateIsNotLostIfASecondProposalMessageIsReceivedForCurrentRound() {
    final Block initialBlock = context.createBlockForProposalFromChainHead(0, 15);
    final Block reproposedBlock = context.createBlockForProposalFromChainHead(1, 15);
    final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
    final PreparedRoundArtifacts preparedRoundArtifacts = createValidPreparedRoundArtifacts(context, roundId, initialBlock);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
    final RoundSpecificPeers nextRoles = context.roundSpecificPeers(nextRoundId);
    final ValidatorPeer nextProposer = nextRoles.getProposer();
    nextProposer.injectProposalForFutureRound(nextRoundId, new RoundChangeCertificate(roundChanges), reproposedBlock);
    peers.verifyMessagesReceived(localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
    // Inject a prepare, then re-inject the proposal - then ensure only a single prepare is enough
    // to trigger a Commit transmission from the local node
    nextRoles.getNonProposing(0).injectPrepare(nextRoundId, reproposedBlock.getHash());
    nextProposer.injectProposalForFutureRound(nextRoundId, new RoundChangeCertificate(roundChanges), reproposedBlock);
    peers.verifyNoMessagesReceived();
    nextRoles.getNonProposing(1).injectPrepare(nextRoundId, reproposedBlock.getHash());
    final Commit expectedCommit = new Commit(IntegrationTestHelpers.createSignedCommitPayload(nextRoundId, reproposedBlock, context.getLocalNodeParams().getNodeKey()));
    peers.verifyMessagesReceived(expectedCommit);
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.ibft.support.ValidatorPeer) Commit(org.hyperledger.besu.consensus.ibft.messagewrappers.Commit) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) RoundChangeCertificate(org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate) RoundSpecificPeers(org.hyperledger.besu.consensus.ibft.support.RoundSpecificPeers) Block(org.hyperledger.besu.ethereum.core.Block) PreparedRoundArtifacts(org.hyperledger.besu.consensus.ibft.statemachine.PreparedRoundArtifacts) IntegrationTestHelpers.createValidPreparedRoundArtifacts(org.hyperledger.besu.consensus.ibft.support.IntegrationTestHelpers.createValidPreparedRoundArtifacts) Test(org.junit.jupiter.api.Test)

Example 3 with ValidatorPeer

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

the class ReceivedFutureProposalTest method proposalWithEmptyPrepareCertificatesOfferNewBlock.

@Test
public void proposalWithEmptyPrepareCertificatesOfferNewBlock() {
    final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
    final Block blockToPropose = context.createBlockForProposalFromChainHead(nextRoundId.getRoundNumber(), 15);
    final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
    final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(targetRound);
    final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
    nextProposer.injectProposalForFutureRound(targetRound, new RoundChangeCertificate(roundChanges), 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.ibft.support.ValidatorPeer) SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) RoundChangeCertificate(org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate) Block(org.hyperledger.besu.ethereum.core.Block) Prepare(org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare) Test(org.junit.jupiter.api.Test)

Example 4 with ValidatorPeer

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

the class RoundChangeTest method multipleRoundChangeMessagesFromSamePeerDoesNotTriggerRoundChange.

@Test
public void multipleRoundChangeMessagesFromSamePeerDoesNotTriggerRoundChange() {
    // Note: Round-3 is the next round for which the local node is Proposer
    final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 4);
    final ValidatorPeer transmitter = peers.getNonProposing(0);
    for (int i = 0; i < BftHelpers.calculateRequiredValidatorQuorum(NETWORK_SIZE); i++) {
        transmitter.injectRoundChange(targetRound, empty());
    }
    peers.verifyNoMessagesReceived();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) ValidatorPeer(org.hyperledger.besu.consensus.ibft.support.ValidatorPeer) Test(org.junit.jupiter.api.Test)

Example 5 with ValidatorPeer

use of org.hyperledger.besu.consensus.ibft.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.ibft.support.ValidatorPeer) ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) MessageFactory(org.hyperledger.besu.consensus.ibft.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.ibft.support.ValidatorPeer)9 Test (org.junit.jupiter.api.Test)9 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)7 SignedData (org.hyperledger.besu.consensus.common.bft.payload.SignedData)5 RoundChangeCertificate (org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate)5 Block (org.hyperledger.besu.ethereum.core.Block)4 MessageFactory (org.hyperledger.besu.consensus.ibft.payload.MessageFactory)2 PreparedRoundArtifacts (org.hyperledger.besu.consensus.ibft.statemachine.PreparedRoundArtifacts)2 IntegrationTestHelpers.createValidPreparedRoundArtifacts (org.hyperledger.besu.consensus.ibft.support.IntegrationTestHelpers.createValidPreparedRoundArtifacts)2 NodeParams (org.hyperledger.besu.consensus.common.bft.inttest.NodeParams)1 Commit (org.hyperledger.besu.consensus.ibft.messagewrappers.Commit)1 Prepare (org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare)1 Proposal (org.hyperledger.besu.consensus.ibft.messagewrappers.Proposal)1 RoundSpecificPeers (org.hyperledger.besu.consensus.ibft.support.RoundSpecificPeers)1 NodeKey (org.hyperledger.besu.crypto.NodeKey)1 SECPSignature (org.hyperledger.besu.crypto.SECPSignature)1