Search in sources :

Example 1 with QbftMessageTransmitter

use of org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter in project besu by hyperledger.

the class QbftRoundFactory method createNewRoundWithState.

public QbftRound createNewRoundWithState(final BlockHeader parentHeader, final RoundState roundState) {
    final ConsensusRoundIdentifier roundIdentifier = roundState.getRoundIdentifier();
    final BlockCreator blockCreator = blockCreatorFactory.create(parentHeader, 0);
    // TODO(tmm): Why is this created everytime?!
    final QbftMessageTransmitter messageTransmitter = new QbftMessageTransmitter(messageFactory, finalState.getValidatorMulticaster());
    return new QbftRound(roundState, blockCreator, protocolContext, protocolSchedule.getByBlockNumber(roundIdentifier.getSequenceNumber()).getBlockImporter(), minedBlockObservers, finalState.getNodeKey(), messageFactory, messageTransmitter, finalState.getRoundTimer(), bftExtraDataCodec);
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) QbftMessageTransmitter(org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter) BlockCreator(org.hyperledger.besu.ethereum.blockcreation.BlockCreator)

Example 2 with QbftMessageTransmitter

use of org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter in project besu by hyperledger.

the class QbftRoundIntegrationTest method setup.

@BeforeEach
public void setup() {
    when(messageValidator.validateProposal(any())).thenReturn(true);
    when(messageValidator.validatePrepare(any())).thenReturn(true);
    when(messageValidator.validateCommit(any())).thenReturn(true);
    when(nodeKey.sign(any())).thenThrow(new SecurityModuleException("Hsm Is Down"));
    final QbftExtraDataCodec qbftExtraDataEncoder = new QbftExtraDataCodec();
    throwingMessageFactory = new MessageFactory(nodeKey);
    transmitter = new QbftMessageTransmitter(throwingMessageFactory, multicaster);
    final BftExtraData proposedExtraData = new BftExtraData(Bytes.wrap(new byte[32]), emptyList(), empty(), 0, emptyList());
    final BlockHeaderTestFixture headerTestFixture = new BlockHeaderTestFixture();
    headerTestFixture.extraData(qbftExtraDataEncoder.encode(proposedExtraData));
    headerTestFixture.number(1);
    final BlockHeader header = headerTestFixture.buildHeader();
    proposedBlock = new Block(header, new BlockBody(emptyList(), emptyList()));
    when(blockImporter.importBlock(any(), any(), any())).thenReturn(true);
    protocolContext = new ProtocolContext(blockChain, worldStateArchive, setupContextWithBftExtraDataEncoder(QbftContext.class, emptyList(), qbftExtraDataEncoder));
}
Also used : QbftMessageTransmitter(org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter) BlockHeaderTestFixture(org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture) MessageFactory(org.hyperledger.besu.consensus.qbft.payload.MessageFactory) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) SecurityModuleException(org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException) QbftExtraDataCodec(org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec) Block(org.hyperledger.besu.ethereum.core.Block) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) BftExtraData(org.hyperledger.besu.consensus.common.bft.BftExtraData) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

QbftMessageTransmitter (org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter)2 BftExtraData (org.hyperledger.besu.consensus.common.bft.BftExtraData)1 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)1 QbftExtraDataCodec (org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec)1 MessageFactory (org.hyperledger.besu.consensus.qbft.payload.MessageFactory)1 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)1 BlockCreator (org.hyperledger.besu.ethereum.blockcreation.BlockCreator)1 Block (org.hyperledger.besu.ethereum.core.Block)1 BlockBody (org.hyperledger.besu.ethereum.core.BlockBody)1 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)1 BlockHeaderTestFixture (org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture)1 SecurityModuleException (org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1