Skip to content

Commit

Permalink
chore: fix winterfell deprecations and no-std build setup (#533)
Browse files Browse the repository at this point in the history
* fix: use of deprecated apis in miden-mock
* fix: use of deprecated apis in miden-objects
* fix: use of deprecated apis in miden-tx
* fix: use of deprecated apis in miden-lib
  • Loading branch information
bitwalker authored Mar 21, 2024
1 parent 1c5f2b5 commit 2922568
Show file tree
Hide file tree
Showing 61 changed files with 209 additions and 126 deletions.
12 changes: 10 additions & 2 deletions miden-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ rust-version = "1.75"
[features]
concurrent = ["miden-objects/concurrent", "std"]
default = ["std"]
std = ["assembly/std", "miden-objects/std", "miden-stdlib/std", "vm-processor/std"]
std = [
"assembly/std",
"miden-objects/std",
"miden-stdlib/std",
"vm-processor/std",
"mock/std",
]
# the testing feature is required to enable the account creation pow patch
testing = ["miden-objects/testing"]

Expand All @@ -25,7 +31,9 @@ miden-objects = { package = "miden-objects", path = "../objects", version = "0.2
miden-stdlib = { workspace = true }

[dev-dependencies]
miden-objects = { package = "miden-objects", path = "../objects", version = "0.2", default-features = false, features = ["testing"]}
miden-objects = { package = "miden-objects", path = "../objects", version = "0.2", default-features = false, features = [
"testing",
] }
mock = { package = "miden-mock", path = "../mock", default-features = false }
vm-processor = { workspace = true, features = ["internals"] }

Expand Down
3 changes: 2 additions & 1 deletion miden-lib/src/accounts/faucets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::string::ToString;

use miden_objects::{
accounts::{
Account, AccountCode, AccountId, AccountStorage, AccountType, SlotItem, StorageSlot,
Expand All @@ -8,7 +10,6 @@ use miden_objects::{
};

use super::{AuthScheme, Library, MidenLib, TransactionKernel};
use crate::utils::{string::*, vec};

// FUNGIBLE FAUCET
// ================================================================================================
Expand Down
4 changes: 2 additions & 2 deletions miden-lib/src/accounts/wallets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use alloc::string::{String, ToString};

use miden_objects::{
accounts::{Account, AccountCode, AccountId, AccountStorage, AccountType, StorageSlot},
assembly::ModuleAst,
assets::AssetVault,
utils::format,
AccountError, Word, ZERO,
};

use super::{AuthScheme, TransactionKernel};
use crate::utils::{string::*, vec};

// BASIC WALLET
// ================================================================================================
Expand Down
9 changes: 6 additions & 3 deletions miden-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]

#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

use miden_objects::{
assembly::{Library, LibraryNamespace, MaslLibrary, Version},
utils::serde::Deserializable,
Expand All @@ -15,7 +18,7 @@ pub mod accounts;
pub mod notes;
pub mod transaction;

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod tests;

// RE-EXPORTS
Expand Down
5 changes: 3 additions & 2 deletions miden-lib/src/notes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::vec::Vec;

use miden_objects::{
accounts::AccountId, assets::Asset, crypto::rand::FeltRng, notes::Note, utils::collections::*,
Felt, NoteError, Word,
accounts::AccountId, assets::Asset, crypto::rand::FeltRng, notes::Note, Felt, NoteError, Word,
};

use self::utils::build_note_script;
Expand Down
3 changes: 2 additions & 1 deletion miden-lib/src/tests/test_note.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use alloc::{collections::BTreeMap, string::String};

use miden_objects::{
notes::Note,
transaction::{PreparedTransaction, TransactionArgs},
utils::collections::*,
WORD_SIZE,
};
use mock::{
Expand Down
2 changes: 2 additions & 0 deletions miden-lib/src/tests/test_tx.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_objects::{
notes::Note,
transaction::{OutputNote, OutputNotes},
Expand Down
3 changes: 2 additions & 1 deletion miden-lib/src/transaction/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::string::String;
use core::fmt;

use miden_objects::{accounts::AccountStorage, utils::string::*, AssetError, Digest};
use miden_objects::{accounts::AccountStorage, AssetError, Digest};

// TRANSACTION KERNEL ERROR
// ================================================================================================
Expand Down
3 changes: 2 additions & 1 deletion miden-lib/src/transaction/inputs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_objects::{
accounts::Account,
transaction::{
Expand All @@ -9,7 +11,6 @@ use miden_objects::{
};

use super::TransactionKernel;
use crate::utils::{collections::*, vec};

// TRANSACTION KERNEL INPUTS
// ================================================================================================
Expand Down
3 changes: 2 additions & 1 deletion miden-lib/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_objects::{
accounts::AccountId,
assembly::{Assembler, AssemblyContext, ProgramAst},
Expand All @@ -9,7 +11,6 @@ use miden_objects::{
use miden_stdlib::StdLibrary;

use super::MidenLib;
use crate::utils::collections::*;

pub mod memory;

Expand Down
3 changes: 2 additions & 1 deletion miden-tx/src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::{collections::BTreeMap, vec::Vec};

use miden_objects::{
assembly::{Assembler, AssemblyContext, ModuleAst, ProgramAst},
transaction::{InputNotes, TransactionScript},
Expand All @@ -8,7 +10,6 @@ use super::{
AccountCode, AccountId, CodeBlock, Digest, NoteScript, Program, TransactionCompilerError,
TransactionKernel,
};
use crate::utils::{collections::*, vec};

#[cfg(test)]
mod tests;
Expand Down
2 changes: 2 additions & 0 deletions miden-tx/src/compiler/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_objects::{
accounts::ACCOUNT_ID_REGULAR_ACCOUNT_IMMUTABLE_CODE_ON_CHAIN,
assets::{Asset, FungibleAsset},
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::string::String;
use core::fmt::{self, Display};

use miden_objects::{
Expand All @@ -7,7 +8,6 @@ use miden_objects::{
use miden_verifier::VerificationError;

use super::{AccountError, AccountId, Digest, ExecutionError};
use crate::utils::string::*;

// TRANSACTION COMPILER ERROR
// ================================================================================================
Expand Down
3 changes: 2 additions & 1 deletion miden-tx/src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_lib::transaction::{ToTransactionKernelInputs, TransactionKernel};
use miden_objects::{
assembly::ProgramAst,
Expand All @@ -12,7 +14,6 @@ use super::{
RecAdviceProvider, ScriptTarget, TransactionCompiler, TransactionExecutorError,
TransactionHost,
};
use crate::utils::collections::*;

mod data;
pub use data::DataStore;
Expand Down
8 changes: 4 additions & 4 deletions miden-tx/src/host/account_delta.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::{collections::BTreeMap, string::ToString, vec::Vec};

use miden_lib::transaction::{memory::ACCT_STORAGE_ROOT_PTR, TransactionKernelError};
use miden_objects::{
accounts::{
Expand All @@ -10,10 +12,6 @@ use miden_objects::{
use vm_processor::{ContextId, ProcessState};

use super::{AdviceProvider, TransactionHost};
use crate::utils::{
collections::{btree_map::*, *},
string::*,
};

// CONSTANTS
// ================================================================================================
Expand Down Expand Up @@ -310,6 +308,8 @@ where
V: Copy,
K: Ord,
{
use alloc::collections::btree_map::Entry;

match delta_map.entry(key) {
Entry::Occupied(mut entry) => {
if entry.get() == &-amount {
Expand Down
4 changes: 2 additions & 2 deletions miden-tx/src/host/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::{collections::BTreeMap, string::ToString};

use miden_lib::transaction::{TransactionEvent, TransactionKernelError};
use miden_objects::{
accounts::{AccountDelta, AccountStub},
Expand All @@ -8,8 +10,6 @@ use vm_processor::{
ExecutionError, Host, HostResponse, ProcessState,
};

use crate::utils::{collections::*, format, string::*};

mod account_delta;
use account_delta::AccountDeltaTracker;

Expand Down
7 changes: 5 additions & 2 deletions miden-tx/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]

#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

use miden_lib::transaction::TransactionKernel;
pub use miden_objects::transaction::TransactionInputs;
use miden_objects::{
Expand Down
2 changes: 2 additions & 0 deletions miden-tx/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use miden_lib::transaction::{ToTransactionKernelInputs, TransactionKernel};
use miden_objects::{
accounts::{Account, AccountCode},
Expand Down
14 changes: 10 additions & 4 deletions mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ required-features = ["executable"]

[features]
default = ["std"]
executable = ["dep:clap", "serde"]
executable = ["std", "serde", "dep:clap"]
serde = ["dep:serde", "miden-objects/serde"]
std = ["miden-lib/std", "miden-objects/std"]

Expand All @@ -27,11 +27,17 @@ clap = { version = "4.4", features = ["derive"], optional = true }
env_logger = { version = "0.11" }
hex = { version = "0.4" }
miden-lib = { path = "../miden-lib", version = "0.2" }
miden-objects = { path = "../objects", version = "0.2", features = ["log", "serde", "testing"] }
miden-objects = { path = "../objects", version = "0.2", features = [
"log",
"serde",
"testing",
] }
miden-prover = { workspace = true }
postcard = { version = "1.0", features = [ "alloc" ] }
postcard = { version = "1.0", features = ["alloc"] }
rand = { version = "0.8" }
rand-utils = { package = "winter-rand-utils", version = "0.8" }
rand_pcg = { version = "0.3", features = ["serde1"] }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true, default-features = false, features = [
"derive",
] }
vm-processor = { workspace = true, features = ["internals"] }
6 changes: 5 additions & 1 deletion mock/src/builders/account.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use alloc::{
string::{String, ToString},
vec::Vec,
};

use miden_objects::{
accounts::{Account, AccountStorage, AccountType, SlotItem},
assets::{Asset, AssetVault},
Expand All @@ -8,7 +13,6 @@ use rand::Rng;
use crate::{
builders::{str_to_account_code, AccountBuilderError, AccountIdBuilder, AccountStorageBuilder},
mock::account::DEFAULT_ACCOUNT_CODE,
utils::{collections::*, string::*},
};

/// Builder for an `Account`, the builder allows for a fluent API to construct an account. Each
Expand Down
3 changes: 2 additions & 1 deletion mock/src/builders/account_id.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::string::{String, ToString};

use miden_objects::{
accounts::{AccountId, AccountType},
utils::string::*,
Digest, Word,
};
use rand::Rng;
Expand Down
7 changes: 3 additions & 4 deletions mock/src/builders/account_storage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use miden_objects::{
accounts::{AccountStorage, SlotItem},
utils::collections::*,
};
use alloc::vec::Vec;

use miden_objects::accounts::{AccountStorage, SlotItem};

#[derive(Default, Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
Expand Down
6 changes: 5 additions & 1 deletion mock/src/builders/note.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use alloc::{
string::{String, ToString},
vec::Vec,
};

use miden_objects::{
accounts::AccountId,
assembly::ProgramAst,
Expand All @@ -8,7 +13,6 @@ use miden_objects::{
use rand::Rng;

use super::TransactionKernel;
use crate::utils::{collections::*, string::*};

const DEFAULT_NOTE_CODE: &str = "\
begin
Expand Down
Loading

0 comments on commit 2922568

Please sign in to comment.