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 benchmark genesis address to match block production address #829

Merged
merged 4 commits into from
Sep 9, 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
2 changes: 1 addition & 1 deletion examples/demo-rollup/benches/rng_xfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sov_rollup_interface::mocks::{
};
use sov_rollup_interface::services::da::DaService;

pub(crate) const SEQUENCER_DA_ADDRESS: [u8; 32] = [99; 32];
pub const SEQUENCER_DA_ADDRESS: [u8; 32] = [99; 32];

#[derive(Clone)]
/// A simple DaService for a random number generator.
Expand Down
39 changes: 26 additions & 13 deletions examples/demo-rollup/benches/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
mod rng_xfers;
use std::env;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};

use anyhow::Context;
use const_rollup_config::SEQUENCER_DA_ADDRESS;
use demo_stf::app::App;
use demo_stf::genesis_config::create_demo_genesis_config;
use prometheus::{Histogram, HistogramOpts, Registry};
use rng_xfers::{RngDaService, RngDaSpec};
use sov_celestia_adapter::verifier::address::CelestiaAddress;
use rng_xfers::{RngDaService, RngDaSpec, SEQUENCER_DA_ADDRESS};
use sov_db::ledger_db::{LedgerDB, SlotCommit};
use sov_modules_api::default_signature::private_key::DefaultPrivateKey;
use sov_modules_api::PrivateKey;
use sov_risc0_adapter::host::Risc0Verifier;
use sov_rollup_interface::mocks::{MockBlock, MockBlockHeader, MockHash};
use sov_rollup_interface::mocks::{MockAddress, MockBlock, MockBlockHeader, MockHash};
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_stf_runner::{from_toml_path, RollupConfig};
Expand All @@ -26,12 +23,24 @@ use tempfile::TempDir;
extern crate prettytable;

use prettytable::Table;

fn print_times(total: Duration, apply_block_time: Duration, blocks: u64, num_txns: u64) {
use sov_modules_stf_template::TxEffect;

fn print_times(
total: Duration,
apply_block_time: Duration,
blocks: u64,
num_txns: u64,
num_success_txns: u64,
) {
let mut table = Table::new();

table.add_row(row!["Blocks", format!("{:?}", blocks)]);
table.add_row(row!["Txns per Block", format!("{:?}", num_txns)]);
// subtract 1 because the first block contains only 1 txn which is the token create txn
dubbelosix marked this conversation as resolved.
Show resolved Hide resolved
table.add_row(row![
"Processed Txns (Success)",
format!("{:?}", num_success_txns - 1)
]);
table.add_row(row!["Total", format!("{:?}", total)]);
table.add_row(row!["Apply Block", format!("{:?}", apply_block_time)]);
table.add_row(row![
Expand All @@ -58,6 +67,7 @@ async fn main() -> Result<(), anyhow::Error> {

let start_height: u64 = 0u64;
let mut end_height: u64 = 10u64;
let mut num_success_txns = 0u64;
let mut num_txns_per_block = 10000;
let mut timer_output = true;
let mut prometheus_output = false;
Expand Down Expand Up @@ -94,7 +104,7 @@ async fn main() -> Result<(), anyhow::Error> {

let mut demo = demo_runner.stf;
let sequencer_private_key = DefaultPrivateKey::generate();
let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS).unwrap();
let sequencer_da_address = MockAddress::from(SEQUENCER_DA_ADDRESS);
let demo_genesis_config = create_demo_genesis_config(
100000000,
sequencer_private_key.default_address(),
Expand All @@ -107,8 +117,7 @@ async fn main() -> Result<(), anyhow::Error> {
// data generation
let mut blobs = vec![];
let mut blocks = vec![];

for height in start_height..end_height {
for height in start_height..end_height + 1 {
dubbelosix marked this conversation as resolved.
Show resolved Hide resolved
let num_bytes = height.to_le_bytes();
let mut barray = [0u8; 32];
barray[..num_bytes.len()].copy_from_slice(&num_bytes);
Expand All @@ -130,7 +139,7 @@ async fn main() -> Result<(), anyhow::Error> {
// rollup processing
let total = Instant::now();
let mut apply_block_time = Duration::new(0, 0);
for height in start_height..end_height {
for height in start_height..end_height + 1 {
dubbelosix marked this conversation as resolved.
Show resolved Hide resolved
let filtered_block = &blocks[height as usize];

let mut data_to_commit = SlotCommit::new(filtered_block.clone());
Expand All @@ -145,8 +154,12 @@ async fn main() -> Result<(), anyhow::Error> {

apply_block_time += now.elapsed();
h_apply_block.observe(now.elapsed().as_secs_f64());

for receipt in apply_block_results.batch_receipts {
for t in &receipt.tx_receipts {
if t.receipt == TxEffect::Successful {
num_success_txns += 1
}
}
data_to_commit.add_batch(receipt);
}

Expand All @@ -155,7 +168,7 @@ async fn main() -> Result<(), anyhow::Error> {

let total = total.elapsed();
if timer_output {
print_times(total, apply_block_time, end_height, num_txns_per_block);
print_times(total, apply_block_time, end_height, num_txns_per_block,num_success_txns);
}
if prometheus_output {
println!("{:#?}", registry.gather());
Expand Down
2 changes: 0 additions & 2 deletions module-system/sov-modules-stf-template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ where
.take()
.expect("Working_set was initialized in begin_slot")
.to_revertable();

let selected_blobs = self
.runtime
.get_blobs_for_this_slot(blobs, &mut batch_workspace)
Expand All @@ -191,7 +190,6 @@ where
self.checkpoint = Some(batch_workspace.checkpoint());

let mut batch_receipts = vec![];

for (blob_idx, mut blob) in selected_blobs.into_iter().enumerate() {
let batch_receipt = self
.apply_blob(blob.as_mut_ref())
Expand Down
Loading