Search in sources :

Example 16 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class MockedRecoveryModule method view.

@Provides
private ViewUpdate view(BFTConfiguration configuration, ProposerElection proposerElection) {
    HighQC highQC = configuration.getVertexStoreState().getHighQC();
    View view = highQC.highestQC().getView().next();
    final BFTNode leader = proposerElection.getProposer(view);
    final BFTNode nextLeader = proposerElection.getProposer(view.next());
    return ViewUpdate.create(view, highQC, leader, nextLeader);
}
Also used : HighQC(com.radixdlt.consensus.HighQC) BFTNode(com.radixdlt.consensus.bft.BFTNode) View(com.radixdlt.consensus.bft.View) Provides(com.google.inject.Provides)

Example 17 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class PacemakerState method processQC.

@Override
public void processQC(HighQC highQC) {
    log.trace("QuorumCertificate: {}", highQC);
    final View view = highQC.getHighestView();
    if (view.gte(this.currentView)) {
        this.highQC = highQC;
        this.updateView(view.next());
    } else {
        log.trace("Ignoring QC for view {}: current view is {}", view, this.currentView);
    }
}
Also used : View(com.radixdlt.consensus.bft.View)

Example 18 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class BFTHeaderSerializeTest method get.

private static BFTHeader get() {
    View view = View.of(1234567890L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    return new BFTHeader(view, HashUtils.random256(), ledgerHeader);
}
Also used : LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) View(com.radixdlt.consensus.bft.View)

Example 19 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class HighQCTest method get.

private static HighQC get() {
    View view = View.of(1234567891L);
    HashCode id = HashUtils.random256();
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader header = new BFTHeader(view, id, ledgerHeader);
    BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
    BFTHeader commit = new BFTHeader(View.of(1234567889L), HashUtils.random256(), ledgerHeader);
    VoteData voteData = new VoteData(header, parent, commit);
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    return HighQC.from(qc, qc, Optional.empty());
}
Also used : HashCode(com.google.common.hash.HashCode) View(com.radixdlt.consensus.bft.View)

Example 20 with View

use of com.radixdlt.consensus.bft.View in project radixdlt by radixdlt.

the class LedgerProofTest method testGetters.

@Test
public void testGetters() {
    LedgerHeader l0 = mock(LedgerHeader.class);
    HashCode accumulatorHash = mock(HashCode.class);
    View view = mock(View.class);
    when(l0.getEpoch()).thenReturn(3L);
    AccumulatorState accumulatorState = mock(AccumulatorState.class);
    when(accumulatorState.getAccumulatorHash()).thenReturn(accumulatorHash);
    when(accumulatorState.getStateVersion()).thenReturn(12345L);
    when(l0.getAccumulatorState()).thenReturn(accumulatorState);
    when(l0.getView()).thenReturn(view);
    when(l0.timestamp()).thenReturn(2468L);
    when(l0.isEndOfEpoch()).thenReturn(true);
    var ledgerHeaderAndProof = new LedgerProof(HashUtils.random256(), l0, mock(TimestampedECDSASignatures.class));
    assertThat(ledgerHeaderAndProof.getEpoch()).isEqualTo(3L);
    assertThat(ledgerHeaderAndProof.getStateVersion()).isEqualTo(12345L);
    assertThat(ledgerHeaderAndProof.getView()).isEqualTo(view);
    assertThat(ledgerHeaderAndProof.timestamp()).isEqualTo(2468L);
    assertThat(ledgerHeaderAndProof.isEndOfEpoch()).isTrue();
}
Also used : AccumulatorState(com.radixdlt.ledger.AccumulatorState) HashCode(com.google.common.hash.HashCode) View(com.radixdlt.consensus.bft.View) Test(org.junit.Test)

Aggregations

View (com.radixdlt.consensus.bft.View)24 BFTNode (com.radixdlt.consensus.bft.BFTNode)11 Test (org.junit.Test)10 HighQC (com.radixdlt.consensus.HighQC)8 BFTHeader (com.radixdlt.consensus.BFTHeader)7 HashCode (com.google.common.hash.HashCode)6 LedgerHeader (com.radixdlt.consensus.LedgerHeader)5 QuorumCertificate (com.radixdlt.consensus.QuorumCertificate)5 Vote (com.radixdlt.consensus.Vote)5 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)5 Proposal (com.radixdlt.consensus.Proposal)4 VoteData (com.radixdlt.consensus.VoteData)4 TimestampedECDSASignatures (com.radixdlt.consensus.TimestampedECDSASignatures)3 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)3 VerifiedVertex (com.radixdlt.consensus.bft.VerifiedVertex)3 ScheduledLocalTimeout (com.radixdlt.consensus.liveness.ScheduledLocalTimeout)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 EventDispatcher (com.radixdlt.environment.EventDispatcher)3 Before (org.junit.Before)3 AbstractModule (com.google.inject.AbstractModule)2