Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

another way to create dags #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions narwhal/benchmark/benchmark/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _parse_clients(self, log):
return size, rate, start, misses, samples

def _parse_primaries(self, log):
if search(r'(?:panicked)', log) is not None:
raise ParseError('Primary(s) panicked')
# if search(r'(?:panicked)', log) is not None:
# raise ParseError('Primary(s) panicked')

tmp = findall(r'(.*?) .* Created B\d+\([^ ]+\) -> ([^ ]+=)', log)
tmp = [(d, self._to_posix(t)) for t, d in tmp]
Expand Down
10 changes: 6 additions & 4 deletions narwhal/consensus/src/bullshark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ impl ConsensusProtocol for Bullshark {
// If it is the case, we can commit the leader. But first, we need to recursively go back to
// the last committed leader, and commit all preceding leaders in the right order. Committing
// a leader block means committing all its dependencies.
if stake < self.committee.validity_threshold() {
debug!("Leader {:?} does not have enough support", leader);
return Ok(Vec::new());
}
// MASATODO
// if stake < self.committee.validity_threshold() {
// debug!("Leader {:?} does not have enough support", leader);
// return Ok(Vec::new());
// }

// Get an ordered list of past leaders that are linked to the current leader.
debug!("Leader {:?} has enough support", leader);
Expand All @@ -90,6 +91,7 @@ impl ConsensusProtocol for Bullshark {
.iter()
.rev()
{
debug!("MASADEBUG: I'm leader!!!");
// Starting from the oldest leader, flatten the sub-dag referenced by the leader.
for x in utils::order_dag(self.gc_depth, leader, state) {
let digest = x.digest();
Expand Down
1 change: 1 addition & 0 deletions narwhal/consensus/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ where
loop {
tokio::select! {
Some(certificate) = self.rx_primary.recv() => {
tracing::debug!("MASADEBUG: Consensus received certificate {:?}", certificate);
// If the core already moved to the next epoch we should pull the next
// committee as well.
match certificate.epoch().cmp(&self.committee.epoch()) {
Expand Down
19 changes: 15 additions & 4 deletions narwhal/primary/src/aggregators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use config::{Committee, Stake};
use crypto::{PublicKey, Signature};
use fastcrypto::traits::EncodeDecodeBase64;
use std::collections::HashSet;
use tracing::debug;
use types::{
ensure,
error::{DagError, DagResult},
Certificate, Header, Vote,
Certificate, Header, Vote, HeaderDigest,
};

/// Aggregates votes for a particular header into a certificate.
Expand Down Expand Up @@ -44,6 +45,7 @@ impl VotesAggregator {

self.votes.push((author.clone(), vote.signature));
self.weight += committee.stake(&author);
debug!("MASADEBUG {:?}.3.5: vote weight count: {:?}/{:?} for header {:?}", vote.round, self.weight, committee.quorum_threshold(), header.id);

if self.weight >= committee.quorum_threshold() {
self.weight = 0; // Ensures quorum is only reached once.
Expand All @@ -61,7 +63,7 @@ impl VotesAggregator {
pub struct CertificatesAggregator {
weight: Stake,
certificates: Vec<Certificate>,
used: HashSet<PublicKey>,
used: HashSet<HeaderDigest>,
}

impl CertificatesAggregator {
Expand All @@ -78,16 +80,25 @@ impl CertificatesAggregator {
certificate: Certificate,
committee: &Committee,
) -> Option<Vec<Certificate>> {
let round = certificate.round();
let origin = certificate.origin();
let header_digest = certificate.header.id;

// Ensure it is the first time this authority votes.
if !self.used.insert(origin.clone()) {
if !self.used.insert(header_digest.clone()) {
return None;
}

self.certificates.push(certificate);
self.weight += committee.stake(&origin);
if self.weight >= committee.quorum_threshold() {

let weight = self.certificates.len();

debug!(
"MASADEBUG {:?}.3.6: certificate weight count: {:?}/{:?}",
round, weight, committee.quorum_threshold()
);
if weight >= committee.quorum_threshold() as usize {
// Note that we do not reset the weight here. If this function is called again and
// the proposer didn't yet advance round, we can add extra certificates as parents.
// This is required when running Bullshark as consensus and does not harm when running
Expand Down
Loading