use of com.radixdlt.hotstuff.VoteData 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);
}
use of com.radixdlt.hotstuff.VoteData 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);
}
use of com.radixdlt.hotstuff.VoteData in project radixdlt by radixdlt.
the class SafetyRules method createVote.
public Vote createVote(VerifiedVertex proposedVertex, BFTHeader proposedHeader, long timestamp, HighQC highQC) {
final VoteData voteData = constructVoteData(proposedVertex, proposedHeader);
final var voteHash = Vote.getHashOfData(hasher, voteData, timestamp);
// TODO make signing more robust by including author in signed hash
final ECDSASignature signature = this.signer.sign(voteHash);
return new Vote(this.self, voteData, timestamp, signature, highQC, Optional.empty());
}
use of com.radixdlt.hotstuff.VoteData in project radixdlt by radixdlt.
the class SafetyRules method constructVoteData.
private static VoteData constructVoteData(VerifiedVertex proposedVertex, BFTHeader proposedHeader) {
final BFTHeader parent = proposedVertex.getParentHeader();
// Add a vertex to commit if creating a quorum for the proposed vertex would
// create three consecutive qcs.
final BFTHeader toCommit;
if (proposedVertex.touchesGenesis() || !proposedVertex.hasDirectParent() || !proposedVertex.parentHasDirectParent()) {
toCommit = null;
} else {
toCommit = proposedVertex.getGrandParentHeader();
}
return new VoteData(proposedHeader, parent, toCommit);
}
use of com.radixdlt.hotstuff.VoteData in project radixdlt by radixdlt.
the class UnverifiedVertexSerializeTest method get.
private static UnverifiedVertex get() {
View view = View.of(1234567891L);
LedgerHeader ledgerHeader = LedgerHeaderMock.get();
BFTHeader header = new BFTHeader(view, HashUtils.random256(), ledgerHeader);
BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
VoteData voteData = new VoteData(header, parent, null);
QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
var txn = Txn.create(new byte[] { 0, 1, 2, 3 });
return UnverifiedVertex.create(qc, view, List.of(txn), BFTNode.random());
}
Aggregations