Search in sources :

Example 6 with LedgerProof

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

the class RadixEngineStateComputerTest method committing_epoch_high_views_should_fail.

// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
// state not easily obtained where checked in the RadixEngine
@Ignore("FIXME: Reinstate when upper bound on epoch view is in place.")
public void committing_epoch_high_views_should_fail() throws TxBuilderException {
    // Arrange
    var cmd0 = systemUpdateCommand(10, 1);
    var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(11), new AccumulatorState(3, HashUtils.zero256()), 0), new TimestampedECDSASignatures());
    var commandsAndProof = VerifiedTxnsAndProof.create(ImmutableList.of(cmd0), ledgerProof);
    // Act
    // Assert
    assertThatThrownBy(() -> sut.commit(commandsAndProof, null)).isInstanceOf(ByzantineQuorumException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LedgerProof(com.radixdlt.hotstuff.LedgerProof) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with LedgerProof

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

the class BerkeleyLedgerEntryStoreTest method storeMetadataWithForks.

private void storeMetadataWithForks(long epoch, ImmutableSet<ForkVotingResult> forkVotingResults) throws RadixEngineException {
    final var fakeTx = mock(REProcessedTxn.class);
    final var txn = mock(Txn.class);
    when(txn.getId()).thenReturn(AID.from(HashUtils.random256().asBytes()));
    when(fakeTx.getTxn()).thenReturn(txn);
    when(fakeTx.getGroupedStateUpdates()).thenReturn(List.of());
    when(txn.getPayload()).thenReturn(HashUtils.random256().asBytes());
    final var proof1 = LedgerAndBFTProof.create(new LedgerProof(HashUtils.random256(), LedgerHeader.create(epoch, View.of(0L), new AccumulatorState(epoch, /* using same state version as epoch */
    HashCode.fromInt(1)), 0L), new TimestampedECDSASignatures(Map.of()))).withForksVotingResults(forkVotingResults);
    sut.transaction(tx -> {
        tx.storeTxn(fakeTx);
        tx.storeMetadata(proof1);
        return null;
    });
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LedgerProof(com.radixdlt.hotstuff.LedgerProof)

Example 8 with LedgerProof

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

the class LocalSyncServiceTest method when_sync_check_is_triggered_at_non_idle__then_should_be_ignored.

@Test
public void when_sync_check_is_triggered_at_non_idle__then_should_be_ignored() {
    final LedgerProof currentHeader = mock(LedgerProof.class);
    this.setupSyncServiceWithState(SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of()));
    this.localSyncService.syncCheckTriggerEventProcessor().process(SyncCheckTrigger.create());
    this.setupSyncServiceWithState(SyncState.SyncingState.init(currentHeader, ImmutableList.of(), currentHeader));
    this.localSyncService.syncCheckTriggerEventProcessor().process(SyncCheckTrigger.create());
    verifyNoMoreInteractions(peersView);
    verifyNoMoreInteractions(statusRequestDispatcher);
}
Also used : LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 9 with LedgerProof

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

the class LocalSyncServiceTest method when_status_timeout_with_at_least_one_response__then_should_start_sync.

@Test
public void when_status_timeout_with_at_least_one_response__then_should_start_sync() {
    final LedgerProof currentHeader = createHeaderAtStateVersion(10L);
    final LedgerProof statusHeader1 = createHeaderAtStateVersion(12L);
    final LedgerProof statusHeader2 = createHeaderAtStateVersion(20L);
    final var waiting1 = createPeer();
    final var waiting2 = createPeer();
    setupPeersView(waiting1, waiting2);
    final var syncState = SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(waiting1, waiting2));
    this.setupSyncServiceWithState(syncState);
    this.localSyncService.statusResponseEventProcessor().process(waiting1, StatusResponse.create(statusHeader1));
    this.localSyncService.syncCheckReceiveStatusTimeoutEventProcessor().process(SyncCheckReceiveStatusTimeout.create());
    // even though statusHeader2 is more up to date, it should be ignored because was received
    // after a timeout event
    this.localSyncService.statusResponseEventProcessor().process(waiting2, StatusResponse.create(statusHeader2));
    verify(syncRequestDispatcher, times(1)).dispatch(eq(waiting1), any());
}
Also used : LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 10 with LedgerProof

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

the class LocalSyncServiceTest method when_status_response_received_at_non_sync_check__then_should_be_ignored.

@Test
public void when_status_response_received_at_non_sync_check__then_should_be_ignored() {
    final LedgerProof currentHeader = mock(LedgerProof.class);
    final LedgerProof statusHeader = mock(LedgerProof.class);
    final BFTNode sender = createPeer();
    this.setupSyncServiceWithState(SyncState.IdleState.init(currentHeader));
    this.localSyncService.statusResponseEventProcessor().process(sender, StatusResponse.create(statusHeader));
    this.setupSyncServiceWithState(SyncState.SyncingState.init(currentHeader, ImmutableList.of(), currentHeader));
    this.localSyncService.statusResponseEventProcessor().process(sender, StatusResponse.create(statusHeader));
    verifyNoMoreInteractions(peersView);
    verifyNoMoreInteractions(statusRequestDispatcher);
    verifyNoMoreInteractions(syncRequestDispatcher);
    verifyNoMoreInteractions(syncRequestTimeoutDispatcher);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Aggregations

LedgerProof (com.radixdlt.hotstuff.LedgerProof)28 Test (org.junit.Test)17 DtoLedgerProof (com.radixdlt.ledger.DtoLedgerProof)13 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)9 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)9 AccumulatorState (com.radixdlt.ledger.AccumulatorState)9 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)4 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 Txn (com.radixdlt.atom.Txn)3 SystemCounters (com.radixdlt.counters.SystemCounters)3 EventDispatcher (com.radixdlt.environment.EventDispatcher)3 BFTConfiguration (com.radixdlt.hotstuff.BFTConfiguration)3 HighQC (com.radixdlt.hotstuff.HighQC)3 Self (com.radixdlt.hotstuff.bft.Self)3 View (com.radixdlt.hotstuff.bft.View)3 StateComputer (com.radixdlt.ledger.StateComputerLedger.StateComputer)3 VerifiedTxnsAndProof (com.radixdlt.ledger.VerifiedTxnsAndProof)3 ImmutableClassToInstanceMap (com.google.common.collect.ImmutableClassToInstanceMap)2 Inject (com.google.inject.Inject)2