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

Fix transactions #1825

Merged
merged 6 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 10 additions & 26 deletions crates/hotshot/examples/infra/modDA.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ pub trait RunDA<
debug!("Generated {} transactions", tx_to_gen);

debug!("Adjusted padding size is {:?} bytes", adjusted_padding);
let mut round = 0;
let mut total_transactions = 0;

let start = Instant::now();
Expand All @@ -284,6 +283,7 @@ pub trait RunDA<
let mut num_successful_commits = 0;

let total_nodes_u64 = total_nodes.get() as u64;
let mut total_transactions_sent = 0;

context.hotshot.start_consensus().await;

Expand Down Expand Up @@ -313,6 +313,13 @@ pub trait RunDA<
}
}

// send transactions
for _ in 0..(total_nodes_u64 / transactions_per_round as u64) {
rob-maron marked this conversation as resolved.
Show resolved Hide resolved
let txn = txns.pop_front().unwrap();
_ = context.submit_transaction(txn).await.unwrap();
total_transactions_sent += 1;
}

if let Some(size) = block_size {
total_transactions += size;
}
Expand All @@ -333,39 +340,16 @@ pub trait RunDA<
EventType::NextLeaderViewTimeout { view_number } => {
warn!("Timed out as the next leader in view {:?}", view_number);
}
EventType::ViewFinished { view_number } => {
if *view_number > round {
round = *view_number;
info!("view finished: {:?}", view_number);
for _ in 0..transactions_per_round {
if node_index >= total_nodes_u64 - 10 {
let txn = txns.pop_front().unwrap();

debug!("Submitting txn on round {}", round);

let result = context.submit_transaction(txn).await;

if result.is_err() {
error! (
"Could not send transaction to web server on round {}",
round
)
}
}
}
}
}
EventType::ViewFinished { view_number: _ } => {}
_ => unimplemented!(),
}
}
}

round += 1;
}

// Output run results
let total_time_elapsed = start.elapsed();
error!("{rounds} rounds completed in {total_time_elapsed:?} - Total transactions committed: {total_transactions} - Total commitments: {num_successful_commits}");
error!("[{node_index}]: {rounds} rounds completed in {total_time_elapsed:?} - Total transactions sent: {total_transactions_sent} - Total transactions committed: {total_transactions} - Total commitments: {num_successful_commits}");
}

/// Returns the da network for this run
Expand Down
7 changes: 5 additions & 2 deletions crates/hotshot/src/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ impl State for SDemoState {
impl TestableState for SDemoState {
fn create_random_transaction(
_state: Option<&Self>,
_rng: &mut dyn rand::RngCore,
rng: &mut dyn rand::RngCore,
padding: u64,
) -> <Self::BlockType as BlockPayload>::Transaction {
VIDTransaction(vec![0; padding as usize])
// random bytes with padding length
rob-maron marked this conversation as resolved.
Show resolved Hide resolved
let mut bytes = vec![0; padding as usize];
rng.fill_bytes(&mut bytes);
VIDTransaction(bytes)
}
}
/// Implementation of [`NodeType`] for [`VDemoNode`]
Expand Down