diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c68d904b97..0dff0f723c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,6 +30,7 @@ jobs: if [[ -n "$s" ]]; then echo "ERROR: found modified files that should be committed:" echo "$s" + git diff | head -n 128 exit 1 else echo "OK: no uncommitted changes detected" diff --git a/Cargo.lock b/Cargo.lock index 0fda3c17b9..14afd8d153 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4609,6 +4609,7 @@ dependencies = [ "penumbra-custody", "penumbra-dex", "penumbra-fee", + "penumbra-genesis", "penumbra-governance", "penumbra-ibc", "penumbra-keys", @@ -4732,9 +4733,12 @@ dependencies = [ "penumbra-distributions", "penumbra-fee", "penumbra-funding", + "penumbra-genesis", "penumbra-governance", "penumbra-ibc", "penumbra-keys", + "penumbra-mock-client", + "penumbra-mock-consensus", "penumbra-num", "penumbra-proof-params", "penumbra-proto", @@ -5098,6 +5102,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "penumbra-genesis" +version = "0.66.0" +dependencies = [ + "anyhow", + "penumbra-community-pool", + "penumbra-distributions", + "penumbra-fee", + "penumbra-funding", + "penumbra-governance", + "penumbra-ibc", + "penumbra-proto", + "penumbra-sct", + "penumbra-shielded-pool", + "penumbra-stake", + "serde", +] + [[package]] name = "penumbra-governance" version = "0.66.0" @@ -5252,6 +5274,24 @@ dependencies = [ "url", ] +[[package]] +name = "penumbra-mock-client" +version = "0.66.0" +dependencies = [ + "anyhow", + "cnidarium", + "penumbra-compact-block", + "penumbra-dex", + "penumbra-keys", + "penumbra-sct", + "penumbra-shielded-pool", + "penumbra-tct", +] + +[[package]] +name = "penumbra-mock-consensus" +version = "0.66.0" + [[package]] name = "penumbra-num" version = "0.66.0" diff --git a/Cargo.toml b/Cargo.toml index b003121108..b95c65caff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,11 +44,13 @@ members = [ "crates/bin/pclientd", "crates/bin/pcli", "crates/wasm", + "crates/test/mock-client", + "crates/test/mock-consensus", "crates/test/tct-property-test", "crates/misc/measure", "crates/misc/tct-visualize", "crates/bench", - "tools/summonerd", "crates/core/component/funding", + "tools/summonerd", "crates/core/component/funding", "crates/core/genesis", ] # Optimize for small binaries in just the wasm crate. @@ -171,8 +173,11 @@ penumbra-distributions = {default-features = false, path = "crates/core/componen penumbra-fee = {default-features = false, path = "crates/core/component/fee"} penumbra-funding = {default-features = false, path = "crates/core/component/funding"} penumbra-governance = {default-features = false, path = "crates/core/component/governance"} +penumbra-genesis = { path = "crates/core/genesis" } penumbra-ibc = {default-features = false, path = "crates/core/component/ibc"} penumbra-keys = {default-features = false, path = "crates/core/keys"} +penumbra-mock-client = {path = "crates/test/mock-client"} +penumbra-mock-consensus = {path = "crates/test/mock-consensus"} penumbra-num = {default-features = false, path = "crates/core/num"} penumbra-proof-params = {default-features = false, path = "crates/crypto/proof-params"} penumbra-proof-setup = {path = "crates/crypto/proof-setup"} diff --git a/crates/bin/pd/Cargo.toml b/crates/bin/pd/Cargo.toml index de91c57a90..069008e70a 100644 --- a/crates/bin/pd/Cargo.toml +++ b/crates/bin/pd/Cargo.toml @@ -55,6 +55,7 @@ penumbra-custody = {workspace = true} penumbra-tower-trace = { path = "../../util/tower-trace" } penumbra-tendermint-proxy = { path = "../../util/tendermint-proxy" } penumbra-auto-https = { path = "../../util/auto-https" } +penumbra-genesis = {workspace = true} decaf377 = {workspace = true, features = ["parallel"], default-features = true} decaf377-rdsa = {workspace = true} tower-abci = "0.11" diff --git a/crates/bin/pd/src/consensus.rs b/crates/bin/pd/src/consensus.rs index 15df818ff0..eea13c43af 100644 --- a/crates/bin/pd/src/consensus.rs +++ b/crates/bin/pd/src/consensus.rs @@ -1,7 +1,6 @@ use anyhow::Result; use cnidarium::Storage; -use penumbra_app::genesis; use tendermint::abci::Event; use tendermint::v0_37::abci::{ request, response, ConsensusRequest as Request, ConsensusResponse as Response, @@ -104,8 +103,9 @@ impl Consensus { /// the database. async fn init_chain(&mut self, init_chain: request::InitChain) -> Result { // Note that errors cannot be handled in InitChain, the application must crash. - let app_state: genesis::AppState = serde_json::from_slice(&init_chain.app_state_bytes) - .expect("can parse app_state in genesis file"); + let app_state: penumbra_genesis::AppState = + serde_json::from_slice(&init_chain.app_state_bytes) + .expect("can parse app_state in genesis file"); self.app.init_chain(&app_state).await; @@ -118,13 +118,13 @@ impl Consensus { let validators = self.app.tendermint_validator_updates(); let app_hash = match &app_state { - genesis::AppState::Checkpoint(h) => { + penumbra_genesis::AppState::Checkpoint(h) => { tracing::info!(?h, "genesis state is a checkpoint"); // If we're starting from a checkpoint, we just need to forward the app hash // back to CometBFT. self.storage.latest_snapshot().root_hash().await? } - genesis::AppState::Content(_) => { + penumbra_genesis::AppState::Content(_) => { tracing::info!("genesis state is a full configuration"); // Check that we haven't got a duplicated InitChain message for some reason: if self.storage.latest_version() != u64::MAX { diff --git a/crates/bin/pd/src/migrate.rs b/crates/bin/pd/src/migrate.rs index 724599cf27..23055c13d0 100644 --- a/crates/bin/pd/src/migrate.rs +++ b/crates/bin/pd/src/migrate.rs @@ -8,7 +8,7 @@ use std::path::PathBuf; use cnidarium::{StateDelta, StateWrite, Storage}; use jmt::RootHash; -use penumbra_app::{genesis, SUBSTORE_PREFIXES}; +use penumbra_app::SUBSTORE_PREFIXES; use penumbra_sct::component::clock::{EpochManager, EpochRead}; use penumbra_stake::{ component::validator_handler::ValidatorDataRead, genesis::Content as StakeContent, @@ -66,7 +66,7 @@ impl Migration { /* ---------- generate genesis ------------ */ let validators = migrated_state.validator_definitions().await?; - let app_state = genesis::Content { + let app_state = penumbra_genesis::Content { stake_content: StakeContent { // TODO(erwan): should remove this. validators: validators.into_iter().map(Into::into).collect(), diff --git a/crates/bin/pd/src/testnet/config.rs b/crates/bin/pd/src/testnet/config.rs index 5f6d534e33..ead16efc52 100644 --- a/crates/bin/pd/src/testnet/config.rs +++ b/crates/bin/pd/src/testnet/config.rs @@ -1,8 +1,8 @@ use anyhow::Context; use decaf377_rdsa::{SigningKey, SpendAuth, VerificationKey}; use directories::UserDirs; -use penumbra_app::genesis::AppState; use penumbra_custody::soft_kms::Config as SoftKmsConfig; +use penumbra_genesis::AppState; use penumbra_keys::keys::{SpendKey, SpendKeyBytes}; use rand::Rng; use rand_core::OsRng; diff --git a/crates/bin/pd/src/testnet/generate.rs b/crates/bin/pd/src/testnet/generate.rs index f7cf5b4bef..3bb15f1bb2 100644 --- a/crates/bin/pd/src/testnet/generate.rs +++ b/crates/bin/pd/src/testnet/generate.rs @@ -3,7 +3,7 @@ //! for Penumbra. use crate::testnet::config::{get_testnet_dir, TestnetTendermintConfig, ValidatorKeys}; use anyhow::{Context, Result}; -use penumbra_app::{genesis, params::AppParameters}; +use penumbra_app::params::AppParameters; use penumbra_governance::genesis::Content as GovernanceContent; use penumbra_keys::{keys::SpendKey, Address}; use penumbra_sct::genesis::Content as SctContent; @@ -35,7 +35,7 @@ pub struct TestnetConfig { /// The name of the network pub name: String, /// The Tendermint genesis for initial chain state. - pub genesis: Genesis, + pub genesis: Genesis, /// Path to local directory where config files will be written to pub testnet_dir: PathBuf, /// Set of validators at genesis. Uses the convenient wrapper type @@ -186,7 +186,7 @@ impl TestnetConfig { epoch_duration: Option, unbonding_epochs: Option, proposal_voting_blocks: Option, - ) -> anyhow::Result { + ) -> anyhow::Result { let default_gov_params = penumbra_governance::params::GovernanceParameters::default(); let gov_params = penumbra_governance::params::GovernanceParameters { @@ -198,7 +198,7 @@ impl TestnetConfig { // Look up default app params, so we can fill in defaults. let default_app_params = AppParameters::default(); - let app_state = genesis::Content { + let app_state = penumbra_genesis::Content { chain_id: chain_id.to_string(), stake_content: StakeContent { validators: validators.into_iter().map(Into::into).collect(), @@ -230,8 +230,8 @@ impl TestnetConfig { /// Build Tendermint genesis data, based on Penumbra initial application state. pub(crate) fn make_genesis( - app_state: genesis::Content, - ) -> anyhow::Result> { + app_state: penumbra_genesis::Content, + ) -> anyhow::Result> { // Use now as genesis time let genesis_time = Time::from_unix_timestamp( SystemTime::now() @@ -272,7 +272,7 @@ impl TestnetConfig { }, // always empty in genesis json app_hash: tendermint::AppHash::default(), - app_state: genesis::AppState::Content(app_state), + app_state: penumbra_genesis::AppState::Content(app_state), // Set empty validator set for Tendermint config, which falls back to reading // validators from the AppState, via ResponseInitChain: // https://docs.tendermint.com/v0.32/tendermint-core/using-tendermint.html @@ -282,12 +282,12 @@ impl TestnetConfig { } pub(crate) fn make_checkpoint( - genesis: Genesis, + genesis: Genesis, checkpoint: Option>, - ) -> Genesis { + ) -> Genesis { match checkpoint { Some(checkpoint) => Genesis { - app_state: genesis::AppState::Checkpoint(checkpoint), + app_state: penumbra_genesis::AppState::Checkpoint(checkpoint), ..genesis }, None => genesis, @@ -672,7 +672,8 @@ mod tests { assert_eq!(testnet_config.name, "test-chain-1234"); assert_eq!(testnet_config.genesis.validators.len(), 0); // No external address template was given, so only 1 validator will be present. - let genesis::AppState::Content(app_state) = testnet_config.genesis.app_state else { + let penumbra_genesis::AppState::Content(app_state) = testnet_config.genesis.app_state + else { unimplemented!("TODO: support checkpointed app state") }; assert_eq!(app_state.stake_content.validators.len(), 1); @@ -699,7 +700,8 @@ mod tests { )?; assert_eq!(testnet_config.name, "test-chain-4567"); assert_eq!(testnet_config.genesis.validators.len(), 0); - let genesis::AppState::Content(app_state) = testnet_config.genesis.app_state else { + let penumbra_genesis::AppState::Content(app_state) = testnet_config.genesis.app_state + else { unimplemented!("TODO: support checkpointed app state") }; assert_eq!(app_state.stake_content.validators.len(), 2); diff --git a/crates/core/app/Cargo.toml b/crates/core/app/Cargo.toml index 941cc7156a..709c9d1fc1 100644 --- a/crates/core/app/Cargo.toml +++ b/crates/core/app/Cargo.toml @@ -36,6 +36,7 @@ penumbra-ibc = {workspace = true, features = ["component"], default-features = t penumbra-distributions = {workspace = true, default-features = true} penumbra-compact-block = {workspace = true, default-features = true} penumbra-transaction = {workspace = true, features = ["parallel"], default-features = true} +penumbra-genesis = {workspace = true} decaf377 = {workspace = true, default-features = true} decaf377-rdsa = {workspace = true} jmt = {workspace = true} @@ -75,6 +76,16 @@ ibc-proto = {workspace = true, default-features = false, features = [ [dev-dependencies] ed25519-consensus = {workspace = true} +penumbra-mock-consensus = {workspace = true} +penumbra-mock-client = {workspace = true} rand_core = {workspace = true} rand_chacha = {workspace = true} tracing-subscriber = {workspace = true} + +# Enable the feature flags to get proving keys when running tests. +[dev-dependencies.penumbra-proof-params] +workspace = true +features = [ + "bundled-proving-keys", + "download-proving-keys", +] diff --git a/crates/core/app/src/app/mod.rs b/crates/core/app/src/app/mod.rs index f3a6463563..f954fea57f 100644 --- a/crates/core/app/src/app/mod.rs +++ b/crates/core/app/src/app/mod.rs @@ -14,6 +14,7 @@ use penumbra_distributions::component::{Distributions, StateReadExt as _, StateW use penumbra_fee::component::{Fee, StateReadExt as _, StateWriteExt as _}; use penumbra_funding::component::Funding; use penumbra_funding::component::{StateReadExt as _, StateWriteExt as _}; +use penumbra_genesis::AppState; use penumbra_governance::component::{Governance, StateReadExt as _}; use penumbra_governance::StateWriteExt as _; use penumbra_ibc::component::{Ibc, StateWriteExt as _}; @@ -38,7 +39,7 @@ use tracing::Instrument; use crate::action_handler::ActionHandler; use crate::params::AppParameters; -use crate::{genesis, CommunityPoolStateReadExt, PenumbraHost}; +use crate::{CommunityPoolStateReadExt, PenumbraHost}; pub mod state_key; @@ -94,13 +95,13 @@ impl App { events } - pub async fn init_chain(&mut self, app_state: &genesis::AppState) { + pub async fn init_chain(&mut self, app_state: &AppState) { let mut state_tx = self .state .try_begin_transaction() .expect("state Arc should not be referenced elsewhere"); match app_state { - genesis::AppState::Content(genesis) => { + AppState::Content(genesis) => { state_tx.put_chain_id(genesis.chain_id.clone()); Sct::init_chain(&mut state_tx, Some(&genesis.sct_content)).await; ShieldedPool::init_chain(&mut state_tx, Some(&genesis.shielded_pool_content)).await; @@ -127,7 +128,7 @@ impl App { .await .expect("must be able to finish compact block"); } - genesis::AppState::Checkpoint(_) => { + AppState::Checkpoint(_) => { ShieldedPool::init_chain(&mut state_tx, None).await; Distributions::init_chain(&mut state_tx, None).await; Staking::init_chain(&mut state_tx, None).await; diff --git a/crates/core/app/src/genesis.rs b/crates/core/app/src/genesis.rs deleted file mode 100644 index fec0c2f6c9..0000000000 --- a/crates/core/app/src/genesis.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod app_state; - -pub use app_state::AppState; -pub use app_state::Content; diff --git a/crates/core/app/src/lib.rs b/crates/core/app/src/lib.rs index 99356a39f2..0dea1ea09c 100644 --- a/crates/core/app/src/lib.rs +++ b/crates/core/app/src/lib.rs @@ -2,24 +2,18 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] pub mod app; -pub mod genesis; pub mod metrics; pub mod params; pub mod rpc; mod action_handler; mod community_pool_ext; -mod mock_client; mod penumbra_host_chain; -mod temp_storage_ext; - -#[cfg(test)] -mod tests; pub use crate::{ action_handler::ActionHandler, app::StateWriteExt, community_pool_ext::CommunityPoolStateReadExt, metrics::register_metrics, - mock_client::MockClient, penumbra_host_chain::PenumbraHost, temp_storage_ext::TempStorageExt, + penumbra_host_chain::PenumbraHost, }; use once_cell::sync::Lazy; diff --git a/crates/core/app/src/tests/mod.rs b/crates/core/app/src/tests/mod.rs deleted file mode 100644 index d8d87e8324..0000000000 --- a/crates/core/app/src/tests/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod spend; -mod swap_and_swap_claim; diff --git a/crates/core/app/src/temp_storage_ext.rs b/crates/core/app/tests/common/mod.rs similarity index 78% rename from crates/core/app/src/temp_storage_ext.rs rename to crates/core/app/tests/common/mod.rs index 882f9fa7d3..74df55887a 100644 --- a/crates/core/app/src/temp_storage_ext.rs +++ b/crates/core/app/tests/common/mod.rs @@ -1,20 +1,18 @@ -use std::ops::Deref; - -use crate::genesis; use async_trait::async_trait; use cnidarium::TempStorage; - -use crate::app::App; +use penumbra_app::app::App; +use penumbra_genesis::AppState; +use std::ops::Deref; #[async_trait] pub trait TempStorageExt: Sized { - async fn apply_genesis(self, genesis: genesis::AppState) -> anyhow::Result; + async fn apply_genesis(self, genesis: AppState) -> anyhow::Result; async fn apply_default_genesis(self) -> anyhow::Result; } #[async_trait] impl TempStorageExt for TempStorage { - async fn apply_genesis(self, genesis: genesis::AppState) -> anyhow::Result { + async fn apply_genesis(self, genesis: AppState) -> anyhow::Result { // Check that we haven't already applied a genesis state: if self.latest_version() != u64::MAX { anyhow::bail!("database already initialized"); diff --git a/crates/core/app/tests/mock_consensus.rs b/crates/core/app/tests/mock_consensus.rs new file mode 100644 index 0000000000..7ea2475bdb --- /dev/null +++ b/crates/core/app/tests/mock_consensus.rs @@ -0,0 +1,18 @@ +//! App integration tests using mock consensus. +// +// Note: these should eventually replace the existing test cases. mock consensus tests are placed +// here while the engine is still in development. See #3588. + +use {cnidarium::TempStorage, penumbra_app::app::App, penumbra_mock_consensus::TestNode}; + +#[tokio::test] +#[should_panic] +async fn an_app_with_mock_consensus_can_be_instantiated() { + let storage = TempStorage::new().await.unwrap(); + let app = App::new(storage.latest_snapshot()); + let _engine = TestNode::<()>::builder() + .single_validator() + .app_state(() /*genesis::AppState::default()*/) + .init_chain(app) + .await; +} diff --git a/crates/core/app/src/tests/spend.rs b/crates/core/app/tests/spend.rs similarity index 98% rename from crates/core/app/src/tests/spend.rs rename to crates/core/app/tests/spend.rs index f9208b226d..dbae6114ce 100644 --- a/crates/core/app/src/tests/spend.rs +++ b/crates/core/app/tests/spend.rs @@ -1,12 +1,14 @@ -use std::{ops::Deref, sync::Arc}; +mod common; -use crate::{ActionHandler, MockClient, TempStorageExt}; +use self::common::TempStorageExt; use cnidarium::{ArcStateDeltaExt, StateDelta, TempStorage}; use cnidarium_component::{ActionHandler as _, Component}; use decaf377_rdsa::SigningKey; +use penumbra_app::ActionHandler; use penumbra_asset::Value; use penumbra_compact_block::component::CompactBlockManager; use penumbra_keys::{test_keys, PayloadKey}; +use penumbra_mock_client::MockClient; use penumbra_num::Amount; use penumbra_sct::{ component::{clock::EpochManager, source::SourceContext}, @@ -16,6 +18,7 @@ use penumbra_shielded_pool::{component::ShieldedPool, SpendPlan}; use penumbra_transaction::{Transaction, TransactionBody, TransactionParameters}; use penumbra_txhash::{AuthorizingData, EffectHash, TransactionContext}; use rand_core::SeedableRng; +use std::{ops::Deref, sync::Arc}; use tendermint::abci; #[tokio::test] diff --git a/crates/core/app/src/tests/swap_and_swap_claim.rs b/crates/core/app/tests/swap_and_swap_claim.rs similarity index 99% rename from crates/core/app/src/tests/swap_and_swap_claim.rs rename to crates/core/app/tests/swap_and_swap_claim.rs index f653449e1f..8cdd1a113c 100644 --- a/crates/core/app/src/tests/swap_and_swap_claim.rs +++ b/crates/core/app/tests/swap_and_swap_claim.rs @@ -1,31 +1,32 @@ -use ark_ff::UniformRand; -use penumbra_compact_block::component::CompactBlockManager as _; -use penumbra_sct::{ - component::{clock::EpochManager, source::SourceContext as _, StateReadExt as _}, - epoch::Epoch, -}; -use std::{ops::Deref, sync::Arc}; +mod common; -use crate::{MockClient, TempStorageExt}; +use self::common::TempStorageExt; +use ark_ff::UniformRand; use cnidarium::{ArcStateDeltaExt, StateDelta, TempStorage}; use cnidarium_component::{ActionHandler, Component}; use decaf377::Fq; use penumbra_asset::asset; +use penumbra_compact_block::component::CompactBlockManager as _; +use penumbra_dex::{ + component::{Dex, StateReadExt as _}, + swap::{SwapPlaintext, SwapPlan}, + swap_claim::SwapClaimPlan, + TradingPair, +}; use penumbra_fee::Fee; use penumbra_keys::{test_keys, Address}; +use penumbra_mock_client::MockClient; use penumbra_num::Amount; +use penumbra_sct::{ + component::{clock::EpochManager, source::SourceContext as _, StateReadExt as _}, + epoch::Epoch, +}; use penumbra_shielded_pool::component::ShieldedPool; use penumbra_transaction::Transaction; use rand_core::SeedableRng; +use std::{ops::Deref, sync::Arc}; use tendermint::abci; -use penumbra_dex::{ - component::{Dex, StateReadExt as _}, - swap::{SwapPlaintext, SwapPlan}, - swap_claim::SwapClaimPlan, - TradingPair, -}; - #[tokio::test] async fn swap_and_swap_claim() -> anyhow::Result<()> { let mut rng = rand_chacha::ChaChaRng::seed_from_u64(1312); diff --git a/crates/core/component/compact-block/Cargo.toml b/crates/core/component/compact-block/Cargo.toml index c0ba561e12..4d85309a46 100644 --- a/crates/core/component/compact-block/Cargo.toml +++ b/crates/core/component/compact-block/Cargo.toml @@ -11,6 +11,7 @@ component = [ "tonic", "tokio-stream", "tokio", + "penumbra-governance/component", ] # proving-keys = ["penumbra-proof-params/proving-keys"] default = ["std", "component"] diff --git a/crates/core/genesis/Cargo.toml b/crates/core/genesis/Cargo.toml new file mode 100644 index 0000000000..95944c99ef --- /dev/null +++ b/crates/core/genesis/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "penumbra-genesis" +authors.workspace = true +edition.workspace = true +version.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true + +[dependencies] +anyhow = { workspace = true } +penumbra-community-pool = { workspace = true } +penumbra-distributions = { workspace = true } +penumbra-fee = { workspace = true } +penumbra-funding = { workspace = true } +penumbra-governance = { workspace = true } +penumbra-ibc = { workspace = true } +penumbra-proto = { workspace = true } +penumbra-sct = { workspace = true } +penumbra-shielded-pool = { workspace = true } +penumbra-stake = { workspace = true } +serde = { workspace = true, features = ["derive"] } diff --git a/crates/core/app/src/genesis/app_state.rs b/crates/core/genesis/src/lib.rs similarity index 100% rename from crates/core/app/src/genesis/app_state.rs rename to crates/core/genesis/src/lib.rs diff --git a/crates/test/mock-client/Cargo.toml b/crates/test/mock-client/Cargo.toml new file mode 100644 index 0000000000..a8ecc75839 --- /dev/null +++ b/crates/test/mock-client/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "penumbra-mock-client" +authors.workspace = true +edition.workspace = true +version.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true + +[dependencies] +anyhow = {workspace = true} +cnidarium = {workspace = true, default-features = true} +penumbra-compact-block = {workspace = true, default-features = true} +penumbra-dex = {workspace = true, default-features = true} +penumbra-keys = {workspace = true, default-features = true} +penumbra-sct = {workspace = true, default-features = true} +penumbra-shielded-pool = {workspace = true, features = [ + "component", +], default-features = true} +penumbra-tct = {workspace = true, default-features = true} diff --git a/crates/core/app/src/mock_client.rs b/crates/test/mock-client/src/lib.rs similarity index 99% rename from crates/core/app/src/mock_client.rs rename to crates/test/mock-client/src/lib.rs index 761a431f31..abb616abb3 100644 --- a/crates/core/app/src/mock_client.rs +++ b/crates/test/mock-client/src/lib.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use cnidarium::StateRead; use penumbra_compact_block::{component::StateReadExt as _, CompactBlock, StatePayload}; use penumbra_dex::swap::SwapPlaintext; @@ -7,6 +5,7 @@ use penumbra_keys::FullViewingKey; use penumbra_sct::component::tree::SctRead; use penumbra_shielded_pool::{note, Note}; use penumbra_tct as tct; +use std::collections::BTreeMap; /// A bare-bones mock client for use exercising the state machine. pub struct MockClient { diff --git a/crates/test/mock-consensus/Cargo.toml b/crates/test/mock-consensus/Cargo.toml new file mode 100644 index 0000000000..52714cbcf7 --- /dev/null +++ b/crates/test/mock-consensus/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "penumbra-mock-consensus" +authors.workspace = true +edition.workspace = true +version.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true + +[dependencies] diff --git a/crates/test/mock-consensus/src/lib.rs b/crates/test/mock-consensus/src/lib.rs new file mode 100644 index 0000000000..5d5d3de6aa --- /dev/null +++ b/crates/test/mock-consensus/src/lib.rs @@ -0,0 +1,48 @@ +pub struct TestNode { + _app: A, + _last_app_hash: Vec, +} + +pub mod block { + use crate::TestNode; + + struct _Builder<'e, C> { + engine: &'e mut TestNode, + } +} + +pub struct Builder; + +impl TestNode { + pub fn builder() -> Builder { + Builder + } +} + +impl Builder { + // TODO: add other convenience methods for validator config? + + /// Creates a single validator with a randomly generated key. + pub fn single_validator(self) -> Self { + todo!(); + } + + pub fn app_state(self, _: ()) -> Self { + todo!() + } + + pub fn app_state_bytes(self, _: Vec) -> Self { + todo!() + } + + // this should take the `consensus` thing from pd/main.rs + pub async fn init_chain(self, _: A) -> TestNode { + // https://rustdoc.penumbra.zone/main/tower_abci/v037/struct.ServerBuilder.html + // Engine should be parameterized by the C here + // init_chain should be parameterized by the C here + // + // C: Service + Send + Clone + 'static, + // C::Future: Send + 'static, + todo!() + } +} diff --git a/deployments/scripts/rust-docs b/deployments/scripts/rust-docs index c31a56964c..8505027898 100755 --- a/deployments/scripts/rust-docs +++ b/deployments/scripts/rust-docs @@ -41,6 +41,7 @@ cargo +nightly-2024-02-01 doc --no-deps \ -p penumbra-community-pool \ -p penumbra-dex \ -p penumbra-distributions \ + -p penumbra-genesis \ -p penumbra-governance \ -p penumbra-ibc \ -p penumbra-keys \ diff --git a/flake.lock b/flake.lock index c63cd7c4e9..587cbdef51 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703961334, - "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", + "lastModified": 1707268954, + "narHash": "sha256-2en1kvde3cJVc3ZnTy8QeD2oKcseLFjYPLKhIGDanQ0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", + "rev": "f8e2ebd66d097614d51a56a755450d4ae1632df1", "type": "github" }, "original": { @@ -37,31 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1704075545, - "narHash": "sha256-L3zgOuVKhPjKsVLc3yTm2YJ6+BATyZBury7wnhyc8QU=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "a0df72e106322b67e9c6e591fe870380bd0da0d5", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index 1a13f84a13..e2139bf19b 100644 --- a/flake.nix +++ b/flake.nix @@ -4,22 +4,14 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; - }; }; - outputs = { self, nixpkgs, flake-utils, rust-overlay }: + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let - overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { - inherit system overlays; + inherit system; }; nativeBuildInputs = with pkgs; [ pkg-config @@ -27,7 +19,7 @@ buildInputs = with pkgs; [ clang openssl - rust-bin.stable.latest.default + rustup ]; in with pkgs;