diff --git a/.github/workflows/fmt.yaml b/.github/workflows/fmt.yaml new file mode 100644 index 0000000000..09ff2e8f12 --- /dev/null +++ b/.github/workflows/fmt.yaml @@ -0,0 +1,19 @@ +name: Format + +on: + push: + branches: [ main, develop ] + pull_request: + +jobs: + format: + name: Format using nightly + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: rustfmt + - name: rustfmt + run: make check-format diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 399824d216..74cbb9a256 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: lint +name: Lint on: push: @@ -18,12 +18,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: toolchain: 1.84 - components: rustfmt, clippy - - name: rustfmt - run: cargo fmt --all -- --check + components: clippy, rustfmt - name: check - run: cargo check --all-targets - env: - RUSTFLAGS: -D warnings + run: make check - name: clippy - run: cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type + run: make lint diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000000..be0b59b240 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,3 @@ +indent_style = "Block" +imports_granularity = "Crate" +reorder_imports = true \ No newline at end of file diff --git a/Makefile b/Makefile index c99a66ac4e..74a465f258 100644 --- a/Makefile +++ b/Makefile @@ -24,13 +24,17 @@ build-wasm: ## Build WebAssembly node check: ## Check code for compilation errors cargo check --all-targets +.PHONY: check-format +check-format: ## Check code formatting + cargo +nightly fmt -- --check + .PHONY: clean clean: ## Clean build artifacts cargo clean -.PHONY: fmt -fmt: ## Format code using rustfmt - cargo fmt --all +.PHONY: format +format: ## Format code using rustfmt + cargo +nightly fmt .PHONY: lint lint: ## Run linter (clippy) diff --git a/cli/src/commands/misc.rs b/cli/src/commands/misc.rs index c53c8487c5..c64ed28396 100644 --- a/cli/src/commands/misc.rs +++ b/cli/src/commands/misc.rs @@ -1,6 +1,5 @@ use libp2p_identity::PeerId; -use node::account::AccountSecretKey; -use node::p2p::identity::SecretKey; +use node::{account::AccountSecretKey, p2p::identity::SecretKey}; #[derive(Debug, clap::Args)] pub struct Misc { diff --git a/cli/src/commands/node/mod.rs b/cli/src/commands/node/mod.rs index 31f78b16da..ec1bab8658 100644 --- a/cli/src/commands/node/mod.rs +++ b/cli/src/commands/node/mod.rs @@ -11,11 +11,12 @@ use node::{ use openmina_node_account::AccountPublicKey; use reqwest::Url; -use node::core::log::inner::Level; -use node::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts; -use node::p2p::identity::SecretKey; -use node::service::Recorder; -use node::SnarkerStrategy; +use node::{ + core::log::inner::Level, + p2p::{connection::outgoing::P2pConnectionOutgoingInitOpts, identity::SecretKey}, + service::Recorder, + SnarkerStrategy, +}; use openmina_node_native::{archive::config::ArchiveStorageOptions, tracing, NodeBuilder}; diff --git a/cli/src/exit_with_error.rs b/cli/src/exit_with_error.rs index e6ca04d412..b1ae4bb01c 100644 --- a/cli/src/exit_with_error.rs +++ b/cli/src/exit_with_error.rs @@ -1,6 +1,5 @@ use console::style; -use std::fmt::Display; -use std::process; +use std::{fmt::Display, process}; pub fn exit_with_error(error: E) -> ! { eprintln!("{} {:#}", style("[ERROR]").red().bold(), error,); diff --git a/cli/src/main.rs b/cli/src/main.rs index 67b73af73d..91a3023ae4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -66,8 +66,7 @@ fn setup_var_from_single_and_only_thread() { /// We store (+ display) panics in non-main threads, and display them all when the main thread panics. #[cfg(not(target_family = "wasm"))] fn new_hook(info: &PanicHookInfo<'_>) { - use std::any::Any; - use std::io::Write; + use std::{any::Any, io::Write}; fn payload_as_str(payload: &dyn Any) -> &str { if let Some(&s) = payload.downcast_ref::<&'static str>() { diff --git a/core/src/block/mod.rs b/core/src/block/mod.rs index 0cef7c0bf7..d490ed1de8 100644 --- a/core/src/block/mod.rs +++ b/core/src/block/mod.rs @@ -10,9 +10,9 @@ pub mod genesis; use std::sync::Arc; -pub use mina_p2p_messages::v2::MinaBlockBlockStableV2 as Block; -pub use mina_p2p_messages::v2::MinaBlockHeaderStableV2 as BlockHeader; -pub use mina_p2p_messages::v2::StateHash as BlockHash; +pub use mina_p2p_messages::v2::{ + MinaBlockBlockStableV2 as Block, MinaBlockHeaderStableV2 as BlockHeader, StateHash as BlockHash, +}; pub type ArcBlock = Arc; pub type ArcBlockWithHash = BlockWithHash>; diff --git a/core/src/chain_id.rs b/core/src/chain_id.rs index 3992432af1..cdd14afbc8 100644 --- a/core/src/chain_id.rs +++ b/core/src/chain_id.rs @@ -2,8 +2,7 @@ use mina_p2p_messages::v2::{ MinaBaseProtocolConstantsCheckedValueStableV1, StateHash, UnsignedExtendedUInt32StableV1, }; use multihash::{Blake2b256, Hasher}; -use time::macros::format_description; -use time::OffsetDateTime; +use time::{macros::format_description, OffsetDateTime}; use std::{ fmt::{self, Debug, Display, Formatter}, diff --git a/core/src/distributed_pool.rs b/core/src/distributed_pool.rs index 7cec46ef9c..234d1f17fe 100644 --- a/core/src/distributed_pool.rs +++ b/core/src/distributed_pool.rs @@ -1,6 +1,4 @@ -use std::cmp::Ord; -use std::collections::BTreeMap; -use std::ops::RangeBounds; +use std::{cmp::Ord, collections::BTreeMap, ops::RangeBounds}; use crate::bug_condition; @@ -161,8 +159,7 @@ where mod ser { use super::*; - use serde::ser::SerializeStruct; - use serde::{Deserialize, Serialize}; + use serde::{ser::SerializeStruct, Deserialize, Serialize}; #[derive(Deserialize)] struct Pool { diff --git a/core/src/encrypted_key.rs b/core/src/encrypted_key.rs index 1d5b894b79..0b481dd93e 100644 --- a/core/src/encrypted_key.rs +++ b/core/src/encrypted_key.rs @@ -1,10 +1,11 @@ -use std::fs; -use std::path::Path; +use std::{fs, path::Path}; use argon2::{password_hash::SaltString, Argon2, PasswordHasher}; use base64::Engine; -use crypto_secretbox::aead::{Aead, OsRng}; -use crypto_secretbox::{AeadCore, KeyInit, XSalsa20Poly1305}; +use crypto_secretbox::{ + aead::{Aead, OsRng}, + AeadCore, KeyInit, XSalsa20Poly1305, +}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] diff --git a/core/src/requests/request_id.rs b/core/src/requests/request_id.rs index 255fc221b1..8e9156595c 100644 --- a/core/src/requests/request_id.rs +++ b/core/src/requests/request_id.rs @@ -1,5 +1,4 @@ -use std::fmt; -use std::marker::PhantomData; +use std::{fmt, marker::PhantomData}; pub trait RequestIdType { fn request_id_type() -> &'static str; diff --git a/core/src/snark/snark.rs b/core/src/snark/snark.rs index 6ca66e068f..140cbd06d7 100644 --- a/core/src/snark/snark.rs +++ b/core/src/snark/snark.rs @@ -1,14 +1,16 @@ use std::sync::Arc; use malloc_size_of::MallocSizeOf; -use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; -use mina_p2p_messages::v2::{ - CurrencyFeeStableV1, MinaBaseFeeWithProverStableV1, - MinaStateBlockchainStateValueStableV2LedgerProofStatement, MinaStateSnarkedLedgerStateStableV2, - MinaStateSnarkedLedgerStateWithSokStableV2, - NetworkPoolSnarkPoolDiffVersionedStableV2AddSolvedWork1, NonZeroCurvePoint, - TransactionSnarkWorkStatementStableV2, TransactionSnarkWorkTStableV2, - TransactionSnarkWorkTStableV2Proofs, +use mina_p2p_messages::{ + binprot::macros::{BinProtRead, BinProtWrite}, + v2::{ + CurrencyFeeStableV1, MinaBaseFeeWithProverStableV1, + MinaStateBlockchainStateValueStableV2LedgerProofStatement, + MinaStateSnarkedLedgerStateStableV2, MinaStateSnarkedLedgerStateWithSokStableV2, + NetworkPoolSnarkPoolDiffVersionedStableV2AddSolvedWork1, NonZeroCurvePoint, + TransactionSnarkWorkStatementStableV2, TransactionSnarkWorkTStableV2, + TransactionSnarkWorkTStableV2Proofs, + }, }; use serde::{Deserialize, Serialize}; diff --git a/core/src/snark/snark_info.rs b/core/src/snark/snark_info.rs index c9222d0ab1..124b5ad0c8 100644 --- a/core/src/snark/snark_info.rs +++ b/core/src/snark/snark_info.rs @@ -1,5 +1,7 @@ -use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; -use mina_p2p_messages::v2::{CurrencyFeeStableV1, NonZeroCurvePoint}; +use mina_p2p_messages::{ + binprot::macros::{BinProtRead, BinProtWrite}, + v2::{CurrencyFeeStableV1, NonZeroCurvePoint}, +}; use serde::{Deserialize, Serialize}; use super::SnarkJobId; diff --git a/core/src/snark/snark_job_commitment.rs b/core/src/snark/snark_job_commitment.rs index c73ed5462a..c850b36543 100644 --- a/core/src/snark/snark_job_commitment.rs +++ b/core/src/snark/snark_job_commitment.rs @@ -1,5 +1,7 @@ -use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; -use mina_p2p_messages::v2::{CurrencyFeeStableV1, NonZeroCurvePoint}; +use mina_p2p_messages::{ + binprot::macros::{BinProtRead, BinProtWrite}, + v2::{CurrencyFeeStableV1, NonZeroCurvePoint}, +}; use redux::Timestamp; use serde::{Deserialize, Serialize}; diff --git a/core/src/snark/snark_job_id.rs b/core/src/snark/snark_job_id.rs index 9b4edab7ce..e34d138f53 100644 --- a/core/src/snark/snark_job_id.rs +++ b/core/src/snark/snark_job_id.rs @@ -1,9 +1,11 @@ use std::str::FromStr; -use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; -use mina_p2p_messages::v2::{ - LedgerHash, MinaStateBlockchainStateValueStableV2LedgerProofStatementSource, - TransactionSnarkWorkTStableV2Proofs, +use mina_p2p_messages::{ + binprot::macros::{BinProtRead, BinProtWrite}, + v2::{ + LedgerHash, MinaStateBlockchainStateValueStableV2LedgerProofStatementSource, + TransactionSnarkWorkTStableV2Proofs, + }, }; use serde::{ser::SerializeStruct, Deserialize, Serialize}; diff --git a/core/src/transaction/transaction_info.rs b/core/src/transaction/transaction_info.rs index 13837d9f63..5e06eae7d3 100644 --- a/core/src/transaction/transaction_info.rs +++ b/core/src/transaction/transaction_info.rs @@ -1,8 +1,10 @@ -use mina_p2p_messages::binprot::{ - self, - macros::{BinProtRead, BinProtWrite}, +use mina_p2p_messages::{ + binprot::{ + self, + macros::{BinProtRead, BinProtWrite}, + }, + v2::NonZeroCurvePoint, }; -use mina_p2p_messages::v2::NonZeroCurvePoint; use serde::{Deserialize, Serialize}; use super::{Transaction, TransactionHash}; diff --git a/ledger/src/account/legacy.rs b/ledger/src/account/legacy.rs index 0530d67695..17d4fa4b31 100644 --- a/ledger/src/account/legacy.rs +++ b/ledger/src/account/legacy.rs @@ -1,8 +1,7 @@ use std::borrow::Cow; use ark_ff::Zero; -use mina_hasher::Fp; -use mina_hasher::{create_legacy, Hashable, Hasher, ROInput}; +use mina_hasher::{create_legacy, Fp, Hashable, Hasher, ROInput}; use mina_signer::CompressedPubKey; use o1_utils::FieldHelpers; diff --git a/ledger/src/cache.rs b/ledger/src/cache.rs index c913cd7577..bf1634454c 100644 --- a/ledger/src/cache.rs +++ b/ledger/src/cache.rs @@ -47,8 +47,7 @@ macro_rules! cache_one { // See comments in `cache` above // Here we don't support generic - use std::cell::RefCell; - use std::mem::ManuallyDrop; + use std::{cell::RefCell, mem::ManuallyDrop}; thread_local! { static CACHE: ManuallyDrop>>> = @@ -72,8 +71,7 @@ mod tests { use crate::proofs::field::FieldWitness; use ark_ec::short_weierstrass_jacobian::GroupAffine; use poly_commitment::srs::endos; - use std::sync::atomic::AtomicUsize; - use std::sync::atomic::Ordering::Relaxed; + use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; #[cfg(target_family = "wasm")] use wasm_bindgen_test::wasm_bindgen_test as test; diff --git a/ledger/src/dummy/for_tests.rs b/ledger/src/dummy/for_tests.rs index f78ce795fb..c1b65eb36c 100644 --- a/ledger/src/dummy/for_tests.rs +++ b/ledger/src/dummy/for_tests.rs @@ -1,5 +1,4 @@ -use mina_p2p_messages::binprot::BinProtRead; -use mina_p2p_messages::v2::MinaBaseUserCommandStableV2; +use mina_p2p_messages::{binprot::BinProtRead, v2::MinaBaseUserCommandStableV2}; use crate::scan_state::transaction_logic::valid; diff --git a/ledger/src/dummy/mod.rs b/ledger/src/dummy/mod.rs index 7ecb6d3a6f..97871d5e31 100644 --- a/ledger/src/dummy/mod.rs +++ b/ledger/src/dummy/mod.rs @@ -1,7 +1,6 @@ use std::sync::Arc; -use mina_p2p_messages::binprot::BinProtRead; -use mina_p2p_messages::v2::PicklesProofProofsVerifiedMaxStableV2; +use mina_p2p_messages::{binprot::BinProtRead, v2::PicklesProofProofsVerifiedMaxStableV2}; pub use openmina_core::dummy::*; diff --git a/ledger/src/ffi/database.rs b/ledger/src/ffi/database.rs index 21ff2604cd..d2b280d5de 100644 --- a/ledger/src/ffi/database.rs +++ b/ledger/src/ffi/database.rs @@ -11,9 +11,9 @@ use std::{ use ark_ff::BigInteger256; use binprot::BinProtWrite; use mina_hasher::Fp; -use mina_p2p_messages::binprot; use mina_p2p_messages::{ bigint::BigInt, + binprot, v2::{MinaBaseAccountUpdateTStableV1, NonZeroCurvePointUncompressedStableV1}, }; use ocaml_interop::{ diff --git a/ledger/src/ffi/mask.rs b/ledger/src/ffi/mask.rs index f840522f31..5a47e732c9 100644 --- a/ledger/src/ffi/mask.rs +++ b/ledger/src/ffi/mask.rs @@ -11,8 +11,7 @@ use crate::{ account::{Account, AccountId}, address::Address, base::{AccountIndex, BaseLedger, MerklePath}, - ffi::util::*, - ffi::DatabaseFFI, + ffi::{util::*, DatabaseFFI}, short_backtrace, Mask, UnregisterBehavior, }; diff --git a/ledger/src/ondisk/lock.rs b/ledger/src/ondisk/lock.rs index 40e55572a5..e8e3432cf5 100644 --- a/ledger/src/ondisk/lock.rs +++ b/ledger/src/ondisk/lock.rs @@ -60,8 +60,7 @@ impl LockedFile { #[cfg(unix)] mod sys { - use std::fs::File; - use std::os::unix::io::AsRawFd; + use std::{fs::File, os::unix::io::AsRawFd}; fn flock(file: &File, flag: libc::c_int) -> std::io::Result<()> { let ret = unsafe { libc::flock(file.as_raw_fd(), flag) }; @@ -99,13 +98,13 @@ mod sys { #[cfg(windows)] mod sys { - use std::fs::File; - use std::mem; - use std::os::windows::io::AsRawHandle; + use std::{fs::File, mem, os::windows::io::AsRawHandle}; - use windows_sys::Win32::Foundation::HANDLE; - use windows_sys::Win32::Storage::FileSystem::{ - LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, + use windows_sys::Win32::{ + Foundation::HANDLE, + Storage::FileSystem::{ + LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, + }, }; pub(super) fn try_lock_exclusive(file: &File) -> std::io::Result<()> { diff --git a/ledger/src/proofs/accumulator_check.rs b/ledger/src/proofs/accumulator_check.rs index c40908b6a0..2243d02f9d 100644 --- a/ledger/src/proofs/accumulator_check.rs +++ b/ledger/src/proofs/accumulator_check.rs @@ -4,8 +4,7 @@ use mina_hasher::Fp; use mina_p2p_messages::{bigint::BigInt, v2::PicklesProofProofsVerified2ReprStableV2}; use poly_commitment::{commitment::CommitmentCurve, srs::SRS}; -use super::public_input::scalar_challenge::ScalarChallenge; -use super::urs_utils; +use super::{public_input::scalar_challenge::ScalarChallenge, urs_utils}; pub fn accumulator_check( urs: &SRS, diff --git a/ledger/src/proofs/group_map.rs b/ledger/src/proofs/group_map.rs index 04f0f46e91..a0b5c525e4 100644 --- a/ledger/src/proofs/group_map.rs +++ b/ledger/src/proofs/group_map.rs @@ -1,7 +1,9 @@ use std::ops::Neg; -use crate::proofs::field::{field, FieldWitness}; -use crate::proofs::witness::Witness; +use crate::proofs::{ + field::{field, FieldWitness}, + witness::Witness, +}; pub mod bw19 { use super::*; @@ -101,8 +103,10 @@ use mina_hasher::Fp; use self::tock::Conic; -use super::field::{Boolean, GroupAffine, ToBoolean}; -use super::transaction::make_group; +use super::{ + field::{Boolean, GroupAffine, ToBoolean}, + transaction::make_group, +}; fn sqrt_exn(x: F, w: &mut Witness) -> F { w.exists(x.sqrt().unwrap()) diff --git a/ledger/src/proofs/mod.rs b/ledger/src/proofs/mod.rs index 879a2639b5..96ba6e1bda 100644 --- a/ledger/src/proofs/mod.rs +++ b/ledger/src/proofs/mod.rs @@ -47,17 +47,20 @@ pub type ProverProof = kimchi::proof::ProverProof< pub fn generate_tx_proof( params: transaction::TransactionParams, ) -> anyhow::Result { - use {mina_hasher::Fp, witness::Witness}; + use mina_hasher::Fp; + use witness::Witness; let mut w: Witness = Witness::new::(); transaction::generate_tx_proof(params, &mut w) } pub fn generate_merge_proof(params: merge::MergeParams) -> anyhow::Result { - use {mina_hasher::Fp, witness::Witness}; + use mina_hasher::Fp; + use witness::Witness; let mut w: Witness = Witness::new::(); merge::generate_merge_proof(params, &mut w) } pub fn generate_block_proof(params: block::BlockParams) -> anyhow::Result { - use {mina_hasher::Fp, witness::Witness}; + use mina_hasher::Fp; + use witness::Witness; let mut w: Witness = Witness::new::(); block::generate_block_proof(params, &mut w) } diff --git a/ledger/src/proofs/numbers/common.rs b/ledger/src/proofs/numbers/common.rs index eaeff5d20a..bdea14b9ff 100644 --- a/ledger/src/proofs/numbers/common.rs +++ b/ledger/src/proofs/numbers/common.rs @@ -1,6 +1,8 @@ use crate::{ - proofs::field::{field, Boolean, FieldWitness}, - proofs::witness::Witness, + proofs::{ + field::{field, Boolean, FieldWitness}, + witness::Witness, + }, scan_state::currency::Magnitude, }; diff --git a/ledger/src/proofs/numbers/currency.rs b/ledger/src/proofs/numbers/currency.rs index 388d558990..9fe0822230 100644 --- a/ledger/src/proofs/numbers/currency.rs +++ b/ledger/src/proofs/numbers/currency.rs @@ -4,13 +4,15 @@ use crate::{ }; use std::{cell::Cell, cmp::Ordering::Less}; -use crate::proofs::{ - field::{field, Boolean, FieldWitness}, - to_field_elements::ToFieldElements, - transaction::Check, - witness::Witness, +use crate::{ + proofs::{ + field::{field, Boolean, FieldWitness}, + to_field_elements::ToFieldElements, + transaction::Check, + witness::Witness, + }, + ToInputs, }; -use crate::ToInputs; use super::common::{range_check, ForZkappCheck}; diff --git a/ledger/src/proofs/public_input/messages.rs b/ledger/src/proofs/public_input/messages.rs index 480b75a9a3..f967b4479f 100644 --- a/ledger/src/proofs/public_input/messages.rs +++ b/ledger/src/proofs/public_input/messages.rs @@ -1,12 +1,14 @@ use std::str::FromStr; -use crate::proofs::to_field_elements::ToFieldElements; -use crate::proofs::transaction::{checked_hash2, InnerCurve, PlonkVerificationKeyEvals}; -use crate::proofs::witness::Witness; -use crate::proofs::VerifierIndex; +use crate::proofs::{ + to_field_elements::ToFieldElements, + transaction::{checked_hash2, InnerCurve, PlonkVerificationKeyEvals}, + witness::Witness, + VerifierIndex, +}; use ark_ec::short_weierstrass_jacobian::GroupAffine; use ark_ff::{BigInteger256, PrimeField}; -use mina_curves::{pasta::Fq, pasta::Pallas}; +use mina_curves::pasta::{Fq, Pallas}; use mina_hasher::Fp; use poly_commitment::PolyComm; diff --git a/ledger/src/proofs/public_input/plonk_checks.rs b/ledger/src/proofs/public_input/plonk_checks.rs index acf4098b95..1caf42cf4d 100644 --- a/ledger/src/proofs/public_input/plonk_checks.rs +++ b/ledger/src/proofs/public_input/plonk_checks.rs @@ -450,8 +450,7 @@ fn get_feature_flag( feature: &kimchi::circuits::expr::FeatureFlag, w: &mut Witness, ) -> Option { - use kimchi::circuits::expr::FeatureFlag::*; - use kimchi::circuits::lookup::lookups::LookupPattern; + use kimchi::circuits::{expr::FeatureFlag::*, lookup::lookups::LookupPattern}; match feature { RangeCheck0 => Some(feature_flags.features.range_check0), diff --git a/ledger/src/proofs/step.rs b/ledger/src/proofs/step.rs index 39aeaf6053..82be584dd6 100644 --- a/ledger/src/proofs/step.rs +++ b/ledger/src/proofs/step.rs @@ -23,8 +23,7 @@ use ark_poly::{ univariate::DensePolynomial, EvaluationDomain, Radix2EvaluationDomain, UVPolynomial, }; use kimchi::proof::{PointEvaluations, ProverCommitments, RecursionChallenge}; -use mina_curves::pasta::Fq; -use mina_curves::pasta::Pallas; +use mina_curves::pasta::{Fq, Pallas}; use mina_hasher::Fp; use mina_p2p_messages::v2; use poly_commitment::{commitment::b_poly_coefficients, evaluation_proof::OpeningProof}; diff --git a/ledger/src/proofs/transaction.rs b/ledger/src/proofs/transaction.rs index 5e804cea84..d4cf5e9747 100644 --- a/ledger/src/proofs/transaction.rs +++ b/ledger/src/proofs/transaction.rs @@ -46,19 +46,14 @@ use crate::{ use super::{ constants::ProofConstants, - field::GroupAffine, + field::{field, Boolean, CircuitVar, FieldWitness, GroupAffine, ToBoolean}, public_input::messages::{dummy_ipa_step_sg, MessagesForNextWrapProof}, + step, + step::{InductiveRule, OptFlag, StepProof}, to_field_elements::{ToFieldElements, ToFieldElementsDebug}, unfinalized::Unfinalized, witness::Witness, wrap::WrapProof, -}; -use super::{ - field::{field, Boolean, CircuitVar, FieldWitness, ToBoolean}, - step, -}; -use super::{ - step::{InductiveRule, OptFlag, StepProof}, ProverIndex, }; @@ -2541,8 +2536,7 @@ pub mod transaction_snark { inputs: legacy::Inputs, w: &mut Witness, ) -> Fp { - use ::poseidon::fp_legacy::params; - use ::poseidon::PlonkSpongeConstantsLegacy as Constants; + use ::poseidon::{fp_legacy::params, PlonkSpongeConstantsLegacy as Constants}; let initial_state: [Fp; 3] = param.state(); let mut sponge = @@ -4043,8 +4037,7 @@ pub(super) fn create_proof( pub mod debug { use super::*; - use mina_p2p_messages::bigint::BigInt; - use mina_p2p_messages::binprot; + use mina_p2p_messages::{bigint::BigInt, binprot}; use sha2::Digest; fn hash_field(state: &mut sha2::Sha256, f: &F) { @@ -4927,9 +4920,11 @@ pub(super) mod tests { #[test] #[ignore] fn make_rsa_key() { - use rsa::pkcs1::{EncodeRsaPrivateKey, EncodeRsaPublicKey}; - use rsa::pkcs8::LineEnding::LF; - use rsa::{RsaPrivateKey, RsaPublicKey}; + use rsa::{ + pkcs1::{EncodeRsaPrivateKey, EncodeRsaPublicKey}, + pkcs8::LineEnding::LF, + RsaPrivateKey, RsaPublicKey, + }; let mut rng = rand::thread_rng(); let bits = 2048; @@ -4947,8 +4942,7 @@ pub(super) mod tests { #[test] fn add_private_key_to_block_proof_input() { use mina_p2p_messages::binprot::BinProtWrite; - use rsa::pkcs1::DecodeRsaPrivateKey; - use rsa::Pkcs1v15Encrypt; + use rsa::{pkcs1::DecodeRsaPrivateKey, Pkcs1v15Encrypt}; #[derive(binprot::macros::BinProtRead)] struct DumpBlockProof { diff --git a/ledger/src/proofs/unfinalized.rs b/ledger/src/proofs/unfinalized.rs index 5794a640a0..daaac4e1ec 100644 --- a/ledger/src/proofs/unfinalized.rs +++ b/ledger/src/proofs/unfinalized.rs @@ -45,8 +45,10 @@ pub mod ro { } pub fn bits_random_oracle(s: &str) -> [bool; N] { - use blake2::digest::{Update, VariableOutput}; - use blake2::Blake2sVar; + use blake2::{ + digest::{Update, VariableOutput}, + Blake2sVar, + }; let mut hasher = Blake2sVar::new(32).unwrap(); hasher.update(s.as_bytes()); diff --git a/ledger/src/proofs/verification.rs b/ledger/src/proofs/verification.rs index ce7c5a4521..7eeeaaaacd 100644 --- a/ledger/src/proofs/verification.rs +++ b/ledger/src/proofs/verification.rs @@ -501,8 +501,7 @@ fn verify_with( proof: &ProverProof, public_input: &[Fq], ) -> Result<(), VerifyError> { - use kimchi::groupmap::GroupMap; - use kimchi::mina_curves::pasta::PallasParameters; + use kimchi::{groupmap::GroupMap, mina_curves::pasta::PallasParameters}; use mina_poseidon::sponge::{DefaultFqSponge, DefaultFrSponge}; use poly_commitment::evaluation_proof::OpeningProof; @@ -527,9 +526,7 @@ pub struct VerificationContext<'a> { } fn batch_verify(proofs: &[VerificationContext]) -> Result<(), VerifyError> { - use kimchi::groupmap::GroupMap; - use kimchi::mina_curves::pasta::PallasParameters; - use kimchi::verifier::Context; + use kimchi::{groupmap::GroupMap, mina_curves::pasta::PallasParameters, verifier::Context}; use mina_poseidon::sponge::{DefaultFqSponge, DefaultFrSponge}; use poly_commitment::evaluation_proof::OpeningProof; @@ -933,8 +930,10 @@ mod on_fail { zkapp_statement: &ZkappStatement, sideloaded_proof: &PicklesProofProofsVerified2ReprStableV2, ) { - use mina_p2p_messages::binprot; - use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; + use mina_p2p_messages::{ + binprot, + binprot::macros::{BinProtRead, BinProtWrite}, + }; #[derive(Clone, Debug, PartialEq, BinProtRead, BinProtWrite)] struct VerifyZkapp { @@ -1046,8 +1045,10 @@ mod tests { #[test] fn test_verify_zkapp() { - use mina_p2p_messages::binprot; - use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite}; + use mina_p2p_messages::{ + binprot, + binprot::macros::{BinProtRead, BinProtWrite}, + }; #[derive(Clone, Debug, PartialEq, BinProtRead, BinProtWrite)] struct VerifyZkapp { diff --git a/ledger/src/proofs/verifiers.rs b/ledger/src/proofs/verifiers.rs index a0acd68096..68d8a9fd57 100644 --- a/ledger/src/proofs/verifiers.rs +++ b/ledger/src/proofs/verifiers.rs @@ -28,10 +28,10 @@ use poly_commitment::srs::SRS; use crate::{proofs::BACKEND_TOCK_ROUNDS_N, VerificationKey}; use super::{ - transaction::endos, + transaction::{endos, InnerCurve}, wrap::{Domain, Domains}, + VerifierIndex, }; -use super::{transaction::InnerCurve, VerifierIndex}; #[derive(Clone, Copy)] enum Kind { diff --git a/ledger/src/proofs/wrap.rs b/ledger/src/proofs/wrap.rs index fb3ca859f6..fe6fe6bb2f 100644 --- a/ledger/src/proofs/wrap.rs +++ b/ledger/src/proofs/wrap.rs @@ -196,8 +196,7 @@ pub fn create_oracle_with_public_input( proof: &ProverProof, public_input: &[F], ) -> Oracles { - use mina_poseidon::constants::PlonkSpongeConstantsKimchi; - use mina_poseidon::sponge::DefaultFrSponge; + use mina_poseidon::{constants::PlonkSpongeConstantsKimchi, sponge::DefaultFrSponge}; use poly_commitment::commitment::shift_scalar; // TODO: Don't clone the SRS here diff --git a/ledger/src/proofs/zkapp.rs b/ledger/src/proofs/zkapp.rs index 9d7e88102d..16860c1cd7 100644 --- a/ledger/src/proofs/zkapp.rs +++ b/ledger/src/proofs/zkapp.rs @@ -1445,8 +1445,7 @@ impl From<&WrapProof> for v2::PicklesProofProofsVerified2ReprStableV2 { assert!(lookup.is_none()); - use mina_p2p_messages::bigint::BigInt; - use mina_p2p_messages::pseq::PaddedSeq; + use mina_p2p_messages::{bigint::BigInt, pseq::PaddedSeq}; use std::array; let to_tuple = |g: &GroupAffine| -> (BigInt, BigInt) { (g.x.into(), g.y.into()) }; diff --git a/ledger/src/scan_state/conv.rs b/ledger/src/scan_state/conv.rs index 0455f6a920..13259dbba2 100644 --- a/ledger/src/scan_state/conv.rs +++ b/ledger/src/scan_state/conv.rs @@ -822,10 +822,12 @@ impl TryFrom<&MinaBaseZkappPreconditionProtocolStateEpochDataStableV1> fn try_from( value: &MinaBaseZkappPreconditionProtocolStateEpochDataStableV1, ) -> Result { - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed as Seed; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint as Start; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Hash; + use mina_p2p_messages::v2::{ + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed as Seed, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint as Start, + MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount, + MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Hash, + }; use zkapp_command::{ClosedInterval, OrIgnore}; Ok(Self { @@ -871,10 +873,12 @@ fn fp_to_statehash(value: &Fp) -> StateHash { impl From<&zkapp_command::EpochData> for MinaBaseZkappPreconditionProtocolStateEpochDataStableV1 { fn from(value: &zkapp_command::EpochData) -> Self { - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed as Seed; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint as Start; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Hash; + use mina_p2p_messages::v2::{ + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed as Seed, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint as Start, + MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount, + MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Hash, + }; use zkapp_command::OrIgnore; Self { @@ -917,11 +921,12 @@ impl TryFrom<&MinaBaseAccountUpdatePreconditionsStableV1> for zkapp_command::Pre type Error = InvalidBigInt; fn try_from(value: &MinaBaseAccountUpdatePreconditionsStableV1) -> Result { - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot as MSlot; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Ledger; - use zkapp_command::AccountPreconditions; - use zkapp_command::{ClosedInterval, Numeric, OrIgnore}; + use mina_p2p_messages::v2::{ + MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount, + MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot as MSlot, + MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Ledger, + }; + use zkapp_command::{AccountPreconditions, ClosedInterval, Numeric, OrIgnore}; Ok(Self { network: zkapp_command::ZkAppPreconditions { @@ -950,12 +955,14 @@ impl TryFrom<&MinaBaseAccountUpdatePreconditionsStableV1> for zkapp_command::Pre }, account: { let account = &value.account.0; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2Balance as MBalance; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2Delegate as Delegate; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2ProvedState as Proved; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash as Receipt; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2StateA as State; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Length as MNonce; + use mina_p2p_messages::v2::{ + MinaBaseZkappPreconditionAccountStableV2Balance as MBalance, + MinaBaseZkappPreconditionAccountStableV2Delegate as Delegate, + MinaBaseZkappPreconditionAccountStableV2ProvedState as Proved, + MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash as Receipt, + MinaBaseZkappPreconditionAccountStableV2StateA as State, + MinaBaseZkappPreconditionProtocolStateStableV1Length as MNonce, + }; AccountPreconditions(zkapp_command::Account { balance: match &account.balance { @@ -1021,10 +1028,12 @@ impl From<&BlockTime> for BlockTimeTimeStableV1 { impl From<&zkapp_command::Preconditions> for MinaBaseAccountUpdatePreconditionsStableV1 { fn from(value: &zkapp_command::Preconditions) -> Self { - use mina_p2p_messages::v2::MinaBaseAccountUpdateAccountPreconditionStableV1 as MAccount; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot as MSlot; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Ledger; + use mina_p2p_messages::v2::{ + MinaBaseAccountUpdateAccountPreconditionStableV1 as MAccount, + MinaBaseZkappPreconditionProtocolStateStableV1Amount as MAmount, + MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot as MSlot, + MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash as Ledger, + }; use zkapp_command::{Numeric, OrIgnore}; Self { @@ -1060,12 +1069,14 @@ impl From<&zkapp_command::Preconditions> for MinaBaseAccountUpdatePreconditionsS next_epoch_data: (&value.network.next_epoch_data).into(), }, account: { - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2Balance as MBalance; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2Delegate as Delegate; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2ProvedState as Proved; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash as Receipt; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionAccountStableV2StateA as State; - use mina_p2p_messages::v2::MinaBaseZkappPreconditionProtocolStateStableV1Length as MNonce; + use mina_p2p_messages::v2::{ + MinaBaseZkappPreconditionAccountStableV2Balance as MBalance, + MinaBaseZkappPreconditionAccountStableV2Delegate as Delegate, + MinaBaseZkappPreconditionAccountStableV2ProvedState as Proved, + MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash as Receipt, + MinaBaseZkappPreconditionAccountStableV2StateA as State, + MinaBaseZkappPreconditionProtocolStateStableV1Length as MNonce, + }; let account = &value.account.0; MAccount(MinaBaseZkappPreconditionAccountStableV2 { @@ -1137,13 +1148,15 @@ impl TryFrom<&MinaBaseAccountUpdateTStableV1> for AccountUpdate { type Error = InvalidBigInt; fn try_from(value: &MinaBaseAccountUpdateTStableV1) -> Result { - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Delegate as Delegate; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Permissions as Perm; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Timing as Timing; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1TokenSymbol as TokenSymbol; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1VerificationKey as VK; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1VotingFor as Voting; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1ZkappUri as ZkAppUri; + use mina_p2p_messages::v2::{ + MinaBaseAccountUpdateUpdateStableV1Delegate as Delegate, + MinaBaseAccountUpdateUpdateStableV1Permissions as Perm, + MinaBaseAccountUpdateUpdateStableV1Timing as Timing, + MinaBaseAccountUpdateUpdateStableV1TokenSymbol as TokenSymbol, + MinaBaseAccountUpdateUpdateStableV1VerificationKey as VK, + MinaBaseAccountUpdateUpdateStableV1VotingFor as Voting, + MinaBaseAccountUpdateUpdateStableV1ZkappUri as ZkAppUri, + }; use MinaBaseAccountUpdateUpdateStableV1AppStateA as AppState; Ok(Self { @@ -1487,13 +1500,15 @@ impl AsAccountUpdateWithHash for MinaBaseZkappCommandTStableV1WireStableV1Accoun impl From<&AccountUpdate> for MinaBaseAccountUpdateTStableV1 { fn from(value: &AccountUpdate) -> Self { - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Delegate as Delegate; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Permissions as Perm; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1Timing as Timing; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1TokenSymbol as TokenSymbol; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1VerificationKey as VK; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1VotingFor as Voting; - use mina_p2p_messages::v2::MinaBaseAccountUpdateUpdateStableV1ZkappUri as ZkAppUri; + use mina_p2p_messages::v2::{ + MinaBaseAccountUpdateUpdateStableV1Delegate as Delegate, + MinaBaseAccountUpdateUpdateStableV1Permissions as Perm, + MinaBaseAccountUpdateUpdateStableV1Timing as Timing, + MinaBaseAccountUpdateUpdateStableV1TokenSymbol as TokenSymbol, + MinaBaseAccountUpdateUpdateStableV1VerificationKey as VK, + MinaBaseAccountUpdateUpdateStableV1VotingFor as Voting, + MinaBaseAccountUpdateUpdateStableV1ZkappUri as ZkAppUri, + }; use MinaBaseAccountUpdateUpdateStableV1AppStateA as AppState; Self { @@ -1838,9 +1853,11 @@ impl TryFrom<&MinaTransactionLogicTransactionAppliedVaryingStableV2> fn try_from( value: &MinaTransactionLogicTransactionAppliedVaryingStableV2, ) -> Result { - use mina_p2p_messages::v2::MinaTransactionLogicTransactionAppliedVaryingStableV2::*; - use mina_p2p_messages::v2::MinaTransactionLogicTransactionAppliedCommandAppliedStableV2::*; - use mina_p2p_messages::v2::MinaTransactionLogicTransactionAppliedSignedCommandAppliedBodyStableV2::*; + use mina_p2p_messages::v2::{ + MinaTransactionLogicTransactionAppliedCommandAppliedStableV2::*, + MinaTransactionLogicTransactionAppliedSignedCommandAppliedBodyStableV2::*, + MinaTransactionLogicTransactionAppliedVaryingStableV2::*, + }; use transaction_applied::signed_command_applied; let result = match value { diff --git a/ledger/src/scan_state/currency.rs b/ledger/src/scan_state/currency.rs index badd586298..bcc1773978 100644 --- a/ledger/src/scan_state/currency.rs +++ b/ledger/src/scan_state/currency.rs @@ -4,10 +4,9 @@ use ark_ff::{fields::arithmetic::InvalidBigInt, BigInteger256, Field}; use mina_p2p_messages::v2::BlockTimeTimeStableV1; use rand::Rng; -use crate::proofs::field::FieldWitness; -use crate::proofs::to_field_elements::ToFieldElements; -use crate::proofs::transaction::Check; -use crate::proofs::witness::Witness; +use crate::proofs::{ + field::FieldWitness, to_field_elements::ToFieldElements, transaction::Check, witness::Witness, +}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Sgn { diff --git a/ledger/src/scan_state/parallel_scan.rs b/ledger/src/scan_state/parallel_scan.rs index 8ee442fcc4..82d4025906 100644 --- a/ledger/src/scan_state/parallel_scan.rs +++ b/ledger/src/scan_state/parallel_scan.rs @@ -1,14 +1,17 @@ -use std::collections::{BTreeMap, VecDeque}; -use std::fmt::Debug; -use std::io::Write; -use std::ops::ControlFlow; -use std::sync::Arc; +use std::{ + collections::{BTreeMap, VecDeque}, + fmt::Debug, + io::Write, + ops::ControlFlow, + sync::Arc, +}; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use sha2::digest::generic_array::GenericArray; -use sha2::digest::typenum::U32; -use sha2::{Digest, Sha256}; +use sha2::{ + digest::{generic_array::GenericArray, typenum::U32}, + Digest, Sha256, +}; use ControlFlow::{Break, Continue}; use super::scan_state::transaction_snark::{LedgerProofWithSokMessage, TransactionWithWitness}; diff --git a/ledger/src/scan_state/scan_state.rs b/ledger/src/scan_state/scan_state.rs index 5ee75063f8..d6be867f67 100644 --- a/ledger/src/scan_state/scan_state.rs +++ b/ledger/src/scan_state/scan_state.rs @@ -14,8 +14,7 @@ use mina_p2p_messages::{ }, }; use mina_signer::CompressedPubKey; -use openmina_core::constants::ConstraintConstants; -use openmina_core::snark::SnarkJobId; +use openmina_core::{constants::ConstraintConstants, snark::SnarkJobId}; use sha2::Sha256; use crate::{ @@ -57,9 +56,8 @@ use super::{ }; // use super::parallel_scan::AvailableJob; -pub use super::parallel_scan::base::Job as JobValueBase; -pub use super::parallel_scan::merge::Job as JobValueMerge; pub use super::parallel_scan::{ + base::Job as JobValueBase, merge::Job as JobValueMerge, AvailableJob as ParallelScanAvailableJob, JobValue, JobValueWithIndex, SpacePartition, }; @@ -104,8 +102,10 @@ pub mod transaction_snark { use serde::{Deserialize, Serialize}; use crate::{ - proofs::field::{field, Boolean}, - proofs::witness::Witness, + proofs::{ + field::{field, Boolean}, + witness::Witness, + }, scan_state::{ currency::{Amount, Signed, Slot}, fee_excess::FeeExcess, diff --git a/ledger/src/scan_state/snark_work.rs b/ledger/src/scan_state/snark_work.rs index 665e87a47b..7c73fdea0e 100644 --- a/ledger/src/scan_state/snark_work.rs +++ b/ledger/src/scan_state/snark_work.rs @@ -12,14 +12,16 @@ pub mod spec { #[cfg(test)] mod tests { - use mina_p2p_messages::binprot::{ - self, - macros::{BinProtRead, BinProtWrite}, - }; - use mina_p2p_messages::v2::{ - MinaBaseTransactionStatusStableV2, MinaTransactionTransactionStableV2, - SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse, - SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponseA0Instances, + use mina_p2p_messages::{ + binprot::{ + self, + macros::{BinProtRead, BinProtWrite}, + }, + v2::{ + MinaBaseTransactionStatusStableV2, MinaTransactionTransactionStableV2, + SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse, + SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponseA0Instances, + }, }; use binprot::{BinProtRead, BinProtWrite}; diff --git a/ledger/src/scan_state/transaction_logic.rs b/ledger/src/scan_state/transaction_logic.rs index 21207c8b28..0e769562fe 100644 --- a/ledger/src/scan_state/transaction_logic.rs +++ b/ledger/src/scan_state/transaction_logic.rs @@ -1,33 +1,38 @@ -use std::collections::{BTreeMap, HashMap, HashSet}; -use std::fmt::Display; +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + fmt::Display, +}; -use ark_ff::fields::arithmetic::InvalidBigInt; -use ark_ff::Zero; +use ark_ff::{fields::arithmetic::InvalidBigInt, Zero}; use itertools::{FoldWhile, Itertools}; use mina_hasher::{Fp, Hashable, ROInput}; -use mina_p2p_messages::binprot; -use mina_p2p_messages::v2::{MinaBaseUserCommandStableV2, MinaTransactionTransactionStableV2}; -use mina_signer::CompressedPubKey; -use mina_signer::NetworkId; +use mina_p2p_messages::{ + binprot, + v2::{MinaBaseUserCommandStableV2, MinaTransactionTransactionStableV2}, +}; +use mina_signer::{CompressedPubKey, NetworkId}; use openmina_core::constants::ConstraintConstants; use openmina_macros::SerdeYojsonEnum; -use poseidon::hash::params::{CODA_RECEIPT_UC, MINA_ZKAPP_MEMO}; -use poseidon::hash::{hash_noinputs, hash_with_kimchi, Inputs}; +use poseidon::hash::{ + hash_noinputs, hash_with_kimchi, + params::{CODA_RECEIPT_UC, MINA_ZKAPP_MEMO}, + Inputs, +}; -use crate::proofs::witness::Witness; -use crate::scan_state::transaction_logic::transaction_partially_applied::FullyApplied; -use crate::scan_state::transaction_logic::zkapp_command::MaybeWithStatus; -use crate::zkapps::non_snark::{LedgerNonSnark, ZkappNonSnark}; use crate::{ - scan_state::transaction_logic::transaction_applied::{CommandApplied, Varying}, + proofs::witness::Witness, + scan_state::transaction_logic::{ + transaction_applied::{CommandApplied, Varying}, + transaction_partially_applied::FullyApplied, + zkapp_command::MaybeWithStatus, + }, sparse_ledger::{LedgerIntf, SparseLedger}, - Account, AccountId, ReceiptChainHash, Timing, TokenId, -}; -use crate::{ - zkapps, AccountIdOrderable, AppendToInputs, BaseLedger, ControlTag, VerificationKeyWire, + zkapps, + zkapps::non_snark::{LedgerNonSnark, ZkappNonSnark}, + Account, AccountId, AccountIdOrderable, AppendToInputs, BaseLedger, ControlTag, + ReceiptChainHash, Timing, TokenId, VerificationKeyWire, }; -use self::zkapp_command::AccessedOrNot; use self::{ local_state::{CallStack, LocalStateEnv, StackFrame}, protocol_state::{GlobalState, ProtocolStateView}, @@ -37,14 +42,13 @@ use self::{ TransactionApplied, ZkappCommandApplied, }, transaction_union_payload::TransactionUnionPayload, - zkapp_command::{AccountUpdate, WithHash, ZkAppCommand}, + zkapp_command::{AccessedOrNot, AccountUpdate, WithHash, ZkAppCommand}, }; -use super::currency::SlotSpan; -use super::fee_rate::FeeRate; use super::{ - currency::{Amount, Balance, Fee, Index, Length, Magnitude, Nonce, Signed, Slot}, + currency::{Amount, Balance, Fee, Index, Length, Magnitude, Nonce, Signed, Slot, SlotSpan}, fee_excess::FeeExcess, + fee_rate::FeeRate, scan_state::transaction_snark::OneOrTwo, }; use crate::zkapps::zkapp_logic::ZkAppCommandElt; @@ -7562,8 +7566,9 @@ pub fn checked_cons_signed_command_payload( last_receipt_chain_hash: ReceiptChainHash, w: &mut Witness, ) -> ReceiptChainHash { - use crate::proofs::transaction::legacy_input::CheckedLegacyInput; - use crate::proofs::transaction::transaction_snark::checked_legacy_hash; + use crate::proofs::transaction::{ + legacy_input::CheckedLegacyInput, transaction_snark::checked_legacy_hash, + }; use ::poseidon::hash::legacy; let mut inputs = payload.to_checked_legacy_input_owned(w); diff --git a/ledger/src/sparse_ledger/sparse_ledger.rs b/ledger/src/sparse_ledger/sparse_ledger.rs index 97a4927240..c6c7df1296 100644 --- a/ledger/src/sparse_ledger/sparse_ledger.rs +++ b/ledger/src/sparse_ledger/sparse_ledger.rs @@ -295,9 +295,10 @@ impl LedgerIntf for SparseLedger { impl From<&SparseLedger> for mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2 { fn from(value: &SparseLedger) -> Self { - use mina_p2p_messages::v2::MinaBaseAccountBinableArgStableV2; - use mina_p2p_messages::v2::MinaBaseAccountIdStableV2; - use mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2Tree; + use mina_p2p_messages::v2::{ + MinaBaseAccountBinableArgStableV2, MinaBaseAccountIdStableV2, + MinaBaseSparseLedgerBaseStableV2Tree, + }; let value = value.inner.try_lock().unwrap(); @@ -389,8 +390,10 @@ impl TryFrom<&mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2> for Spars fn try_from( value: &mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2, ) -> Result { - use mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2Tree; - use mina_p2p_messages::v2::MinaBaseSparseLedgerBaseStableV2Tree::{Account, Hash, Node}; + use mina_p2p_messages::v2::{ + MinaBaseSparseLedgerBaseStableV2Tree, + MinaBaseSparseLedgerBaseStableV2Tree::{Account, Hash, Node}, + }; fn build_matrix( matrix: &mut HashesMatrix, diff --git a/ledger/src/staged_ledger/diff_creation_log.rs b/ledger/src/staged_ledger/diff_creation_log.rs index ccc9c08b73..a3986f1d1e 100644 --- a/ledger/src/staged_ledger/diff_creation_log.rs +++ b/ledger/src/staged_ledger/diff_creation_log.rs @@ -1,14 +1,13 @@ -use crate::scan_state::currency::{Fee, Magnitude}; use crate::{ scan_state::{ + currency::{Fee, Magnitude}, scan_state::transaction_snark::work, transaction_logic::{valid, CoinbaseFeeTransfer, GenericCommand}, }, staged_ledger::diff::AtMostTwo, }; -use self::detail::Detail; -use self::summary::Summary; +use self::{detail::Detail, summary::Summary}; type CountAndFee = (u64, Fee); diff --git a/ledger/src/staged_ledger/pre_diff_info.rs b/ledger/src/staged_ledger/pre_diff_info.rs index f9187a29aa..d6355c5514 100644 --- a/ledger/src/staged_ledger/pre_diff_info.rs +++ b/ledger/src/staged_ledger/pre_diff_info.rs @@ -272,8 +272,7 @@ fn create_fee_transfers<'a>( fn check_coinbase( (fst, snd): &(PreDiffTwo, Option>), ) -> Result<(), PreDiffError> { - use diff::AtMostOne as O; - use diff::AtMostTwo::*; + use diff::{AtMostOne as O, AtMostTwo::*}; match ( &fst.coinbase, diff --git a/ledger/src/staged_ledger/staged_ledger.rs b/ledger/src/staged_ledger/staged_ledger.rs index 1076accc92..d494d8778d 100644 --- a/ledger/src/staged_ledger/staged_ledger.rs +++ b/ledger/src/staged_ledger/staged_ledger.rs @@ -1961,9 +1961,9 @@ impl StagedLedger { /// https://github.com/MinaProtocol/mina/blob/05c2f73d0f6e4f1341286843814ce02dcb3919e0/src/lib/staged_ledger/staged_ledger.ml#L2024 pub fn latest_block_accounts_created(&self, previous_block_state_hash: Fp) -> Vec { - use scan_state::transaction_logic::transaction_applied::signed_command_applied::Body; - use scan_state::transaction_logic::transaction_applied::CommandApplied; - use scan_state::transaction_logic::transaction_applied::Varying; + use scan_state::transaction_logic::transaction_applied::{ + signed_command_applied::Body, CommandApplied, Varying, + }; let block_transactions_applied = { let f = |t: Arc| { @@ -2013,8 +2013,7 @@ mod tests_ocaml { use ark_ec::{AffineCurve, ProjectiveCurve}; use ark_ff::Zero; use mina_curves::pasta::Fq; - use mina_signer::Signer; - use mina_signer::{Keypair, Signature}; + use mina_signer::{Keypair, Signature, Signer}; use o1_utils::FieldHelpers; use once_cell::sync::Lazy; use rand::{seq::SliceRandom, CryptoRng, Rng}; diff --git a/ledger/src/staged_ledger/validate_block.rs b/ledger/src/staged_ledger/validate_block.rs index f10ff4745e..d93b6a8eda 100644 --- a/ledger/src/staged_ledger/validate_block.rs +++ b/ledger/src/staged_ledger/validate_block.rs @@ -1,9 +1,9 @@ use std::collections::{BTreeMap, VecDeque}; use itertools::Itertools; -use mina_p2p_messages::binprot::BinProtWrite; -use mina_p2p_messages::v2::{ - ConsensusBodyReferenceStableV1, MinaBlockBlockStableV2, StagedLedgerDiffDiffStableV2, +use mina_p2p_messages::{ + binprot::BinProtWrite, + v2::{ConsensusBodyReferenceStableV1, MinaBlockBlockStableV2, StagedLedgerDiffDiffStableV2}, }; const BODY_TAG: u8 = 0; @@ -68,8 +68,10 @@ fn serialize_with_len_and_tag(block: &StagedLedgerDiffDiffStableV2) -> Vec { } fn blake2(data: &[u8]) -> Link { - use blake2::digest::{Update, VariableOutput}; - use blake2::Blake2bVar; + use blake2::{ + digest::{Update, VariableOutput}, + Blake2bVar, + }; let mut hasher = Blake2bVar::new(LINK_SIZE).unwrap(); hasher.update(data); diff --git a/ledger/src/verifier/mod.rs b/ledger/src/verifier/mod.rs index 86a7f363d9..1e5f0cc9b4 100644 --- a/ledger/src/verifier/mod.rs +++ b/ledger/src/verifier/mod.rs @@ -318,8 +318,7 @@ pub mod common { tx_commitment }; - use zkapp_command::AuthorizationKind as AK; - use zkapp_command::Control as C; + use zkapp_command::{AuthorizationKind as AK, Control as C}; match (&p.authorization, &p.body.authorization_kind) { (C::Signature(s), AK::Signature) => { let pk = decompress_pk(&p.body.public_key).unwrap(); @@ -380,8 +379,7 @@ pub mod common { ) -> bool { use ark_ec::{AffineCurve, ProjectiveCurve}; use ark_ff::{BigInteger, PrimeField, Zero}; - use mina_curves::pasta::Fq; - use mina_curves::pasta::Pallas; + use mina_curves::pasta::{Fq, Pallas}; use mina_signer::CurvePoint; use std::ops::Neg; @@ -411,8 +409,7 @@ pub mod common { use ::poseidon::hash::legacy; use ark_ec::{AffineCurve, ProjectiveCurve}; use ark_ff::{BigInteger, PrimeField, Zero}; - use mina_curves::pasta::Fq; - use mina_curves::pasta::Pallas; + use mina_curves::pasta::{Fq, Pallas}; use mina_signer::CurvePoint; use std::ops::Neg; diff --git a/ledger/src/zkapps/intefaces.rs b/ledger/src/zkapps/intefaces.rs index 4578e6b49a..4dfc2f8733 100644 --- a/ledger/src/zkapps/intefaces.rs +++ b/ledger/src/zkapps/intefaces.rs @@ -3,19 +3,25 @@ use std::marker::PhantomData; use mina_hasher::Fp; use mina_signer::CompressedPubKey; -use crate::proofs::field::{Boolean, FieldWitness}; -use crate::proofs::to_field_elements::ToFieldElements; -use crate::proofs::transaction::Check; +use crate::proofs::{ + field::{Boolean, FieldWitness}, + to_field_elements::ToFieldElements, + transaction::Check, +}; -use crate::scan_state::currency::{self, SlotSpan, TxnVersion}; -use crate::zkapps::zkapp_logic; +use crate::{ + scan_state::currency::{self, SlotSpan, TxnVersion}, + zkapps::zkapp_logic, +}; -use crate::scan_state::transaction_logic::zkapp_command::{ - self, CheckAuthorizationResult, SetOrKeep, +use crate::{ + scan_state::transaction_logic::{ + zkapp_command::{self, CheckAuthorizationResult, SetOrKeep}, + TimingValidation, TransactionFailure, + }, + sparse_ledger::LedgerIntf, + AccountId, AuthRequired, MyCow, ReceiptChainHash, TokenId, ZkAppAccount, }; -use crate::scan_state::transaction_logic::{TimingValidation, TransactionFailure}; -use crate::sparse_ledger::LedgerIntf; -use crate::{AccountId, AuthRequired, MyCow, ReceiptChainHash, TokenId, ZkAppAccount}; pub trait WitnessGenerator where diff --git a/ledger/src/zkapps/snark.rs b/ledger/src/zkapps/snark.rs index 748dc995b8..118ed8e96d 100644 --- a/ledger/src/zkapps/snark.rs +++ b/ledger/src/zkapps/snark.rs @@ -642,8 +642,10 @@ impl AccountUpdateInterface for SnarkAccountUpdate { single_data: &Self::SingleData, w: &mut Self::W, ) -> CheckAuthorizationResult { - use crate::scan_state::transaction_logic::zkapp_statement::TransactionCommitment; - use crate::ControlTag::{NoneGiven, Proof, Signature}; + use crate::{ + scan_state::transaction_logic::zkapp_statement::TransactionCommitment, + ControlTag::{NoneGiven, Proof, Signature}, + }; let Self::CallForest { data: _, diff --git a/ledger/src/zkapps/zkapp_logic.rs b/ledger/src/zkapps/zkapp_logic.rs index 3c831b9c8e..a03b050bb0 100644 --- a/ledger/src/zkapps/zkapp_logic.rs +++ b/ledger/src/zkapps/zkapp_logic.rs @@ -2,20 +2,18 @@ use mina_hasher::Fp; use mina_signer::CompressedPubKey; use openmina_core::constants::constraint_constants; -use crate::scan_state::transaction_logic::zkapp_command::{Actions, SetOrKeep}; -use crate::scan_state::transaction_logic::TimingValidation; use crate::{ scan_state::{ currency::{Fee, Magnitude, SlotSpan}, transaction_logic::{ - protocol_state::GlobalStateSkeleton, zkapp_command::CheckAuthorizationResult, - TransactionFailure, + protocol_state::GlobalStateSkeleton, + zkapp_command::{Actions, CheckAuthorizationResult, SetOrKeep}, + TimingValidation, TransactionFailure, }, }, zkapps::intefaces::*, - AuthRequired, MyCow, TokenId, + AuthRequired, MyCow, Permissions, SetVerificationKey, TokenId, VerificationKeyWire, }; -use crate::{Permissions, SetVerificationKey, VerificationKeyWire}; use crate::proofs::{ field::{Boolean, ToBoolean}, diff --git a/mina-p2p-messages/src/b58.rs b/mina-p2p-messages/src/b58.rs index 1af06978eb..3479e68803 100644 --- a/mina-p2p-messages/src/b58.rs +++ b/mina-p2p-messages/src/b58.rs @@ -1,8 +1,6 @@ //! Base58check encoding/decoding. -use std::fmt; -use std::marker::PhantomData; -use std::str::FromStr; +use std::{fmt, marker::PhantomData, str::FromStr}; use binprot::{BinProtRead, BinProtWrite}; use binprot_derive::{BinProtRead, BinProtWrite}; diff --git a/mina-p2p-messages/src/hash_input.rs b/mina-p2p-messages/src/hash_input.rs index 8d323c05b0..b11e58bf37 100644 --- a/mina-p2p-messages/src/hash_input.rs +++ b/mina-p2p-messages/src/hash_input.rs @@ -7,8 +7,7 @@ use crate::{ bigint::BigInt, list::List, number::{Int32, Int64, UInt32, UInt64}, - string::ByteString, - string::ZkAppUri, + string::{ByteString, ZkAppUri}, }; /// Difference with `ToInputs` in `ledger` is that it can fail here, due diff --git a/mina-p2p-messages/src/rpc.rs b/mina-p2p-messages/src/rpc.rs index 53eddfe082..d0484ced53 100644 --- a/mina-p2p-messages/src/rpc.rs +++ b/mina-p2p-messages/src/rpc.rs @@ -5,14 +5,14 @@ use binprot::{BinProtRead, BinProtWrite}; use binprot_derive::{BinProtRead, BinProtWrite}; use serde::{Deserialize, Serialize}; -use crate::common::*; -use crate::core; -use crate::list::List; -use crate::rpc_kernel::*; -use crate::v2; use crate::{ + common::*, + core, core::InetAddrV1Versioned, + list::List, + rpc_kernel::*, string::CharString, + v2, v2::MinaBaseSparseLedgerBaseStableV2, versioned::{Ver, Versioned}, }; diff --git a/mina-p2p-messages/src/v2/hashing.rs b/mina-p2p-messages/src/v2/hashing.rs index 239063f26a..3b65d27e6b 100644 --- a/mina-p2p-messages/src/v2/hashing.rs +++ b/mina-p2p-messages/src/v2/hashing.rs @@ -275,8 +275,7 @@ impl generated::MinaBaseZkappCommandTStableV1WireStableV1 { #[cfg(test)] mod tests { - use super::super::manual; - use super::*; + use super::{super::manual, *}; use manual::MinaBaseSignedCommandMemoStableV1; fn pub_key(address: &str) -> manual::NonZeroCurvePoint { @@ -298,8 +297,7 @@ mod tests { nonce: u32, valid_until: u32, ) -> String { - use crate::number::Number; - use crate::string::CharString; + use crate::{number::Number, string::CharString}; let from = pub_key(from); let to = pub_key(to); diff --git a/mina-p2p-messages/tests/decode_alloc.rs b/mina-p2p-messages/tests/decode_alloc.rs index cd6dc346c4..9b47ff5d9d 100644 --- a/mina-p2p-messages/tests/decode_alloc.rs +++ b/mina-p2p-messages/tests/decode_alloc.rs @@ -1,20 +1,22 @@ mod decode_bench; -use std::collections::BTreeMap; -use std::fs; +use std::{collections::BTreeMap, fs}; use binprot::BinProtWrite; use decode_bench::*; -use alloc_test::alloc::measure::MemoryTracingHooks; use alloc_test::{ - alloc::compare::{AllocThresholds, AllocThresholdsBuilder, AllocThresholdsError}, + alloc::{ + compare::{AllocThresholds, AllocThresholdsBuilder, AllocThresholdsError}, + measure::MemoryTracingHooks, + }, alloc_bench, threshold::{CheckThresholdError, Threshold}, }; -use mina_p2p_messages::rpc_kernel::Message; -use mina_p2p_messages::utils::{FromBinProtStream, Greedy}; -use time::format_description::well_known::Rfc3339; -use time::OffsetDateTime; +use mina_p2p_messages::{ + rpc_kernel::Message, + utils::{FromBinProtStream, Greedy}, +}; +use time::{format_description::well_known::Rfc3339, OffsetDateTime}; #[global_allocator] static ALLOCATOR: alloc_test::alloc::allocator::TracingAllocator< diff --git a/node/account/src/public_key.rs b/node/account/src/public_key.rs index 781a1bde8f..a72b994916 100644 --- a/node/account/src/public_key.rs +++ b/node/account/src/public_key.rs @@ -1,11 +1,11 @@ use std::{fmt, str::FromStr}; -use mina_p2p_messages::binprot::{ - self, - macros::{BinProtRead, BinProtWrite}, -}; use mina_p2p_messages::{ b58::FromBase58CheckError, + binprot::{ + self, + macros::{BinProtRead, BinProtWrite}, + }, v2::{NonZeroCurvePoint, NonZeroCurvePointUncompressedStableV1}, }; use serde::{Deserialize, Serialize}; diff --git a/node/account/src/secret_key.rs b/node/account/src/secret_key.rs index f346b48934..b530bc4731 100644 --- a/node/account/src/secret_key.rs +++ b/node/account/src/secret_key.rs @@ -1,10 +1,10 @@ use std::{fmt, fs, io, path::Path, str::FromStr}; use mina_p2p_messages::{bigint::BigInt, v2::SignatureLibPrivateKeyStableV1}; -use mina_signer::seckey::SecKeyError; -use mina_signer::{keypair::KeypairError, CompressedPubKey, Keypair}; -use openmina_core::constants::GENESIS_PRODUCER_SK; -use openmina_core::{EncryptedSecretKey, EncryptedSecretKeyFile, EncryptionError}; +use mina_signer::{keypair::KeypairError, seckey::SecKeyError, CompressedPubKey, Keypair}; +use openmina_core::{ + constants::GENESIS_PRODUCER_SK, EncryptedSecretKey, EncryptedSecretKeyFile, EncryptionError, +}; use rand::{rngs::StdRng, CryptoRng, Rng, SeedableRng}; use serde::{Deserialize, Serialize}; diff --git a/node/build.rs b/node/build.rs index e56793cd02..a691c8da8d 100644 --- a/node/build.rs +++ b/node/build.rs @@ -1,12 +1,13 @@ // This build script will generate `node/src/action_kind.rs`. // See the top comment on that file for some context. -use std::collections::btree_map::Entry as BTreeMapEntry; -use std::collections::{BTreeMap, VecDeque}; -use std::error::Error; -use std::fs::{self, DirEntry}; -use std::io::{self, BufRead, BufReader, Read}; -use std::path::{Path, PathBuf}; +use std::{ + collections::{btree_map::Entry as BTreeMapEntry, BTreeMap, VecDeque}, + error::Error, + fs::{self, DirEntry}, + io::{self, BufRead, BufReader, Read}, + path::{Path, PathBuf}, +}; use regex::Regex; use rust_format::Formatter; diff --git a/node/common/src/service/archive/mod.rs b/node/common/src/service/archive/mod.rs index c05d921b11..04d5f2844c 100644 --- a/node/common/src/service/archive/mod.rs +++ b/node/common/src/service/archive/mod.rs @@ -1,8 +1,9 @@ use mina_p2p_messages::v2::{self}; -use node::core::{channels::mpsc, thread}; -use node::ledger::write::BlockApplyResult; -use std::env; -use std::io::Write; +use node::{ + core::{channels::mpsc, thread}, + ledger::write::BlockApplyResult, +}; +use std::{env, io::Write}; use mina_p2p_messages::v2::PrecomputedBlock; use openmina_core::NetworkConfig; @@ -315,8 +316,10 @@ impl node::transition_frontier::archive::archive_service::ArchiveService for Nod mod rpc {} fn write_to_local_storage(base_path: &str, key: &str, data: &[u8]) -> Result<(), Error> { - use std::fs::{create_dir_all, File}; - use std::path::Path; + use std::{ + fs::{create_dir_all, File}, + path::Path, + }; let path = Path::new(base_path).join(key); if let Some(parent) = path.parent() { diff --git a/node/common/src/service/archive/rpc.rs b/node/common/src/service/archive/rpc.rs index cd31ea593d..ca98fd658e 100644 --- a/node/common/src/service/archive/rpc.rs +++ b/node/common/src/service/archive/rpc.rs @@ -1,11 +1,13 @@ use binprot::BinProtWrite; -use mina_p2p_messages::rpc_kernel::{Message, NeedsLength, Query, RpcMethod}; -use mina_p2p_messages::v2::{self, ArchiveRpc}; -use mio::event::Event; -use mio::net::TcpStream; -use mio::{Events, Interest, Poll, Registry, Token}; -use std::io::{self, Read, Write}; -use std::net::SocketAddr; +use mina_p2p_messages::{ + rpc_kernel::{Message, NeedsLength, Query, RpcMethod}, + v2::{self, ArchiveRpc}, +}; +use mio::{event::Event, net::TcpStream, Events, Interest, Poll, Registry, Token}; +use std::{ + io::{self, Read, Write}, + net::SocketAddr, +}; const MAX_RECURSION_DEPTH: u8 = 25; diff --git a/node/common/src/service/block_producer/vrf_evaluator.rs b/node/common/src/service/block_producer/vrf_evaluator.rs index 11bfa54c72..e31a521032 100644 --- a/node/common/src/service/block_producer/vrf_evaluator.rs +++ b/node/common/src/service/block_producer/vrf_evaluator.rs @@ -1,9 +1,8 @@ use mina_signer::Keypair; use node::{ - block_producer::BlockProducerVrfEvaluatorEvent, block_producer::{ vrf_evaluator::{VrfEvaluationOutputWithHash, VrfEvaluatorInput}, - BlockProducerEvent, + BlockProducerEvent, BlockProducerVrfEvaluatorEvent, }, core::channels::mpsc::{TrackedUnboundedReceiver, UnboundedSender}, event_source::Event, diff --git a/node/common/src/service/event_receiver.rs b/node/common/src/service/event_receiver.rs index 957c9324ba..1e2c17c946 100644 --- a/node/common/src/service/event_receiver.rs +++ b/node/common/src/service/event_receiver.rs @@ -1,5 +1,4 @@ -use node::core::channels::mpsc; -use node::event_source::Event; +use node::{core::channels::mpsc, event_source::Event}; pub type EventSender = mpsc::UnboundedSender; diff --git a/node/common/src/service/rpc/mod.rs b/node/common/src/service/rpc/mod.rs index c4e21f3c41..ec43ef6122 100644 --- a/node/common/src/service/rpc/mod.rs +++ b/node/common/src/service/rpc/mod.rs @@ -21,11 +21,16 @@ use node::rpc::{ }; use serde::{Deserialize, Serialize}; -use node::core::channels::{mpsc, oneshot}; -use node::core::requests::PendingRequests; -use node::p2p::connection::P2pConnectionResponse; -use node::State; -use node::{event_source::Event, rpc::RpcSnarkPoolJobGetResponse}; +use node::{ + core::{ + channels::{mpsc, oneshot}, + requests::PendingRequests, + }, + event_source::Event, + p2p::connection::P2pConnectionResponse, + rpc::RpcSnarkPoolJobGetResponse, + State, +}; pub use node::{ rpc::{ ActionStatsResponse, RpcActionStatsGetResponse, RpcId, RpcIdType, diff --git a/node/common/src/service/rpc/sender.rs b/node/common/src/service/rpc/sender.rs index 14cccf912f..56af0a2481 100644 --- a/node/common/src/service/rpc/sender.rs +++ b/node/common/src/service/rpc/sender.rs @@ -4,16 +4,16 @@ use serde::Serialize; #[cfg(target_family = "wasm")] use wasm_bindgen::prelude::*; -use node::core::channels::{mpsc, oneshot}; -use node::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts; -use node::rpc::*; - -use super::ledger::Ledger; -use super::state::State; -use super::stats::Stats; -use super::transaction_pool::TransactionPool; -use super::transition_frontier::TransitionFrontier; -use super::NodeRpcRequest; +use node::{ + core::channels::{mpsc, oneshot}, + p2p::connection::outgoing::P2pConnectionOutgoingInitOpts, + rpc::*, +}; + +use super::{ + ledger::Ledger, state::State, stats::Stats, transaction_pool::TransactionPool, + transition_frontier::TransitionFrontier, NodeRpcRequest, +}; #[derive(Clone)] #[cfg_attr(target_family = "wasm", wasm_bindgen)] diff --git a/node/common/src/service/snark_worker.rs b/node/common/src/service/snark_worker.rs index 8c408e593f..2f2a3d81b1 100644 --- a/node/common/src/service/snark_worker.rs +++ b/node/common/src/service/snark_worker.rs @@ -1,15 +1,21 @@ -use ledger::proofs::provers::{TransactionProver, ZkappProver}; -use ledger::proofs::zkapp::ZkappParams; -use ledger::scan_state::scan_state::transaction_snark::SokMessage; +use ledger::{ + proofs::{ + provers::{TransactionProver, ZkappProver}, + zkapp::ZkappParams, + }, + scan_state::scan_state::transaction_snark::SokMessage, +}; use mina_p2p_messages::v2; use mina_signer::CompressedPubKey; -use node::core::channels::mpsc; -use node::event_source::ExternalSnarkWorkerEvent; -use node::external_snark_worker::{ - ExternalSnarkWorkerError, ExternalSnarkWorkerWorkError, SnarkWorkResult, SnarkWorkSpec, - SnarkWorkSpecError, +use node::{ + core::channels::mpsc, + event_source::ExternalSnarkWorkerEvent, + external_snark_worker::{ + ExternalSnarkWorkerError, ExternalSnarkWorkerWorkError, SnarkWorkResult, SnarkWorkSpec, + SnarkWorkSpecError, + }, + snark::TransactionVerifier, }; -use node::snark::TransactionVerifier; use crate::NodeService; diff --git a/node/invariants/src/transition_frontier/only_syncs_to_better_blocks.rs b/node/invariants/src/transition_frontier/only_syncs_to_better_blocks.rs index 2d09935ecb..32c3b384c1 100644 --- a/node/invariants/src/transition_frontier/only_syncs_to_better_blocks.rs +++ b/node/invariants/src/transition_frontier/only_syncs_to_better_blocks.rs @@ -1,6 +1,7 @@ -use node::core::block::ArcBlockWithHash; -use node::core::consensus::consensus_take; -use node::{ActionKind, ActionWithMeta, Store}; +use node::{ + core::{block::ArcBlockWithHash, consensus::consensus_take}, + ActionKind, ActionWithMeta, Store, +}; use crate::{Invariant, InvariantResult}; diff --git a/node/native/src/graphql/mod.rs b/node/native/src/graphql/mod.rs index 819bf2d5d6..802436b03a 100644 --- a/node/native/src/graphql/mod.rs +++ b/node/native/src/graphql/mod.rs @@ -7,7 +7,6 @@ use mina_p2p_messages::v2::{ MinaBaseZkappCommandTStableV1WireStableV1, TokenIdKeyHash, TransactionHash, }; use mina_signer::CompressedPubKey; -use node::rpc::RpcSnarkerConfig; use node::{ account::AccountPublicKey, ledger::read::LedgerStatus, @@ -16,8 +15,9 @@ use node::{ RpcGenesisBlockResponse, RpcGetBlockResponse, RpcLedgerAccountDelegatorsGetResponse, RpcLedgerStatusGetResponse, RpcNodeStatus, RpcPooledUserCommandsResponse, RpcPooledZkappCommandsResponse, RpcRequest, RpcSnarkPoolCompletedJobsResponse, - RpcSnarkPoolPendingJobsGetResponse, RpcStatusGetResponse, RpcSyncStatsGetResponse, - RpcTransactionInjectResponse, RpcTransactionStatusGetResponse, SyncStatsQuery, + RpcSnarkPoolPendingJobsGetResponse, RpcSnarkerConfig, RpcStatusGetResponse, + RpcSyncStatsGetResponse, RpcTransactionInjectResponse, RpcTransactionStatusGetResponse, + SyncStatsQuery, }, stats::sync::SyncKind, BuildEnv, diff --git a/node/native/src/graphql/zkapp.rs b/node/native/src/graphql/zkapp.rs index b0e321d741..5ce9a19157 100644 --- a/node/native/src/graphql/zkapp.rs +++ b/node/native/src/graphql/zkapp.rs @@ -2,57 +2,62 @@ use std::str::FromStr; use juniper::{GraphQLInputObject, GraphQLObject}; use ledger::{FpExt, VerificationKey}; -use mina_p2p_messages::bigint::BigInt; -use mina_p2p_messages::list::List; -use mina_p2p_messages::pseq::PaddedSeq; -use mina_p2p_messages::string::{TokenSymbol, ZkAppUri}; -use mina_p2p_messages::v2::{ - CurrencyAmountStableV1, CurrencyBalanceStableV1, CurrencyFeeStableV1, - MinaBaseAccountUpdateAccountPreconditionStableV1, - MinaBaseAccountUpdateAuthorizationKindStableV1, MinaBaseAccountUpdateBodyEventsStableV1, - MinaBaseAccountUpdateBodyFeePayerStableV1, MinaBaseAccountUpdateBodyStableV1, - MinaBaseAccountUpdateFeePayerStableV1, MinaBaseAccountUpdateMayUseTokenStableV1, - MinaBaseAccountUpdatePreconditionsStableV1, MinaBaseAccountUpdateTStableV1, - MinaBaseAccountUpdateUpdateStableV1, MinaBaseAccountUpdateUpdateStableV1AppStateA, - MinaBaseAccountUpdateUpdateStableV1Delegate, MinaBaseAccountUpdateUpdateStableV1Permissions, - MinaBaseAccountUpdateUpdateStableV1Timing, MinaBaseAccountUpdateUpdateStableV1TokenSymbol, - MinaBaseAccountUpdateUpdateStableV1VerificationKey, - MinaBaseAccountUpdateUpdateStableV1VotingFor, MinaBaseAccountUpdateUpdateStableV1ZkappUri, - MinaBaseAccountUpdateUpdateTimingInfoStableV1, MinaBaseControlStableV2, - MinaBasePermissionsStableV2, MinaBaseReceiptChainHashStableV1, - MinaBaseSignedCommandMemoStableV1, MinaBaseUserCommandStableV2, - MinaBaseVerificationKeyWireStableV1, MinaBaseZkappCommandTStableV1WireStableV1, - MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesA, - MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesAA, - MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesAACallsA, - MinaBaseZkappPreconditionAccountStableV2, MinaBaseZkappPreconditionAccountStableV2Balance, - MinaBaseZkappPreconditionAccountStableV2BalanceA, - MinaBaseZkappPreconditionAccountStableV2Delegate, - MinaBaseZkappPreconditionAccountStableV2ProvedState, - MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash, - MinaBaseZkappPreconditionAccountStableV2StateA, - MinaBaseZkappPreconditionProtocolStateEpochDataStableV1, - MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochLedger, - MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed, - MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint, - MinaBaseZkappPreconditionProtocolStateStableV1, - MinaBaseZkappPreconditionProtocolStateStableV1Amount, - MinaBaseZkappPreconditionProtocolStateStableV1AmountA, - MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot, - MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlotA, - MinaBaseZkappPreconditionProtocolStateStableV1Length, - MinaBaseZkappPreconditionProtocolStateStableV1LengthA, - MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash, - MinaNumbersGlobalSlotSinceGenesisMStableV1, MinaNumbersGlobalSlotSpanStableV1, - MinaStateBlockchainStateValueStableV2SignedAmount, PicklesProofProofsVerifiedMaxStableV2, - StateHash, +use mina_p2p_messages::{ + bigint::BigInt, + list::List, + pseq::PaddedSeq, + string::{TokenSymbol, ZkAppUri}, + v2::{ + CurrencyAmountStableV1, CurrencyBalanceStableV1, CurrencyFeeStableV1, + MinaBaseAccountUpdateAccountPreconditionStableV1, + MinaBaseAccountUpdateAuthorizationKindStableV1, MinaBaseAccountUpdateBodyEventsStableV1, + MinaBaseAccountUpdateBodyFeePayerStableV1, MinaBaseAccountUpdateBodyStableV1, + MinaBaseAccountUpdateFeePayerStableV1, MinaBaseAccountUpdateMayUseTokenStableV1, + MinaBaseAccountUpdatePreconditionsStableV1, MinaBaseAccountUpdateTStableV1, + MinaBaseAccountUpdateUpdateStableV1, MinaBaseAccountUpdateUpdateStableV1AppStateA, + MinaBaseAccountUpdateUpdateStableV1Delegate, + MinaBaseAccountUpdateUpdateStableV1Permissions, MinaBaseAccountUpdateUpdateStableV1Timing, + MinaBaseAccountUpdateUpdateStableV1TokenSymbol, + MinaBaseAccountUpdateUpdateStableV1VerificationKey, + MinaBaseAccountUpdateUpdateStableV1VotingFor, MinaBaseAccountUpdateUpdateStableV1ZkappUri, + MinaBaseAccountUpdateUpdateTimingInfoStableV1, MinaBaseControlStableV2, + MinaBasePermissionsStableV2, MinaBaseReceiptChainHashStableV1, + MinaBaseSignedCommandMemoStableV1, MinaBaseUserCommandStableV2, + MinaBaseVerificationKeyWireStableV1, MinaBaseZkappCommandTStableV1WireStableV1, + MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesA, + MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesAA, + MinaBaseZkappCommandTStableV1WireStableV1AccountUpdatesAACallsA, + MinaBaseZkappPreconditionAccountStableV2, MinaBaseZkappPreconditionAccountStableV2Balance, + MinaBaseZkappPreconditionAccountStableV2BalanceA, + MinaBaseZkappPreconditionAccountStableV2Delegate, + MinaBaseZkappPreconditionAccountStableV2ProvedState, + MinaBaseZkappPreconditionAccountStableV2ReceiptChainHash, + MinaBaseZkappPreconditionAccountStableV2StateA, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochLedger, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1EpochSeed, + MinaBaseZkappPreconditionProtocolStateEpochDataStableV1StartCheckpoint, + MinaBaseZkappPreconditionProtocolStateStableV1, + MinaBaseZkappPreconditionProtocolStateStableV1Amount, + MinaBaseZkappPreconditionProtocolStateStableV1AmountA, + MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlot, + MinaBaseZkappPreconditionProtocolStateStableV1GlobalSlotA, + MinaBaseZkappPreconditionProtocolStateStableV1Length, + MinaBaseZkappPreconditionProtocolStateStableV1LengthA, + MinaBaseZkappPreconditionProtocolStateStableV1SnarkedLedgerHash, + MinaNumbersGlobalSlotSinceGenesisMStableV1, MinaNumbersGlobalSlotSpanStableV1, + MinaStateBlockchainStateValueStableV2SignedAmount, PicklesProofProofsVerifiedMaxStableV2, + StateHash, + }, }; use node::account::AccountPublicKey; use serde::Deserialize; -use super::account::{GraphQLTiming, InputGraphQLTiming}; -use super::ConversionError; +use super::{ + account::{GraphQLTiming, InputGraphQLTiming}, + ConversionError, +}; #[derive(GraphQLInputObject, Debug)] pub struct SendZkappInput { diff --git a/node/native/src/http_server.rs b/node/native/src/http_server.rs index c2daf04323..2473e8a5dc 100644 --- a/node/native/src/http_server.rs +++ b/node/native/src/http_server.rs @@ -9,8 +9,7 @@ use warp::{ Filter, Rejection, Reply, }; -use node::core::snark::SnarkJobId; -use node::rpc::*; +use node::{core::snark::SnarkJobId, rpc::*}; use openmina_node_common::rpc::{ RpcActionStatsGetResponse, RpcSender, RpcSnarkPoolGetResponse, RpcSnarkerJobCommitResponse, @@ -737,8 +736,10 @@ async fn recover(rejection: warp::Rejection) -> Result() -> BoxedFilter<(T,)> { warp::any() diff --git a/node/src/action.rs b/node/src/action.rs index fd85ea8138..651979ba50 100644 --- a/node/src/action.rs +++ b/node/src/action.rs @@ -4,24 +4,25 @@ use serde::{Deserialize, Serialize}; pub type ActionWithMeta = redux::ActionWithMeta; pub type ActionWithMetaRef<'a> = redux::ActionWithMeta<&'a Action>; -pub use crate::block_producer::BlockProducerAction; -pub use crate::block_producer_effectful::BlockProducerEffectfulAction; -pub use crate::event_source::EventSourceAction; -pub use crate::external_snark_worker::ExternalSnarkWorkerAction; -use crate::external_snark_worker_effectful::ExternalSnarkWorkerEffectfulAction; -pub use crate::ledger::LedgerAction; -use crate::ledger_effectful::LedgerEffectfulAction; -use crate::p2p::callbacks::P2pCallbacksAction; -pub use crate::p2p::P2pAction; -pub use crate::rpc::RpcAction; -use crate::rpc_effectful::RpcEffectfulAction; -pub use crate::snark::SnarkAction; -pub use crate::snark_pool::SnarkPoolAction; -pub use crate::snark_pool::SnarkPoolEffectfulAction; -pub use crate::transaction_pool::TransactionPoolAction; -use crate::transaction_pool::TransactionPoolEffectfulAction; -pub use crate::transition_frontier::TransitionFrontierAction; -pub use crate::watched_accounts::WatchedAccountsAction; +pub use crate::{ + block_producer::BlockProducerAction, + block_producer_effectful::BlockProducerEffectfulAction, + event_source::EventSourceAction, + external_snark_worker::ExternalSnarkWorkerAction, + ledger::LedgerAction, + p2p::P2pAction, + rpc::RpcAction, + snark::SnarkAction, + snark_pool::{SnarkPoolAction, SnarkPoolEffectfulAction}, + transaction_pool::TransactionPoolAction, + transition_frontier::TransitionFrontierAction, + watched_accounts::WatchedAccountsAction, +}; +use crate::{ + external_snark_worker_effectful::ExternalSnarkWorkerEffectfulAction, + ledger_effectful::LedgerEffectfulAction, p2p::callbacks::P2pCallbacksAction, + rpc_effectful::RpcEffectfulAction, transaction_pool::TransactionPoolEffectfulAction, +}; pub trait ActionKindGet { fn kind(&self) -> crate::ActionKind; diff --git a/node/src/action_kind.rs b/node/src/action_kind.rs index d01e8d4ccf..7ad8b77696 100644 --- a/node/src/action_kind.rs +++ b/node/src/action_kind.rs @@ -15,81 +15,100 @@ use num_enum::TryFromPrimitive; use serde::{Deserialize, Serialize}; use strum_macros::VariantArray; -use crate::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorAction; -use crate::block_producer::BlockProducerAction; -use crate::block_producer_effectful::vrf_evaluator_effectful::BlockProducerVrfEvaluatorEffectfulAction; -use crate::block_producer_effectful::BlockProducerEffectfulAction; -use crate::event_source::EventSourceAction; -use crate::external_snark_worker::ExternalSnarkWorkerAction; -use crate::external_snark_worker_effectful::ExternalSnarkWorkerEffectfulAction; -use crate::ledger::read::LedgerReadAction; -use crate::ledger::write::LedgerWriteAction; -use crate::ledger::LedgerAction; -use crate::ledger_effectful::LedgerEffectfulAction; -use crate::p2p::callbacks::P2pCallbacksAction; -use crate::p2p::channels::best_tip::P2pChannelsBestTipAction; -use crate::p2p::channels::rpc::P2pChannelsRpcAction; -use crate::p2p::channels::signaling::discovery::P2pChannelsSignalingDiscoveryAction; -use crate::p2p::channels::signaling::exchange::P2pChannelsSignalingExchangeAction; -use crate::p2p::channels::snark::P2pChannelsSnarkAction; -use crate::p2p::channels::snark_job_commitment::P2pChannelsSnarkJobCommitmentAction; -use crate::p2p::channels::streaming_rpc::P2pChannelsStreamingRpcAction; -use crate::p2p::channels::transaction::P2pChannelsTransactionAction; -use crate::p2p::channels::{ - P2pChannelsAction, P2pChannelsEffectfulAction, P2pChannelsMessageReceivedAction, +use crate::{ + block_producer::{vrf_evaluator::BlockProducerVrfEvaluatorAction, BlockProducerAction}, + block_producer_effectful::{ + vrf_evaluator_effectful::BlockProducerVrfEvaluatorEffectfulAction, + BlockProducerEffectfulAction, + }, + event_source::EventSourceAction, + external_snark_worker::ExternalSnarkWorkerAction, + external_snark_worker_effectful::ExternalSnarkWorkerEffectfulAction, + ledger::{read::LedgerReadAction, write::LedgerWriteAction, LedgerAction}, + ledger_effectful::LedgerEffectfulAction, + p2p::{ + callbacks::P2pCallbacksAction, + channels::{ + best_tip::P2pChannelsBestTipAction, + rpc::P2pChannelsRpcAction, + signaling::{ + discovery::P2pChannelsSignalingDiscoveryAction, + exchange::P2pChannelsSignalingExchangeAction, + }, + snark::P2pChannelsSnarkAction, + snark_job_commitment::P2pChannelsSnarkJobCommitmentAction, + streaming_rpc::P2pChannelsStreamingRpcAction, + transaction::P2pChannelsTransactionAction, + P2pChannelsAction, P2pChannelsEffectfulAction, P2pChannelsMessageReceivedAction, + }, + connection::{ + incoming::P2pConnectionIncomingAction, + incoming_effectful::P2pConnectionIncomingEffectfulAction, + outgoing::P2pConnectionOutgoingAction, + outgoing_effectful::P2pConnectionOutgoingEffectfulAction, P2pConnectionAction, + P2pConnectionEffectfulAction, + }, + disconnection::P2pDisconnectionAction, + disconnection_effectful::P2pDisconnectionEffectfulAction, + identify::P2pIdentifyAction, + network::{ + identify::{ + stream::P2pNetworkIdentifyStreamAction, + stream_effectful::P2pNetworkIdentifyStreamEffectfulAction, + P2pNetworkIdentifyAction, P2pNetworkIdentifyEffectfulAction, + }, + kad::{ + bootstrap::P2pNetworkKadBootstrapAction, + kad_effectful::P2pNetworkKadEffectfulAction, request::P2pNetworkKadRequestAction, + stream::P2pNetworkKademliaStreamAction, P2pNetworkKadAction, + P2pNetworkKademliaAction, + }, + noise::P2pNetworkNoiseAction, + pnet::P2pNetworkPnetAction, + pnet_effectful::P2pNetworkPnetEffectfulAction, + pubsub::{pubsub_effectful::P2pNetworkPubsubEffectfulAction, P2pNetworkPubsubAction}, + rpc::P2pNetworkRpcAction, + scheduler::P2pNetworkSchedulerAction, + scheduler_effectful::P2pNetworkSchedulerEffectfulAction, + select::P2pNetworkSelectAction, + yamux::P2pNetworkYamuxAction, + P2pNetworkAction, P2pNetworkEffectfulAction, + }, + peer::P2pPeerAction, + P2pAction, P2pEffectfulAction, P2pInitializeAction, + }, + rpc::RpcAction, + rpc_effectful::RpcEffectfulAction, + snark::{ + block_verify::SnarkBlockVerifyAction, + block_verify_effectful::SnarkBlockVerifyEffectfulAction, + user_command_verify::SnarkUserCommandVerifyAction, + user_command_verify_effectful::SnarkUserCommandVerifyEffectfulAction, + work_verify::SnarkWorkVerifyAction, work_verify_effectful::SnarkWorkVerifyEffectfulAction, + SnarkAction, + }, + snark_pool::{candidate::SnarkPoolCandidateAction, SnarkPoolAction, SnarkPoolEffectfulAction}, + transaction_pool::{ + candidate::TransactionPoolCandidateAction, TransactionPoolAction, + TransactionPoolEffectfulAction, + }, + transition_frontier::{ + candidate::TransitionFrontierCandidateAction, + genesis::TransitionFrontierGenesisAction, + genesis_effectful::TransitionFrontierGenesisEffectfulAction, + sync::{ + ledger::{ + snarked::TransitionFrontierSyncLedgerSnarkedAction, + staged::TransitionFrontierSyncLedgerStagedAction, + TransitionFrontierSyncLedgerAction, + }, + TransitionFrontierSyncAction, + }, + TransitionFrontierAction, + }, + watched_accounts::WatchedAccountsAction, + Action, ActionKindGet, CheckTimeoutsAction, }; -use crate::p2p::connection::incoming::P2pConnectionIncomingAction; -use crate::p2p::connection::incoming_effectful::P2pConnectionIncomingEffectfulAction; -use crate::p2p::connection::outgoing::P2pConnectionOutgoingAction; -use crate::p2p::connection::outgoing_effectful::P2pConnectionOutgoingEffectfulAction; -use crate::p2p::connection::{P2pConnectionAction, P2pConnectionEffectfulAction}; -use crate::p2p::disconnection::P2pDisconnectionAction; -use crate::p2p::disconnection_effectful::P2pDisconnectionEffectfulAction; -use crate::p2p::identify::P2pIdentifyAction; -use crate::p2p::network::identify::stream::P2pNetworkIdentifyStreamAction; -use crate::p2p::network::identify::stream_effectful::P2pNetworkIdentifyStreamEffectfulAction; -use crate::p2p::network::identify::{P2pNetworkIdentifyAction, P2pNetworkIdentifyEffectfulAction}; -use crate::p2p::network::kad::bootstrap::P2pNetworkKadBootstrapAction; -use crate::p2p::network::kad::kad_effectful::P2pNetworkKadEffectfulAction; -use crate::p2p::network::kad::request::P2pNetworkKadRequestAction; -use crate::p2p::network::kad::stream::P2pNetworkKademliaStreamAction; -use crate::p2p::network::kad::{P2pNetworkKadAction, P2pNetworkKademliaAction}; -use crate::p2p::network::noise::P2pNetworkNoiseAction; -use crate::p2p::network::pnet::P2pNetworkPnetAction; -use crate::p2p::network::pnet_effectful::P2pNetworkPnetEffectfulAction; -use crate::p2p::network::pubsub::pubsub_effectful::P2pNetworkPubsubEffectfulAction; -use crate::p2p::network::pubsub::P2pNetworkPubsubAction; -use crate::p2p::network::rpc::P2pNetworkRpcAction; -use crate::p2p::network::scheduler::P2pNetworkSchedulerAction; -use crate::p2p::network::scheduler_effectful::P2pNetworkSchedulerEffectfulAction; -use crate::p2p::network::select::P2pNetworkSelectAction; -use crate::p2p::network::yamux::P2pNetworkYamuxAction; -use crate::p2p::network::{P2pNetworkAction, P2pNetworkEffectfulAction}; -use crate::p2p::peer::P2pPeerAction; -use crate::p2p::{P2pAction, P2pEffectfulAction, P2pInitializeAction}; -use crate::rpc::RpcAction; -use crate::rpc_effectful::RpcEffectfulAction; -use crate::snark::block_verify::SnarkBlockVerifyAction; -use crate::snark::block_verify_effectful::SnarkBlockVerifyEffectfulAction; -use crate::snark::user_command_verify::SnarkUserCommandVerifyAction; -use crate::snark::user_command_verify_effectful::SnarkUserCommandVerifyEffectfulAction; -use crate::snark::work_verify::SnarkWorkVerifyAction; -use crate::snark::work_verify_effectful::SnarkWorkVerifyEffectfulAction; -use crate::snark::SnarkAction; -use crate::snark_pool::candidate::SnarkPoolCandidateAction; -use crate::snark_pool::{SnarkPoolAction, SnarkPoolEffectfulAction}; -use crate::transaction_pool::candidate::TransactionPoolCandidateAction; -use crate::transaction_pool::{TransactionPoolAction, TransactionPoolEffectfulAction}; -use crate::transition_frontier::candidate::TransitionFrontierCandidateAction; -use crate::transition_frontier::genesis::TransitionFrontierGenesisAction; -use crate::transition_frontier::genesis_effectful::TransitionFrontierGenesisEffectfulAction; -use crate::transition_frontier::sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedAction; -use crate::transition_frontier::sync::ledger::staged::TransitionFrontierSyncLedgerStagedAction; -use crate::transition_frontier::sync::ledger::TransitionFrontierSyncLedgerAction; -use crate::transition_frontier::sync::TransitionFrontierSyncAction; -use crate::transition_frontier::TransitionFrontierAction; -use crate::watched_accounts::WatchedAccountsAction; -use crate::{Action, ActionKindGet, CheckTimeoutsAction}; /// Unified kind enum for all action types #[derive( diff --git a/node/src/block_producer/block_producer_actions.rs b/node/src/block_producer/block_producer_actions.rs index e1b14e9d80..cca3491bdc 100644 --- a/node/src/block_producer/block_producer_actions.rs +++ b/node/src/block_producer/block_producer_actions.rs @@ -2,14 +2,15 @@ use std::sync::Arc; use ledger::scan_state::transaction_logic::valid; use mina_p2p_messages::v2::MinaBaseProofStableV2; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::ActionEvent; +use openmina_core::{block::ArcBlockWithHash, ActionEvent}; use serde::{Deserialize, Serialize}; use crate::block_producer_effectful::StagedLedgerDiffCreateOutput; -use super::vrf_evaluator::BlockProducerVrfEvaluatorAction; -use super::{BlockProducerCurrentState, BlockProducerWonSlot, BlockProducerWonSlotDiscardReason}; +use super::{ + vrf_evaluator::BlockProducerVrfEvaluatorAction, BlockProducerCurrentState, + BlockProducerWonSlot, BlockProducerWonSlotDiscardReason, +}; pub type BlockProducerActionWithMeta = redux::ActionWithMeta; pub type BlockProducerActionWithMetaRef<'a> = redux::ActionWithMeta<&'a BlockProducerAction>; diff --git a/node/src/block_producer/block_producer_reducer.rs b/node/src/block_producer/block_producer_reducer.rs index a00ccb6d1e..0746399914 100644 --- a/node/src/block_producer/block_producer_reducer.rs +++ b/node/src/block_producer/block_producer_reducer.rs @@ -1,13 +1,13 @@ use ledger::scan_state::currency::{Amount, Signed}; use mina_p2p_messages::{list::List, v2}; use openmina_core::{ - block::ArcBlockWithHash, consensus::ConsensusConstants, constants::constraint_constants, -}; -use openmina_core::{ + block::ArcBlockWithHash, bug_condition, consensus::{ global_sub_window, in_same_checkpoint_window, in_seed_update_range, relative_sub_window, + ConsensusConstants, }, + constants::constraint_constants, }; use p2p::P2pNetworkPubsubAction; use redux::{callback, Dispatcher, Timestamp}; diff --git a/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_actions.rs b/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_actions.rs index 94fbf40997..52116aa15a 100644 --- a/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_actions.rs +++ b/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_actions.rs @@ -1,23 +1,18 @@ use std::sync::Arc; -use crate::account::AccountPublicKey; -use crate::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorStatus; -use crate::block_producer::vrf_evaluator::EpochContext; +use crate::{ + account::AccountPublicKey, + block_producer::vrf_evaluator::{BlockProducerVrfEvaluatorStatus, EpochContext}, +}; use mina_p2p_messages::v2::{ ConsensusProofOfStakeDataEpochDataNextValueVersionedValueStableV1, ConsensusProofOfStakeDataEpochDataStakingValueVersionedValueStableV1, LedgerHash, }; -use openmina_core::action_info; -use openmina_core::action_trace; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::ActionEvent; +use openmina_core::{action_info, action_trace, block::ArcBlockWithHash, ActionEvent}; use serde::{Deserialize, Serialize}; -use vrf::VrfEvaluationOutput; -use vrf::VrfWonSlot; +use vrf::{VrfEvaluationOutput, VrfWonSlot}; -use super::DelegatorTable; -use super::InterruptReason; -use super::{EpochData, VrfEvaluatorInput}; +use super::{DelegatorTable, EpochData, InterruptReason, VrfEvaluatorInput}; pub type BlockProducerVrfEvaluatorActionWithMeta = redux::ActionWithMeta; diff --git a/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_state.rs b/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_state.rs index 69b4d51000..604a522fdd 100644 --- a/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_state.rs +++ b/node/src/block_producer/vrf_evaluator/block_producer_vrf_evaluator_state.rs @@ -1,5 +1,4 @@ -use std::collections::BTreeMap; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; use mina_p2p_messages::v2; use openmina_core::block::ArcBlockWithHash; diff --git a/node/src/block_producer/vrf_evaluator/mod.rs b/node/src/block_producer/vrf_evaluator/mod.rs index 0cfe2e0014..8f5dcfa63e 100644 --- a/node/src/block_producer/vrf_evaluator/mod.rs +++ b/node/src/block_producer/vrf_evaluator/mod.rs @@ -9,8 +9,7 @@ pub use block_producer_vrf_evaluator_actions::*; mod block_producer_vrf_evaluator_reducer; -use std::collections::BTreeMap; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; use ledger::AccountIndex; use mina_p2p_messages::v2::{EpochSeed, LedgerHash}; diff --git a/node/src/block_producer_effectful/vrf_evaluator_effectful/block_producer_vrf_evaluator_effectful_effects.rs b/node/src/block_producer_effectful/vrf_evaluator_effectful/block_producer_vrf_evaluator_effectful_effects.rs index 4f11f33b2f..27fa97c759 100644 --- a/node/src/block_producer_effectful/vrf_evaluator_effectful/block_producer_vrf_evaluator_effectful_effects.rs +++ b/node/src/block_producer_effectful/vrf_evaluator_effectful/block_producer_vrf_evaluator_effectful_effects.rs @@ -1,5 +1,4 @@ -use crate::Service; -use crate::Store; +use crate::{Service, Store}; use redux::ActionMeta; use super::BlockProducerVrfEvaluatorEffectfulAction; diff --git a/node/src/config.rs b/node/src/config.rs index 2dd3713d15..f96ed12281 100644 --- a/node/src/config.rs +++ b/node/src/config.rs @@ -1,19 +1,17 @@ -use std::str::FromStr; -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; use mina_p2p_messages::v2::CurrencyFeeStableV1; use openmina_core::consensus::ConsensusConstants; use serde::{Deserialize, Serialize}; -use crate::account::AccountPublicKey; -pub use crate::block_producer::BlockProducerConfig; -pub use crate::ledger::LedgerConfig; -pub use crate::p2p::P2pConfig; -pub use crate::snark::SnarkConfig; -pub use crate::snark_pool::SnarkPoolConfig; -use crate::transition_frontier::archive::archive_config::ArchiveConfig; -use crate::transition_frontier::genesis::GenesisConfig; -pub use crate::transition_frontier::TransitionFrontierConfig; +use crate::{ + account::AccountPublicKey, + transition_frontier::{archive::archive_config::ArchiveConfig, genesis::GenesisConfig}, +}; +pub use crate::{ + block_producer::BlockProducerConfig, ledger::LedgerConfig, p2p::P2pConfig, snark::SnarkConfig, + snark_pool::SnarkPoolConfig, transition_frontier::TransitionFrontierConfig, +}; pub use mina_p2p_messages::v2::MinaBaseProtocolConstantsCheckedValueStableV1 as ProtocolConstants; // TODO(binier): maybe make sure config is immutable. diff --git a/node/src/daemon_json/json_genesis.rs b/node/src/daemon_json/json_genesis.rs index 08ff44b9f0..64975169da 100644 --- a/node/src/daemon_json/json_genesis.rs +++ b/node/src/daemon_json/json_genesis.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; -use time::format_description::well_known::Rfc3339; -use time::OffsetDateTime; +use time::{format_description::well_known::Rfc3339, OffsetDateTime}; use mina_p2p_messages::v2::{ BlockTimeTimeStableV1, MinaBaseProtocolConstantsCheckedValueStableV1, diff --git a/node/src/effects.rs b/node/src/effects.rs index 2939bc6d1a..69eec2e4aa 100644 --- a/node/src/effects.rs +++ b/node/src/effects.rs @@ -1,24 +1,22 @@ use openmina_core::log::system_time; use rand::prelude::*; -use crate::block_producer::BlockProducerAction; -use crate::block_producer_effectful::block_producer_effects; -use crate::event_source::event_source_effects; -use crate::external_snark_worker_effectful::external_snark_worker_effectful_effects; -use crate::ledger::read::LedgerReadAction; -use crate::ledger_effectful::ledger_effectful_effects; -use crate::logger::logger_effects; -use crate::p2p::node_p2p_effects; -use crate::rpc_effectful::rpc_effects; -use crate::snark::snark_effects; -use crate::snark_pool::candidate::SnarkPoolCandidateAction; -use crate::snark_pool::{snark_pool_effects, SnarkPoolAction}; -use crate::transaction_pool::candidate::TransactionPoolCandidateAction; -use crate::transition_frontier::genesis::TransitionFrontierGenesisAction; -use crate::transition_frontier::transition_frontier_effects; use crate::{ - p2p_ready, Action, ActionWithMeta, ExternalSnarkWorkerAction, Service, Store, - TransactionPoolAction, + block_producer::BlockProducerAction, + block_producer_effectful::block_producer_effects, + event_source::event_source_effects, + external_snark_worker_effectful::external_snark_worker_effectful_effects, + ledger::read::LedgerReadAction, + ledger_effectful::ledger_effectful_effects, + logger::logger_effects, + p2p::node_p2p_effects, + p2p_ready, + rpc_effectful::rpc_effects, + snark::snark_effects, + snark_pool::{candidate::SnarkPoolCandidateAction, snark_pool_effects, SnarkPoolAction}, + transaction_pool::candidate::TransactionPoolCandidateAction, + transition_frontier::{genesis::TransitionFrontierGenesisAction, transition_frontier_effects}, + Action, ActionWithMeta, ExternalSnarkWorkerAction, Service, Store, TransactionPoolAction, }; use crate::p2p::channels::rpc::{P2pChannelsRpcAction, P2pRpcRequest}; diff --git a/node/src/event_source/event.rs b/node/src/event_source/event.rs index c0c9001ea3..12f997106c 100644 --- a/node/src/event_source/event.rs +++ b/node/src/event_source/event.rs @@ -1,11 +1,13 @@ use serde::{Deserialize, Serialize}; -pub use crate::block_producer::BlockProducerEvent; -pub use crate::external_snark_worker_effectful::ExternalSnarkWorkerEvent; -pub use crate::ledger::LedgerEvent; -pub use crate::p2p::{P2pConnectionEvent, P2pEvent}; -pub use crate::rpc::{RpcId, RpcRequest}; -pub use crate::snark::SnarkEvent; +pub use crate::{ + block_producer::BlockProducerEvent, + external_snark_worker_effectful::ExternalSnarkWorkerEvent, + ledger::LedgerEvent, + p2p::{P2pConnectionEvent, P2pEvent}, + rpc::{RpcId, RpcRequest}, + snark::SnarkEvent, +}; use crate::transition_frontier::genesis::GenesisConfigLoaded; diff --git a/node/src/event_source/event_source_effects.rs b/node/src/event_source/event_source_effects.rs index d9d54a0e4a..b99d31343d 100644 --- a/node/src/event_source/event_source_effects.rs +++ b/node/src/event_source/event_source_effects.rs @@ -1,33 +1,42 @@ -use p2p::channels::signaling::discovery::P2pChannelsSignalingDiscoveryAction; -use p2p::channels::signaling::exchange::P2pChannelsSignalingExchangeAction; -use p2p::channels::snark::P2pChannelsSnarkAction; -use p2p::channels::streaming_rpc::P2pChannelsStreamingRpcAction; -use p2p::channels::transaction::P2pChannelsTransactionAction; +use p2p::channels::{ + signaling::{ + discovery::P2pChannelsSignalingDiscoveryAction, + exchange::P2pChannelsSignalingExchangeAction, + }, + snark::P2pChannelsSnarkAction, + streaming_rpc::P2pChannelsStreamingRpcAction, + transaction::P2pChannelsTransactionAction, +}; use snark::user_command_verify::{SnarkUserCommandVerifyAction, SnarkUserCommandVerifyError}; -use crate::action::CheckTimeoutsAction; -use crate::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorAction; -use crate::block_producer::{BlockProducerEvent, BlockProducerVrfEvaluatorEvent}; -use crate::external_snark_worker_effectful::ExternalSnarkWorkerEvent; -use crate::ledger::read::LedgerReadAction; -use crate::ledger::write::LedgerWriteAction; -use crate::p2p::channels::best_tip::P2pChannelsBestTipAction; -use crate::p2p::channels::rpc::P2pChannelsRpcAction; -use crate::p2p::channels::snark_job_commitment::P2pChannelsSnarkJobCommitmentAction; -use crate::p2p::channels::{ChannelId, P2pChannelsMessageReceivedAction}; -use crate::p2p::connection::incoming::P2pConnectionIncomingAction; -use crate::p2p::connection::outgoing::P2pConnectionOutgoingAction; -use crate::p2p::connection::{P2pConnectionErrorResponse, P2pConnectionResponse}; -use crate::p2p::disconnection::{P2pDisconnectionAction, P2pDisconnectionReason}; -use crate::p2p::P2pChannelEvent; #[cfg(feature = "p2p-libp2p")] use crate::p2p::{MioEvent, P2pNetworkSchedulerAction}; -use crate::rpc::{RpcAction, RpcRequest}; -use crate::snark::block_verify::SnarkBlockVerifyAction; -use crate::snark::work_verify::SnarkWorkVerifyAction; -use crate::snark::SnarkEvent; -use crate::transition_frontier::genesis::TransitionFrontierGenesisAction; -use crate::{BlockProducerAction, ExternalSnarkWorkerAction, Service, Store}; +use crate::{ + action::CheckTimeoutsAction, + block_producer::{ + vrf_evaluator::BlockProducerVrfEvaluatorAction, BlockProducerEvent, + BlockProducerVrfEvaluatorEvent, + }, + external_snark_worker_effectful::ExternalSnarkWorkerEvent, + ledger::{read::LedgerReadAction, write::LedgerWriteAction}, + p2p::{ + channels::{ + best_tip::P2pChannelsBestTipAction, rpc::P2pChannelsRpcAction, + snark_job_commitment::P2pChannelsSnarkJobCommitmentAction, ChannelId, + P2pChannelsMessageReceivedAction, + }, + connection::{ + incoming::P2pConnectionIncomingAction, outgoing::P2pConnectionOutgoingAction, + P2pConnectionErrorResponse, P2pConnectionResponse, + }, + disconnection::{P2pDisconnectionAction, P2pDisconnectionReason}, + P2pChannelEvent, + }, + rpc::{RpcAction, RpcRequest}, + snark::{block_verify::SnarkBlockVerifyAction, work_verify::SnarkWorkVerifyAction, SnarkEvent}, + transition_frontier::genesis::TransitionFrontierGenesisAction, + BlockProducerAction, ExternalSnarkWorkerAction, Service, Store, +}; use super::{ Event, EventSourceAction, EventSourceActionWithMeta, LedgerEvent, P2pConnectionEvent, P2pEvent, diff --git a/node/src/ledger/mod.rs b/node/src/ledger/mod.rs index d30ba68896..aa2f7fc67f 100644 --- a/node/src/ledger/mod.rs +++ b/node/src/ledger/mod.rs @@ -21,8 +21,7 @@ pub use ledger_service::*; pub mod ledger_manager; -pub use ledger::AccountIndex as LedgerAccountIndex; -pub use ledger::Address as LedgerAddress; +pub use ledger::{AccountIndex as LedgerAccountIndex, Address as LedgerAddress}; pub use ledger_manager::LedgerManager; use ledger::TreeVersion; diff --git a/node/src/ledger/read/mod.rs b/node/src/ledger/read/mod.rs index f892fbd7b8..0b39ffab8d 100644 --- a/node/src/ledger/read/mod.rs +++ b/node/src/ledger/read/mod.rs @@ -4,25 +4,27 @@ pub use ledger_read_actions::*; mod ledger_read_state; pub use ledger_read_state::*; -use openmina_core::block::AppliedBlock; -use openmina_core::requests::{RequestId, RpcId, RpcIdType}; -use p2p::channels::rpc::P2pRpcId; -use p2p::PeerId; +use openmina_core::{ + block::AppliedBlock, + requests::{RequestId, RpcId, RpcIdType}, +}; +use p2p::{channels::rpc::P2pRpcId, PeerId}; use redux::Callback; mod ledger_read_reducer; -use std::collections::BTreeMap; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; use mina_p2p_messages::v2; use serde::{Deserialize, Serialize}; -use crate::account::AccountPublicKey; -use crate::block_producer::vrf_evaluator::DelegatorTable; -use crate::ledger::LedgerAddress; -use crate::p2p::channels::rpc::StagedLedgerAuxAndPendingCoinbases; -use crate::rpc::{AccountQuery, RpcScanStateSummaryScanStateJob}; +use crate::{ + account::AccountPublicKey, + block_producer::vrf_evaluator::DelegatorTable, + ledger::LedgerAddress, + p2p::channels::rpc::StagedLedgerAuxAndPendingCoinbases, + rpc::{AccountQuery, RpcScanStateSummaryScanStateJob}, +}; #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone, Copy)] pub enum LedgerReadKind { diff --git a/node/src/ledger/write/mod.rs b/node/src/ledger/write/mod.rs index 192c817c95..f69ce1708d 100644 --- a/node/src/ledger/write/mod.rs +++ b/node/src/ledger/write/mod.rs @@ -1,6 +1,5 @@ mod ledger_write_actions; -use ledger::scan_state::transaction_logic::valid; -use ledger::{Account, AccountId, AccountIndex, TokenId}; +use ledger::{scan_state::transaction_logic::valid, Account, AccountId, AccountIndex, TokenId}; pub use ledger_write_actions::*; mod ledger_write_state; @@ -9,19 +8,26 @@ use openmina_core::block::AppliedBlock; mod ledger_write_reducer; -use std::collections::{BTreeMap, BTreeSet}; -use std::sync::Arc; +use std::{ + collections::{BTreeMap, BTreeSet}, + sync::Arc, +}; -use ledger::scan_state::scan_state::transaction_snark::OneOrTwo; -use ledger::scan_state::scan_state::AvailableJobMessage; +use ledger::scan_state::scan_state::{transaction_snark::OneOrTwo, AvailableJobMessage}; use mina_p2p_messages::v2::{self, StateBodyHash}; use serde::{Deserialize, Serialize}; -use crate::block_producer_effectful::StagedLedgerDiffCreateOutput; -use crate::core::block::ArcBlockWithHash; -use crate::core::snark::{Snark, SnarkJobId}; -use crate::transition_frontier::sync::ledger::staged::StagedLedgerAuxAndPendingCoinbasesValid; -use crate::transition_frontier::sync::TransitionFrontierRootSnarkedLedgerUpdates; +use crate::{ + block_producer_effectful::StagedLedgerDiffCreateOutput, + core::{ + block::ArcBlockWithHash, + snark::{Snark, SnarkJobId}, + }, + transition_frontier::sync::{ + ledger::staged::StagedLedgerAuxAndPendingCoinbasesValid, + TransitionFrontierRootSnarkedLedgerUpdates, + }, +}; #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone, Copy)] pub enum LedgerWriteKind { diff --git a/node/src/logger/logger_effects.rs b/node/src/logger/logger_effects.rs index 51078446a1..99dfc05ea8 100644 --- a/node/src/logger/logger_effects.rs +++ b/node/src/logger/logger_effects.rs @@ -1,16 +1,22 @@ -use openmina_core::log::inner::field::{display, DisplayValue}; -use openmina_core::log::inner::Value; -use openmina_core::log::{time_to_str, ActionEvent, EventContext}; -use p2p::connection::P2pConnectionEffectfulAction; -use p2p::{P2pNetworkConnectionError, P2pNetworkSchedulerAction, PeerId}; +use openmina_core::log::{ + inner::{ + field::{display, DisplayValue}, + Value, + }, + time_to_str, ActionEvent, EventContext, +}; +use p2p::{ + connection::P2pConnectionEffectfulAction, P2pNetworkConnectionError, P2pNetworkSchedulerAction, + PeerId, +}; -use crate::p2p::channels::P2pChannelsAction; -use crate::p2p::connection::P2pConnectionAction; -use crate::p2p::network::P2pNetworkAction; -use crate::p2p::P2pAction; -use crate::snark::SnarkAction; -use crate::transition_frontier::candidate::TransitionFrontierCandidateAction; use crate::{ + p2p::{ + channels::P2pChannelsAction, connection::P2pConnectionAction, network::P2pNetworkAction, + P2pAction, + }, + snark::SnarkAction, + transition_frontier::candidate::TransitionFrontierCandidateAction, Action, ActionWithMetaRef, BlockProducerAction, Service, Store, TransitionFrontierAction, }; diff --git a/node/src/p2p/callbacks/p2p_callbacks_reducer.rs b/node/src/p2p/callbacks/p2p_callbacks_reducer.rs index 87f7e5412f..c0093b33dc 100644 --- a/node/src/p2p/callbacks/p2p_callbacks_reducer.rs +++ b/node/src/p2p/callbacks/p2p_callbacks_reducer.rs @@ -23,16 +23,20 @@ use crate::{ p2p_ready, snark_pool::candidate::SnarkPoolCandidateAction, transaction_pool::candidate::TransactionPoolCandidateAction, - transition_frontier::candidate::{allow_block_too_late, TransitionFrontierCandidateAction}, - transition_frontier::sync::{ - ledger::{ - snarked::{ - PeerLedgerQueryError, PeerLedgerQueryResponse, - TransitionFrontierSyncLedgerSnarkedAction, + transition_frontier::{ + candidate::{allow_block_too_late, TransitionFrontierCandidateAction}, + sync::{ + ledger::{ + snarked::{ + PeerLedgerQueryError, PeerLedgerQueryResponse, + TransitionFrontierSyncLedgerSnarkedAction, + }, + staged::{ + PeerStagedLedgerPartsFetchError, TransitionFrontierSyncLedgerStagedAction, + }, }, - staged::{PeerStagedLedgerPartsFetchError, TransitionFrontierSyncLedgerStagedAction}, + PeerBlockFetchError, TransitionFrontierSyncAction, }, - PeerBlockFetchError, TransitionFrontierSyncAction, }, watched_accounts::{ WatchedAccountLedgerInitialState, WatchedAccountsLedgerInitialStateGetError, diff --git a/node/src/recorder/mod.rs b/node/src/recorder/mod.rs index b586927fcc..45ff47d63a 100644 --- a/node/src/recorder/mod.rs +++ b/node/src/recorder/mod.rs @@ -13,8 +13,7 @@ use std::{ use serde::{Deserialize, Serialize}; -use crate::p2p::identity::SecretKey as P2pSecretKey; -use crate::{Action, ActionKind, ActionWithMeta, State}; +use crate::{p2p::identity::SecretKey as P2pSecretKey, Action, ActionKind, ActionWithMeta, State}; fn initial_state_path>(path: P) -> PathBuf { path.as_ref().join("initial_state.postcard") diff --git a/node/src/recorder/recorder.rs b/node/src/recorder/recorder.rs index b9895fb6a6..fb846b5f0b 100644 --- a/node/src/recorder/recorder.rs +++ b/node/src/recorder/recorder.rs @@ -1,11 +1,14 @@ -use std::borrow::Cow; -use std::fs; -use std::io::{BufWriter, Write}; -use std::path::{Path, PathBuf}; -use std::sync::{Mutex, TryLockError}; - -use crate::p2p::identity::SecretKey as P2pSecretKey; -use crate::{Action, ActionWithMeta, EventSourceAction, State}; +use std::{ + borrow::Cow, + fs, + io::{BufWriter, Write}, + path::{Path, PathBuf}, + sync::{Mutex, TryLockError}, +}; + +use crate::{ + p2p::identity::SecretKey as P2pSecretKey, Action, ActionWithMeta, EventSourceAction, State, +}; use super::{RecordedActionWithMeta, RecordedInitialState}; diff --git a/node/src/recorder/replayer.rs b/node/src/recorder/replayer.rs index 8bf6ed531e..879a3786cf 100644 --- a/node/src/recorder/replayer.rs +++ b/node/src/recorder/replayer.rs @@ -1,7 +1,9 @@ -use std::error::Error; -use std::fs; -use std::io::Read; -use std::path::{Path, PathBuf}; +use std::{ + error::Error, + fs, + io::Read, + path::{Path, PathBuf}, +}; use super::{RecordedActionWithMeta, RecordedInitialState}; diff --git a/node/src/rpc/mod.rs b/node/src/rpc/mod.rs index dbac579702..113e9672df 100644 --- a/node/src/rpc/mod.rs +++ b/node/src/rpc/mod.rs @@ -1,23 +1,29 @@ mod rpc_state; -use std::collections::BTreeMap; -use std::str::FromStr; +use std::{collections::BTreeMap, str::FromStr}; use ark_ff::fields::arithmetic::InvalidBigInt; -use ledger::scan_state::currency::{Amount, Balance, Fee, Nonce, Slot}; -use ledger::scan_state::transaction_logic::signed_command::SignedCommandPayload; -use ledger::scan_state::transaction_logic::{signed_command, valid, Memo}; -use ledger::transaction_pool::{diff, ValidCommandWithHash}; -use ledger::{Account, AccountId}; -use mina_p2p_messages::bigint::BigInt; -use mina_p2p_messages::v2::{ - LedgerHash, MinaBaseSignedCommandPayloadBodyStableV2, MinaBaseSignedCommandStableV2, - MinaBaseTransactionStatusStableV2, MinaBaseUserCommandStableV2, - MinaBaseZkappCommandTStableV1WireStableV1, MinaTransactionTransactionStableV2, - SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse, StateHash, TransactionHash, - TransactionSnarkWorkTStableV2, +use ledger::{ + scan_state::{ + currency::{Amount, Balance, Fee, Nonce, Slot}, + transaction_logic::{signed_command, signed_command::SignedCommandPayload, valid, Memo}, + }, + transaction_pool::{diff, ValidCommandWithHash}, + Account, AccountId, +}; +use mina_p2p_messages::{ + bigint::BigInt, + v2::{ + LedgerHash, MinaBaseSignedCommandPayloadBodyStableV2, MinaBaseSignedCommandStableV2, + MinaBaseTransactionStatusStableV2, MinaBaseUserCommandStableV2, + MinaBaseZkappCommandTStableV1WireStableV1, MinaTransactionTransactionStableV2, + SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse, StateHash, TransactionHash, + TransactionSnarkWorkTStableV2, + }, +}; +use openmina_core::{ + block::{AppliedBlock, ArcBlockWithHash}, + consensus::{ConsensusConstants, ConsensusTime}, }; -use openmina_core::block::{AppliedBlock, ArcBlockWithHash}; -use openmina_core::consensus::{ConsensusConstants, ConsensusTime}; use openmina_node_account::AccountPublicKey; use p2p::bootstrap::P2pNetworkKadBootstrapStats; pub use rpc_state::*; @@ -35,28 +41,36 @@ pub use heartbeat::{NodeHeartbeat, ProducedBlockInfo, SignedNodeHeartbeat}; pub use openmina_core::requests::{RpcId, RpcIdType}; -use ledger::scan_state::scan_state::transaction_snark::OneOrTwo; -use ledger::scan_state::scan_state::AvailableJobMessage; +use ledger::scan_state::scan_state::{transaction_snark::OneOrTwo, AvailableJobMessage}; use mina_p2p_messages::v2::{CurrencyFeeStableV1, NonZeroCurvePoint}; use openmina_core::snark::SnarkJobId; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::external_snark_worker::{ - ExternalSnarkWorkerError, ExternalSnarkWorkerWorkError, SnarkWorkSpecError, -}; -use crate::ledger::read::{LedgerReadId, LedgerReadKind, LedgerStatus}; -use crate::ledger::write::LedgerWriteKind; -use crate::p2p::connection::incoming::P2pConnectionIncomingInitOpts; -use crate::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts; -use crate::p2p::PeerId; -use crate::service::Queues; -use crate::snark_pool::{JobCommitment, JobState, JobSummary}; -use crate::stats::actions::{ActionStatsForBlock, ActionStatsSnapshot}; -use crate::stats::block_producer::{ - BlockProductionAttempt, BlockProductionAttemptWonSlot, VrfEvaluatorStats, +use crate::{ + external_snark_worker::{ + ExternalSnarkWorkerError, ExternalSnarkWorkerWorkError, SnarkWorkSpecError, + }, + ledger::{ + read::{LedgerReadId, LedgerReadKind, LedgerStatus}, + write::LedgerWriteKind, + }, + p2p::{ + connection::{ + incoming::P2pConnectionIncomingInitOpts, outgoing::P2pConnectionOutgoingInitOpts, + }, + PeerId, + }, + service::Queues, + snark_pool::{JobCommitment, JobState, JobSummary}, + stats::{ + actions::{ActionStatsForBlock, ActionStatsSnapshot}, + block_producer::{ + BlockProductionAttempt, BlockProductionAttemptWonSlot, VrfEvaluatorStats, + }, + sync::SyncStatsSnapshot, + }, }; -use crate::stats::sync::SyncStatsSnapshot; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum RpcRequest { diff --git a/node/src/rpc/rpc_actions.rs b/node/src/rpc/rpc_actions.rs index 29cf1402df..98fbcee7fe 100644 --- a/node/src/rpc/rpc_actions.rs +++ b/node/src/rpc/rpc_actions.rs @@ -1,18 +1,21 @@ -use ledger::transaction_pool::{diff, ValidCommandWithHash}; -use ledger::{Account, AccountId}; -use mina_p2p_messages::v2::TokenIdKeyHash; -use mina_p2p_messages::v2::{LedgerHash, MinaBaseUserCommandStableV2}; -use openmina_core::block::AppliedBlock; -use openmina_core::snark::SnarkJobId; -use openmina_core::ActionEvent; +use ledger::{ + transaction_pool::{diff, ValidCommandWithHash}, + Account, AccountId, +}; +use mina_p2p_messages::v2::{LedgerHash, MinaBaseUserCommandStableV2, TokenIdKeyHash}; +use openmina_core::{block::AppliedBlock, snark::SnarkJobId, ActionEvent}; use openmina_node_account::AccountPublicKey; use p2p::PeerId; use serde::{Deserialize, Serialize}; -use crate::external_snark_worker::SnarkWorkId; -use crate::p2p::connection::incoming::P2pConnectionIncomingInitOpts; -use crate::p2p::connection::outgoing::{P2pConnectionOutgoingError, P2pConnectionOutgoingInitOpts}; -use crate::p2p::connection::P2pConnectionResponse; +use crate::{ + external_snark_worker::SnarkWorkId, + p2p::connection::{ + incoming::P2pConnectionIncomingInitOpts, + outgoing::{P2pConnectionOutgoingError, P2pConnectionOutgoingInitOpts}, + P2pConnectionResponse, + }, +}; use super::{ ActionStatsQuery, ConsensusTimeQuery, GetBlockQuery, PooledUserCommandsQuery, diff --git a/node/src/service.rs b/node/src/service.rs index b09f561023..1332ca7b23 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,17 +1,24 @@ -pub use crate::block_producer_effectful::vrf_evaluator_effectful::BlockProducerVrfEvaluatorService; -pub use crate::block_producer_effectful::BlockProducerService; -pub use crate::event_source::EventSourceService; -pub use crate::external_snark_worker_effectful::ExternalSnarkWorkerService; -pub use crate::ledger::LedgerService; -pub use crate::p2p::service::*; -pub use crate::recorder::Recorder; -pub use crate::rpc_effectful::RpcService; -pub use crate::snark::block_verify_effectful::SnarkBlockVerifyService; -pub use crate::snark::work_verify_effectful::SnarkWorkVerifyService; -pub use crate::snark_pool::SnarkPoolService; -pub use crate::transition_frontier::archive::archive_service::ArchiveService; -pub use crate::transition_frontier::genesis_effectful::TransitionFrontierGenesisService; -pub use crate::transition_frontier::sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedService; +pub use crate::{ + block_producer_effectful::{ + vrf_evaluator_effectful::BlockProducerVrfEvaluatorService, BlockProducerService, + }, + event_source::EventSourceService, + external_snark_worker_effectful::ExternalSnarkWorkerService, + ledger::LedgerService, + p2p::service::*, + recorder::Recorder, + rpc_effectful::RpcService, + snark::{ + block_verify_effectful::SnarkBlockVerifyService, + work_verify_effectful::SnarkWorkVerifyService, + }, + snark_pool::SnarkPoolService, + transition_frontier::{ + archive::archive_service::ArchiveService, + genesis_effectful::TransitionFrontierGenesisService, + sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedService, + }, +}; pub use redux::TimeService; pub use snark::user_command_verify_effectful::SnarkUserCommandVerifyService; diff --git a/node/src/snark/block_verify/mod.rs b/node/src/snark/block_verify/mod.rs index 87bbc6304e..3ed3f8f6a7 100644 --- a/node/src/snark/block_verify/mod.rs +++ b/node/src/snark/block_verify/mod.rs @@ -1,4 +1,3 @@ -pub use ::snark::block_verify::*; -pub use ::snark::block_verify_effectful::*; +pub use ::snark::{block_verify::*, block_verify_effectful::*}; mod snark_block_verify_actions; diff --git a/node/src/snark/work_verify/mod.rs b/node/src/snark/work_verify/mod.rs index 4d09f3e72f..e6f0549737 100644 --- a/node/src/snark/work_verify/mod.rs +++ b/node/src/snark/work_verify/mod.rs @@ -1,4 +1,3 @@ -pub use ::snark::work_verify::*; -pub use ::snark::work_verify_effectful::*; +pub use ::snark::{work_verify::*, work_verify_effectful::*}; mod snark_work_verify_actions; diff --git a/node/src/snark_pool/candidate/snark_pool_candidate_actions.rs b/node/src/snark_pool/candidate/snark_pool_candidate_actions.rs index a9aa1d35c6..8cc73371a1 100644 --- a/node/src/snark_pool/candidate/snark_pool_candidate_actions.rs +++ b/node/src/snark_pool/candidate/snark_pool_candidate_actions.rs @@ -1,12 +1,15 @@ use std::cmp::Ordering; -use openmina_core::snark::{Snark, SnarkInfo, SnarkJobId}; -use openmina_core::ActionEvent; +use openmina_core::{ + snark::{Snark, SnarkInfo, SnarkJobId}, + ActionEvent, +}; use serde::{Deserialize, Serialize}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::snark::work_verify::SnarkWorkVerifyId; +use crate::{ + p2p::{channels::rpc::P2pRpcId, PeerId}, + snark::work_verify::SnarkWorkVerifyId, +}; use super::SnarkPoolCandidateState; diff --git a/node/src/snark_pool/candidate/snark_pool_candidate_state.rs b/node/src/snark_pool/candidate/snark_pool_candidate_state.rs index 61f52d1778..39391d397a 100644 --- a/node/src/snark_pool/candidate/snark_pool_candidate_state.rs +++ b/node/src/snark_pool/candidate/snark_pool_candidate_state.rs @@ -4,9 +4,10 @@ use openmina_core::snark::{Snark, SnarkInfo, SnarkJobId}; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::snark::work_verify::SnarkWorkVerifyId; +use crate::{ + p2p::{channels::rpc::P2pRpcId, PeerId}, + snark::work_verify::SnarkWorkVerifyId, +}; static EMPTY_PEER_WORK_CANDIDATES: BTreeMap = BTreeMap::new(); diff --git a/node/src/snark_pool/snark_pool_actions.rs b/node/src/snark_pool/snark_pool_actions.rs index 189b5e2352..6d76e52d1e 100644 --- a/node/src/snark_pool/snark_pool_actions.rs +++ b/node/src/snark_pool/snark_pool_actions.rs @@ -1,15 +1,15 @@ use std::sync::Arc; -use ledger::scan_state::scan_state::transaction_snark::OneOrTwo; -use ledger::scan_state::scan_state::AvailableJobMessage; -use openmina_core::snark::{Snark, SnarkJobCommitment, SnarkJobId}; -use openmina_core::ActionEvent; +use ledger::scan_state::scan_state::{transaction_snark::OneOrTwo, AvailableJobMessage}; +use openmina_core::{ + snark::{Snark, SnarkJobCommitment, SnarkJobId}, + ActionEvent, +}; use serde::{Deserialize, Serialize}; use crate::p2p::PeerId; -use super::candidate::SnarkPoolCandidateAction; -use super::SnarkWork; +use super::{candidate::SnarkPoolCandidateAction, SnarkWork}; pub type SnarkPoolActionWithMeta = redux::ActionWithMeta; pub type SnarkPoolActionWithMetaRef<'a> = redux::ActionWithMeta<&'a SnarkPoolAction>; diff --git a/node/src/snark_pool/snark_pool_state.rs b/node/src/snark_pool/snark_pool_state.rs index 707ff96ddd..e0f30aa36c 100644 --- a/node/src/snark_pool/snark_pool_state.rs +++ b/node/src/snark_pool/snark_pool_state.rs @@ -1,16 +1,13 @@ -use std::time::Duration; -use std::{fmt, ops::RangeBounds}; +use std::{fmt, ops::RangeBounds, time::Duration}; use ledger::scan_state::scan_state::{transaction_snark::OneOrTwo, AvailableJobMessage}; use openmina_core::snark::{Snark, SnarkInfo, SnarkJobCommitment, SnarkJobId}; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::core::distributed_pool::DistributedPool; -use crate::p2p::PeerId; +use crate::{core::distributed_pool::DistributedPool, p2p::PeerId}; -use super::candidate::SnarkPoolCandidatesState; -use super::SnarkPoolConfig; +use super::{candidate::SnarkPoolCandidatesState, SnarkPoolConfig}; #[derive(Serialize, Deserialize, Clone)] pub struct SnarkPoolState { diff --git a/node/src/state.rs b/node/src/state.rs index 867540c526..060d6dde95 100644 --- a/node/src/state.rs +++ b/node/src/state.rs @@ -1,64 +1,76 @@ -use std::sync::Arc; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; use malloc_size_of_derive::MallocSizeOf; use mina_p2p_messages::v2; -use openmina_core::block::prevalidate::{prevalidate_block, BlockPrevalidationError}; -use openmina_core::consensus::ConsensusTime; -use openmina_core::transaction::{TransactionInfo, TransactionWithHash}; +use openmina_core::{ + block::prevalidate::{prevalidate_block, BlockPrevalidationError}, + consensus::ConsensusTime, + transaction::{TransactionInfo, TransactionWithHash}, +}; use p2p::P2pNetworkPubsubMessageCacheId; use rand::prelude::*; -use openmina_core::block::BlockWithHash; -use openmina_core::requests::RpcId; -use openmina_core::snark::{Snark, SnarkInfo}; use openmina_core::{ - block::ArcBlockWithHash, consensus::ConsensusConstants, constants::constraint_constants, error, - snark::SnarkJobCommitment, ChainId, + block::{ArcBlockWithHash, BlockWithHash}, + consensus::ConsensusConstants, + constants::constraint_constants, + error, + requests::RpcId, + snark::{Snark, SnarkInfo, SnarkJobCommitment}, + ChainId, }; -use p2p::channels::rpc::{P2pRpcId, P2pRpcRequest, P2pRpcResponse}; -use p2p::channels::streaming_rpc::P2pStreamingRpcResponseFull; -use p2p::connection::outgoing::P2pConnectionOutgoingError; -use p2p::connection::P2pConnectionResponse; use p2p::{ - bootstrap::P2pNetworkKadBootstrapState, network::identify::P2pNetworkIdentifyState, + bootstrap::P2pNetworkKadBootstrapState, + channels::{ + rpc::{P2pRpcId, P2pRpcRequest, P2pRpcResponse}, + streaming_rpc::P2pStreamingRpcResponseFull, + }, + connection::{outgoing::P2pConnectionOutgoingError, P2pConnectionResponse}, + network::identify::P2pNetworkIdentifyState, P2pCallbacks, P2pConfig, P2pNetworkSchedulerState, P2pPeerState, P2pPeerStatusReady, PeerId, }; use redux::{ActionMeta, EnablingCondition, Timestamp}; use serde::{Deserialize, Serialize}; -use snark::block_verify::SnarkBlockVerifyState; -use snark::user_command_verify::SnarkUserCommandVerifyState; -use snark::work_verify::SnarkWorkVerifyState; - -use crate::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorState; -pub use crate::block_producer::BlockProducerState; -use crate::external_snark_worker::{ExternalSnarkWorker, ExternalSnarkWorkers}; -use crate::ledger::read::LedgerReadState; -use crate::ledger::write::LedgerWriteState; -pub use crate::ledger::LedgerState; -use crate::p2p::callbacks::P2pCallbacksAction; -pub use crate::p2p::P2pState; -pub use crate::rpc::RpcState; -pub use crate::snark::SnarkState; -use crate::snark_pool::candidate::SnarkPoolCandidateAction; -pub use crate::snark_pool::candidate::SnarkPoolCandidatesState; -pub use crate::snark_pool::SnarkPoolState; -use crate::transaction_pool::candidate::{ - TransactionPoolCandidateAction, TransactionPoolCandidatesState, +use snark::{ + block_verify::SnarkBlockVerifyState, user_command_verify::SnarkUserCommandVerifyState, + work_verify::SnarkWorkVerifyState, +}; + +use crate::{ + block_producer::vrf_evaluator::BlockProducerVrfEvaluatorState, + config::GlobalConfig, + external_snark_worker::{ExternalSnarkWorker, ExternalSnarkWorkers}, + ledger::{read::LedgerReadState, write::LedgerWriteState}, + p2p::callbacks::P2pCallbacksAction, + snark_pool::candidate::SnarkPoolCandidateAction, + transaction_pool::{ + candidate::{TransactionPoolCandidateAction, TransactionPoolCandidatesState}, + TransactionPoolState, + }, + transition_frontier::{ + candidate::TransitionFrontierCandidateAction, + genesis::TransitionFrontierGenesisState, + sync::{ + ledger::{ + snarked::TransitionFrontierSyncLedgerSnarkedState, + staged::TransitionFrontierSyncLedgerStagedState, TransitionFrontierSyncLedgerState, + }, + TransitionFrontierSyncState, + }, + }, + ActionWithMeta, RpcAction, SnarkPoolAction, +}; +pub use crate::{ + block_producer::BlockProducerState, + ledger::LedgerState, + p2p::P2pState, + rpc::RpcState, + snark::SnarkState, + snark_pool::{candidate::SnarkPoolCandidatesState, SnarkPoolState}, + transition_frontier::{candidate::TransitionFrontierCandidatesState, TransitionFrontierState}, + watched_accounts::WatchedAccountsState, + Config, }; -use crate::transaction_pool::TransactionPoolState; -use crate::transition_frontier::candidate::TransitionFrontierCandidateAction; -pub use crate::transition_frontier::candidate::TransitionFrontierCandidatesState; -use crate::transition_frontier::genesis::TransitionFrontierGenesisState; -use crate::transition_frontier::sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedState; -use crate::transition_frontier::sync::ledger::staged::TransitionFrontierSyncLedgerStagedState; -use crate::transition_frontier::sync::ledger::TransitionFrontierSyncLedgerState; -use crate::transition_frontier::sync::TransitionFrontierSyncState; -pub use crate::transition_frontier::TransitionFrontierState; -pub use crate::watched_accounts::WatchedAccountsState; -pub use crate::Config; -use crate::{config::GlobalConfig, SnarkPoolAction}; -use crate::{ActionWithMeta, RpcAction}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct State { diff --git a/node/src/stats/mod.rs b/node/src/stats/mod.rs index 7f6a6f411d..671e007e95 100644 --- a/node/src/stats/mod.rs +++ b/node/src/stats/mod.rs @@ -19,10 +19,13 @@ use block_producer::BlockProducerStats; use openmina_core::block::{AppliedBlock, ArcBlockWithHash}; use redux::{ActionMeta, ActionWithMeta, Timestamp}; -use crate::transition_frontier::sync::ledger::staged::PeerStagedLedgerPartsFetchError; -use crate::transition_frontier::sync::ledger::SyncLedgerTargetKind; -use crate::transition_frontier::sync::TransitionFrontierSyncBlockState; -use crate::ActionKind; +use crate::{ + transition_frontier::sync::{ + ledger::{staged::PeerStagedLedgerPartsFetchError, SyncLedgerTargetKind}, + TransitionFrontierSyncBlockState, + }, + ActionKind, +}; pub type ActionKindWithMeta = ActionWithMeta; diff --git a/node/src/stats/stats_actions.rs b/node/src/stats/stats_actions.rs index 6a81a70088..311e8e686d 100644 --- a/node/src/stats/stats_actions.rs +++ b/node/src/stats/stats_actions.rs @@ -2,8 +2,7 @@ use std::collections::{BTreeMap, VecDeque}; use mina_p2p_messages::v2::StateHash; use redux::Timestamp; -use serde::ser::SerializeMap; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; use crate::ActionKind; diff --git a/node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs b/node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs index 3fefaa90fa..0dbf04dcb2 100644 --- a/node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs +++ b/node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs @@ -1,12 +1,13 @@ -use openmina_core::transaction::{ - TransactionHash, TransactionInfo, TransactionPoolMessageSource, TransactionWithHash, +use openmina_core::{ + transaction::{ + TransactionHash, TransactionInfo, TransactionPoolMessageSource, TransactionWithHash, + }, + ActionEvent, }; -use openmina_core::ActionEvent; use p2p::P2pNetworkPubsubMessageCacheId; use serde::{Deserialize, Serialize}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; +use crate::p2p::{channels::rpc::P2pRpcId, PeerId}; use super::TransactionPoolCandidateState; diff --git a/node/src/transaction_pool/candidate/transaction_pool_candidate_state.rs b/node/src/transaction_pool/candidate/transaction_pool_candidate_state.rs index acf6e33286..d6625889ae 100644 --- a/node/src/transaction_pool/candidate/transaction_pool_candidate_state.rs +++ b/node/src/transaction_pool/candidate/transaction_pool_candidate_state.rs @@ -8,11 +8,10 @@ use p2p::P2pNetworkPubsubMessageCacheId; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::core::transaction::{ - Transaction, TransactionHash, TransactionInfo, TransactionWithHash, +use crate::{ + core::transaction::{Transaction, TransactionHash, TransactionInfo, TransactionWithHash}, + p2p::{channels::rpc::P2pRpcId, PeerId}, }; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; static EMPTY_PEER_TX_CANDIDATES: BTreeMap = BTreeMap::new(); diff --git a/node/src/transaction_pool/transaction_pool_effects.rs b/node/src/transaction_pool/transaction_pool_effects.rs index 56ec52e4e3..c9095c3a3f 100644 --- a/node/src/transaction_pool/transaction_pool_effects.rs +++ b/node/src/transaction_pool/transaction_pool_effects.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; -use crate::ledger::LedgerService; -use crate::snark::SnarkStore; +use crate::{ledger::LedgerService, snark::SnarkStore}; use super::TransactionPoolEffectfulAction; diff --git a/node/src/transaction_pool/transaction_pool_state.rs b/node/src/transaction_pool/transaction_pool_state.rs index 6b72fe77fc..bb23519c70 100644 --- a/node/src/transaction_pool/transaction_pool_state.rs +++ b/node/src/transaction_pool/transaction_pool_state.rs @@ -133,8 +133,7 @@ impl TransactionPoolState { #[cfg(test)] mod tests { - use super::super::TransactionPoolActionWithMeta; - use super::*; + use super::{super::TransactionPoolActionWithMeta, *}; use crate::State; use redux::Dispatcher; diff --git a/node/src/transition_frontier/candidate/transition_frontier_candidate_actions.rs b/node/src/transition_frontier/candidate/transition_frontier_candidate_actions.rs index 435e9e55b7..1f90002d2c 100644 --- a/node/src/transition_frontier/candidate/transition_frontier_candidate_actions.rs +++ b/node/src/transition_frontier/candidate/transition_frontier_candidate_actions.rs @@ -1,8 +1,10 @@ use mina_p2p_messages::v2::StateHash; -use openmina_core::block::prevalidate::BlockPrevalidationError; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::consensus::consensus_take; -use openmina_core::{action_event, ActionEvent}; +use openmina_core::{ + action_event, + block::{prevalidate::BlockPrevalidationError, ArcBlockWithHash}, + consensus::consensus_take, + ActionEvent, +}; use serde::{Deserialize, Serialize}; use snark::block_verify::SnarkBlockVerifyError; diff --git a/node/src/transition_frontier/candidate/transition_frontier_candidate_state.rs b/node/src/transition_frontier/candidate/transition_frontier_candidate_state.rs index 136d476185..48b7526706 100644 --- a/node/src/transition_frontier/candidate/transition_frontier_candidate_state.rs +++ b/node/src/transition_frontier/candidate/transition_frontier_candidate_state.rs @@ -3,13 +3,16 @@ use std::collections::{BTreeMap, BTreeSet}; use mina_p2p_messages::v2::StateHash; use serde::{Deserialize, Serialize}; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::consensus::{ - consensus_take, ConsensusLongRangeForkDecisionReason, ConsensusShortRangeForkDecisionReason, +use openmina_core::{ + block::ArcBlockWithHash, + consensus::{ + consensus_take, ConsensusLongRangeForkDecisionReason, ConsensusShortRangeForkDecisionReason, + }, }; -use crate::snark::block_verify::SnarkBlockVerifyId; -use crate::transition_frontier::TransitionFrontierState; +use crate::{ + snark::block_verify::SnarkBlockVerifyId, transition_frontier::TransitionFrontierState, +}; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum ConsensusShortRangeForkDecision { diff --git a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_actions.rs b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_actions.rs index 8fa768b891..7257af0952 100644 --- a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_actions.rs +++ b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_actions.rs @@ -2,10 +2,11 @@ use mina_p2p_messages::v2::{LedgerHash, MinaBaseAccountBinableArgStableV2}; use openmina_core::ActionEvent; use serde::{Deserialize, Serialize}; -use crate::ledger::{LedgerAddress, LEDGER_DEPTH}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::transition_frontier::sync::ledger::TransitionFrontierSyncLedgerState; +use crate::{ + ledger::{LedgerAddress, LEDGER_DEPTH}, + p2p::{channels::rpc::P2pRpcId, PeerId}, + transition_frontier::sync::ledger::TransitionFrontierSyncLedgerState, +}; use super::{ PeerLedgerQueryError, PeerLedgerQueryResponse, PeerRpcState, diff --git a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_effects.rs b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_effects.rs index 51be57d2f8..3f6711f890 100644 --- a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_effects.rs +++ b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_effects.rs @@ -1,7 +1,6 @@ use redux::ActionMeta; -use crate::ledger::hash_node_at_depth; -use crate::Store; +use crate::{ledger::hash_node_at_depth, Store}; use super::{ TransitionFrontierSyncLedgerSnarkedAction, TransitionFrontierSyncLedgerSnarkedService, diff --git a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_state.rs b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_state.rs index d05d9ad5e3..10c7504d3a 100644 --- a/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_state.rs +++ b/node/src/transition_frontier/sync/ledger/snarked/transition_frontier_sync_ledger_snarked_state.rs @@ -4,11 +4,12 @@ use mina_p2p_messages::v2::LedgerHash; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::ledger::{tree_height_for_num_accounts, LedgerAddress}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::rpc::LedgerSyncProgress; -use crate::transition_frontier::sync::ledger::SyncLedgerTarget; +use crate::{ + ledger::{tree_height_for_num_accounts, LedgerAddress}, + p2p::{channels::rpc::P2pRpcId, PeerId}, + rpc::LedgerSyncProgress, + transition_frontier::sync::ledger::SyncLedgerTarget, +}; use super::{PeerLedgerQueryError, ACCOUNT_SUBTREE_HEIGHT}; diff --git a/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_actions.rs b/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_actions.rs index 19434a8704..f17cd0f4f1 100644 --- a/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_actions.rs +++ b/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_actions.rs @@ -4,9 +4,13 @@ use mina_p2p_messages::v2::{self, LedgerHash}; use openmina_core::ActionEvent; use serde::{Deserialize, Serialize}; -use crate::p2p::channels::rpc::{P2pRpcId, StagedLedgerAuxAndPendingCoinbases}; -use crate::p2p::PeerId; -use crate::transition_frontier::sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedState; +use crate::{ + p2p::{ + channels::rpc::{P2pRpcId, StagedLedgerAuxAndPendingCoinbases}, + PeerId, + }, + transition_frontier::sync::ledger::snarked::TransitionFrontierSyncLedgerSnarkedState, +}; use super::{ PeerStagedLedgerPartsFetchError, PeerStagedLedgerPartsFetchState, diff --git a/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_state.rs b/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_state.rs index 3aaef96c64..cde4bea212 100644 --- a/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_state.rs +++ b/node/src/transition_frontier/sync/ledger/staged/transition_frontier_sync_ledger_staged_state.rs @@ -1,14 +1,14 @@ -use std::collections::BTreeMap; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; use mina_p2p_messages::v2::{MinaStateProtocolStateValueStableV2, StateHash}; use p2p::channels::rpc::StagedLedgerAuxAndPendingCoinbases; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::transition_frontier::sync::ledger::SyncLedgerTargetWithStaged; +use crate::{ + p2p::{channels::rpc::P2pRpcId, PeerId}, + transition_frontier::sync::ledger::SyncLedgerTargetWithStaged, +}; use super::{ PeerStagedLedgerPartsFetchError, StagedLedgerAuxAndPendingCoinbasesValid, diff --git a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_actions.rs b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_actions.rs index bd8fa7a0be..daf5aaca38 100644 --- a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_actions.rs +++ b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_actions.rs @@ -1,12 +1,12 @@ use openmina_core::ActionEvent; use serde::{Deserialize, Serialize}; -use crate::transition_frontier::sync::TransitionFrontierSyncAction; -use crate::TransitionFrontierAction; +use crate::{transition_frontier::sync::TransitionFrontierSyncAction, TransitionFrontierAction}; -use super::snarked::TransitionFrontierSyncLedgerSnarkedAction; -use super::staged::TransitionFrontierSyncLedgerStagedAction; -use super::TransitionFrontierSyncLedgerState; +use super::{ + snarked::TransitionFrontierSyncLedgerSnarkedAction, + staged::TransitionFrontierSyncLedgerStagedAction, TransitionFrontierSyncLedgerState, +}; pub type TransitionFrontierSyncLedgerActionWithMeta = redux::ActionWithMeta; diff --git a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_effects.rs b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_effects.rs index 78a4cddb6c..2223d895f0 100644 --- a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_effects.rs +++ b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_effects.rs @@ -2,9 +2,10 @@ use redux::ActionMeta; use crate::Store; -use super::snarked::TransitionFrontierSyncLedgerSnarkedAction; -use super::staged::TransitionFrontierSyncLedgerStagedAction; -use super::TransitionFrontierSyncLedgerAction; +use super::{ + snarked::TransitionFrontierSyncLedgerSnarkedAction, + staged::TransitionFrontierSyncLedgerStagedAction, TransitionFrontierSyncLedgerAction, +}; // TODO(refactor): all this should be in the reducers? diff --git a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_reducer.rs b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_reducer.rs index 462883a8bf..f19d8ac9b9 100644 --- a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_reducer.rs +++ b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_reducer.rs @@ -1,12 +1,10 @@ use crate::Substate; -use super::snarked::{ - TransitionFrontierSyncLedgerSnarkedAction, TransitionFrontierSyncLedgerSnarkedState, -}; -use super::staged::{ - TransitionFrontierSyncLedgerStagedAction, TransitionFrontierSyncLedgerStagedState, -}; use super::{ + snarked::{ + TransitionFrontierSyncLedgerSnarkedAction, TransitionFrontierSyncLedgerSnarkedState, + }, + staged::{TransitionFrontierSyncLedgerStagedAction, TransitionFrontierSyncLedgerStagedState}, TransitionFrontierSyncLedgerAction, TransitionFrontierSyncLedgerActionWithMetaRef, TransitionFrontierSyncLedgerState, }; diff --git a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_state.rs b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_state.rs index 55be085367..e74ae6b166 100644 --- a/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_state.rs +++ b/node/src/transition_frontier/sync/ledger/transition_frontier_sync_ledger_state.rs @@ -4,9 +4,10 @@ use mina_p2p_messages::v2::{MinaStateProtocolStateValueStableV2, StateHash}; use redux::Timestamp; use serde::{Deserialize, Serialize}; -use super::snarked::TransitionFrontierSyncLedgerSnarkedState; -use super::staged::TransitionFrontierSyncLedgerStagedState; -use super::{SyncLedgerTarget, SyncLedgerTargetKind}; +use super::{ + snarked::TransitionFrontierSyncLedgerSnarkedState, + staged::TransitionFrontierSyncLedgerStagedState, SyncLedgerTarget, SyncLedgerTargetKind, +}; #[derive(derive_more::From, Serialize, Deserialize, Debug, Clone)] pub enum TransitionFrontierSyncLedgerState { diff --git a/node/src/transition_frontier/sync/transition_frontier_sync_actions.rs b/node/src/transition_frontier/sync/transition_frontier_sync_actions.rs index 44ff17ce0a..2d71d09064 100644 --- a/node/src/transition_frontier/sync/transition_frontier_sync_actions.rs +++ b/node/src/transition_frontier/sync/transition_frontier_sync_actions.rs @@ -1,20 +1,21 @@ use mina_p2p_messages::v2::{LedgerHash, StateHash}; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::consensus::consensus_take; -use openmina_core::ActionEvent; +use openmina_core::{block::ArcBlockWithHash, consensus::consensus_take, ActionEvent}; use redux::Callback; use serde::{Deserialize, Serialize}; -use crate::ledger::write::{BlockApplyResult, CommitResult}; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; -use crate::transition_frontier::sync::TransitionFrontierSyncLedgerPending; -use crate::TransitionFrontierAction; +use crate::{ + ledger::write::{BlockApplyResult, CommitResult}, + p2p::{channels::rpc::P2pRpcId, PeerId}, + transition_frontier::sync::TransitionFrontierSyncLedgerPending, + TransitionFrontierAction, +}; -use super::ledger::{ - SyncLedgerTarget, TransitionFrontierSyncLedgerAction, TransitionFrontierSyncLedgerState, +use super::{ + ledger::{ + SyncLedgerTarget, TransitionFrontierSyncLedgerAction, TransitionFrontierSyncLedgerState, + }, + PeerBlockFetchError, TransitionFrontierSyncState, }; -use super::{PeerBlockFetchError, TransitionFrontierSyncState}; pub type TransitionFrontierSyncActionWithMeta = redux::ActionWithMeta; pub type TransitionFrontierSyncActionWithMetaRef<'a> = diff --git a/node/src/transition_frontier/sync/transition_frontier_sync_effects.rs b/node/src/transition_frontier/sync/transition_frontier_sync_effects.rs index 764d1ac818..7cadf917b6 100644 --- a/node/src/transition_frontier/sync/transition_frontier_sync_effects.rs +++ b/node/src/transition_frontier/sync/transition_frontier_sync_effects.rs @@ -1,18 +1,27 @@ use mina_p2p_messages::v2::LedgerHash; use openmina_core::block::{AppliedBlock, ArcBlockWithHash}; -use p2p::channels::rpc::{P2pChannelsRpcAction, P2pRpcId}; -use p2p::{P2pNetworkPubsubAction, PeerId}; +use p2p::{ + channels::rpc::{P2pChannelsRpcAction, P2pRpcId}, + P2pNetworkPubsubAction, PeerId, +}; use redux::ActionMeta; -use crate::ledger::write::{LedgerWriteAction, LedgerWriteRequest, LedgersToKeep}; -use crate::p2p::channels::rpc::P2pRpcRequest; -use crate::service::TransitionFrontierSyncLedgerSnarkedService; -use crate::{p2p_ready, Service, Store, TransitionFrontierAction}; - -use super::ledger::snarked::TransitionFrontierSyncLedgerSnarkedAction; -use super::ledger::staged::TransitionFrontierSyncLedgerStagedAction; -use super::ledger::{SyncLedgerTarget, TransitionFrontierSyncLedgerAction}; -use super::{SyncError, TransitionFrontierSyncAction, TransitionFrontierSyncState}; +use crate::{ + ledger::write::{LedgerWriteAction, LedgerWriteRequest, LedgersToKeep}, + p2p::channels::rpc::P2pRpcRequest, + p2p_ready, + service::TransitionFrontierSyncLedgerSnarkedService, + Service, Store, TransitionFrontierAction, +}; + +use super::{ + ledger::{ + snarked::TransitionFrontierSyncLedgerSnarkedAction, + staged::TransitionFrontierSyncLedgerStagedAction, SyncLedgerTarget, + TransitionFrontierSyncLedgerAction, + }, + SyncError, TransitionFrontierSyncAction, TransitionFrontierSyncState, +}; impl TransitionFrontierSyncAction { pub fn effects(&self, meta: &ActionMeta, store: &mut Store) diff --git a/node/src/transition_frontier/sync/transition_frontier_sync_state.rs b/node/src/transition_frontier/sync/transition_frontier_sync_state.rs index e95ec4e0db..031daec0af 100644 --- a/node/src/transition_frontier/sync/transition_frontier_sync_state.rs +++ b/node/src/transition_frontier/sync/transition_frontier_sync_state.rs @@ -6,11 +6,12 @@ use redux::Timestamp; use serde::{Deserialize, Serialize}; use strum_macros::Display; -use crate::p2p::channels::rpc::P2pRpcId; -use crate::p2p::PeerId; +use crate::p2p::{channels::rpc::P2pRpcId, PeerId}; -use super::ledger::{SyncLedgerTarget, SyncLedgerTargetKind, TransitionFrontierSyncLedgerState}; -use super::PeerBlockFetchError; +use super::{ + ledger::{SyncLedgerTarget, SyncLedgerTargetKind, TransitionFrontierSyncLedgerState}, + PeerBlockFetchError, +}; #[derive(Serialize, Deserialize, Display, Debug, Clone)] pub enum TransitionFrontierSyncState { diff --git a/node/src/transition_frontier/transition_frontier_actions.rs b/node/src/transition_frontier/transition_frontier_actions.rs index 6ed9dcf7d4..44ead62391 100644 --- a/node/src/transition_frontier/transition_frontier_actions.rs +++ b/node/src/transition_frontier/transition_frontier_actions.rs @@ -1,15 +1,15 @@ -use std::collections::BTreeSet; -use std::sync::Arc; +use std::{collections::BTreeSet, sync::Arc}; use mina_p2p_messages::v2::StateHash; -use openmina_core::block::ArcBlockWithHash; -use openmina_core::ActionEvent; +use openmina_core::{block::ArcBlockWithHash, ActionEvent}; use serde::{Deserialize, Serialize}; -use super::candidate::TransitionFrontierCandidateAction; -use super::genesis::TransitionFrontierGenesisAction; -use super::genesis_effectful::TransitionFrontierGenesisEffectfulAction; -use super::sync::{SyncError, TransitionFrontierSyncAction, TransitionFrontierSyncState}; +use super::{ + candidate::TransitionFrontierCandidateAction, + genesis::TransitionFrontierGenesisAction, + genesis_effectful::TransitionFrontierGenesisEffectfulAction, + sync::{SyncError, TransitionFrontierSyncAction, TransitionFrontierSyncState}, +}; pub type TransitionFrontierActionWithMeta = redux::ActionWithMeta; pub type TransitionFrontierActionWithMetaRef<'a> = diff --git a/node/src/transition_frontier/transition_frontier_effects.rs b/node/src/transition_frontier/transition_frontier_effects.rs index c92e279011..e46c06c7a6 100644 --- a/node/src/transition_frontier/transition_frontier_effects.rs +++ b/node/src/transition_frontier/transition_frontier_effects.rs @@ -1,27 +1,31 @@ use mina_p2p_messages::gossip::GossipNetMessageV2; use redux::Timestamp; -use crate::block_producer::BlockProducerAction; -use crate::ledger::LEDGER_DEPTH; -use crate::p2p::channels::best_tip::P2pChannelsBestTipAction; -use crate::p2p::P2pNetworkPubsubAction; -use crate::snark_pool::{SnarkPoolAction, SnarkWork}; -use crate::stats::sync::SyncingLedger; -use crate::{Store, TransactionPoolAction}; - -use super::candidate::TransitionFrontierCandidateAction; -use super::genesis::TransitionFrontierGenesisAction; -use super::sync::ledger::snarked::{ - TransitionFrontierSyncLedgerSnarkedAction, ACCOUNT_SUBTREE_HEIGHT, +use crate::{ + block_producer::BlockProducerAction, + ledger::LEDGER_DEPTH, + p2p::{channels::best_tip::P2pChannelsBestTipAction, P2pNetworkPubsubAction}, + snark_pool::{SnarkPoolAction, SnarkWork}, + stats::sync::SyncingLedger, + Store, TransactionPoolAction, }; -use super::sync::ledger::staged::TransitionFrontierSyncLedgerStagedAction; -use super::sync::ledger::{ - transition_frontier_sync_ledger_init_effects, - transition_frontier_sync_ledger_snarked_success_effects, - transition_frontier_sync_ledger_staged_success_effects, TransitionFrontierSyncLedgerAction, + +use super::{ + candidate::TransitionFrontierCandidateAction, + genesis::TransitionFrontierGenesisAction, + sync::{ + ledger::{ + snarked::{TransitionFrontierSyncLedgerSnarkedAction, ACCOUNT_SUBTREE_HEIGHT}, + staged::TransitionFrontierSyncLedgerStagedAction, + transition_frontier_sync_ledger_init_effects, + transition_frontier_sync_ledger_snarked_success_effects, + transition_frontier_sync_ledger_staged_success_effects, + TransitionFrontierSyncLedgerAction, + }, + TransitionFrontierSyncAction, TransitionFrontierSyncState, + }, + TransitionFrontierAction, TransitionFrontierActionWithMeta, TransitionFrontierState, }; -use super::sync::{TransitionFrontierSyncAction, TransitionFrontierSyncState}; -use super::{TransitionFrontierAction, TransitionFrontierActionWithMeta, TransitionFrontierState}; // TODO(refactor): all service accesses are for stats, how should that be handled? diff --git a/node/src/transition_frontier/transition_frontier_reducer.rs b/node/src/transition_frontier/transition_frontier_reducer.rs index af4d8f0c91..8551cce166 100644 --- a/node/src/transition_frontier/transition_frontier_reducer.rs +++ b/node/src/transition_frontier/transition_frontier_reducer.rs @@ -1,5 +1,5 @@ -use super::sync::{SyncError, TransitionFrontierSyncState}; use super::{ + sync::{SyncError, TransitionFrontierSyncState}, TransitionFrontierAction, TransitionFrontierActionWithMetaRef, TransitionFrontierState, }; use openmina_core::block::AppliedBlock; diff --git a/node/src/transition_frontier/transition_frontier_state.rs b/node/src/transition_frontier/transition_frontier_state.rs index 9c888ca833..00753eb365 100644 --- a/node/src/transition_frontier/transition_frontier_state.rs +++ b/node/src/transition_frontier/transition_frontier_state.rs @@ -5,14 +5,16 @@ use mina_p2p_messages::v2::{ MinaStateProtocolStateBodyValueStableV2, MinaStateProtocolStateValueStableV2, StateHash, TransactionHash, }; -use openmina_core::block::{AppliedBlock, ArcBlockWithHash}; -use openmina_core::bug_condition; +use openmina_core::{ + block::{AppliedBlock, ArcBlockWithHash}, + bug_condition, +}; use serde::{Deserialize, Serialize}; -use super::candidate::TransitionFrontierCandidatesState; -use super::genesis::TransitionFrontierGenesisState; -use super::sync::TransitionFrontierSyncState; -use super::TransitionFrontierConfig; +use super::{ + candidate::TransitionFrontierCandidatesState, genesis::TransitionFrontierGenesisState, + sync::TransitionFrontierSyncState, TransitionFrontierConfig, +}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct TransitionFrontierState { diff --git a/node/testing/src/cluster/mod.rs b/node/testing/src/cluster/mod.rs index 3d2ebed61b..e6754befb9 100644 --- a/node/testing/src/cluster/mod.rs +++ b/node/testing/src/cluster/mod.rs @@ -9,45 +9,43 @@ use openmina_core::channels::Aborter; pub mod runner; -use std::collections::BTreeMap; -use std::io::Read; -use std::path::{Path, PathBuf}; -use std::sync::Mutex as StdMutex; -use std::time::Duration; -use std::{collections::VecDeque, sync::Arc}; +use std::{ + collections::{BTreeMap, VecDeque}, + io::Read, + path::{Path, PathBuf}, + sync::{Arc, Mutex as StdMutex}, + time::Duration, +}; use libp2p::futures::{stream::FuturesUnordered, StreamExt}; use ledger::proofs::provers::BlockProver; -use node::account::{AccountPublicKey, AccountSecretKey}; -use node::core::consensus::ConsensusConstants; -use node::core::constants::constraint_constants; -use node::core::invariants::InvariantsState; -use node::core::log::system_time; -use node::core::requests::RpcId; -use node::core::{thread, warn}; -use node::p2p::{P2pConnectionEvent, P2pEvent, P2pLimits, P2pMeshsubConfig, PeerId}; -use node::snark::{BlockVerifier, TransactionVerifier, VerifierSRS}; use node::{ + account::{AccountPublicKey, AccountSecretKey}, + core::{ + consensus::ConsensusConstants, constants::constraint_constants, + invariants::InvariantsState, log::system_time, requests::RpcId, thread, warn, + }, event_source::Event, - p2p::{channels::ChannelId, identity::SecretKey as P2pSecretKey}, + p2p::{ + channels::ChannelId, identity::SecretKey as P2pSecretKey, P2pConnectionEvent, P2pEvent, + P2pLimits, P2pMeshsubConfig, PeerId, + }, service::{Recorder, Service}, - snark::get_srs, + snark::{get_srs, BlockVerifier, TransactionVerifier, VerifierSRS}, BuildEnv, Config, GlobalConfig, LedgerConfig, P2pConfig, SnarkConfig, State, TransitionFrontierConfig, }; use openmina_node_invariants::{InvariantResult, Invariants}; -use openmina_node_native::http_server; -use openmina_node_native::NodeServiceBuilder; +use openmina_node_native::{http_server, NodeServiceBuilder}; use serde::{de::DeserializeOwned, Serialize}; use temp_dir::TempDir; -use crate::node::{DaemonJson, NonDeterministicEvent, OcamlStep, TestPeerId}; use crate::{ network_debugger::Debugger, node::{ - Node, NodeTestingConfig, OcamlNode, OcamlNodeConfig, OcamlNodeTestingConfig, - RustNodeTestingConfig, + DaemonJson, Node, NodeTestingConfig, NonDeterministicEvent, OcamlNode, OcamlNodeConfig, + OcamlNodeTestingConfig, OcamlStep, RustNodeTestingConfig, TestPeerId, }, scenario::{ListenerNode, Scenario, ScenarioId, ScenarioStep}, service::{NodeTestingService, PendingEventId}, diff --git a/node/testing/src/cluster/p2p_task_spawner.rs b/node/testing/src/cluster/p2p_task_spawner.rs index 4b5f31029a..7f33e5407f 100644 --- a/node/testing/src/cluster/p2p_task_spawner.rs +++ b/node/testing/src/cluster/p2p_task_spawner.rs @@ -1,5 +1,4 @@ -use node::core::thread; -use node::p2p::service_impl::TaskSpawner; +use node::{core::thread, p2p::service_impl::TaskSpawner}; use openmina_core::channels::Aborted; #[derive(Clone)] diff --git a/node/testing/src/cluster/runner/mod.rs b/node/testing/src/cluster/runner/mod.rs index c21d37210b..f57168ce9b 100644 --- a/node/testing/src/cluster/runner/mod.rs +++ b/node/testing/src/cluster/runner/mod.rs @@ -4,18 +4,21 @@ pub use run::*; use std::{path::PathBuf, time::Duration}; use ledger::BaseLedger; -use node::account::{AccountPublicKey, AccountSecretKey}; -use node::{event_source::Event, ledger::LedgerService, ActionKind, State}; +use node::{ + account::{AccountPublicKey, AccountSecretKey}, + event_source::Event, + ledger::LedgerService, + ActionKind, State, +}; use rand::{rngs::StdRng, SeedableRng}; use time::OffsetDateTime; -use crate::node::OcamlStep; use crate::{ cluster::{Cluster, ClusterNodeId, ClusterOcamlNodeId}, network_debugger::Debugger, node::{ DaemonJson, DaemonJsonGenConfig, Node, NodeTestingConfig, NonDeterministicEvent, OcamlNode, - OcamlNodeTestingConfig, RustNodeTestingConfig, + OcamlNodeTestingConfig, OcamlStep, RustNodeTestingConfig, }, scenario::ScenarioStep, service::{DynEffects, PendingEventId}, diff --git a/node/testing/src/exit_with_error.rs b/node/testing/src/exit_with_error.rs index 7f4009c793..7dfd26fda8 100644 --- a/node/testing/src/exit_with_error.rs +++ b/node/testing/src/exit_with_error.rs @@ -1,6 +1,5 @@ use console::style; -use std::fmt::Display; -use std::process; +use std::{fmt::Display, process}; pub fn exit_with_error(error: E) -> ! { eprintln!("{} {}", style("[ERROR]").red().bold(), error,); diff --git a/node/testing/src/main.rs b/node/testing/src/main.rs index 6e57203fc5..224103c4b1 100644 --- a/node/testing/src/main.rs +++ b/node/testing/src/main.rs @@ -1,10 +1,13 @@ use clap::Parser; use node::p2p::webrtc::Host; -use openmina_node_testing::cluster::{Cluster, ClusterConfig}; -use openmina_node_testing::scenario::Scenario; -use openmina_node_testing::scenarios::Scenarios; -use openmina_node_testing::{exit_with_error, server, setup}; +use openmina_node_testing::{ + cluster::{Cluster, ClusterConfig}, + exit_with_error, + scenario::Scenario, + scenarios::Scenarios, + server, setup, +}; pub type CommandError = anyhow::Error; diff --git a/node/testing/src/node/config.rs b/node/testing/src/node/config.rs index 2f4c28fc23..ffbdcc286b 100644 --- a/node/testing/src/node/config.rs +++ b/node/testing/src/node/config.rs @@ -1,7 +1,6 @@ use serde::{Deserialize, Serialize}; -pub use super::ocaml::*; -pub use super::rust::*; +pub use super::{ocaml::*, rust::*}; #[derive(Serialize, Deserialize, derive_more::From, Debug, Clone)] #[serde(tag = "kind")] diff --git a/node/testing/src/node/ocaml/config.rs b/node/testing/src/node/ocaml/config.rs index c05aeb2d8a..8ce3c45775 100644 --- a/node/testing/src/node/ocaml/config.rs +++ b/node/testing/src/node/ocaml/config.rs @@ -1,11 +1,12 @@ -use std::ffi::{OsStr, OsString}; -use std::fs; -use std::path::PathBuf; -use std::process::{Command, Stdio}; -use std::str::FromStr; - -use node::account::AccountSecretKey; -use node::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts; +use std::{ + ffi::{OsStr, OsString}, + fs, + path::PathBuf, + process::{Command, Stdio}, + str::FromStr, +}; + +use node::{account::AccountSecretKey, p2p::connection::outgoing::P2pConnectionOutgoingInitOpts}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/node/testing/src/node/rust/config.rs b/node/testing/src/node/rust/config.rs index c0ca491d19..f5395fbf7a 100644 --- a/node/testing/src/node/rust/config.rs +++ b/node/testing/src/node/rust/config.rs @@ -1,11 +1,9 @@ -use std::fs::File; -use std::path::Path; -use std::sync::Arc; - -use node::account::AccountSecretKey; -use node::config::DEVNET_CONFIG; -use node::transition_frontier::genesis::GenesisConfig; -use node::{p2p::P2pTimeouts, BlockProducerConfig, SnarkerConfig}; +use std::{fs::File, path::Path, sync::Arc}; + +use node::{ + account::AccountSecretKey, config::DEVNET_CONFIG, p2p::P2pTimeouts, + transition_frontier::genesis::GenesisConfig, BlockProducerConfig, SnarkerConfig, +}; use serde::{Deserialize, Serialize}; use crate::scenario::ListenerNode; diff --git a/node/testing/src/node/rust/mod.rs b/node/testing/src/node/rust/mod.rs index 189c5d95cc..0b638a6e72 100644 --- a/node/testing/src/node/rust/mod.rs +++ b/node/testing/src/node/rust/mod.rs @@ -4,19 +4,25 @@ pub use config::*; mod event; pub use event::*; -use node::event_source::EventSourceAction; -use node::p2p::connection::outgoing::{ - P2pConnectionOutgoingInitLibp2pOpts, P2pConnectionOutgoingInitOpts, +use node::{ + event_source::EventSourceAction, + p2p::{ + connection::outgoing::{ + P2pConnectionOutgoingInitLibp2pOpts, P2pConnectionOutgoingInitOpts, + }, + webrtc::SignalingMethod, + PeerId, + }, + service::P2pDisconnectionService, + Action, CheckTimeoutsAction, State, Store, }; -use node::p2p::webrtc::SignalingMethod; -use node::p2p::PeerId; -use node::service::P2pDisconnectionService; -use node::{Action, CheckTimeoutsAction, State, Store}; use redux::EnablingCondition; use temp_dir::TempDir; -use crate::cluster::ClusterNodeId; -use crate::service::{DynEffects, NodeTestingService, PendingEventId}; +use crate::{ + cluster::ClusterNodeId, + service::{DynEffects, NodeTestingService, PendingEventId}, +}; pub struct Node { work_dir: TempDir, diff --git a/node/testing/src/scenario/step.rs b/node/testing/src/scenario/step.rs index a970e649f2..c12cfe948f 100644 --- a/node/testing/src/scenario/step.rs +++ b/node/testing/src/scenario/step.rs @@ -1,8 +1,10 @@ use node::{event_source::Event, p2p::connection::outgoing::P2pConnectionOutgoingInitOpts}; use serde::{Deserialize, Serialize}; -use crate::cluster::{ClusterNodeId, ClusterOcamlNodeId}; -use crate::node::{NodeTestingConfig, NonDeterministicEvent, OcamlStep}; +use crate::{ + cluster::{ClusterNodeId, ClusterOcamlNodeId}, + node::{NodeTestingConfig, NonDeterministicEvent, OcamlStep}, +}; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] diff --git a/node/testing/src/scenarios/mod.rs b/node/testing/src/scenarios/mod.rs index 18532e4c45..8b2ce48a60 100644 --- a/node/testing/src/scenarios/mod.rs +++ b/node/testing/src/scenarios/mod.rs @@ -23,46 +23,54 @@ pub use crate::cluster::runner::*; use strum_macros::{EnumIter, EnumString, IntoStaticStr}; -use crate::cluster::{Cluster, ClusterConfig}; -use crate::scenario::{Scenario, ScenarioId, ScenarioStep}; - -use self::multi_node::basic_connectivity_initial_joining::MultiNodeBasicConnectivityInitialJoining; -use self::multi_node::basic_connectivity_peer_discovery::MultiNodeBasicConnectivityPeerDiscovery; -use self::multi_node::connection_discovery::RustNodeAsSeed as P2pConnectionDiscoveryRustNodeAsSeed; -use self::multi_node::connection_discovery::{ - OCamlToRust, OCamlToRustViaSeed, RustToOCaml, RustToOCamlViaSeed, +use crate::{ + cluster::{Cluster, ClusterConfig}, + scenario::{Scenario, ScenarioId, ScenarioStep}, }; -use self::multi_node::pubsub_advanced::MultiNodePubsubPropagateBlock; -use self::multi_node::sync_4_block_producers::MultiNodeSync4BlockProducers; -use self::multi_node::vrf_correct_ledgers::MultiNodeVrfGetCorrectLedgers; -use self::multi_node::vrf_correct_slots::MultiNodeVrfGetCorrectSlots; -use self::multi_node::vrf_epoch_bounds_correct_ledgers::MultiNodeVrfEpochBoundsCorrectLedger; -use self::multi_node::vrf_epoch_bounds_evaluation::MultiNodeVrfEpochBoundsEvaluation; -use self::p2p::basic_connection_handling::{ - AllNodesConnectionsAreSymmetric, MaxNumberOfPeersIncoming, MaxNumberOfPeersIs1, - SeedConnectionsAreSymmetric, SimultaneousConnections, -}; -use self::p2p::basic_incoming_connections::{ - AcceptIncomingConnection, AcceptMultipleIncomingConnections, -}; -use self::p2p::basic_outgoing_connections::{ - ConnectToInitialPeers, ConnectToInitialPeersBecomeReady, ConnectToUnavailableInitialPeers, - DontConnectToInitialPeerWithSameId, DontConnectToNodeWithSameId, DontConnectToSelfInitialPeer, - MakeMultipleOutgoingConnections, MakeOutgoingConnection, -}; -use self::p2p::kademlia::KademliaBootstrap; -use self::p2p::pubsub::P2pReceiveMessage; -use self::p2p::signaling::P2pSignaling; -use self::record_replay::block_production::RecordReplayBlockProduction; -use self::record_replay::bootstrap::RecordReplayBootstrap; -use self::simulation::small::SimulationSmall; -use self::simulation::small_forever_real_time::SimulationSmallForeverRealTime; -use self::solo_node::sync_to_genesis::SoloNodeSyncToGenesis; -use self::solo_node::sync_to_genesis_custom::SoloNodeSyncToGenesisCustom; -use self::solo_node::{ - basic_connectivity_accept_incoming::SoloNodeBasicConnectivityAcceptIncoming, - basic_connectivity_initial_joining::SoloNodeBasicConnectivityInitialJoining, - bootstrap::SoloNodeBootstrap, sync_root_snarked_ledger::SoloNodeSyncRootSnarkedLedger, + +use self::{ + multi_node::{ + basic_connectivity_initial_joining::MultiNodeBasicConnectivityInitialJoining, + basic_connectivity_peer_discovery::MultiNodeBasicConnectivityPeerDiscovery, + connection_discovery::{ + OCamlToRust, OCamlToRustViaSeed, + RustNodeAsSeed as P2pConnectionDiscoveryRustNodeAsSeed, RustToOCaml, + RustToOCamlViaSeed, + }, + pubsub_advanced::MultiNodePubsubPropagateBlock, + sync_4_block_producers::MultiNodeSync4BlockProducers, + vrf_correct_ledgers::MultiNodeVrfGetCorrectLedgers, + vrf_correct_slots::MultiNodeVrfGetCorrectSlots, + vrf_epoch_bounds_correct_ledgers::MultiNodeVrfEpochBoundsCorrectLedger, + vrf_epoch_bounds_evaluation::MultiNodeVrfEpochBoundsEvaluation, + }, + p2p::{ + basic_connection_handling::{ + AllNodesConnectionsAreSymmetric, MaxNumberOfPeersIncoming, MaxNumberOfPeersIs1, + SeedConnectionsAreSymmetric, SimultaneousConnections, + }, + basic_incoming_connections::{AcceptIncomingConnection, AcceptMultipleIncomingConnections}, + basic_outgoing_connections::{ + ConnectToInitialPeers, ConnectToInitialPeersBecomeReady, + ConnectToUnavailableInitialPeers, DontConnectToInitialPeerWithSameId, + DontConnectToNodeWithSameId, DontConnectToSelfInitialPeer, + MakeMultipleOutgoingConnections, MakeOutgoingConnection, + }, + kademlia::KademliaBootstrap, + pubsub::P2pReceiveMessage, + signaling::P2pSignaling, + }, + record_replay::{ + block_production::RecordReplayBlockProduction, bootstrap::RecordReplayBootstrap, + }, + simulation::{small::SimulationSmall, small_forever_real_time::SimulationSmallForeverRealTime}, + solo_node::{ + basic_connectivity_accept_incoming::SoloNodeBasicConnectivityAcceptIncoming, + basic_connectivity_initial_joining::SoloNodeBasicConnectivityInitialJoining, + bootstrap::SoloNodeBootstrap, sync_root_snarked_ledger::SoloNodeSyncRootSnarkedLedger, + sync_to_genesis::SoloNodeSyncToGenesis, + sync_to_genesis_custom::SoloNodeSyncToGenesisCustom, + }, }; #[derive(EnumIter, EnumString, IntoStaticStr, derive_more::From, Clone, Copy)] diff --git a/node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs b/node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs index 0b4fe5b05e..f0abe38305 100644 --- a/node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs +++ b/node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs @@ -4,10 +4,12 @@ use std::time::Duration; use node::p2p::PeerId; -use crate::cluster::ClusterOcamlNodeId; -use crate::node::{DaemonJson, OcamlNodeTestingConfig, OcamlStep}; -use crate::scenarios::ClusterRunner; -use crate::{node::RustNodeTestingConfig, scenario::ScenarioStep}; +use crate::{ + cluster::ClusterOcamlNodeId, + node::{DaemonJson, OcamlNodeTestingConfig, OcamlStep, RustNodeTestingConfig}, + scenario::ScenarioStep, + scenarios::ClusterRunner, +}; /// Global test with OCaml nodes. /// Run an OCaml node as a seed node. Run three normal OCaml nodes connecting only to the seed node. diff --git a/node/testing/src/scenarios/multi_node/vrf_correct_ledgers.rs b/node/testing/src/scenarios/multi_node/vrf_correct_ledgers.rs index 1e4898f8a5..da7f8c36fa 100644 --- a/node/testing/src/scenarios/multi_node/vrf_correct_ledgers.rs +++ b/node/testing/src/scenarios/multi_node/vrf_correct_ledgers.rs @@ -1,8 +1,11 @@ use std::{collections::BTreeMap, str::FromStr, time::Duration}; use ledger::AccountIndex; -use node::account::{AccountPublicKey, AccountSecretKey}; -use node::{p2p::P2pTimeouts, ActionKind, BlockProducerConfig}; +use node::{ + account::{AccountPublicKey, AccountSecretKey}, + p2p::P2pTimeouts, + ActionKind, BlockProducerConfig, +}; use crate::{ node::{RustNodeBlockProducerTestingConfig, RustNodeTestingConfig}, diff --git a/node/testing/src/scenarios/multi_node/vrf_correct_slots.rs b/node/testing/src/scenarios/multi_node/vrf_correct_slots.rs index 03e5733076..1d11f52682 100644 --- a/node/testing/src/scenarios/multi_node/vrf_correct_slots.rs +++ b/node/testing/src/scenarios/multi_node/vrf_correct_slots.rs @@ -1,7 +1,7 @@ use std::{collections::BTreeMap, str::FromStr, time::Duration}; -use node::account::AccountSecretKey; use node::{ + account::AccountSecretKey, block_producer::{ vrf_evaluator::VrfEvaluationOutputWithHash, BlockProducerEvent, BlockProducerVrfEvaluatorEvent, diff --git a/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_correct_ledgers.rs b/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_correct_ledgers.rs index 98e2c1d87d..c9ff36c2b2 100644 --- a/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_correct_ledgers.rs +++ b/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_correct_ledgers.rs @@ -4,8 +4,8 @@ use ledger::AccountIndex; use mina_p2p_messages::v2::{ CurrencyFeeStableV1, UnsignedExtendedUInt64Int64ForVersionTagsStableV1, }; -use node::account::AccountSecretKey; use node::{ + account::AccountSecretKey, block_producer::vrf_evaluator::{BlockProducerVrfEvaluatorStatus, EpochContext}, p2p::P2pTimeouts, ActionKind, BlockProducerConfig, SnarkerConfig, SnarkerStrategy, diff --git a/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_evaluation.rs b/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_evaluation.rs index a126aac773..97979b185b 100644 --- a/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_evaluation.rs +++ b/node/testing/src/scenarios/multi_node/vrf_epoch_bounds_evaluation.rs @@ -3,8 +3,10 @@ use std::{str::FromStr, time::Duration}; use mina_p2p_messages::v2::{ CurrencyFeeStableV1, UnsignedExtendedUInt64Int64ForVersionTagsStableV1, }; -use node::account::AccountSecretKey; -use node::{p2p::P2pTimeouts, BlockProducerConfig, SnarkerConfig, SnarkerStrategy}; +use node::{ + account::AccountSecretKey, p2p::P2pTimeouts, BlockProducerConfig, SnarkerConfig, + SnarkerStrategy, +}; use crate::{ node::{RustNodeBlockProducerTestingConfig, RustNodeTestingConfig}, diff --git a/node/testing/src/server/mod.rs b/node/testing/src/server/mod.rs index 102c68e36d..8088498f24 100644 --- a/node/testing/src/server/mod.rs +++ b/node/testing/src/server/mod.rs @@ -1,36 +1,44 @@ pub mod simulator; pub mod webnode; -use crate::cluster::{Cluster, ClusterConfig, ClusterNodeId}; -use crate::node::NodeTestingConfig; -use crate::scenario::{event_details, Scenario, ScenarioId, ScenarioInfo, ScenarioStep}; -use crate::service::PendingEventId; - -use std::collections::BTreeSet; -use std::path::PathBuf; -use std::{collections::BTreeMap, sync::Arc, time::Duration}; - -use axum::http::header; -use axum::middleware; -use axum::routing::get_service; +use crate::{ + cluster::{Cluster, ClusterConfig, ClusterNodeId}, + node::NodeTestingConfig, + scenario::{event_details, Scenario, ScenarioId, ScenarioInfo, ScenarioStep}, + service::PendingEventId, +}; + +use std::{ + collections::{BTreeMap, BTreeSet}, + path::PathBuf, + sync::Arc, + time::Duration, +}; + use axum::{ extract::{Path, State}, - http::StatusCode, - routing::{get, post, put}, + http::{header, StatusCode}, + middleware, + routing::{get, get_service, post, put}, Json, Router, }; -use node::account::AccountPublicKey; -use node::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts; -use node::p2p::webrtc::{Host, Offer, P2pConnectionResponse, SignalingMethod}; -use node::transition_frontier::genesis::{GenesisConfig, PrebuiltGenesisConfig}; +use node::{ + account::AccountPublicKey, + p2p::{ + connection::outgoing::P2pConnectionOutgoingInitOpts, + webrtc::{Host, Offer, P2pConnectionResponse, SignalingMethod}, + }, + transition_frontier::genesis::{GenesisConfig, PrebuiltGenesisConfig}, +}; use openmina_node_native::p2p::webrtc::webrtc_signal_send; use rand::{rngs::StdRng, Rng, SeedableRng}; use serde::{Deserialize, Serialize}; -use tokio::net::TcpListener; -use tokio::runtime::Runtime; -use tokio::sync::{oneshot, Mutex, MutexGuard, OwnedMutexGuard}; -use tower_http::cors::CorsLayer; -use tower_http::services::ServeDir; +use tokio::{ + net::TcpListener, + runtime::Runtime, + sync::{oneshot, Mutex, MutexGuard, OwnedMutexGuard}, +}; +use tower_http::{cors::CorsLayer, services::ServeDir}; pub fn server(rt: Runtime, host: Host, port: u16, ssl_port: Option) { let fe_dist_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/node/testing/src/service/mod.rs b/node/testing/src/service/mod.rs index 673bc5f8cd..502745168f 100644 --- a/node/testing/src/service/mod.rs +++ b/node/testing/src/service/mod.rs @@ -1,64 +1,74 @@ mod rpc_service; -use std::collections::VecDeque; -use std::sync::Mutex as StdMutex; -use std::time::Duration; -use std::{collections::BTreeMap, sync::Arc}; - -use ledger::dummy::dummy_transaction_proof; -use ledger::proofs::transaction::ProofError; -use ledger::scan_state::scan_state::transaction_snark::SokMessage; -use ledger::scan_state::transaction_logic::{verifiable, WithStatus}; -use ledger::Mask; -use mina_p2p_messages::string::ByteString; -use mina_p2p_messages::v2::{ - CurrencyFeeStableV1, LedgerHash, LedgerProofProdStableV2, MinaBaseProofStableV2, - MinaStateSnarkedLedgerStateWithSokStableV2, NonZeroCurvePoint, - ProverExtendBlockchainInputStableV2, SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponseA0Single, - StateHash, TransactionSnarkStableV2, TransactionSnarkWorkTStableV2Proofs, +use std::{ + collections::{BTreeMap, VecDeque}, + sync::{Arc, Mutex as StdMutex}, + time::Duration, }; -use node::account::AccountPublicKey; -use node::block_producer::vrf_evaluator::VrfEvaluatorInput; -use node::block_producer::BlockProducerEvent; -use node::core::channels::mpsc; -use node::core::invariants::InvariantsState; -use node::core::snark::{Snark, SnarkJobId}; -use node::external_snark_worker_effectful::ExternalSnarkWorkerEvent; -use node::ledger::write::BlockApplyResult; -use node::p2p::service_impl::webrtc_with_libp2p::P2pServiceWebrtcWithLibp2p; -use node::p2p::P2pCryptoService; -use node::recorder::Recorder; -use node::service::{ - BlockProducerService, BlockProducerVrfEvaluatorService, TransitionFrontierGenesisService, + +use ledger::{ + dummy::dummy_transaction_proof, + proofs::transaction::ProofError, + scan_state::{ + scan_state::transaction_snark::SokMessage, + transaction_logic::{verifiable, WithStatus}, + }, + Mask, }; -use node::snark::block_verify::{ - SnarkBlockVerifyId, SnarkBlockVerifyService, VerifiableBlockWithHash, +use mina_p2p_messages::{ + string::ByteString, + v2::{ + CurrencyFeeStableV1, LedgerHash, LedgerProofProdStableV2, MinaBaseProofStableV2, + MinaStateSnarkedLedgerStateWithSokStableV2, NonZeroCurvePoint, + ProverExtendBlockchainInputStableV2, + SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponseA0Single, StateHash, + TransactionSnarkStableV2, TransactionSnarkWorkTStableV2Proofs, + }, }; -use node::snark::user_command_verify::SnarkUserCommandVerifyId; -use node::snark::user_command_verify_effectful::SnarkUserCommandVerifyService; -use node::snark::work_verify::{SnarkWorkVerifyId, SnarkWorkVerifyService}; -use node::snark::{BlockVerifier, SnarkEvent, TransactionVerifier, VerifierSRS}; -use node::snark_pool::SnarkPoolService; -use node::stats::Stats; -use node::transition_frontier::archive::archive_service::ArchiveService; -use node::transition_frontier::genesis::GenesisConfig; use node::{ + account::AccountPublicKey, + block_producer::{vrf_evaluator::VrfEvaluatorInput, BlockProducerEvent}, + core::{ + channels::mpsc, + invariants::InvariantsState, + snark::{Snark, SnarkJobId}, + }, event_source::Event, external_snark_worker::SnarkWorkSpec, - external_snark_worker_effectful::ExternalSnarkWorkerService, + external_snark_worker_effectful::{ExternalSnarkWorkerEvent, ExternalSnarkWorkerService}, + ledger::write::BlockApplyResult, p2p::{ connection::outgoing::P2pConnectionOutgoingInitOpts, - service_impl::webrtc::{Cmd, P2pServiceWebrtc, PeerState}, - webrtc, PeerId, + service_impl::{ + webrtc::{Cmd, P2pServiceWebrtc, PeerState}, + webrtc_with_libp2p::P2pServiceWebrtcWithLibp2p, + }, + webrtc, P2pCryptoService, PeerId, }, + recorder::Recorder, + service::{ + BlockProducerService, BlockProducerVrfEvaluatorService, TransitionFrontierGenesisService, + }, + snark::{ + block_verify::{SnarkBlockVerifyId, SnarkBlockVerifyService, VerifiableBlockWithHash}, + user_command_verify::SnarkUserCommandVerifyId, + user_command_verify_effectful::SnarkUserCommandVerifyService, + work_verify::{SnarkWorkVerifyId, SnarkWorkVerifyService}, + BlockVerifier, SnarkEvent, TransactionVerifier, VerifierSRS, + }, + snark_pool::SnarkPoolService, + stats::Stats, + transition_frontier::{archive::archive_service::ArchiveService, genesis::GenesisConfig}, + ActionWithMeta, State, }; -use node::{ActionWithMeta, State}; use openmina_core::channels::Aborter; use openmina_node_native::NodeService; use redux::Instant; -use crate::cluster::{ClusterNodeId, ProofKind}; -use crate::node::NonDeterministicEvent; +use crate::{ + cluster::{ClusterNodeId, ProofKind}, + node::NonDeterministicEvent, +}; pub type DynEffects = Box; diff --git a/node/web/src/lib.rs b/node/web/src/lib.rs index d5bd716b73..870512b0da 100644 --- a/node/web/src/lib.rs +++ b/node/web/src/lib.rs @@ -9,9 +9,11 @@ pub use rayon::init_rayon; mod node; pub use node::{Node, NodeBuilder}; -use ::node::account::AccountSecretKey; -use ::node::core::thread; -use ::node::snark::{BlockVerifier, TransactionVerifier}; +use ::node::{ + account::AccountSecretKey, + core::thread, + snark::{BlockVerifier, TransactionVerifier}, +}; use anyhow::Context; use gloo_utils::format::JsValueSerdeExt; use ledger::proofs::provers::BlockProver; diff --git a/p2p/libp2p-rpc-behaviour/src/behaviour.rs b/p2p/libp2p-rpc-behaviour/src/behaviour.rs index d2645c2b10..363aea2c83 100644 --- a/p2p/libp2p-rpc-behaviour/src/behaviour.rs +++ b/p2p/libp2p-rpc-behaviour/src/behaviour.rs @@ -14,12 +14,9 @@ use libp2p::{ Multiaddr, PeerId, }; -use mina_p2p_messages::rpc_kernel::{ - Error, Message, NeedsLength, Query, Response, RpcMethod, RpcResult, -}; use mina_p2p_messages::{ binprot::{self, BinProtWrite}, - rpc_kernel::RpcTag, + rpc_kernel::{Error, Message, NeedsLength, Query, Response, RpcMethod, RpcResult, RpcTag}, versioned::Ver, }; diff --git a/p2p/src/channels/mod.rs b/p2p/src/channels/mod.rs index a66b92323b..fc5f1ced3c 100644 --- a/p2p/src/channels/mod.rs +++ b/p2p/src/channels/mod.rs @@ -23,16 +23,14 @@ use binprot::{BinProtRead, BinProtWrite}; use binprot_derive::{BinProtRead, BinProtWrite}; use derive_more::From; use serde::{Deserialize, Serialize}; -use signaling::discovery::SignalingDiscoveryChannelMsg; -use signaling::exchange::SignalingExchangeChannelMsg; +use signaling::{discovery::SignalingDiscoveryChannelMsg, exchange::SignalingExchangeChannelMsg}; use strum_macros::EnumIter; -use self::best_tip::BestTipPropagationChannelMsg; -use self::rpc::RpcChannelMsg; -use self::snark::SnarkPropagationChannelMsg; -use self::snark_job_commitment::SnarkJobCommitmentPropagationChannelMsg; -use self::streaming_rpc::StreamingRpcChannelMsg; -use self::transaction::TransactionPropagationChannelMsg; +use self::{ + best_tip::BestTipPropagationChannelMsg, rpc::RpcChannelMsg, snark::SnarkPropagationChannelMsg, + snark_job_commitment::SnarkJobCommitmentPropagationChannelMsg, + streaming_rpc::StreamingRpcChannelMsg, transaction::TransactionPropagationChannelMsg, +}; #[derive(Serialize, Deserialize, EnumIter, Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Copy)] #[repr(u8)] diff --git a/p2p/src/channels/snark/p2p_channels_snark_actions.rs b/p2p/src/channels/snark/p2p_channels_snark_actions.rs index 8468d91402..0ce4b4682d 100644 --- a/p2p/src/channels/snark/p2p_channels_snark_actions.rs +++ b/p2p/src/channels/snark/p2p_channels_snark_actions.rs @@ -1,5 +1,4 @@ -use openmina_core::snark::Snark; -use openmina_core::ActionEvent; +use openmina_core::{snark::Snark, ActionEvent}; use serde::{Deserialize, Serialize}; use crate::{channels::P2pChannelsAction, P2pState, PeerId}; diff --git a/p2p/src/channels/transaction/p2p_channels_transaction_actions.rs b/p2p/src/channels/transaction/p2p_channels_transaction_actions.rs index 38650150c7..55536bb0f3 100644 --- a/p2p/src/channels/transaction/p2p_channels_transaction_actions.rs +++ b/p2p/src/channels/transaction/p2p_channels_transaction_actions.rs @@ -1,5 +1,4 @@ -use openmina_core::ActionEvent; -use openmina_core::{p2p::P2pNetworkPubsubMessageCacheId, transaction::Transaction}; +use openmina_core::{p2p::P2pNetworkPubsubMessageCacheId, transaction::Transaction, ActionEvent}; use serde::{Deserialize, Serialize}; use crate::{channels::P2pChannelsAction, P2pState, PeerId}; diff --git a/p2p/src/connection/incoming/mod.rs b/p2p/src/connection/incoming/mod.rs index 923f68a43a..affec68e65 100644 --- a/p2p/src/connection/incoming/mod.rs +++ b/p2p/src/connection/incoming/mod.rs @@ -9,8 +9,7 @@ mod p2p_connection_incoming_reducer; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; -use crate::connection::RejectionReason; -use crate::{webrtc, P2pState, PeerId}; +use crate::{connection::RejectionReason, webrtc, P2pState, PeerId}; #[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)] pub struct P2pConnectionIncomingInitOpts { diff --git a/p2p/src/connection/outgoing/mod.rs b/p2p/src/connection/outgoing/mod.rs index d80b465d9a..10ab2de996 100644 --- a/p2p/src/connection/outgoing/mod.rs +++ b/p2p/src/connection/outgoing/mod.rs @@ -6,10 +6,9 @@ pub use p2p_connection_outgoing_actions::*; mod p2p_connection_outgoing_reducer; -use std::net::IpAddr; #[cfg(feature = "p2p-libp2p")] use std::net::SocketAddr; -use std::{fmt, str::FromStr}; +use std::{fmt, net::IpAddr, str::FromStr}; use binprot_derive::{BinProtRead, BinProtWrite}; use multiaddr::{Multiaddr, Protocol}; diff --git a/p2p/src/connection/outgoing/p2p_connection_outgoing_actions.rs b/p2p/src/connection/outgoing/p2p_connection_outgoing_actions.rs index 88098fe8b0..888c60724d 100644 --- a/p2p/src/connection/outgoing/p2p_connection_outgoing_actions.rs +++ b/p2p/src/connection/outgoing/p2p_connection_outgoing_actions.rs @@ -4,8 +4,7 @@ use serde::{Deserialize, Serialize}; use openmina_core::requests::RpcId; -use crate::connection::P2pConnectionErrorResponse; -use crate::{webrtc, P2pState, PeerId}; +use crate::{connection::P2pConnectionErrorResponse, webrtc, P2pState, PeerId}; use super::{P2pConnectionOutgoingError, P2pConnectionOutgoingInitOpts}; diff --git a/p2p/src/connection/p2p_connection_state.rs b/p2p/src/connection/p2p_connection_state.rs index f3aa46c002..b83b5707ea 100644 --- a/p2p/src/connection/p2p_connection_state.rs +++ b/p2p/src/connection/p2p_connection_state.rs @@ -6,8 +6,10 @@ use serde::{Deserialize, Serialize}; use crate::P2pTimeouts; -use super::incoming::{P2pConnectionIncomingInitOpts, P2pConnectionIncomingState}; -use super::outgoing::{P2pConnectionOutgoingInitOpts, P2pConnectionOutgoingState}; +use super::{ + incoming::{P2pConnectionIncomingInitOpts, P2pConnectionIncomingState}, + outgoing::{P2pConnectionOutgoingInitOpts, P2pConnectionOutgoingState}, +}; #[derive(Serialize, Deserialize, Debug, Clone, MallocSizeOf)] #[serde(tag = "direction")] diff --git a/p2p/src/network/kad/mod.rs b/p2p/src/network/kad/mod.rs index 904d2a3db7..93ef508e7b 100644 --- a/p2p/src/network/kad/mod.rs +++ b/p2p/src/network/kad/mod.rs @@ -2,9 +2,10 @@ pub mod bootstrap; pub mod request; pub mod stream; -pub use self::bootstrap::P2pNetworkKadBootstrapAction; -pub use self::request::P2pNetworkKadRequestAction; -pub use self::stream::P2pNetworkKademliaStreamAction; +pub use self::{ + bootstrap::P2pNetworkKadBootstrapAction, request::P2pNetworkKadRequestAction, + stream::P2pNetworkKademliaStreamAction, +}; mod p2p_network_kad_state; pub use self::p2p_network_kad_state::*; diff --git a/p2p/src/network/kad/stream/mod.rs b/p2p/src/network/kad/stream/mod.rs index 64ef134dda..3d2ab3bc49 100644 --- a/p2p/src/network/kad/stream/mod.rs +++ b/p2p/src/network/kad/stream/mod.rs @@ -2,18 +2,14 @@ mod p2p_network_kad_stream_state; use redux::Callback; use serde::{Deserialize, Serialize}; -use crate::ConnectionAddr; -use crate::P2pNetworkKademliaAction; -use crate::PeerId; -use crate::StreamId; +use crate::{ConnectionAddr, P2pNetworkKademliaAction, PeerId, StreamId}; pub use self::p2p_network_kad_stream_state::*; mod p2p_network_kad_stream_actions; pub use self::p2p_network_kad_stream_actions::*; -use super::P2pNetworkKadEntry; -use super::CID; +use super::{P2pNetworkKadEntry, CID}; #[cfg(feature = "p2p-libp2p")] mod p2p_network_kad_stream_reducer; diff --git a/p2p/src/network/mod.rs b/p2p/src/network/mod.rs index a397fd9847..1dd9fad108 100644 --- a/p2p/src/network/mod.rs +++ b/p2p/src/network/mod.rs @@ -1,7 +1,6 @@ mod p2p_network_actions; use malloc_size_of_derive::MallocSizeOf; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use crate::Limit; diff --git a/p2p/src/network/noise/p2p_network_noise_reducer.rs b/p2p/src/network/noise/p2p_network_noise_reducer.rs index a08d864c8f..356d88405c 100644 --- a/p2p/src/network/noise/p2p_network_noise_reducer.rs +++ b/p2p/src/network/noise/p2p_network_noise_reducer.rs @@ -2,8 +2,8 @@ use chacha20poly1305::{aead::generic_array::GenericArray, AeadInPlace, ChaCha20P use crypto_bigint::consts::U12; use openmina_core::{bug_condition, fuzzed_maybe, Substate}; -use crate::connection::incoming::{P2pConnectionIncomingAction, P2pConnectionIncomingState}; use crate::{ + connection::incoming::{P2pConnectionIncomingAction, P2pConnectionIncomingState}, Data, P2pNetworkConnectionError, P2pNetworkPnetAction, P2pNetworkSchedulerAction, P2pNetworkSchedulerState, P2pNetworkSelectAction, P2pState, PeerId, SelectKind, }; diff --git a/p2p/src/network/pnet_effectful/p2p_network_pnet_effectful_effects.rs b/p2p/src/network/pnet_effectful/p2p_network_pnet_effectful_effects.rs index 8784011eba..99c45d3c07 100644 --- a/p2p/src/network/pnet_effectful/p2p_network_pnet_effectful_effects.rs +++ b/p2p/src/network/pnet_effectful/p2p_network_pnet_effectful_effects.rs @@ -1,8 +1,7 @@ use openmina_core::fuzzed_maybe; use super::P2pNetworkPnetEffectfulAction; -use crate::P2pMioService; -use crate::{P2pNetworkSelectAction, SelectKind}; +use crate::{P2pMioService, P2pNetworkSelectAction, SelectKind}; impl P2pNetworkPnetEffectfulAction { pub fn effects(self, _meta: &redux::ActionMeta, store: &mut Store) diff --git a/p2p/src/p2p_actions.rs b/p2p/src/p2p_actions.rs index 01198c02ed..70c5a11b4a 100644 --- a/p2p/src/p2p_actions.rs +++ b/p2p/src/p2p_actions.rs @@ -2,18 +2,16 @@ use openmina_macros::ActionEvent; use redux::EnablingCondition; use serde::{Deserialize, Serialize}; -use crate::channels::P2pChannelsEffectfulAction; -use crate::connection::P2pConnectionEffectfulAction; -use crate::disconnection_effectful::P2pDisconnectionEffectfulAction; -use crate::P2pNetworkEffectfulAction; +use crate::{ + channels::P2pChannelsEffectfulAction, connection::P2pConnectionEffectfulAction, + disconnection_effectful::P2pDisconnectionEffectfulAction, P2pNetworkEffectfulAction, +}; -use super::channels::P2pChannelsAction; -use super::connection::P2pConnectionAction; -use super::disconnection::P2pDisconnectionAction; -use super::identify::P2pIdentifyAction; -use super::network::P2pNetworkAction; -use super::peer::P2pPeerAction; -use super::P2pState; +use super::{ + channels::P2pChannelsAction, connection::P2pConnectionAction, + disconnection::P2pDisconnectionAction, identify::P2pIdentifyAction, network::P2pNetworkAction, + peer::P2pPeerAction, P2pState, +}; #[derive(Serialize, Deserialize, Debug, Clone, derive_more::From, ActionEvent)] pub enum P2pAction { diff --git a/p2p/src/p2p_event.rs b/p2p/src/p2p_event.rs index f1d2d54cf5..c51aee5fd7 100644 --- a/p2p/src/p2p_event.rs +++ b/p2p/src/p2p_event.rs @@ -1,18 +1,23 @@ -use std::fmt; -use std::net::{IpAddr, SocketAddr}; +use std::{ + fmt, + net::{IpAddr, SocketAddr}, +}; use derive_more::From; use serde::{Deserialize, Serialize}; -use crate::channels::signaling::discovery::SignalingDiscoveryChannelMsg; -use crate::channels::signaling::exchange::SignalingExchangeChannelMsg; -use crate::channels::streaming_rpc::StreamingRpcChannelMsg; -use crate::webrtc::ConnectionAuthEncrypted; -use crate::ConnectionAddr; use crate::{ - channels::{transaction::TransactionPropagationChannelMsg, ChannelId, ChannelMsg, MsgId}, + channels::{ + signaling::{ + discovery::SignalingDiscoveryChannelMsg, exchange::SignalingExchangeChannelMsg, + }, + streaming_rpc::StreamingRpcChannelMsg, + transaction::TransactionPropagationChannelMsg, + ChannelId, ChannelMsg, MsgId, + }, connection::P2pConnectionResponse, - PeerId, + webrtc::ConnectionAuthEncrypted, + ConnectionAddr, PeerId, }; #[derive(Serialize, Deserialize, From, Debug, Clone)] @@ -123,10 +128,11 @@ impl fmt::Display for P2pConnectionEvent { impl fmt::Display for P2pChannelEvent { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use crate::channels::best_tip::BestTipPropagationChannelMsg; - use crate::channels::rpc::RpcChannelMsg; - use crate::channels::snark::SnarkPropagationChannelMsg; - use crate::channels::snark_job_commitment::SnarkJobCommitmentPropagationChannelMsg; + use crate::channels::{ + best_tip::BestTipPropagationChannelMsg, rpc::RpcChannelMsg, + snark::SnarkPropagationChannelMsg, + snark_job_commitment::SnarkJobCommitmentPropagationChannelMsg, + }; write!(f, "Channel, ")?; match self { diff --git a/p2p/src/p2p_service.rs b/p2p/src/p2p_service.rs index 880dc5766e..e4e629072b 100644 --- a/p2p/src/p2p_service.rs +++ b/p2p/src/p2p_service.rs @@ -1,8 +1,9 @@ pub use redux::TimeService; -pub use crate::channels::P2pChannelsService; -pub use crate::connection::P2pConnectionService; -pub use crate::disconnection_effectful::P2pDisconnectionService; +pub use crate::{ + channels::P2pChannelsService, connection::P2pConnectionService, + disconnection_effectful::P2pDisconnectionService, +}; #[cfg(all(not(target_arch = "wasm32"), feature = "p2p-libp2p"))] pub use crate::{P2pCryptoService, P2pMioService, P2pNetworkService}; diff --git a/p2p/src/service_impl/webrtc/mod.rs b/p2p/src/service_impl/webrtc/mod.rs index 6cb4df4ebe..b50058c1fa 100644 --- a/p2p/src/service_impl/webrtc/mod.rs +++ b/p2p/src/service_impl/webrtc/mod.rs @@ -5,10 +5,7 @@ mod webrtc_cpp; #[cfg(all(not(target_arch = "wasm32"), feature = "p2p-webrtc-rs"))] mod webrtc_rs; -use std::future::Future; -use std::pin::Pin; -use std::sync::Arc; -use std::{collections::BTreeMap, time::Duration}; +use std::{collections::BTreeMap, future::Future, pin::Pin, sync::Arc, time::Duration}; use openmina_core::bug_condition; use serde::Serialize; @@ -21,13 +18,13 @@ use wasm_bindgen_futures::spawn_local; use openmina_core::channels::{mpsc, oneshot, Aborted, Aborter}; -use crate::identity::{EncryptableType, PublicKey}; -use crate::webrtc::{ConnectionAuth, ConnectionAuthEncrypted}; use crate::{ channels::{ChannelId, ChannelMsg, MsgId}, connection::outgoing::P2pConnectionOutgoingInitOpts, - identity::SecretKey, - webrtc, P2pChannelEvent, P2pConnectionEvent, P2pEvent, PeerId, + identity::{EncryptableType, PublicKey, SecretKey}, + webrtc, + webrtc::{ConnectionAuth, ConnectionAuthEncrypted}, + P2pChannelEvent, P2pConnectionEvent, P2pEvent, PeerId, }; #[cfg(all(not(target_arch = "wasm32"), feature = "p2p-webrtc-rs"))] diff --git a/p2p/src/service_impl/webrtc/web.rs b/p2p/src/service_impl/webrtc/web.rs index 17a9627987..032078a7bc 100644 --- a/p2p/src/service_impl/webrtc/web.rs +++ b/p2p/src/service_impl/webrtc/web.rs @@ -1,6 +1,8 @@ -use std::future::Future; -use std::rc::{Rc, Weak}; -use std::sync::Once; +use std::{ + future::Future, + rc::{Rc, Weak}, + sync::Once, +}; use gloo_utils::format::JsValueSerdeExt; use wasm_bindgen::{convert::FromWasmAbi, prelude::*}; diff --git a/p2p/src/service_impl/webrtc/webrtc_rs.rs b/p2p/src/service_impl/webrtc/webrtc_rs.rs index aaf7b7826e..ce87ed9be4 100644 --- a/p2p/src/service_impl/webrtc/webrtc_rs.rs +++ b/p2p/src/service_impl/webrtc/webrtc_rs.rs @@ -1,5 +1,4 @@ -use std::future::Future; -use std::sync::Arc; +use std::{future::Future, sync::Arc}; use webrtc::{ api::APIBuilder, diff --git a/p2p/testing/src/cluster.rs b/p2p/testing/src/cluster.rs index 9740e06bbd..cb4a647916 100644 --- a/p2p/testing/src/cluster.rs +++ b/p2p/testing/src/cluster.rs @@ -8,8 +8,7 @@ use std::{ use futures::StreamExt; use libp2p::{multiaddr::multiaddr, swarm::DialError, Multiaddr}; -use openmina_core::channels::mpsc; -use openmina_core::{ChainId, Substate, DEVNET_CHAIN_ID}; +use openmina_core::{channels::mpsc, ChainId, Substate, DEVNET_CHAIN_ID}; use p2p::{ connection::outgoing::{ P2pConnectionOutgoingAction, P2pConnectionOutgoingInitLibp2pOpts, @@ -23,8 +22,7 @@ use redux::SystemTime; use crate::{ event::{event_mapper_effect, RustNodeEvent}, libp2p_node::{create_swarm, Libp2pEvent, Libp2pNode, Libp2pNodeConfig, Libp2pNodeId}, - redux::State, - redux::{log_action, Action}, + redux::{log_action, Action, State}, rust_node::{RustNode, RustNodeConfig, RustNodeId}, service::ClusterService, stream::{ClusterStreamExt, MapErrors, TakeDuring}, diff --git a/p2p/testing/src/test_node.rs b/p2p/testing/src/test_node.rs index ad1ed61c18..3ce1e1e862 100644 --- a/p2p/testing/src/test_node.rs +++ b/p2p/testing/src/test_node.rs @@ -1,7 +1,6 @@ use std::net::IpAddr; -use libp2p::multiaddr::multiaddr; -use libp2p::Multiaddr; +use libp2p::{multiaddr::multiaddr, Multiaddr}; use p2p::{ connection::outgoing::{P2pConnectionOutgoingInitLibp2pOpts, P2pConnectionOutgoingInitOpts}, PeerId, diff --git a/producer-dashboard/src/evaluator/mod.rs b/producer-dashboard/src/evaluator/mod.rs index 57e8c3d0ac..3a45bfb159 100644 --- a/producer-dashboard/src/evaluator/mod.rs +++ b/producer-dashboard/src/evaluator/mod.rs @@ -2,8 +2,7 @@ use std::str::FromStr; use mina_p2p_messages::v2::EpochSeed; use openmina_node_account::AccountSecretKey; -use tokio::sync::mpsc::UnboundedReceiver; -use tokio::task::JoinHandle; +use tokio::{sync::mpsc::UnboundedReceiver, task::JoinHandle}; use vrf::{VrfEvaluationInput, VrfEvaluationOutput}; use crate::{ diff --git a/producer-dashboard/src/node/epoch_ledgers.rs b/producer-dashboard/src/node/epoch_ledgers.rs index 2656232824..22a6c2643e 100644 --- a/producer-dashboard/src/node/epoch_ledgers.rs +++ b/producer-dashboard/src/node/epoch_ledgers.rs @@ -4,8 +4,7 @@ use std::{ }; use num_bigint::BigInt; -use num_traits::identities::Zero; -use num_traits::FromPrimitive; +use num_traits::{identities::Zero, FromPrimitive}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::str::FromStr; diff --git a/producer-dashboard/src/node/watchdog.rs b/producer-dashboard/src/node/watchdog.rs index 90370b116a..bea232ae49 100644 --- a/producer-dashboard/src/node/watchdog.rs +++ b/producer-dashboard/src/node/watchdog.rs @@ -1,11 +1,8 @@ -use tokio::time::Duration; -use tokio::{sync::mpsc::UnboundedSender, task::JoinHandle}; +use tokio::{sync::mpsc::UnboundedSender, task::JoinHandle, time::Duration}; -use crate::evaluator::EpochInit; -use crate::{storage::db_sled::Database, NodeStatus}; +use crate::{evaluator::EpochInit, storage::db_sled::Database, NodeStatus}; -use super::daemon_status::SyncStatus; -use super::Node; +use super::{daemon_status::SyncStatus, Node}; // TODO(adonagy): move to struct pub fn spawn_watchdog( diff --git a/snark/src/lib.rs b/snark/src/lib.rs index 100a4574e7..ebe3be3d55 100644 --- a/snark/src/lib.rs +++ b/snark/src/lib.rs @@ -2,10 +2,10 @@ use kimchi::mina_curves::pasta::Vesta; mod merkle_path; -pub use ledger::proofs::caching::{ - srs_from_bytes, srs_to_bytes, verifier_index_from_bytes, verifier_index_to_bytes, +pub use ledger::proofs::{ + caching::{srs_from_bytes, srs_to_bytes, verifier_index_from_bytes, verifier_index_to_bytes}, + verifiers::{BlockVerifier, TransactionVerifier}, }; -pub use ledger::proofs::verifiers::{BlockVerifier, TransactionVerifier}; pub use merkle_path::calc_merkle_root_hash; diff --git a/snark/src/snark_actions.rs b/snark/src/snark_actions.rs index 702e8759b1..dc17f5f155 100644 --- a/snark/src/snark_actions.rs +++ b/snark/src/snark_actions.rs @@ -1,12 +1,13 @@ use serde::{Deserialize, Serialize}; -use crate::block_verify_effectful::SnarkBlockVerifyEffectfulAction; -use crate::user_command_verify::SnarkUserCommandVerifyAction; -use crate::user_command_verify_effectful::SnarkUserCommandVerifyEffectfulAction; -use crate::work_verify_effectful::SnarkWorkVerifyEffectfulAction; +use crate::{ + block_verify_effectful::SnarkBlockVerifyEffectfulAction, + user_command_verify::SnarkUserCommandVerifyAction, + user_command_verify_effectful::SnarkUserCommandVerifyEffectfulAction, + work_verify_effectful::SnarkWorkVerifyEffectfulAction, +}; -use super::block_verify::SnarkBlockVerifyAction; -use super::work_verify::SnarkWorkVerifyAction; +use super::{block_verify::SnarkBlockVerifyAction, work_verify::SnarkWorkVerifyAction}; pub type SnarkActionWithMeta = redux::ActionWithMeta; pub type SnarkActionWithMetaRef<'a> = redux::ActionWithMeta<&'a SnarkAction>; diff --git a/snark/src/snark_event.rs b/snark/src/snark_event.rs index bf24a5e477..aeb62ad145 100644 --- a/snark/src/snark_event.rs +++ b/snark/src/snark_event.rs @@ -1,8 +1,10 @@ use ledger::scan_state::transaction_logic::valid; use serde::{Deserialize, Serialize}; -use super::block_verify::{SnarkBlockVerifyError, SnarkBlockVerifyId}; -use super::work_verify::{SnarkWorkVerifyError, SnarkWorkVerifyId}; +use super::{ + block_verify::{SnarkBlockVerifyError, SnarkBlockVerifyId}, + work_verify::{SnarkWorkVerifyError, SnarkWorkVerifyId}, +}; use crate::user_command_verify::SnarkUserCommandVerifyId; #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/snark/src/snark_state.rs b/snark/src/snark_state.rs index 24e110475d..e5f8c38fe3 100644 --- a/snark/src/snark_state.rs +++ b/snark/src/snark_state.rs @@ -1,10 +1,8 @@ use serde::{Deserialize, Serialize}; -use crate::user_command_verify::SnarkUserCommandVerifyState; -use crate::SnarkConfig; +use crate::{user_command_verify::SnarkUserCommandVerifyState, SnarkConfig}; -use super::block_verify::SnarkBlockVerifyState; -use super::work_verify::SnarkWorkVerifyState; +use super::{block_verify::SnarkBlockVerifyState, work_verify::SnarkWorkVerifyState}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SnarkState { diff --git a/snark/src/work_verify/snark_work_verify_state.rs b/snark/src/work_verify/snark_work_verify_state.rs index cdd7f7eb1c..4ee887a4dc 100644 --- a/snark/src/work_verify/snark_work_verify_state.rs +++ b/snark/src/work_verify/snark_work_verify_state.rs @@ -2,8 +2,10 @@ use std::sync::Arc; use serde::{Deserialize, Serialize}; -use openmina_core::snark::Snark; -use openmina_core::{requests::PendingRequests, snark::SnarkJobId}; +use openmina_core::{ + requests::PendingRequests, + snark::{Snark, SnarkJobId}, +}; use crate::{TransactionVerifier, VerifierSRS}; diff --git a/tools/fuzzing/src/main.rs b/tools/fuzzing/src/main.rs index 3fa13fa44e..43bde9859c 100644 --- a/tools/fuzzing/src/main.rs +++ b/tools/fuzzing/src/main.rs @@ -26,10 +26,10 @@ pub mod transaction_fuzzer { use mina_hasher::Fp; use mina_p2p_messages::bigint::BigInt; use openmina_core::constants::ConstraintConstantsUnversioned; - use std::io::{Read, Write}; - use std::panic; use std::{ env, + io::{Read, Write}, + panic, process::{ChildStdin, ChildStdout}, }; diff --git a/tools/fuzzing/src/transaction_fuzzer/context.rs b/tools/fuzzing/src/transaction_fuzzer/context.rs index 0ae131484b..f9b6edc4e2 100644 --- a/tools/fuzzing/src/transaction_fuzzer/context.rs +++ b/tools/fuzzing/src/transaction_fuzzer/context.rs @@ -1,34 +1,34 @@ use crate::transaction_fuzzer::{ + deserialize, generator::{Generator, GeneratorRange32, GeneratorRange64}, mutator::Mutator, - {deserialize, serialize}, -}; -use ark_ff::fields::arithmetic::InvalidBigInt; -use ark_ff::Zero; -use ledger::scan_state::transaction_logic::transaction_applied::{ - signed_command_applied, CommandApplied, TransactionApplied, Varying, -}; -use ledger::scan_state::transaction_logic::{ - apply_transactions, Transaction, TransactionStatus, UserCommand, -}; -use ledger::sparse_ledger::LedgerIntf; -use ledger::staged_ledger::staged_ledger::StagedLedger; -use ledger::{dummy, Account, AccountId, Database, Mask, Timing, TokenId}; -use ledger::{ - scan_state::currency::{Amount, Fee, Length, Magnitude, Nonce, Signed, Slot}, - transaction_pool::TransactionPool, + serialize, }; +use ark_ff::{fields::arithmetic::InvalidBigInt, Zero}; use ledger::{ - scan_state::transaction_logic::protocol_state::{ - protocol_state_view, EpochData, EpochLedger, ProtocolStateView, + dummy, + scan_state::{ + currency::{Amount, Fee, Length, Magnitude, Nonce, Signed, Slot}, + transaction_logic::{ + apply_transactions, + protocol_state::{protocol_state_view, EpochData, EpochLedger, ProtocolStateView}, + transaction_applied::{ + signed_command_applied, CommandApplied, TransactionApplied, Varying, + }, + Transaction, TransactionStatus, UserCommand, + }, }, + sparse_ledger::LedgerIntf, + staged_ledger::staged_ledger::StagedLedger, transaction_pool, + transaction_pool::TransactionPool, + Account, AccountId, Database, Mask, Timing, TokenId, }; use mina_curves::pasta::Fq; use mina_hasher::Fp; -use mina_p2p_messages::binprot::SmallString1k; use mina_p2p_messages::{ bigint, binprot, + binprot::SmallString1k, v2::{ MinaTransactionLogicTransactionAppliedStableV2, TransactionSnarkScanStateLedgerProofWithSokMessageStableV2, @@ -39,9 +39,12 @@ use node::DEVNET_CONFIG; use openmina_core::{consensus::ConsensusConstants, constants::ConstraintConstants, NetworkConfig}; use rand::{rngs::SmallRng, seq::SliceRandom, Rng, SeedableRng}; use ring_buffer::RingBuffer; -use std::collections::{BTreeMap, HashMap}; -use std::fmt::Debug; -use std::{fs, str::FromStr}; +use std::{ + collections::{BTreeMap, HashMap}, + fmt::Debug, + fs, + str::FromStr, +}; // Taken from ocaml_tests /// Same values when we run `dune runtest src/lib/staged_ledger -f` diff --git a/tools/fuzzing/src/transaction_fuzzer/coverage/reports.rs b/tools/fuzzing/src/transaction_fuzzer/coverage/reports.rs index 35f10cc30e..4f52914f55 100644 --- a/tools/fuzzing/src/transaction_fuzzer/coverage/reports.rs +++ b/tools/fuzzing/src/transaction_fuzzer/coverage/reports.rs @@ -1,8 +1,10 @@ use super::cov::FileDump; use itertools::Itertools; -use std::fs::File; -use std::io::{BufRead, BufReader, Write}; -use std::{env, fmt, fs}; +use std::{ + env, fmt, fs, + fs::File, + io::{BufRead, BufReader, Write}, +}; //#[derive(Debug, Clone, Serialize)] pub struct LineCounter { diff --git a/tools/fuzzing/src/transaction_fuzzer/coverage/util.rs b/tools/fuzzing/src/transaction_fuzzer/coverage/util.rs index 977a9c6af0..e3ef796c7e 100644 --- a/tools/fuzzing/src/transaction_fuzzer/coverage/util.rs +++ b/tools/fuzzing/src/transaction_fuzzer/coverage/util.rs @@ -1,8 +1,7 @@ use core::slice; use std::{ collections::HashMap, - io::Read, - io::{Cursor, Seek, SeekFrom}, + io::{Cursor, Read, Seek, SeekFrom}, path::Path, }; diff --git a/tools/fuzzing/src/transaction_fuzzer/generator.rs b/tools/fuzzing/src/transaction_fuzzer/generator.rs index 9989cdd47d..3fc2ec53d0 100644 --- a/tools/fuzzing/src/transaction_fuzzer/generator.rs +++ b/tools/fuzzing/src/transaction_fuzzer/generator.rs @@ -1,18 +1,16 @@ -use ark_ec::AffineCurve; -use ark_ec::ProjectiveCurve; -use ark_ff::SquareRootField; -use ark_ff::{Field, UniformRand}; -use ledger::generators::zkapp_command_builder::get_transaction_commitments; -use ledger::proofs::field::GroupAffine; -use ledger::proofs::transaction::InnerCurve; -use ledger::scan_state::currency::TxnVersion; -use ledger::scan_state::currency::{Magnitude, SlotSpan}; -use ledger::MutableFp; -use ledger::VerificationKeyWire; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::{Field, SquareRootField, UniformRand}; use ledger::{ - proofs::transaction::PlonkVerificationKeyEvals, + generators::zkapp_command_builder::get_transaction_commitments, + proofs::{ + field::GroupAffine, + transaction::{InnerCurve, PlonkVerificationKeyEvals}, + }, scan_state::{ - currency::{Amount, Balance, BlockTime, Fee, Length, MinMax, Nonce, Sgn, Signed, Slot}, + currency::{ + Amount, Balance, BlockTime, Fee, Length, Magnitude, MinMax, Nonce, Sgn, Signed, Slot, + SlotSpan, TxnVersion, + }, transaction_logic::{ signed_command::{ self, PaymentPayload, SignedCommand, SignedCommandPayload, StakeDelegationPayload, @@ -26,20 +24,14 @@ use ledger::{ Memo, Transaction, UserCommand, }, }, - Account, AuthRequired, Permissions, ProofVerified, TokenId, TokenSymbol, VerificationKey, - VotingFor, ZkAppUri, + Account, AuthRequired, MutableFp, Permissions, ProofVerified, SetVerificationKey, TokenId, + TokenSymbol, VerificationKey, VerificationKeyWire, VotingFor, ZkAppUri, TXN_VERSION_CURRENT, }; -use ledger::{SetVerificationKey, TXN_VERSION_CURRENT}; use mina_curves::pasta::Fq; use mina_hasher::Fp; -use mina_p2p_messages::array::ArrayN; -use mina_p2p_messages::list::List; -use mina_p2p_messages::v2::{ - PicklesProofProofsVerified2ReprStableV2StatementProofStateDeferredValuesPlonk, - PicklesWrapWireProofCommitmentsStableV1, PicklesWrapWireProofEvaluationsStableV1, - PicklesWrapWireProofStableV1, PicklesWrapWireProofStableV1Bulletproof, -}; use mina_p2p_messages::{ + array::ArrayN, + list::List, number::Number, pseq::PaddedSeq, v2::{ @@ -62,20 +54,22 @@ use mina_p2p_messages::{ PicklesProofProofsVerified2ReprStableV2StatementFp, PicklesProofProofsVerified2ReprStableV2StatementProofState, PicklesProofProofsVerified2ReprStableV2StatementProofStateDeferredValues, + PicklesProofProofsVerified2ReprStableV2StatementProofStateDeferredValuesPlonk, PicklesProofProofsVerified2ReprStableV2StatementProofStateDeferredValuesPlonkFeatureFlags, PicklesProofProofsVerifiedMaxStableV2, PicklesReducedMessagesForNextProofOverSameFieldWrapChallengesVectorStableV2, PicklesReducedMessagesForNextProofOverSameFieldWrapChallengesVectorStableV2A, PicklesReducedMessagesForNextProofOverSameFieldWrapChallengesVectorStableV2AChallenge, - SgnStableV1, SignedAmount, TokenFeeExcess, TokenIdKeyHash, UnsignedExtendedUInt32StableV1, + PicklesWrapWireProofCommitmentsStableV1, PicklesWrapWireProofEvaluationsStableV1, + PicklesWrapWireProofStableV1, PicklesWrapWireProofStableV1Bulletproof, SgnStableV1, + SignedAmount, TokenFeeExcess, TokenIdKeyHash, UnsignedExtendedUInt32StableV1, UnsignedExtendedUInt64Int64ForVersionTagsStableV1, }, }; use mina_signer::{ CompressedPubKey, CurvePoint, Keypair, NetworkId, ScalarField, SecKey, Signature, Signer, }; -use rand::seq::SliceRandom; -use rand::Rng; +use rand::{seq::SliceRandom, Rng}; use std::{array, iter, ops::RangeInclusive, sync::Arc}; use tuple_map::TupleMap2; diff --git a/tools/heartbeats-processor/src/local_db.rs b/tools/heartbeats-processor/src/local_db.rs index f5603e5077..426117851c 100644 --- a/tools/heartbeats-processor/src/local_db.rs +++ b/tools/heartbeats-processor/src/local_db.rs @@ -4,13 +4,16 @@ use firestore::FirestoreDb; use serde::Serialize; use sqlx::{Row, SqlitePool}; -use std::collections::{HashMap, HashSet}; -use std::fs; - -use crate::config::Config; -use crate::remote_db::BlockInfo; -use crate::remote_db::HeartbeatChunkState; -use crate::time::*; +use std::{ + collections::{HashMap, HashSet}, + fs, +}; + +use crate::{ + config::Config, + remote_db::{BlockInfo, HeartbeatChunkState}, + time::*, +}; use mina_tree::proofs::verification::verify_block; #[derive(Debug)] diff --git a/tools/transport/src/lib.rs b/tools/transport/src/lib.rs index ed6e9cfe0e..08522b4c04 100644 --- a/tools/transport/src/lib.rs +++ b/tools/transport/src/lib.rs @@ -1,12 +1,12 @@ #![forbid(unsafe_code)] pub use libp2p::identity::{ed25519, Keypair}; -use libp2p::swarm::NetworkBehaviour; -use libp2p::Swarm; -use libp2p::{core::upgrade, noise, pnet, tcp, yamux, Transport}; use libp2p::{ + core::upgrade, futures::{AsyncRead, AsyncWrite}, - identity, Multiaddr, SwarmBuilder, + identity, noise, pnet, + swarm::NetworkBehaviour, + tcp, yamux, Multiaddr, Swarm, SwarmBuilder, Transport, }; pub use libp2p::futures; diff --git a/vrf/src/output.rs b/vrf/src/output.rs index 6d92ee1a23..c758f24b1f 100644 --- a/vrf/src/output.rs +++ b/vrf/src/output.rs @@ -1,7 +1,6 @@ use ark_ec::short_weierstrass_jacobian::GroupAffine; use ark_ff::{BigInteger, BigInteger256, PrimeField}; -use ledger::proofs::transaction::field_to_bits; -use ledger::{AppendToInputs, ToInputs}; +use ledger::{proofs::transaction::field_to_bits, AppendToInputs, ToInputs}; use mina_p2p_messages::v2::ConsensusVrfOutputTruncatedStableV1; use num::{BigInt, BigRational, One, ToPrimitive}; use o1_utils::FieldHelpers; @@ -13,8 +12,7 @@ use crate::{BaseField, BigInt2048, ScalarField}; use super::serialize::{ark_deserialize, ark_serialize}; -use super::message::VrfMessage; -use super::CurvePoint; +use super::{message::VrfMessage, CurvePoint}; #[derive(Clone, Debug)] pub struct VrfOutputHashInput {