Skip to content

Commit

Permalink
fix: fixes after e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
th7nder committed Nov 26, 2024
1 parent 88acdab commit 42a5b00
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
17 changes: 10 additions & 7 deletions cli/polka-storage-provider/client/src/commands/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use primitives_commitment::{
};
use primitives_proofs::{
derive_prover_id,
randomness::{self, draw_randomness, DomainSeparationTag},
randomness::{draw_randomness, DomainSeparationTag},
RegisteredPoStProof, RegisteredSealProof, SectorNumber,
};
use storagext::multipair::{MultiPairArgs, MultiPairSigner};
Expand Down Expand Up @@ -115,10 +115,6 @@ pub enum ProofsCommand {
/// It must be the same, or else it won't work.
#[arg(short, long)]
cache_directory: PathBuf,
/// Replica file generated with `porep` command e.g. `77.sector.sealed`.
replica_path: PathBuf,
/// CID - CommR of a replica (output of `porep` command)
comm_r: String,
#[arg(short, long)]
/// Directory where the PoSt proof will be stored. Defaults to the current directory.
output_path: Option<PathBuf>,
Expand All @@ -127,7 +123,12 @@ pub enum ProofsCommand {
sector_number: u32,
/// Block Number at which the randomness should be fetched from.
/// It comes from the [`pallet_storage_provider::DeadlineInfo::challenge`] field.
#[arg(long)]
challenge_block: u64,
/// Replica file generated with `porep` command e.g. `77.sector.sealed`.
replica_path: PathBuf,
/// CID - CommR of a replica (output of `porep` command)
comm_r: String,
},
}

Expand Down Expand Up @@ -412,15 +413,16 @@ impl ProofsCommand {
comm_r,
output_path,
sector_number,
challenge_block,
} => {
let Some(signer) = Option::<MultiPairSigner>::from(signer_key) else {
return Err(UtilsCommandError::NoSigner)?;
};

let entropy = derive_prover_id(signer.account_id());
let entropy = signer.account_id().encode();
let randomness = get_randomness(
DomainSeparationTag::WindowedPoStChallengeSeed,
seal_randomness_height,
challenge_block,
&entropy,
);

Expand Down Expand Up @@ -453,6 +455,7 @@ impl ProofsCommand {
let proof_parameters = post::load_groth16_parameters(proof_parameters_path)
.map_err(|e| UtilsCommandError::GeneratePoStError(e))?;

let prover_id = derive_prover_id(signer.account_id());
let proofs = post::generate_window_post(
post_type,
&proof_parameters,
Expand Down
5 changes: 4 additions & 1 deletion primitives/proofs/src/randomness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ pub fn draw_randomness(
data.extend_from_slice(entropy);

// Hash the data
blake2_256(&data)
let mut hashed = blake2_256(&data);
// Necessary to be valid bls12 381 element.
hashed[31] &= 0x3f;
hashed
}

#[cfg(test)]
Expand Down

0 comments on commit 42a5b00

Please sign in to comment.