Search in sources :

Example 6 with BFTConfiguration

use of com.radixdlt.hotstuff.BFTConfiguration in project radixdlt by radixdlt.

the class ConsensusModuleTest method setup.

@Before
public void setup() {
    var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
    var genesis = UnverifiedVertex.createGenesis(LedgerHeader.genesis(accumulatorState, null, 0));
    var hashedGenesis = new VerifiedVertex(genesis, HashUtils.zero256());
    var qc = QuorumCertificate.ofGenesis(hashedGenesis, LedgerHeader.genesis(accumulatorState, null, 0));
    this.validatorKeyPair = ECKeyPair.generateNew();
    this.validatorBftNode = BFTNode.create(this.validatorKeyPair.getPublicKey());
    var validatorSet = BFTValidatorSet.from(Stream.of(BFTValidator.from(this.validatorBftNode, UInt256.ONE)));
    var vertexStoreState = VerifiedVertexStoreState.create(HighQC.from(qc), hashedGenesis, Optional.empty(), hasher);
    var proposerElection = new WeightedRotatingLeaders(validatorSet);
    this.bftConfiguration = new BFTConfiguration(proposerElection, validatorSet, vertexStoreState);
    this.ecKeyPair = ECKeyPair.generateNew();
    this.requestSender = rmock(RemoteEventDispatcher.class);
    this.responseSender = rmock(RemoteEventDispatcher.class);
    this.errorResponseSender = rmock(RemoteEventDispatcher.class);
    Guice.createInjector(new ConsensusModule(), new CryptoModule(), getExternalModule()).injectMembers(this);
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) AccumulatorState(com.radixdlt.ledger.AccumulatorState) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Before(org.junit.Before)

Example 7 with BFTConfiguration

use of com.radixdlt.hotstuff.BFTConfiguration in project radixdlt by radixdlt.

the class BFTValidatorSetNodeSelector method nextNode.

@Override
public Single<BFTNode> nextNode(RunningNetwork network) {
    BFTConfiguration config = network.bftConfiguration();
    ImmutableList<BFTNode> validators = config.getValidatorSet().nodes().asList();
    int validatorSetSize = validators.size();
    BFTNode node = validators.get(random.nextInt(validatorSetSize));
    return Single.just(node);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration)

Aggregations

BFTConfiguration (com.radixdlt.hotstuff.BFTConfiguration)7 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)5 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)5 WeightedRotatingLeaders (com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders)5 EventDispatcher (com.radixdlt.environment.EventDispatcher)4 RemoteEventDispatcher (com.radixdlt.environment.RemoteEventDispatcher)4 HighQC (com.radixdlt.hotstuff.HighQC)4 View (com.radixdlt.hotstuff.bft.View)4 AccumulatorState (com.radixdlt.ledger.AccumulatorState)4 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 ScheduledEventDispatcher (com.radixdlt.environment.ScheduledEventDispatcher)3 HashSigner (com.radixdlt.hotstuff.HashSigner)3 Proposal (com.radixdlt.hotstuff.Proposal)3 ImmutableClassToInstanceMap (com.google.common.collect.ImmutableClassToInstanceMap)2 Inject (com.google.inject.Inject)2 Txn (com.radixdlt.atom.Txn)2 Hasher (com.radixdlt.crypto.Hasher)2 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)2