Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(polka-storage-provider-server): prove commit #502

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

Binary file modified cli/artifacts/metadata.scale
Binary file not shown.
4 changes: 3 additions & 1 deletion cli/polka-storage-provider/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "0.1.0"
[dependencies]
# "Homegrown" crates
mater = { workspace = true }
polka-storage-proofs = { workspace = true, features = ["std"] }
polka-storage-proofs = { workspace = true, features = ["std", "substrate"] }
polka-storage-provider-common = { workspace = true }
primitives-commitment = { workspace = true, features = ["serde", "std"] }
primitives-proofs = { workspace = true, features = ["clap"] }
Expand All @@ -20,11 +20,13 @@ async-trait = { workspace = true }
axum = { workspace = true, features = ["macros", "multipart"] }
cid = { workspace = true, features = ["serde", "std"] }
clap = { workspace = true, features = ["derive"] }
codec = { workspace = true }
futures = { workspace = true }
jsonrpsee = { workspace = true, features = ["http-client", "macros", "server", "ws-client"] }
rand = { workspace = true }
rocksdb = { workspace = true }
sc-cli = { workspace = true }
hex = { workspace = true, features = ["std"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
subxt = { workspace = true }
Expand Down
24 changes: 23 additions & 1 deletion cli/polka-storage-provider/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{env::temp_dir, net::SocketAddr, path::PathBuf, sync::Arc, time::Durati

use clap::Parser;
use pipeline::types::PipelineMessage;
use polka_storage_proofs::porep::{self, PoRepParameters};
use polka_storage_provider_common::rpc::ServerInfo;
use primitives_proofs::{RegisteredPoStProof, RegisteredSealProof};
use rand::Rng;
Expand Down Expand Up @@ -118,6 +119,9 @@ pub enum ServerError {
#[error("proof sectors sizes do not match")]
SectorSizeMismatch,

#[error("failed to load PoRep parameters from: {0}, because: {1}")]
InvalidPoRepParameters(std::path::PathBuf, porep::PoRepError),

#[error("FromEnv error: {0}")]
EnvFilter(#[from] tracing_subscriber::filter::FromEnvError),

Expand Down Expand Up @@ -194,13 +198,22 @@ pub struct ServerArguments {
/// Proof of Spacetime proof type.
#[arg(long)]
post_proof: RegisteredPoStProof,

/// Proving Parameters for PoRep proof, corresponding to given `seal_proof` sector size.
/// They are shared across all of the nodes in the network, as the chain stores corresponding Verifying Key parameters.
/// Shared parameters available to get in the [root repo](http://github.com/eigerco/polka-storage/README.md#Parameters).
///
/// Testing/temporary parameters can be also generated via `polka-storage-provider-client proofs porep-params` command.
/// Note that when you generate keys, for local testnet,
/// **they need to be set** via an extrinsic pallet-proofs::set_porep_verifyingkey.
#[arg(long)]
porep_parameters: PathBuf,
}

/// A valid server configuration. To be created using [`ServerConfiguration::try_from`].
///
/// The main difference to [`Server`] is that this structure only contains validated and
/// ready to use parameters.
#[derive(Debug)]
pub struct ServerConfiguration {
/// Storage server listen address.
upload_listen_address: SocketAddr,
Expand All @@ -226,6 +239,10 @@ pub struct ServerConfiguration {

/// Proof of Spacetime proof type.
post_proof: RegisteredPoStProof,

/// Proving Parameters for PoRep proof
th7nder marked this conversation as resolved.
Show resolved Hide resolved
/// For 2KiB sectors they're ~1GiB of data.
porep_parameters: PoRepParameters,
}

impl TryFrom<ServerArguments> for ServerConfiguration {
Expand Down Expand Up @@ -264,6 +281,9 @@ impl TryFrom<ServerArguments> for ServerConfiguration {
});
std::fs::create_dir_all(&storage_directory)?;

let porep_parameters = porep::load_groth16_parameters(value.porep_parameters.clone())
.map_err(|e| ServerError::InvalidPoRepParameters(value.porep_parameters, e))?;

Ok(Self {
upload_listen_address: value.upload_listen_address,
rpc_listen_address: value.rpc_listen_address,
Expand All @@ -273,6 +293,7 @@ impl TryFrom<ServerArguments> for ServerConfiguration {
storage_directory,
seal_proof: value.seal_proof,
post_proof: value.post_proof,
porep_parameters,
})
}
}
Expand Down Expand Up @@ -395,6 +416,7 @@ impl ServerConfiguration {
unsealed_sectors_dir: unsealed_sector_storage_dir,
sealed_sectors_dir: sealed_sector_storage_dir,
sealing_cache_dir,
porep_parameters: Arc::new(self.porep_parameters),
xt_client,
xt_keypair: self.multi_pair_signer,
pipeline_sender: pipeline_tx,
Expand Down
Loading