Search in sources :

Example 1 with SignedData

use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.

the class ProposalValidatorTest method validationFailsIfPiggybackedRoundChangePayloadHasDuplicatedAuthors.

@Test
public void validationFailsIfPiggybackedRoundChangePayloadHasDuplicatedAuthors() {
    final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
    final List<SignedData<RoundChangePayload>> roundChanges = createEmptyRoundChangePayloads(roundItem.roundIdentifier, validators.getNode(0), validators.getNode(1), validators.getNode(1));
    final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, emptyList());
    assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
Also used : SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Proposal(org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal) Test(org.junit.Test)

Example 2 with SignedData

use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.

the class ProposalValidatorTest method validationFailsIfBlockHashInLatestPreparedMetadataDoesNotMatchProposedBlock.

@Test
public void validationFailsIfBlockHashInLatestPreparedMetadataDoesNotMatchProposedBlock() {
    final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
    final List<SignedData<RoundChangePayload>> roundChanges = createEmptyRoundChangePayloads(roundItem.roundIdentifier, validators.getNode(0), validators.getNode(1));
    final RoundChangePayload illegalPayload = new RoundChangePayload(roundItem.roundIdentifier, Optional.of(new PreparedRoundMetadata(Hash.fromHexStringLenient("0x1"), roundItems.get(ROUND_ID.ZERO).roundIdentifier.getRoundNumber())));
    final SignedData<RoundChangePayload> preparedRoundChange = SignedData.create(illegalPayload, validators.getNode(2).getNodeKey().sign(illegalPayload.hashForSignature()));
    roundChanges.add(preparedRoundChange);
    final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, Hash.fromHexStringLenient("0x1"), validators.getNode(0), validators.getNode(1), validators.getNode(2)));
    assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
Also used : SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Proposal(org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal) Test(org.junit.Test)

Example 3 with SignedData

use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.

the class ProposalValidatorTest method validationFailsIfPiggybackedPreparePayloadIsFromNonValidator.

@Test
public void validationFailsIfPiggybackedPreparePayloadIsFromNonValidator() {
    final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
    final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
    final QbftNode nonValidator = QbftNode.create();
    final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, roundItems.get(ROUND_ID.ZERO).block.getHash(), validators.getNode(0), validators.getNode(1), nonValidator));
    assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
Also used : SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Proposal(org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal) Test(org.junit.Test)

Example 4 with SignedData

use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.

the class ProposalValidatorTest method validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges.

@Test
public void validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges() {
    final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
    final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
    final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, Hash.fromHexStringLenient("0x1"), validators.getNode(0), validators.getNode(1), validators.getNode(2)));
    assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
Also used : SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) Proposal(org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal) Test(org.junit.Test)

Example 5 with SignedData

use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.

the class ProposalValidatorTest method validationFailsIfTwoRoundChangesArePreparedOnSameRoundDifferentBlock.

@Test
public void validationFailsIfTwoRoundChangesArePreparedOnSameRoundDifferentBlock() {
    final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
    final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
    final RoundChangePayload illegalPreparedRoundChangePayload = new RoundChangePayload(roundItem.roundIdentifier, Optional.of(new PreparedRoundMetadata(roundItems.get(ROUND_ID.ONE).block.getHash(), roundItems.get(ROUND_ID.ZERO).roundIdentifier.getRoundNumber())));
    final SignedData<RoundChangePayload> preparedRoundChange = SignedData.create(illegalPreparedRoundChangePayload, validators.getNode(3).getNodeKey().sign(illegalPreparedRoundChangePayload.hashForSignature()));
    roundChanges.add(preparedRoundChange);
    final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, Hash.fromHexStringLenient("0x1"), validators.getNode(0), validators.getNode(1), validators.getNode(2)));
    assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
Also used : SignedData(org.hyperledger.besu.consensus.common.bft.payload.SignedData) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Proposal(org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal) Test(org.junit.Test)

Aggregations

SignedData (org.hyperledger.besu.consensus.common.bft.payload.SignedData)44 Block (org.hyperledger.besu.ethereum.core.Block)21 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)19 Proposal (org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal)18 Test (org.junit.jupiter.api.Test)18 Test (org.junit.Test)17 RoundChangeCertificate (org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate)7 ValidatorPeer (org.hyperledger.besu.consensus.qbft.support.ValidatorPeer)7 Prepare (org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare)6 ValidatorPeer (org.hyperledger.besu.consensus.ibft.support.ValidatorPeer)5 PreparedCertificate (org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate)5 IntegrationTestHelpers.createValidPreparedCertificate (org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate)5 PreparedRoundMetadata (org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata)4 RoundChangePayload (org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload)4 RLPInput (org.hyperledger.besu.ethereum.rlp.RLPInput)4 Proposal (org.hyperledger.besu.consensus.ibft.messagewrappers.Proposal)3 PreparedRoundArtifacts (org.hyperledger.besu.consensus.ibft.statemachine.PreparedRoundArtifacts)3 IntegrationTestHelpers.createValidPreparedRoundArtifacts (org.hyperledger.besu.consensus.ibft.support.IntegrationTestHelpers.createValidPreparedRoundArtifacts)3 BytesValueRLPOutput (org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput)3 Prepare (org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare)2