Search in sources :

Example 6 with GetVerticesRequest

use of com.radixdlt.hotstuff.sync.GetVerticesRequest in project radixdlt by radixdlt.

the class ConsensusModuleTest method on_sync_request_timeout_should_retry.

@Test
public void on_sync_request_timeout_should_retry() {
    // Arrange
    QuorumCertificate parent = vertexStore.highQC().highestQC();
    Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, validatorKeyPair);
    HighQC unsyncedHighQC = HighQC.from(nextVertex.getFirst(), nextVertex.getFirst(), Optional.empty());
    bftSync.syncToQC(unsyncedHighQC, validatorBftNode);
    GetVerticesRequest request = new GetVerticesRequest(nextVertex.getSecond().getId(), 1);
    VertexRequestTimeout timeout = VertexRequestTimeout.create(request);
    // Act
    // FIXME: Remove when rate limit on send removed
    nothrowSleep(100);
    bftSync.vertexRequestTimeoutEventProcessor().process(timeout);
    // Assert
    verify(requestSender, times(2)).dispatch(eq(validatorBftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) HighQC(com.radixdlt.hotstuff.HighQC) Module(com.google.inject.Module) BFTHighQCUpdate(com.radixdlt.hotstuff.bft.BFTHighQCUpdate) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Inject(com.google.inject.Inject) PersistentSafetyStateStore(com.radixdlt.hotstuff.safety.PersistentSafetyStateStore) Hasher(com.radixdlt.crypto.Hasher) HighQC(com.radixdlt.hotstuff.HighQC) VerifiedVertexStoreState(com.radixdlt.hotstuff.bft.VerifiedVertexStoreState) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) Ledger(com.radixdlt.hotstuff.Ledger) Map(java.util.Map) PersistentVertexStore(com.radixdlt.hotstuff.bft.PersistentVertexStore) PacemakerTimeout(com.radixdlt.hotstuff.bft.PacemakerTimeout) GetVerticesErrorResponse(com.radixdlt.hotstuff.sync.GetVerticesErrorResponse) BFTRebuildUpdate(com.radixdlt.hotstuff.bft.BFTRebuildUpdate) HashUtils(com.radixdlt.crypto.HashUtils) BFTSyncPatienceMillis(com.radixdlt.hotstuff.sync.BFTSyncPatienceMillis) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) SystemCounters(com.radixdlt.counters.SystemCounters) Vote(com.radixdlt.hotstuff.Vote) NextTxnsGenerator(com.radixdlt.hotstuff.liveness.NextTxnsGenerator) VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) GetVerticesRequestRateLimit(com.radixdlt.middleware2.network.GetVerticesRequestRateLimit) PacemakerRate(com.radixdlt.hotstuff.bft.PacemakerRate) List(java.util.List) Stream(java.util.stream.Stream) PacemakerMaxExponent(com.radixdlt.hotstuff.bft.PacemakerMaxExponent) Optional(java.util.Optional) TypeLiteral(com.google.inject.TypeLiteral) Proposal(com.radixdlt.hotstuff.Proposal) ViewQuorumReached(com.radixdlt.hotstuff.bft.ViewQuorumReached) Mockito.mock(org.mockito.Mockito.mock) BFTCommittedUpdate(com.radixdlt.hotstuff.bft.BFTCommittedUpdate) BFTValidatorSet(com.radixdlt.hotstuff.bft.BFTValidatorSet) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) LedgerProof(com.radixdlt.hotstuff.LedgerProof) WeightedRotatingLeaders(com.radixdlt.hotstuff.liveness.WeightedRotatingLeaders) Sha256Hasher(com.radixdlt.hotstuff.Sha256Hasher) GetVerticesResponse(com.radixdlt.hotstuff.sync.GetVerticesResponse) RateLimiter(com.google.common.util.concurrent.RateLimiter) TypedMocks.rmock(com.radixdlt.utils.TypedMocks.rmock) HashSigner(com.radixdlt.hotstuff.HashSigner) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) VertexStore(com.radixdlt.hotstuff.bft.VertexStore) View(com.radixdlt.hotstuff.bft.View) ImmutableList(com.google.common.collect.ImmutableList) BFTConfiguration(com.radixdlt.hotstuff.BFTConfiguration) AccumulatorState(com.radixdlt.ledger.AccumulatorState) UInt256(com.radixdlt.utils.UInt256) Before(org.junit.Before) BFTSync(com.radixdlt.hotstuff.sync.BFTSync) BFTHeader(com.radixdlt.hotstuff.BFTHeader) TimeSupplier(com.radixdlt.utils.TimeSupplier) EventDispatcher(com.radixdlt.environment.EventDispatcher) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) NoVote(com.radixdlt.hotstuff.bft.NoVote) Txn(com.radixdlt.atom.Txn) VoteData(com.radixdlt.hotstuff.VoteData) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature) BFTValidator(com.radixdlt.hotstuff.bft.BFTValidator) LocalTimeoutOccurrence(com.radixdlt.hotstuff.liveness.LocalTimeoutOccurrence) Guice(com.google.inject.Guice) Self(com.radixdlt.hotstuff.bft.Self) Pair(com.radixdlt.utils.Pair) LastProof(com.radixdlt.store.LastProof) AbstractModule(com.google.inject.AbstractModule) GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VertexRequestTimeout(com.radixdlt.hotstuff.sync.VertexRequestTimeout) Test(org.junit.Test)

