Skip to content

Commit

Permalink
[benchmark] Respect current Epoch and Committee on block proposal cre…
Browse files Browse the repository at this point in the history
…ation (#3297)

## Motivation

Right now we don't respect the current Epoch when creating block proposals for the benchmark, as well as not getting the committee for the current epoch (we always just build a committee from the genesis config)

## Proposal

Send block proposals to committee of the current epoch, and build block proposals taking current epoch into consideration

## Test Plan

CI + ran benchmark locally

## Release Plan

- Nothing to do / These changes follow the usual release cycle.
  • Loading branch information
ndr-ds authored Feb 13, 2025
1 parent a279de2 commit f77f41e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
3 changes: 2 additions & 1 deletion linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,14 @@ where
blocks_infos_iter: impl Iterator<Item = &(ChainId, Vec<Operation>, KeyPair)>,
clients: Vec<linera_rpc::Client>,
transactions_per_block: usize,
epoch: Epoch,
) -> Result<(), Error> {
let mut num_sent_proposals = 0;
let mut start = Instant::now();
for (chain_id, operations, key_pair) in blocks_infos_iter {
let chain = self.wallet.get(*chain_id).expect("should have chain");
let block = ProposedBlock {
epoch: Epoch::ZERO,
epoch,
chain_id: *chain_id,
incoming_bundles: Vec::new(),
operations: operations.clone(),
Expand Down
31 changes: 27 additions & 4 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,26 +778,49 @@ impl Runnable for Job {
);
}

let default_chain_id = context
.wallet
.default_chain()
.expect("should have default chain");
let chain_client = context.make_chain_client(default_chain_id)?;
let (epoch, committees) =
chain_client.epoch_and_committees(default_chain_id).await?;
let epoch = epoch.expect("default chain should have an epoch");
let committee = committees
.get(&epoch)
.expect("current epoch should have a committee");
let blocks_infos = context.make_benchmark_block_info(
key_pairs,
transactions_per_block,
fungible_application_id,
);
let committee = context.wallet.genesis_config().create_committee();

let clients = context
.make_node_provider()
.make_nodes(&committee)?
.make_nodes(committee)?
.map(|(_, node)| node)
.collect::<Vec<_>>();
let blocks_infos_iter = blocks_infos.iter();
if bps.is_some() {
let blocks_infos_iter = blocks_infos_iter.cycle();
context
.run_benchmark(bps, blocks_infos_iter, clients, transactions_per_block)
.run_benchmark(
bps,
blocks_infos_iter,
clients,
transactions_per_block,
epoch,
)
.await?;
} else {
context
.run_benchmark(bps, blocks_infos_iter, clients, transactions_per_block)
.run_benchmark(
bps,
blocks_infos_iter,
clients,
transactions_per_block,
epoch,
)
.await?;
}
}
Expand Down

0 comments on commit f77f41e

Please sign in to comment.