Skip to content

Commit

Permalink
fix: make it work with fixed randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
th7nder committed Nov 22, 2024
1 parent f988f24 commit d64dbc4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions cli/polka-storage-provider/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bls12_381 = { workspace = true }
cid = { workspace = true, features = ["std"] }
clap = { workspace = true, features = ["derive"] }
codec = { workspace = true }
hex = { workspace = true }
jsonrpsee = { workspace = true, features = ["http-client", "macros", "server", "ws-client"] }
sc-cli = { workspace = true }
serde = { workspace = true }
Expand Down
21 changes: 17 additions & 4 deletions cli/polka-storage-provider/client/src/commands/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ pub enum ProofsCommand {
#[arg(short, long)]
/// Directory where the PoSt proof will be stored. Defaults to the current directory.
output_path: Option<PathBuf>,
#[arg(short, long)]
sector_number: u64,
#[arg(short, long)]
randomness: Option<String>,
},
}

Expand Down Expand Up @@ -361,6 +365,8 @@ impl ProofsCommand {
replica_path,
comm_r,
output_path,
sector_number,
randomness,
} => {
let Some(signer) = Option::<MultiPairSigner>::from(signer_key) else {
return Err(UtilsCommandError::NoSigner)?;
Expand All @@ -369,8 +375,15 @@ impl ProofsCommand {

// Those are hardcoded for the showcase only.
// They should come from Storage Provider Node, precommits and other information.
let sector_id = 77.into();
let randomness = [1u8; 32];

// how do I get the same randomness as on-chain? :(
// need to be able to calculate deadline info and challenge
// I'll hardcode it for now
let randomness: [u8; 32] = if let Some(randomness) = randomness {
hex::decode(randomness).unwrap().try_into().unwrap()
} else {
[1u8; 32]
};

let output_path = if let Some(output_path) = output_path {
output_path
Expand All @@ -380,15 +393,15 @@ impl ProofsCommand {

let (proof_scale_filename, mut proof_scale_file) = file_with_extension(
&output_path,
format!("{}", sector_id).as_str(),
format!("{}", sector_number).as_str(),
POST_PROOF_EXT,
)?;

let comm_r =
cid::Cid::from_str(&comm_r).map_err(|_| UtilsCommandError::CommRError)?;

let replicas = vec![ReplicaInfo {
sector_id,
sector_id: sector_number,
comm_r: comm_r
.hash()
.digest()
Expand Down
2 changes: 1 addition & 1 deletion cli/polka-storage-provider/server/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async fn precommit(
})
};
let sealing_output = sealing_handle.await??;
tracing::info!("Created sector's replica: {:?}", sealing_output);
tracing::info!("Created sector's replica, CommD: {}, CommR: {}", sealing_output.comm_d.cid(), sealing_output.comm_r.cid());

let sealing_output_commr = Commitment::<CommR>::from(sealing_output.comm_r);
let sealing_output_commd = Commitment::<CommD>::from(sealing_output.comm_d);
Expand Down

0 comments on commit d64dbc4

Please sign in to comment.