Search in sources :

Example 1 with FormedQC

use of com.radixdlt.hotstuff.bft.ViewVotingResult.FormedQC in project radixdlt by radixdlt.

the class OneNodeAlwaysAliveSafetyTest method setup.

@Before
public void setup() {
    var allNodes = nodeKeys.stream().map(k -> BFTNode.create(k.getPublicKey())).toList();
    this.network = new DeterministicNetwork(allNodes, MessageSelector.firstSelector(), (message, queue) -> message.message() instanceof GetVerticesRequest || message.message() instanceof LocalSyncRequest);
    Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<ImmutableSet<BFTNode>>() {
            }).toInstance(ImmutableSet.copyOf(allNodes));
        }

        @ProvidesIntoSet
        public NodeEventProcessor<?> updateChecker() {
            return new NodeEventProcessor<>(ViewQuorumReached.class, (node, viewQuorumReached) -> {
                if (viewQuorumReached.votingResult() instanceof FormedQC && ((FormedQC) viewQuorumReached.votingResult()).getQC().getCommitted().isPresent()) {
                    lastNodeToCommit = network.lookup(node);
                }
            });
        }
    }, new SafetyCheckerModule(), new NodeEventsModule()).injectMembers(this);
    this.nodeCreators = nodeKeys.stream().<Supplier<Injector>>map(k -> () -> createRunner(k, allNodes)).toList();
    for (var nodeCreator : nodeCreators) {
        this.nodes.add(nodeCreator.get());
    }
}
Also used : RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) Inject(com.google.inject.Inject) Key(com.google.inject.Key) PersistentSafetyStateStore(com.radixdlt.hotstuff.safety.PersistentSafetyStateStore) EventProcessor(com.radixdlt.environment.EventProcessor) FeeTable(com.radixdlt.application.system.FeeTable) After(org.junit.After) MSG(com.radixdlt.constraintmachine.REInstruction.REMicroOp.MSG) NodeEvents(com.radixdlt.harness.deterministic.NodeEvents) PersistedNodeForTestingModule(com.radixdlt.modules.PersistedNodeForTestingModule) Parameterized(org.junit.runners.Parameterized) ThreadContext(org.apache.logging.log4j.ThreadContext) ImmutableSet(com.google.common.collect.ImmutableSet) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) DatabaseEnvironment(com.radixdlt.store.DatabaseEnvironment) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) KeyComparator(com.radixdlt.utils.KeyComparator) NodeEventsModule(com.radixdlt.harness.deterministic.NodeEventsModule) Amount(com.radixdlt.application.tokens.Amount) Pattern(java.util.regex.Pattern) ProcessOnDispatch(com.radixdlt.environment.ProcessOnDispatch) TypeLiteral(com.google.inject.TypeLiteral) Proposal(com.radixdlt.hotstuff.Proposal) ViewQuorumReached(com.radixdlt.hotstuff.bft.ViewQuorumReached) SafetyCheckerModule(com.radixdlt.harness.deterministic.SafetyCheckerModule) BFTCommittedUpdate(com.radixdlt.hotstuff.bft.BFTCommittedUpdate) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) OptionalInt(java.util.OptionalInt) Supplier(java.util.function.Supplier) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) ArrayList(java.util.ArrayList) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MempoolConfig(com.radixdlt.mempool.MempoolConfig) RERulesConfig(com.radixdlt.statecomputer.forks.RERulesConfig) BerkeleyLedgerEntryStore(com.radixdlt.store.berkeley.BerkeleyLedgerEntryStore) Before(org.junit.Before) EventProcessorOnDispatch(com.radixdlt.environment.EventProcessorOnDispatch) Environment(com.radixdlt.environment.Environment) Test(org.junit.Test) DeterministicProcessor(com.radixdlt.environment.deterministic.DeterministicProcessor) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) ECKeyPair(com.radixdlt.crypto.ECKeyPair) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) Rule(org.junit.Rule) NodeEventProcessor(com.radixdlt.harness.deterministic.NodeEvents.NodeEventProcessor) Guice(com.google.inject.Guice) Self(com.radixdlt.hotstuff.bft.Self) PeersView(com.radixdlt.network.p2p.PeersView) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) FormedQC(com.radixdlt.hotstuff.bft.ViewVotingResult.FormedQC) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) FormedQC(com.radixdlt.hotstuff.bft.ViewVotingResult.FormedQC) AbstractModule(com.google.inject.AbstractModule) SafetyCheckerModule(com.radixdlt.harness.deterministic.SafetyCheckerModule) TypeLiteral(com.google.inject.TypeLiteral) Supplier(java.util.function.Supplier) NodeEventsModule(com.radixdlt.harness.deterministic.NodeEventsModule) NodeEventProcessor(com.radixdlt.harness.deterministic.NodeEvents.NodeEventProcessor) Before(org.junit.Before)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 AbstractModule (com.google.inject.AbstractModule)1 Guice (com.google.inject.Guice)1 Inject (com.google.inject.Inject)1 Injector (com.google.inject.Injector)1 Key (com.google.inject.Key)1 TypeLiteral (com.google.inject.TypeLiteral)1 ProvidesIntoSet (com.google.inject.multibindings.ProvidesIntoSet)1 FeeTable (com.radixdlt.application.system.FeeTable)1 Amount (com.radixdlt.application.tokens.Amount)1 MSG (com.radixdlt.constraintmachine.REInstruction.REMicroOp.MSG)1 ECKeyPair (com.radixdlt.crypto.ECKeyPair)1 Environment (com.radixdlt.environment.Environment)1 EventProcessor (com.radixdlt.environment.EventProcessor)1 EventProcessorOnDispatch (com.radixdlt.environment.EventProcessorOnDispatch)1 ProcessOnDispatch (com.radixdlt.environment.ProcessOnDispatch)1 DeterministicProcessor (com.radixdlt.environment.deterministic.DeterministicProcessor)1 DeterministicNetwork (com.radixdlt.environment.deterministic.network.DeterministicNetwork)1 MessageSelector (com.radixdlt.environment.deterministic.network.MessageSelector)1 NodeEvents (com.radixdlt.harness.deterministic.NodeEvents)1