Search in sources :

Example 1 with TimestampedECDSASignatures

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

the class ForksVotingResultsHandlerTest method storeMetadataWithForks.

private void storeMetadataWithForks(long epoch, ImmutableSet<com.radixdlt.statecomputer.forks.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.getTxnId()).thenReturn(AID.ZERO);
    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);
    berkeleyLedgerEntryStore.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 2 with TimestampedECDSASignatures

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

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_root_not_committed_should_fail.

@Test
public void creating_vertex_store_with_root_not_committed_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, null);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 3 with TimestampedECDSASignatures

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

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail.

@Test
public void creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    BFTHeader otherHeader = new BFTHeader(View.of(0), HashUtils.random256(), mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, otherHeader);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 4 with TimestampedECDSASignatures

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

the class RadixEngineStateComputerTest method committing_epoch_change_with_additional_cmds_should_fail.

// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
public void committing_epoch_change_with_additional_cmds_should_fail() throws Exception {
    // Arrange
    var keyPair = ECKeyPair.generateNew();
    var cmd0 = systemUpdateCommand(0, 2);
    var cmd1 = registerCommand(keyPair);
    var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(9), new AccumulatorState(3, HashUtils.zero256()), 0), new TimestampedECDSASignatures());
    var commandsAndProof = VerifiedTxnsAndProof.create(ImmutableList.of(cmd0, cmd1), 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) Test(org.junit.Test)

Example 5 with TimestampedECDSASignatures

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

the class RadixEngineStateComputerTest method committing_epoch_change_when_there_shouldnt_be_one__should_fail.

// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
public void committing_epoch_change_when_there_shouldnt_be_one__should_fail() throws TxBuilderException {
    // Arrange
    var cmd0 = systemUpdateCommand(1, 1);
    var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(9), new AccumulatorState(3, HashUtils.zero256()), 0, BFTValidatorSet.from(Stream.of(BFTValidator.from(BFTNode.random(), UInt256.ONE)))), 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) Test(org.junit.Test)

Aggregations

TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)18 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)9 VoteData (com.radixdlt.hotstuff.VoteData)9 Test (org.junit.Test)9 BFTHeader (com.radixdlt.hotstuff.BFTHeader)8 LedgerProof (com.radixdlt.hotstuff.LedgerProof)8 AccumulatorState (com.radixdlt.ledger.AccumulatorState)8 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)7 HashCode (com.google.common.hash.HashCode)3 View (com.radixdlt.hotstuff.bft.View)3 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)2 Before (org.junit.Before)2 REEvent (com.radixdlt.constraintmachine.REEvent)1 EventDispatcher (com.radixdlt.environment.EventDispatcher)1 HighQC (com.radixdlt.hotstuff.HighQC)1 Ledger (com.radixdlt.hotstuff.Ledger)1 Proposal (com.radixdlt.hotstuff.Proposal)1 UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)1 Vote (com.radixdlt.hotstuff.Vote)1 BFTValidatorSet (com.radixdlt.hotstuff.bft.BFTValidatorSet)1