-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use alloy::{ | ||
primitives::B256, providers::Provider, rpc::types::eth::BlockId, transports::Transport, | ||
}; | ||
use prover::BlockProverInput; | ||
use trace_decoder::BlockTrace; | ||
|
||
use super::{fetch_other_block_data, CachedProvider}; | ||
|
||
pub async fn block_prover_input<ProviderT, TransportT>( | ||
provider: &CachedProvider<ProviderT, TransportT>, | ||
target_block_id: BlockId, | ||
checkpoint_state_trie_root: B256, | ||
) -> anyhow::Result<BlockProverInput> | ||
where | ||
ProviderT: Provider<TransportT>, | ||
TransportT: Transport + Clone, | ||
{ | ||
let block_number = match target_block_id { | ||
BlockId::Number(block_number) => block_number, | ||
_ => return Err(anyhow::anyhow!("block number expected")), | ||
}; | ||
|
||
let block_trace = provider | ||
.as_provider() | ||
.raw_request::<_, BlockTrace>("zero_getBlockTraceByNumber".into(), vec![block_number]) | ||
.await?; | ||
|
||
let other_data = | ||
fetch_other_block_data(provider, target_block_id, checkpoint_state_trie_root).await?; | ||
|
||
// Assemble | ||
Ok(BlockProverInput { | ||
block_trace, | ||
other_data, | ||
}) | ||
} |