Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Aug 29, 2024
1 parent 5ab3b20 commit 5186041
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ execution-reports/
db/proofs.db

**/bin/op-proposer

artifact_*
24 changes: 15 additions & 9 deletions crates/host-utils/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,21 @@ impl SP1KonaDataFetcher {
/// with block_number. Return the arguments to be passed to the native host for datagen.
pub async fn get_host_cli_args(
&self,
l2_block_safe_head: u64,
l2_claim_block_nb: u64,
l2_start_block: u64,
l2_end_block: u64,
multi_block: ProgramType,
) -> Result<HostCli> {
if l2_start_block >= l2_end_block {
return Err(anyhow::anyhow!(
"L2 block safe head is greater than or equal to the claim block number"
));
}

let l2_provider = self.l2_provider.clone();

// Get L2 output data.
let l2_output_block = l2_provider
.get_block_by_number(l2_block_safe_head.into(), false)
.get_block_by_number(l2_start_block.into(), false)
.await?
.unwrap();
let l2_output_state_root = l2_output_block.header.state_root;
Expand All @@ -273,7 +279,7 @@ impl SP1KonaDataFetcher {
Address::from_str("0x4200000000000000000000000000000000000016")?,
Vec::new(),
)
.block_id(l2_block_safe_head.into())
.block_id(l2_start_block.into())
.await?
.storage_hash;

Expand All @@ -287,7 +293,7 @@ impl SP1KonaDataFetcher {

// Get L2 claim data.
let l2_claim_block = l2_provider
.get_block_by_number(l2_claim_block_nb.into(), false)
.get_block_by_number(l2_end_block.into(), false)
.await?
.unwrap();
let l2_claim_state_root = l2_claim_block.header.state_root;
Expand All @@ -300,7 +306,7 @@ impl SP1KonaDataFetcher {
Address::from_str("0x4200000000000000000000000000000000000016")?,
Vec::new(),
)
.block_id(l2_claim_block_nb.into())
.block_id(l2_end_block.into())
.await?
.storage_hash;

Expand Down Expand Up @@ -331,14 +337,14 @@ impl SP1KonaDataFetcher {
ProgramType::Single => {
let proof_dir = format!(
"{}/data/{}/single/{}",
workspace_root, l2_chain_id, l2_claim_block_nb
workspace_root, l2_chain_id, l2_end_block
);
proof_dir
}
ProgramType::Multi => {
let proof_dir = format!(
"{}/data/{}/multi/{}-{}",
workspace_root, l2_chain_id, l2_block_safe_head, l2_claim_block_nb
workspace_root, l2_chain_id, l2_start_block, l2_end_block
);
proof_dir
}
Expand All @@ -362,7 +368,7 @@ impl SP1KonaDataFetcher {
l1_head: l1_head.0.into(),
l2_output_root: l2_output_root.0.into(),
l2_claim: l2_claim.0.into(),
l2_block_number: l2_claim_block_nb,
l2_block_number: l2_end_block,
l2_chain_id,
l2_head: l2_head.0.into(),
l2_node_address: Some(self.l2_rpc.clone()),
Expand Down
4 changes: 4 additions & 0 deletions op-succinct-proposer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ path = "bin/vkey.rs"
name = "cost_estimator"
path = "bin/cost_estimator.rs"

[[bin]]
name = "load_stdin"
path = "bin/load_stdin.rs"

[dependencies]

# workspace
Expand Down
22 changes: 22 additions & 0 deletions op-succinct-proposer/bin/load_stdin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use bincode;
use client_utils::RawBootInfo;
use host_utils::fetcher::SP1KonaDataFetcher;
use sp1_sdk::{utils, SP1Stdin};
use std::fs;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
utils::setup_logger();
// Read the artifact file
// Claiming block 16544118
let artifact_bytes = fs::read("artifact_01j6dxg0f7evpv9v7myf0q9xcd")?;

// Deserialize the bytes into SP1Stdin
let mut stdin: SP1Stdin = bincode::deserialize(&artifact_bytes)?;

let boot = stdin.read::<RawBootInfo>();

println!("{:?}", boot);

Ok(())
}

0 comments on commit 5186041

Please sign in to comment.