Skip to content

Commit

Permalink
Refactor Makefile to enable release and concurrent flags (#435)
Browse files Browse the repository at this point in the history
* Updated makefile

* Updated CI

* Added concurrent and testing flags

* Fixed flaky tests

* Fixed CI
  • Loading branch information
phklive authored Jan 25, 2024
1 parent dcbf6f6 commit 38cc253
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
args: [--release --features testing]
args: [--release --features concurrent testing]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ watch:
cargo watch -w miden-lib/asm -x build

test:
cargo test --features testing
cargo test --release --features concurrent testing
4 changes: 2 additions & 2 deletions mock/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use miden_objects::{
accounts::{AccountId, AccountType, SlotItem, StorageSlotType},
accounts::{get_account_seed_single, AccountId, AccountType, SlotItem, StorageSlotType},
assets::{Asset, NonFungibleAsset, NonFungibleAssetDetails},
Felt, FieldElement, Word, ZERO,
};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn generate_account_seed(account_seed_type: AccountSeedType) -> (AccountId,
),
};

let seed = AccountId::get_account_seed(
let seed = get_account_seed_single(
init_seed,
account_type,
true,
Expand Down
2 changes: 1 addition & 1 deletion objects/src/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod delta;
pub use delta::{AccountDelta, AccountStorageDelta, AccountVaultDelta};

mod seed;
pub use seed::get_account_seed;
pub use seed::{get_account_seed, get_account_seed_single};

mod storage;
pub use storage::{AccountStorage, SlotItem, StorageSlotType};
Expand Down
16 changes: 13 additions & 3 deletions objects/src/accounts/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{compute_digest, AccountError, AccountId, AccountType, Digest, Felt,
// --------------------------------------------------------------------------------------------

/// Finds and returns a seed suitable for creating an account ID for the specified account type
/// using the provided initial seed as a starting point.
/// using the provided initial seed as a starting point. Using multi-threading.
#[cfg(feature = "concurrent")]
pub fn get_account_seed(
init_seed: [u8; 32],
Expand Down Expand Up @@ -114,15 +114,25 @@ pub fn get_account_seed_inner(
}
}

/// Finds and returns a seed suitable for creating an account ID for the specified account type
/// using the provided initial seed as a starting point.
#[cfg(not(feature = "concurrent"))]
pub fn get_account_seed(
init_seed: [u8; 32],
account_type: AccountType,
on_chain: bool,
code_root: Digest,
storage_root: Digest,
) -> Result<Word, AccountError> {
get_account_seed_single(init_seed, account_type, on_chain, code_root, storage_root)
}

/// Finds and returns a seed suitable for creating an account ID for the specified account type
/// using the provided initial seed as a starting point. Using a single thread.
pub fn get_account_seed_single(
init_seed: [u8; 32],
account_type: AccountType,
on_chain: bool,
code_root: Digest,
storage_root: Digest,
) -> Result<Word, AccountError> {
let init_seed: Vec<[u8; 8]> =
init_seed.chunks(8).map(|chunk| chunk.try_into().unwrap()).collect();
Expand Down

0 comments on commit 38cc253

Please sign in to comment.