Example 7 with GetVerticesRequest

use of com.radixdlt.hotstuff.sync.GetVerticesRequest in project radixdlt by radixdlt.

the class FProposalsPerViewDropperTest method given_incorrect_module_where_vertex_sync_is_disabled__then_test_should_fail_against_drop_proposal_adversary.

/**
 * Tests a configuration of 4 nodes with a dropping proposal adversary Test should fail with
 * GetVertices RPC disabled
 */
@Test
public void given_incorrect_module_where_vertex_sync_is_disabled__then_test_should_fail_against_drop_proposal_adversary() {
    SimulationTest test = bftTestBuilder.addOverrideModuleToAllInitialNodes(new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<RemoteEventDispatcher<GetVerticesRequest>>() {
            }).toInstance((node, request) -> {
            });
        }
    }).build();
    final var runningTest = test.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).hasEntrySatisfying(Monitor.CONSENSUS_NO_TIMEOUTS, error -> assertThat(error).isPresent());
}
Also used : GetVerticesRequest(com.radixdlt.hotstuff.sync.GetVerticesRequest) TypeLiteral(com.google.inject.TypeLiteral) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 8 with GetVerticesRequest

use of com.radixdlt.hotstuff.sync.GetVerticesRequest 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

GetVerticesRequest (com.radixdlt.hotstuff.sync.GetVerticesRequest)8 AbstractModule (com.google.inject.AbstractModule)5 TypeLiteral (com.google.inject.TypeLiteral)5 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)5 GetVerticesErrorResponse (com.radixdlt.hotstuff.sync.GetVerticesErrorResponse)5 Test (org.junit.Test)5 Proposal (com.radixdlt.hotstuff.Proposal)4 BFTCommittedUpdate (com.radixdlt.hotstuff.bft.BFTCommittedUpdate)4 Self (com.radixdlt.hotstuff.bft.Self)4 ViewQuorumReached (com.radixdlt.hotstuff.bft.ViewQuorumReached)4 PersistentSafetyStateStore (com.radixdlt.hotstuff.safety.PersistentSafetyStateStore)4 LocalSyncRequest (com.radixdlt.sync.messages.local.LocalSyncRequest)4 SystemCounters (com.radixdlt.counters.SystemCounters)3 EventDispatcher (com.radixdlt.environment.EventDispatcher)3 RemoteEventDispatcher (com.radixdlt.environment.RemoteEventDispatcher)3 ScheduledEventDispatcher (com.radixdlt.environment.ScheduledEventDispatcher)3 HighQC (com.radixdlt.hotstuff.HighQC)3 Guice (com.google.inject.Guice)2 Inject (com.google.inject.Inject)2 ECKeyPair (com.radixdlt.crypto.ECKeyPair)2