diff --git a/README.md b/README.md index 6d9111d6..477f2c9e 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ This will: cargo run -- init \ --curio local:/home/user/code/curio \ --filecoin-services local:/home/user/code/filecoin-services \ + --pdp local:/home/user/code/pdp \ --lotus local:/home/user/code/lotus \ ``` @@ -124,8 +125,9 @@ Only needs three things on your machine: Everything else (Lotus, Curio, dependencies) is built inside Docker. ### ⚙️ Configurable Repositories -Depends on 3 repositories, all configurable: +Depends on these repositories, all configurable: - `filecoin-services` - FOC smart contracts +- `pdp` - PDP contracts, optionally pinned independently from filecoin-services - `curio` - Next-gen storage provider - `lotus` - Filecoin daemon diff --git a/README_ADVANCED.md b/README_ADVANCED.md index 4d089a79..8a1de7d0 100644 --- a/README_ADVANCED.md +++ b/README_ADVANCED.md @@ -38,6 +38,7 @@ foc-devnet init [OPTIONS] - `--curio ` - Curio source location - `--lotus ` - Lotus source location - `--filecoin-services ` - Filecoin Services source location +- `--pdp ` - PDP source location. If omitted, uses the PDP submodule bundled with Filecoin Services. - `--proof-params-dir ` - Local proof params directory - `--rand` - Use random mnemonic instead of deterministic one. Use this for unique test scenarios. @@ -257,6 +258,12 @@ branch = "pdpv0" url = "https://github.com/FilOzone/filecoin-services.git" tag = "v1.0.0" +# Optional. When omitted, filecoin-services' service_contracts/lib/pdp +# submodule is used. +[pdp] +url = "https://github.com/FilOzone/pdp.git" +tag = "v3.4.0" + [multicall3] url = "https://github.com/mds1/multicall3.git" branch = "main" @@ -809,6 +816,7 @@ port_range_count = 100 - **[lotus](https://github.com/filecoin-project/lotus)** - Filecoin daemon - **[curio](https://github.com/filecoin-project/curio)** - Storage provider (PDP) - **[filecoin-services](https://github.com/FilOzone/filecoin-services)** - FOC smart contracts +- **[pdp](https://github.com/FilOzone/pdp)** - PDP contracts; optional independent override mounted over `service_contracts/lib/pdp` - **[multicall3](https://github.com/mds1/multicall3)** - Multicall3 contract ### Dependent Version Strategy @@ -830,7 +838,8 @@ Default versions for these repositories are defined in code (see [`src/config.rs foc-devnet init \ --lotus local:/home/user/dev/lotus \ --curio local:/home/user/dev/curio \ - --filecoin-services local:/home/user/dev/filecoin-services + --filecoin-services local:/home/user/dev/filecoin-services \ + --pdp local:/home/user/dev/pdp ``` **Mixed approach:** @@ -1324,7 +1333,10 @@ Scenarios run automatically in CI after the devnet starts. On nightly runs (or m CI resolves compatibility-sensitive dependencies from `ci/dependency-profiles.json`. Pull requests use the pinned `default` profile, while nightly `stability` runs use the latest final releases and nightly `frontier` runs pin current development -branch heads to immutable commits. The resolved metadata path is exposed to -scenarios as `CI_DEPENDENCY_METADATA`; Synapse SDK and filecoin-pin also receive -their exact source, version/ref, and commit through `SYNAPSE_SDK_*` and -`FILECOIN_PIN_*` environment variables. +branch heads to immutable commits. In `stability`, PDP comes from the stable +filecoin-services checkout's bundled submodule; in `frontier`, PDP is pinned as +an independent repo. The resolved metadata path is exposed to scenarios as +`CI_DEPENDENCY_METADATA`; Synapse SDK and filecoin-pin also receive their exact +source, version/ref, and commit through `SYNAPSE_SDK_*` and `FILECOIN_PIN_*` +environment variables. PDP receives `PDP_SOURCE`, `PDP_REF`, and `PDP_COMMIT` +when dependency profiles are resolved. diff --git a/ci/README.md b/ci/README.md index 7dc40dd6..e25c2595 100644 --- a/ci/README.md +++ b/ci/README.md @@ -159,7 +159,7 @@ components. Installation currently lives in three places (which consume the resolved metadata): -- `foc-devnet init`: Lotus, Curio, and filecoin-services. +- `foc-devnet init`: Lotus, Curio, filecoin-services, and optionally PDP. - `scenarios/synapse.py`: Synapse SDK scenario dependency. - `scenarios/test_multi_copy_upload.py`: filecoin-pin scenario dependency. diff --git a/ci/dependency-profiles.json b/ci/dependency-profiles.json index f4874146..957c9c00 100644 --- a/ci/dependency-profiles.json +++ b/ci/dependency-profiles.json @@ -43,6 +43,19 @@ "branch": "main" } }, + "pdp": { + "repository": "https://github.com/FilOzone/pdp.git", + "default": { + "strategy": "config_default" + }, + "stability": { + "strategy": "config_default" + }, + "frontier": { + "strategy": "git_branch", + "branch": "main" + } + }, "synapse-sdk": { "repository": "https://github.com/FilOzone/synapse-sdk.git", "npm_package": "@filoz/synapse-sdk", diff --git a/scripts/resolve-ci-dependencies.py b/scripts/resolve-ci-dependencies.py index 56ddcade..066c4d4b 100644 --- a/scripts/resolve-ci-dependencies.py +++ b/scripts/resolve-ci-dependencies.py @@ -18,6 +18,7 @@ "lotus": "--lotus", "curio": "--curio", "filecoin-services": "--filecoin-services", + "pdp": "--pdp", } VERSION_RE = re.compile(r"^\d+(?:\.\d+)*(?:[-+][0-9A-Za-z.-]+)?$") STABLE_VERSION_RE = re.compile(r"^\d+(?:\.\d+)*$") @@ -306,6 +307,9 @@ def scenario_environment(metadata_path: Path, components: dict) -> dict: "FILECOIN_PIN_SOURCE": filecoin_pin["source"], "FILECOIN_PIN_VERSION": filecoin_pin.get("version", ""), "FILECOIN_PIN_COMMIT": filecoin_pin.get("commit", ""), + "PDP_SOURCE": components["pdp"]["source"], + "PDP_REF": components["pdp"].get("ref", ""), + "PDP_COMMIT": components["pdp"].get("commit", ""), } @@ -335,6 +339,8 @@ def verify(args) -> None: metadata = json.loads(args.metadata.read_text()) components = metadata["components"] for name in INIT_COMPONENT_FLAGS: + if name == "pdp" and components[name]["source"] == "config_default": + continue repository_path = args.code_dir / name actual = run_command(["git", "-C", str(repository_path), "rev-parse", "HEAD"]) expected = components[name].get("commit") diff --git a/scripts/tests/test_resolve_ci_dependencies.py b/scripts/tests/test_resolve_ci_dependencies.py index c44f3cb7..1302dca7 100644 --- a/scripts/tests/test_resolve_ci_dependencies.py +++ b/scripts/tests/test_resolve_ci_dependencies.py @@ -314,6 +314,11 @@ def test_init_args_skip_config_defaults_and_pin_other_sources(self): "repository": "https://example.test/services.git", "commit": "def", }, + "pdp": { + "source": "git", + "repository": "https://example.test/pdp.git", + "commit": "123", + }, } self.assertEqual( resolver.build_init_args(components), @@ -322,9 +327,20 @@ def test_init_args_skip_config_defaults_and_pin_other_sources(self): "gitcommit:https://example.test/curio.git:abc", "--filecoin-services", "gitcommit:https://example.test/services.git:def", + "--pdp", + "gitcommit:https://example.test/pdp.git:123", ], ) + def test_init_args_skip_default_pdp(self): + components = { + "lotus": {"source": "config_default"}, + "curio": {"source": "config_default"}, + "filecoin-services": {"source": "config_default"}, + "pdp": {"source": "config_default"}, + } + self.assertEqual(resolver.build_init_args(components), []) + def test_cache_hash_depends_only_on_lotus_and_curio_commits(self): base = { "lotus": {"commit": "aaa"}, @@ -348,7 +364,10 @@ def test_verify_records_checkouts_and_writes_cache_key(self, run_command): metadata = { "schema_version": 1, "profile": "default", - "components": {name: {"source": "config_default"} for name in commits}, + "components": { + **{name: {"source": "config_default"} for name in commits}, + "pdp": {"source": "config_default"}, + }, } with tempfile.TemporaryDirectory() as directory: directory = Path(directory) @@ -370,8 +389,45 @@ def test_verify_records_checkouts_and_writes_cache_key(self, run_command): self.assertEqual(verified["components"]["lotus"]["commit"], "aaa") self.assertTrue(verified["components"]["curio"]["verified"]) + self.assertFalse(verified["components"]["pdp"].get("verified", False)) self.assertIn("source-hash=", outputs) + @patch.object(resolver, "run_command") + def test_verify_checks_independent_pdp_checkout(self, run_command): + commits = { + "lotus": "aaa", + "curio": "bbb", + "filecoin-services": "ccc", + "pdp": "ddd", + } + run_command.side_effect = lambda command: commits[Path(command[2]).name] + metadata = { + "schema_version": 1, + "profile": "frontier", + "components": { + name: {"source": "git", "commit": commit} + for name, commit in commits.items() + }, + } + with tempfile.TemporaryDirectory() as directory: + directory = Path(directory) + metadata_path = directory / "metadata.json" + metadata_path.write_text(json.dumps(metadata)) + args = type( + "Args", + (), + { + "metadata": metadata_path, + "code_dir": directory / "code", + "github_output": None, + }, + ) + resolver.verify(args) + verified = json.loads(metadata_path.read_text()) + + self.assertTrue(verified["components"]["pdp"]["verified"]) + self.assertEqual(verified["components"]["pdp"]["commit"], "ddd") + if __name__ == "__main__": unittest.main() diff --git a/src/cli.rs b/src/cli.rs index 552843a7..0b798313 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -56,6 +56,14 @@ pub enum Commands { /// 'local:/path/to/filecoin-services'. #[arg(long)] filecoin_services: Option, + /// PDP source location. If omitted, uses filecoin-services' bundled lib/pdp submodule. + /// Latest tag: 'latesttag' (newest), 'latesttag:' (e.g. 'latesttag:v*'), + /// 'latesttag::' (custom repo). Resolved once at init. + /// Explicit: 'gittag:', 'gittag::', 'gitcommit:', + /// 'gitcommit::', 'gitbranch:', 'gitbranch::', + /// 'local:/path/to/pdp'. + #[arg(long)] + pdp: Option, /// Path to local filecoin-proof-params directory to use instead of downloading #[arg(long)] proof_params_dir: Option, diff --git a/src/commands/init/config.rs b/src/commands/init/config.rs index 3e478752..85fc1db8 100644 --- a/src/commands/init/config.rs +++ b/src/commands/init/config.rs @@ -21,6 +21,7 @@ use crate::paths::foc_devnet_config; /// * `curio_location` - Optional override for Curio repository location /// * `lotus_location` - Optional override for Lotus repository location /// * `filecoin_services_location` - Optional override for Filecoin Services repository location +/// * `pdp_location` - Optional override for PDP repository location /// /// # Returns /// Returns `Ok(())` on successful config generation, or an error if generation fails. @@ -28,6 +29,7 @@ pub fn generate_default_config( curio_location: Option, lotus_location: Option, filecoin_services_location: Option, + pdp_location: Option, ) -> Result<(), Box> { let config_path = foc_devnet_config(); @@ -37,6 +39,7 @@ pub fn generate_default_config( if curio_location.is_some() || lotus_location.is_some() || filecoin_services_location.is_some() + || pdp_location.is_some() { let content = fs::read_to_string(&config_path)?; let mut config: Config = toml::from_str(&content) @@ -46,6 +49,7 @@ pub fn generate_default_config( curio_location, lotus_location, filecoin_services_location, + pdp_location, )?; let updated = toml::to_string(&config) .map_err(|e| format!("Failed to serialize config: {}", e))?; @@ -66,6 +70,7 @@ pub fn generate_default_config( curio_location, lotus_location, filecoin_services_location, + pdp_location, )?; let default_config = toml::to_string(&config) @@ -83,6 +88,7 @@ fn apply_overrides( curio_location: Option, lotus_location: Option, filecoin_services_location: Option, + pdp_location: Option, ) -> Result<(), Box> { apply_location_override( &mut config.lotus, @@ -99,6 +105,18 @@ fn apply_overrides( filecoin_services_location, "https://github.com/FilOzone/filecoin-services.git", )?; + if let Some(pdp_location) = pdp_location { + let mut pdp = config.pdp.clone().unwrap_or_else(|| Location::GitBranch { + url: "https://github.com/FilOzone/pdp.git".to_string(), + branch: "main".to_string(), + }); + apply_location_override( + &mut pdp, + Some(pdp_location), + "https://github.com/FilOzone/pdp.git", + )?; + config.pdp = Some(pdp); + } Ok(()) } diff --git a/src/commands/init/mod.rs b/src/commands/init/mod.rs index 47280ca7..f503f869 100644 --- a/src/commands/init/mod.rs +++ b/src/commands/init/mod.rs @@ -24,6 +24,7 @@ pub struct InitOptions { pub curio_location: Option, pub lotus_location: Option, pub filecoin_services_location: Option, + pub pdp_location: Option, pub proof_params_dir: Option, pub use_random_mnemonic: bool, pub no_docker_build: bool, @@ -47,6 +48,7 @@ pub fn init_environment(options: InitOptions) -> Result<(), Box Result<(), Box> { // Download filecoin-services repository if Git-based download_repository("filecoin-services", &config.filecoin_services)?; + // Download PDP repository if independently configured. Otherwise use the + // filecoin-services submodule. + if let Some(pdp) = &config.pdp { + download_repository("pdp", pdp)?; + } + // Download multicall3 repository if Git-based download_repository("multicall3", &config.multicall3)?; diff --git a/src/commands/start/foc_deploy/deployment.rs b/src/commands/start/foc_deploy/deployment.rs index edd3f85d..d2f26045 100644 --- a/src/commands/start/foc_deploy/deployment.rs +++ b/src/commands/start/foc_deploy/deployment.rs @@ -4,7 +4,7 @@ //! including contract deployment and output parsing. use crate::commands::start::foc_deploy::contract_addresses::ContractAddresses; -use crate::commands::start::foc_deployer::deploy_foc_contracts; +use crate::commands::start::foc_deployer::{deploy_foc_contracts, DeployFocContractsParams}; use crate::paths::{contract_addresses_file, foc_metadata_file}; use std::error::Error; use tracing::{info, warn}; @@ -51,6 +51,7 @@ pub fn perform_deployment( super::helpers::check_required_addresses(context)?; let services_repo = super::helpers::get_filecoin_services_repo_path()?; + let pdp_repo = super::helpers::get_pdp_repo_path()?; // Get Lotus container name and RPC URL let run_id = context.run_id(); @@ -58,15 +59,16 @@ pub fn perform_deployment( let lotus_rpc_url = crate::commands::start::lotus_utils::get_lotus_rpc_url(context)?; // Deploy FOC contracts using deployment script - let contract_addresses = deploy_foc_contracts( - &foc_deployer, - &foc_deployer_eth, - &mock_usdfc_address, - &services_repo, - &lotus_container, - &lotus_rpc_url, + let contract_addresses = deploy_foc_contracts(DeployFocContractsParams { + foc_deployer: &foc_deployer, + deployer_eth_addr: &foc_deployer_eth, + mock_usdfc_address: &mock_usdfc_address, + services_repo_path: &services_repo, + pdp_repo_path: pdp_repo.as_deref(), + lotus_container: &lotus_container, + lotus_rpc_url: &lotus_rpc_url, run_id, - )?; + })?; // Store contract addresses in context for (name, addr) in &contract_addresses.addresses { diff --git a/src/commands/start/foc_deploy/foc_deploy_step.rs b/src/commands/start/foc_deploy/foc_deploy_step.rs index e04db7cc..16f228f3 100644 --- a/src/commands/start/foc_deploy/foc_deploy_step.rs +++ b/src/commands/start/foc_deploy/foc_deploy_step.rs @@ -6,6 +6,7 @@ use super::deployment::{check_existing_deployment, perform_deployment, post_execute_verification}; use super::helpers::{ check_lotus_running, check_required_addresses, get_filecoin_services_repo_path, + get_pdp_repo_path, }; use crate::commands::start::step::{SetupContext, Step}; use std::error::Error; @@ -56,6 +57,18 @@ impl Step for FOCDeployStep { } info!("filecoin-services repository found"); + if let Some(pdp_repo) = get_pdp_repo_path()? { + if !pdp_repo.exists() { + return Err(format!( + "PDP repository not found at {}. \ + Please run 'foc-devnet init' to clone the repository.", + pdp_repo.display() + ) + .into()); + } + info!("PDP repository found"); + } + // Check if deployment script exists let deploy_script = services_repo .join("service_contracts") diff --git a/src/commands/start/foc_deploy/helpers.rs b/src/commands/start/foc_deploy/helpers.rs index 2c48ab93..33a026eb 100644 --- a/src/commands/start/foc_deploy/helpers.rs +++ b/src/commands/start/foc_deploy/helpers.rs @@ -7,7 +7,7 @@ use crate::config::{Config, Location}; use crate::constants::LOCAL_NETWORK_CHAIN_ID; use crate::docker::containers::lotus_container_name; use crate::docker::core::container_is_running; -use crate::paths::{foc_devnet_config, foc_devnet_filecoin_services_repo}; +use crate::paths::{foc_devnet_config, foc_devnet_filecoin_services_repo, foc_devnet_pdp_repo}; use std::error::Error; use std::fs; use std::path::PathBuf; @@ -40,6 +40,23 @@ pub fn get_filecoin_services_repo_path() -> Result> { Ok(repo_path) } +/// Get the independently configured PDP repository path, if any. +pub fn get_pdp_repo_path() -> Result, Box> { + let config_path = foc_devnet_config(); + let config_content = fs::read_to_string(&config_path) + .map_err(|e| format!("Failed to read config file at {:?}: {}", config_path, e))?; + let config: Config = toml::from_str(&config_content) + .map_err(|e| format!("Failed to parse config file: {}", e))?; + + let repo_path = match &config.pdp { + Some(Location::LocalSource { dir }) => Some(PathBuf::from(dir)), + Some(_) => Some(foc_devnet_pdp_repo()), + None => None, + }; + + Ok(repo_path) +} + /// Check if Lotus is running and accessible /// /// # Arguments diff --git a/src/commands/start/foc_deployer/mod.rs b/src/commands/start/foc_deployer/mod.rs index 1db0c3e4..f4902285 100644 --- a/src/commands/start/foc_deployer/mod.rs +++ b/src/commands/start/foc_deployer/mod.rs @@ -23,6 +23,18 @@ pub struct DeploymentResult { pub metadata: FOCMetadata, } +/// Inputs required to deploy FOC contracts. +pub struct DeployFocContractsParams<'a> { + pub foc_deployer: &'a str, + pub deployer_eth_addr: &'a str, + pub mock_usdfc_address: &'a str, + pub services_repo_path: &'a std::path::Path, + pub pdp_repo_path: Option<&'a std::path::Path>, + pub lotus_container: &'a str, + pub lotus_rpc_url: &'a str, + pub run_id: &'a str, +} + /// Get the private key for an address in hex format (for use with cast/forge) /// /// # Arguments @@ -67,23 +79,18 @@ pub fn get_private_key(address: &str, _lotus_container: &str) -> Result, ) -> Result> { info!("Running warm-storage-deploy-all.sh..."); // Log the RPC URL for debugging - info!("Lotus RPC URL: {}", lotus_rpc_url); + info!("Lotus RPC URL: {}", params.lotus_rpc_url); // Resolve symlinks to get the real path for Docker mounting - let services_repo = services_repo_path + let services_repo = params + .services_repo_path .canonicalize() - .unwrap_or_else(|_| services_repo_path.to_path_buf()); + .unwrap_or_else(|_| params.services_repo_path.to_path_buf()); let contracts_dir = services_repo.join("service_contracts"); let deploy_script = contracts_dir .join("tools") @@ -98,12 +105,12 @@ pub fn deploy_foc_contracts( foc_devnet_docker_volumes_cache().join(crate::constants::BUILDER_CONTAINER); // Get the private key from lotus for the deployer address - let private_key = get_private_key(foc_deployer, lotus_container)?; + let private_key = get_private_key(params.foc_deployer, params.lotus_container)?; // Prepare environment variables for the deployment script let env_vars = [ - ("ETH_RPC_URL", lotus_rpc_url.to_string()), - ("USDFC_TOKEN_ADDRESS", mock_usdfc_address.to_string()), + ("ETH_RPC_URL", params.lotus_rpc_url.to_string()), + ("USDFC_TOKEN_ADDRESS", params.mock_usdfc_address.to_string()), ("SERVICE_NAME", "FOC DevNet Warm Storage".to_string()), ( "SERVICE_DESCRIPTION", @@ -111,7 +118,7 @@ pub fn deploy_foc_contracts( ), ("DRY_RUN", "false".to_string()), ("CHAIN", LOCAL_NETWORK_CHAIN_ID.to_string()), - ("DEPLOYER_ADDRESS", deployer_eth_addr.to_string()), + ("DEPLOYER_ADDRESS", params.deployer_eth_addr.to_string()), ("AUTO_VERIFY", "false".to_string()), ("ETH_PRIVATE_KEY", private_key.clone()), ("PASSWORD", "".to_string()), @@ -171,7 +178,7 @@ bash /service_contracts/tools/warm-storage-deploy-all.sh 2>&1 | tee /tmp/foc-dep info!("This may take several minutes..."); - let container_name = format!("foc-{}-foc-deploy", run_id); + let container_name = format!("foc-{}-foc-deploy", params.run_id); let mut docker_args = vec![ "run".to_string(), @@ -199,6 +206,13 @@ bash /service_contracts/tools/warm-storage-deploy-all.sh 2>&1 | tee /tmp/foc-dep )); docker_args.push("-v".to_string()); docker_args.push(format!("{}:/service_contracts", contracts_dir.display())); + if let Some(pdp_repo_path) = params.pdp_repo_path { + let pdp_repo = pdp_repo_path + .canonicalize() + .unwrap_or_else(|_| pdp_repo_path.to_path_buf()); + docker_args.push("-v".to_string()); + docker_args.push(format!("{}:/service_contracts/lib/pdp", pdp_repo.display())); + } // Add image and command docker_args.push(BUILDER_DOCKER_IMAGE.to_string()); diff --git a/src/commands/status/code_version.rs b/src/commands/status/code_version.rs index b122fef7..bd6c8b48 100644 --- a/src/commands/status/code_version.rs +++ b/src/commands/status/code_version.rs @@ -90,6 +90,16 @@ pub fn print_code_version() -> Result<(), Box> { "Filecoin-Services: [{},{},{}] {}", fc_services_source_type, fc_services_version, fc_services_commit, fc_services_status ); + if let Some(pdp) = &config.pdp { + let pdp_repo_path = get_repo_path_from_config(pdp, "pdp"); + let pdp_git_info = get_git_info(&pdp_repo_path)?; + let (pdp_source_type, pdp_version, pdp_commit, pdp_status) = + format_location_info(pdp, &pdp_git_info, &pdp_repo_path); + info!( + "PDP: [{},{},{}] {}", + pdp_source_type, pdp_version, pdp_commit, pdp_status + ); + } Ok(()) } diff --git a/src/config.rs b/src/config.rs index e2e788c7..17706f5d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -229,6 +229,15 @@ pub struct Config { /// See [`Location`] for available options. pub filecoin_services: Location, + /// Optional location specification for the PDP repository. + /// + /// When unset, foc-devnet uses the PDP submodule bundled with + /// filecoin-services. When set, this checkout is mounted over + /// service_contracts/lib/pdp during FOC contract deployment. + /// See [`Location`] for available options. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pdp: Option, + /// Location specification for the multicall3 repository. /// /// Defines how to obtain the multicall3 code, which provides the @@ -287,6 +296,7 @@ impl Default for Config { url: "https://github.com/FilOzone/filecoin-services.git".to_string(), tag: "v1.3.0".to_string(), }, + pdp: None, multicall3: Location::GitTag { url: "https://github.com/mds1/multicall3.git".to_string(), tag: "v3.1.0".to_string(), @@ -333,7 +343,7 @@ impl Config { #[cfg(test)] mod tests { - use super::Location; + use super::{Config, Location}; const DEFAULT_URL: &str = "https://github.com/default/repo.git"; @@ -458,4 +468,30 @@ mod tests { fn empty_string_returns_error() { assert!(canonicalize("").is_err()); } + + #[test] + fn default_config_omits_optional_pdp_and_parses_without_it() { + let serialized = toml::to_string(&Config::default()).unwrap(); + + assert!(!serialized.contains("[pdp")); + assert!(!serialized.contains("pdp =")); + let parsed: Config = toml::from_str(&serialized).unwrap(); + assert!(parsed.pdp.is_none()); + } + + #[test] + fn config_serializes_configured_pdp() { + let config = Config { + pdp: Some(Location::GitTag { + url: "https://github.com/FilOzone/pdp.git".to_string(), + tag: "v3.4.0".to_string(), + }), + ..Default::default() + }; + + let serialized = toml::to_string(&config).unwrap(); + + assert!(serialized.contains("pdp")); + assert!(serialized.contains("https://github.com/FilOzone/pdp.git")); + } } diff --git a/src/main.rs b/src/main.rs index e2fd8f1d..203931e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ fn main() -> Result<(), Box> { curio, lotus, filecoin_services, + pdp, proof_params_dir, rand, no_docker_build, @@ -36,6 +37,7 @@ fn main() -> Result<(), Box> { curio, lotus, filecoin_services, + pdp, proof_params_dir, rand, no_docker_build, diff --git a/src/main_app/command_handlers.rs b/src/main_app/command_handlers.rs index 1b742fea..461f568d 100644 --- a/src/main_app/command_handlers.rs +++ b/src/main_app/command_handlers.rs @@ -35,6 +35,7 @@ pub fn handle_init( curio: Option, lotus: Option, filecoin_services: Option, + pdp: Option, proof_params_dir: Option, rand: bool, no_docker_build: bool, @@ -52,6 +53,7 @@ pub fn handle_init( curio_location: curio, lotus_location: lotus, filecoin_services_location: filecoin_services, + pdp_location: pdp, proof_params_dir, use_random_mnemonic: rand, no_docker_build, diff --git a/src/paths.rs b/src/paths.rs index 16db8e9f..85e26561 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -129,6 +129,11 @@ pub fn foc_devnet_filecoin_services_repo() -> PathBuf { foc_devnet_code().join("filecoin-services") } +/// Returns the path to the "pdp" repository +pub fn foc_devnet_pdp_repo() -> PathBuf { + foc_devnet_code().join("pdp") +} + /// Returns the path to the "multicall3" repository pub fn foc_devnet_multicall3_repo() -> PathBuf { foc_devnet_code().join("multicall3")