Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Aug 15, 2024
1 parent bfc3de5 commit 2f08cbc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions zero_bin/leader/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::sync::Arc;
use alloy::rpc::types::{BlockId, BlockNumberOrTag, BlockTransactionsKind};
use alloy::transports::http::reqwest::Url;
use anyhow::Result;
use futures::StreamExt;
use paladin::runtime::Runtime;
use proof_gen::proof_types::GeneratedBlockProof;
use rpc::{retry::build_http_retry_provider, RpcType};
Expand Down Expand Up @@ -37,7 +36,8 @@ pub(crate) async fn client_main(
block_interval: BlockInterval,
mut params: ProofParams,
) -> Result<()> {
use futures::FutureExt;
use futures::{FutureExt, StreamExt};

let cached_provider = Arc::new(rpc::provider::CachedProvider::new(
build_http_retry_provider(
rpc_params.rpc_url.clone(),
Expand All @@ -57,10 +57,10 @@ pub(crate) async fn client_main(
.state_root;

let mut block_prover_inputs = Vec::new();
let mut block_interval = block_interval.clone().into_bounded_stream()?;
let mut block_interval = block_interval.into_bounded_stream()?;
while let Some(block_num) = block_interval.next().await {
let block_id = BlockId::Number(BlockNumberOrTag::Number(block_num));
// Get future of prover input for particular block
// Get future of prover input for particular block.
let block_prover_input = rpc::block_prover_input(
cached_provider.clone(),
block_id,
Expand Down
7 changes: 3 additions & 4 deletions zero_bin/leader/src/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::{Read, Write};
use anyhow::Result;
use paladin::runtime::Runtime;
use proof_gen::proof_types::GeneratedBlockProof;
use prover::{into_block_prover_input_future, BlockProverInput, FutureBlockProverInput};
use prover::{into_block_prover_input_future, BlockProverInput, BlockProverInputFuture};
use tracing::info;

/// The main function for the stdio mode.
Expand All @@ -16,11 +16,10 @@ pub(crate) async fn stdio_main(
std::io::stdin().read_to_string(&mut buffer)?;

let des = &mut serde_json::Deserializer::from_str(&buffer);
let block_prover_inputs: Vec<BlockProverInput> = serde_path_to_error::deserialize(des)?;
let block_prover_inputs = block_prover_inputs
let block_prover_inputs = serde_path_to_error::deserialize::<_, Vec<BlockProverInput>>(des)?
.into_iter()
.map(into_block_prover_input_future)
.collect::<Vec<FutureBlockProverInput>>();
.collect::<Vec<BlockProverInputFuture>>();

let proved_blocks = prover::prove(
block_prover_inputs,
Expand Down
7 changes: 4 additions & 3 deletions zero_bin/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use trace_decoder::{BlockTrace, OtherBlockData};
use tracing::info;
use zero_bin_common::fs::generate_block_proof_file_name;

pub type FutureBlockProverInput = std::pin::Pin<
pub type BlockProverInputFuture = std::pin::Pin<
Box<dyn Future<Output = std::result::Result<BlockProverInput, anyhow::Error>> + Send>,
>;

pub fn into_block_prover_input_future(value: BlockProverInput) -> FutureBlockProverInput {
pub fn into_block_prover_input_future(value: BlockProverInput) -> BlockProverInputFuture {
async fn into(value: BlockProverInput) -> Result<BlockProverInput, anyhow::Error> {
Ok(value)
}
Expand Down Expand Up @@ -130,7 +130,7 @@ impl BlockProverInput {
/// Return the list of block numbers that are proved and if the proof data
/// is not saved to disk, return the generated block proofs as well.
pub async fn prove(
block_prover_inputs: Vec<FutureBlockProverInput>,
block_prover_inputs: Vec<BlockProverInputFuture>,
runtime: &Runtime,
previous_proof: Option<GeneratedBlockProof>,
save_inputs_on_error: bool,
Expand All @@ -145,6 +145,7 @@ pub async fn prove(
let proof_output_dir = proof_output_dir.clone();
let previos_block_proof = prev.take();
let fut = async move {
// Get the prover input data from the external source (e.g. Erigon node).
let block = block_prover_input.await?;
let block_number = block.get_block_number();
info!("Proving block {block_number}");
Expand Down
6 changes: 3 additions & 3 deletions zero_bin/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ where
.chunks(2)
.into_iter()
.map(|mut chunk| {
// We convert to type of (current, Option previous block)
// We convert to tuple of (current, Option previous block)
if let Some(first) = chunk.next() {
let second = chunk.next();
(first, second)
} else {
panic!("Not be possible according to itertools::Iterator::chunks definition")
panic!("not possible according to itertools::Iterator::chunks definition")
}
})
.collect::<Vec<_>>();
println!(">>>>>>>>> Ovde je kontrola: {:?}", previous_block_numbers);

let concurrency = previous_block_numbers.len();
let collected_hashes = futures::stream::iter(
previous_block_numbers
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Cli {
let mut block_interval = block_interval.clone().into_bounded_stream()?;
while let Some(block_num) = block_interval.next().await {
let block_id = BlockId::Number(BlockNumberOrTag::Number(block_num));
// Get future of prover input for particular block
// Get the prover input for particular block.
let result = rpc::block_prover_input(
cached_provider.clone(),
block_id,
Expand Down

0 comments on commit 2f08cbc

Please sign in to comment.