lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 1dcee031c8bc4a6fd8a4db00a80ce7ebd980d67b
parent 0c4bed11d173609ed50b0460e27c697abc75a9e8
Author: triesap <tyson@radroots.org>
Date:   Sat, 13 Jun 2026 03:28:54 -0700

workspace: restore all-features gates

- Remove the non-additive replica DB coverage-minimal feature
- Gate SP1 guest ELF and real-proof tests behind explicit build cfgs
- Keep SP1 guest binaries out of host test harnesses
- Restore workspace all-features and flake validation gates

Diffstat:
Mcrates/replica_db/Cargo.toml | 11++---------
Mcrates/replica_db/src/lib.rs | 23-----------------------
Mcrates/sp1_guest_trade/Cargo.toml | 1+
Mcrates/sp1_host_trade/build.rs | 13+++++++++++++
Mcrates/sp1_host_trade/src/lib.rs | 88++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mcrates/sql_core/Cargo.toml | 17+++--------------
6 files changed, 88 insertions(+), 65 deletions(-)

diff --git a/crates/replica_db/Cargo.toml b/crates/replica_db/Cargo.toml @@ -18,15 +18,8 @@ crate-type = ["rlib"] [features] default = ["std"] std = ["radroots_sql_core/std"] -web = [ - "std", - "radroots_sql_core/web", -] -native = [ - "std", - "radroots_sql_core/native", -] -coverage-minimal = [] +web = ["std", "radroots_sql_core/web"] +native = ["std", "radroots_sql_core/native"] [dependencies] radroots_sql_core = { workspace = true } diff --git a/crates/replica_db/src/lib.rs b/crates/replica_db/src/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(feature = "coverage-minimal", allow(unused_imports))] - pub use radroots_sql_core::error::SqlError; pub use radroots_sql_core::{ExecOutcome, SqlExecutor}; use radroots_types::types::IError; @@ -110,25 +108,16 @@ use radroots_replica_db_schema::trade_product_media::{ ITradeProductMediaRelation, ITradeProductMediaResolve, }; -#[cfg(not(feature = "coverage-minimal"))] pub mod backup; -#[cfg(not(feature = "coverage-minimal"))] pub mod export; -#[cfg(not(feature = "coverage-minimal"))] pub mod migrations; -#[cfg(not(feature = "coverage-minimal"))] pub mod models; -#[cfg(not(feature = "coverage-minimal"))] pub mod query; -#[cfg(not(feature = "coverage-minimal"))] pub use backup::{DatabaseBackup, MigrationBackup, SchemaEntry}; -#[cfg(not(feature = "coverage-minimal"))] pub use export::{ REPLICA_DB_EXPORT_VERSION, ReplicaDbExportManifestRs, TableCount, export_manifest, }; -#[cfg(not(feature = "coverage-minimal"))] pub use models::*; -#[cfg(not(feature = "coverage-minimal"))] pub use query::ReplicaTradeProductSummaryRow; pub struct ReplicaSql<E: SqlExecutor> { @@ -141,7 +130,6 @@ impl<E: SqlExecutor> ReplicaSql<E> { } } -#[cfg(not(feature = "coverage-minimal"))] impl<E: SqlExecutor> ReplicaSql<E> { pub fn new(executor: E) -> Self { Self { executor } @@ -725,17 +713,6 @@ impl<E: SqlExecutor> ReplicaSql<E> { } } -#[cfg(feature = "coverage-minimal")] -impl<E: SqlExecutor> ReplicaSql<E> { - pub fn new(executor: E) -> Self { - Self { executor } - } - - pub fn executor(&self) -> &E { - &self.executor - } -} - #[cfg(test)] mod tests { use super::ReplicaSql; diff --git a/crates/sp1_guest_trade/Cargo.toml b/crates/sp1_guest_trade/Cargo.toml @@ -14,6 +14,7 @@ homepage.workspace = true name = "radroots_sp1_trade_order_acceptance_guest" path = "src/bin/order_acceptance_guest.rs" required-features = ["sp1_guest"] +test = false [features] default = [] diff --git a/crates/sp1_host_trade/build.rs b/crates/sp1_host_trade/build.rs @@ -1,5 +1,17 @@ fn main() { + let build_guest_elf_env = "RADROOTS_SP1_HOST_TRADE_BUILD_GUEST_ELF"; + let run_real_proof_tests_env = "RADROOTS_SP1_HOST_TRADE_RUN_REAL_PROOF_TESTS"; println!("cargo:rerun-if-env-changed=CARGO_FEATURE_SP1_VERIFY"); + println!("cargo:rerun-if-env-changed={build_guest_elf_env}"); + println!("cargo:rerun-if-env-changed={run_real_proof_tests_env}"); + println!("cargo:rustc-check-cfg=cfg(radroots_sp1_guest_elf)"); + println!("cargo:rustc-check-cfg=cfg(radroots_sp1_real_proof_tests)"); + if std::env::var(run_real_proof_tests_env).as_deref() == Ok("1") { + println!("cargo:rustc-cfg=radroots_sp1_real_proof_tests"); + } + if std::env::var(build_guest_elf_env).as_deref() != Ok("1") { + return; + } #[cfg(feature = "sp1_verify")] { let args = sp1_build::BuildArgs { @@ -9,5 +21,6 @@ fn main() { ..sp1_build::BuildArgs::default() }; sp1_build::build_program_with_args("../sp1_guest_trade", args); + println!("cargo:rustc-cfg=radroots_sp1_guest_elf"); } } diff --git a/crates/sp1_host_trade/src/lib.rs b/crates/sp1_host_trade/src/lib.rs @@ -429,23 +429,32 @@ pub struct RadrootsSp1TradeExecuteBundle { pub report: RadrootsSp1TradeExecuteReport, } -#[cfg(feature = "sp1_verify")] +#[cfg(all(feature = "sp1_verify", radroots_sp1_guest_elf))] pub fn order_acceptance_guest_elf() -> sp1_sdk::Elf { sp1_sdk::include_elf!("radroots_sp1_trade_order_acceptance_guest") } -#[cfg(feature = "sp1_verify")] +#[cfg(all(feature = "sp1_verify", radroots_sp1_guest_elf))] pub fn sp1_program_hash_for_order_acceptance_guest() -> String { sp1_program_hash_for_elf(&order_acceptance_guest_elf()) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] pub async fn execute_order_acceptance_sp1_public_values( witness: &RadrootsSp1TradeOrderAcceptanceWitness, ) -> Result<RadrootsSp1TradeExecuteBundle, RadrootsSp1TradeHostError> { execute_order_acceptance_sp1_public_values_with_elf(order_acceptance_guest_elf(), witness).await } +#[cfg(all(feature = "sp1_proving", not(radroots_sp1_guest_elf)))] +pub async fn execute_order_acceptance_sp1_public_values( + _witness: &RadrootsSp1TradeOrderAcceptanceWitness, +) -> Result<RadrootsSp1TradeExecuteBundle, RadrootsSp1TradeHostError> { + Err(RadrootsSp1TradeHostError::Sp1SetupFailed( + "SP1 guest ELF build is not enabled".to_owned(), + )) +} + #[cfg(feature = "sp1_proving")] pub async fn execute_order_acceptance_sp1_public_values_with_elf( elf: sp1_sdk::Elf, @@ -494,7 +503,7 @@ pub async fn execute_order_acceptance_sp1_public_values_with_elf( }) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] pub async fn generate_order_acceptance_sp1_proof( witness: &RadrootsSp1TradeOrderAcceptanceWitness, mode: RadrootsSp1TradeProofMode, @@ -503,7 +512,17 @@ pub async fn generate_order_acceptance_sp1_proof( .await } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", not(radroots_sp1_guest_elf)))] +pub async fn generate_order_acceptance_sp1_proof( + _witness: &RadrootsSp1TradeOrderAcceptanceWitness, + _mode: RadrootsSp1TradeProofMode, +) -> Result<RadrootsSp1TradeProofBundle, RadrootsSp1TradeHostError> { + Err(RadrootsSp1TradeHostError::Sp1SetupFailed( + "SP1 guest ELF build is not enabled".to_owned(), + )) +} + +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] pub async fn generate_order_acceptance_sp1_proof_with_engine( witness: &RadrootsSp1TradeOrderAcceptanceWitness, mode: RadrootsSp1TradeProofMode, @@ -520,7 +539,18 @@ pub async fn generate_order_acceptance_sp1_proof_with_engine( } } -#[cfg(all(feature = "sp1_proving", feature = "sp1_cuda"))] +#[cfg(all(feature = "sp1_proving", not(radroots_sp1_guest_elf)))] +pub async fn generate_order_acceptance_sp1_proof_with_engine( + _witness: &RadrootsSp1TradeOrderAcceptanceWitness, + _mode: RadrootsSp1TradeProofMode, + _engine: RadrootsSp1TradeProofEngine, +) -> Result<RadrootsSp1TradeProofBundle, RadrootsSp1TradeHostError> { + Err(RadrootsSp1TradeHostError::Sp1SetupFailed( + "SP1 guest ELF build is not enabled".to_owned(), + )) +} + +#[cfg(all(feature = "sp1_proving", feature = "sp1_cuda", radroots_sp1_guest_elf))] async fn generate_order_acceptance_sp1_cuda_proof( witness: &RadrootsSp1TradeOrderAcceptanceWitness, mode: RadrootsSp1TradeProofMode, @@ -533,7 +563,7 @@ async fn generate_order_acceptance_sp1_cuda_proof( generate_order_acceptance_sp1_proof_with_client(&client, witness, mode).await } -#[cfg(all(feature = "sp1_proving", feature = "sp1_cuda"))] +#[cfg(all(feature = "sp1_proving", feature = "sp1_cuda", radroots_sp1_guest_elf))] fn cuda_panic_to_host_error(payload: Box<dyn std::any::Any + Send>) -> RadrootsSp1TradeHostError { let message = payload .downcast_ref::<&str>() @@ -543,7 +573,11 @@ fn cuda_panic_to_host_error(payload: Box<dyn std::any::Any + Send>) -> RadrootsS RadrootsSp1TradeHostError::Sp1CudaProofEngineUnavailable(message) } -#[cfg(all(feature = "sp1_proving", not(feature = "sp1_cuda")))] +#[cfg(all( + feature = "sp1_proving", + not(feature = "sp1_cuda"), + radroots_sp1_guest_elf +))] async fn generate_order_acceptance_sp1_cuda_proof( _witness: &RadrootsSp1TradeOrderAcceptanceWitness, _mode: RadrootsSp1TradeProofMode, @@ -553,7 +587,7 @@ async fn generate_order_acceptance_sp1_cuda_proof( )) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] async fn generate_order_acceptance_sp1_proof_with_client<P>( client: &P, witness: &RadrootsSp1TradeOrderAcceptanceWitness, @@ -1131,7 +1165,7 @@ pub fn referenced_order_acceptance_proof_artifact_for_execution( Ok(artifact) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] fn proof_artifact_for_real_sp1_execution( execution: &RadrootsSp1TradePublicValuesExecution, mode: RadrootsSp1TradeProofMode, @@ -1200,7 +1234,7 @@ fn proof_digest_for_execution( Ok(format!("0x{}", hex_lower(hasher.finalize().as_slice()))) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] fn proof_envelope_for_real_sp1_execution( execution: &RadrootsSp1TradePublicValuesExecution, system: RadrootsValidationReceiptProofSystem, @@ -1573,7 +1607,7 @@ fn execution_from_sp1_public_values( )) } -#[cfg(feature = "sp1_proving")] +#[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] fn sp1_proof_mode( mode: RadrootsSp1TradeProofMode, ) -> Result<sp1_sdk::SP1ProofMode, RadrootsSp1TradeHostError> { @@ -1710,7 +1744,7 @@ mod tests { validation_receipt_for_order_acceptance_proof, verify_order_acceptance_proof_artifact_structure, }; - #[cfg(feature = "sp1_proving")] + #[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] use base64::Engine; use radroots_events::{RadrootsNostrEvent, kinds::KIND_TRADE_VALIDATION_RECEIPT}; use radroots_sp1_guest_trade::{ @@ -1723,6 +1757,7 @@ mod tests { RadrootsSp1TradeOrderAcceptanceWitness, RadrootsSp1TradeOrderDecisionEventWitness, RadrootsSp1TradeOrderDecisionWitness, RadrootsSp1TradeOrderItemWitness, RadrootsSp1TradeOrderRequestWitness, RadrootsSp1TradeProofResult, + RadrootsSp1TradePublicValuesExecution, }; use radroots_trade::validation_receipt::{ RadrootsValidationReceiptExpectedBinding, RadrootsValidationReceiptProof, @@ -1763,7 +1798,7 @@ mod tests { } } - #[cfg(feature = "sp1_proving")] + #[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] fn witness_without_sp1_identity() -> RadrootsSp1TradeOrderAcceptanceWitness { let mut input = witness(); input.sp1_program_hash = None; @@ -2222,8 +2257,10 @@ mod tests { } #[cfg(feature = "sp1_verify")] - #[tokio::test] - async fn remote_returned_proof_artifact_verifies() { + fn verified_remote_returned_proof_fixture() -> ( + RadrootsSp1TradePublicValuesExecution, + super::RadrootsSp1TradeProofArtifact, + ) { let fixture = remote_returned_proof_fixture(); assert_eq!(fixture.schema_version, 1); assert_eq!( @@ -2281,6 +2318,19 @@ mod tests { let artifact = response.proof_artifact.expect("proof artifact"); verify_order_acceptance_proof_artifact_structure(&execution, &artifact) .expect("artifact structure"); + (execution, artifact) + } + + #[cfg(feature = "sp1_verify")] + #[test] + fn remote_returned_proof_artifact_fixture_is_structurally_valid() { + verified_remote_returned_proof_fixture(); + } + + #[cfg(all(feature = "sp1_verify", radroots_sp1_real_proof_tests))] + #[tokio::test] + async fn remote_returned_proof_artifact_real_sp1_verifies() { + let (execution, artifact) = verified_remote_returned_proof_fixture(); super::verify_order_acceptance_resolved_sp1_proof_artifact( &execution, &super::RadrootsSp1TradeResolvedProofArtifact::inline(artifact.clone()), @@ -2381,7 +2431,7 @@ mod tests { } } - #[cfg(feature = "sp1_proving")] + #[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] #[tokio::test] async fn sp1_execute_public_values_match_deterministic_reducer() { let input = witness_without_sp1_identity(); @@ -2407,7 +2457,7 @@ mod tests { assert!(execution.report.total_instruction_count > 0); } - #[cfg(feature = "sp1_proving")] + #[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] #[tokio::test] async fn expensive_proof_generation_and_verification_is_runnable() { let bundle = super::generate_order_acceptance_sp1_proof( @@ -2448,7 +2498,7 @@ mod tests { ); } - #[cfg(feature = "sp1_proving")] + #[cfg(all(feature = "sp1_proving", radroots_sp1_guest_elf))] #[tokio::test] async fn real_sp1_verifier_rejects_missing_and_synthetic_material() { let execution = diff --git a/crates/sql_core/Cargo.toml b/crates/sql_core/Cargo.toml @@ -17,16 +17,8 @@ crate-type = ["rlib"] [features] default = ["std"] -std = [ - "dep:chrono", - "dep:uuid", - "serde/std", - "serde_json/std", -] -web = [ - "std", - "uuid/js", -] +std = ["dep:chrono", "dep:uuid", "serde/std", "serde_json/std"] +web = ["std", "uuid/js"] bridge = [ "std", "web", @@ -34,10 +26,7 @@ bridge = [ "dep:serde-wasm-bindgen", "dep:wasm-bindgen", ] -native = [ - "std", - "dep:rusqlite", -] +native = ["std", "dep:rusqlite"] embedded = [] [dependencies]