Skip to content

Commit

Permalink
add no_std attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ajen committed Apr 12, 2023
1 parent 81d19fc commit 654d7e3
Show file tree
Hide file tree
Showing 41 changed files with 1,707 additions and 1,341 deletions.
2,631 changes: 1,439 additions & 1,192 deletions Cargo.lock

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,53 @@ default-members = [
# Dependencies that should be kept in sync through the whole workspace
[workspace.dependencies]
bcs = "0.1.4"
sha3 = "0.9.1"
tracing = "0.1.26"

petgraph = "0.5.1"

ref-cast = "1.0.6"
variant_count = "1.1.0"

serde = { version = "1.0.124", default-features = false, features = ["alloc"]}
serde_bytes = "0.11.5"
hex = "0.4.3"
primitive-types = {version = "0.10.1", features = ["impl-serde"]}
uint = "0.9.4"
num = "0.4.0"
ethnum = "1.0.4"
smallvec = "1.6.1"
hashbrown = "0.13.2"
spin = "0.9.5"

thiserror = "1.0.24"

serde_json = "1.0.64"

#regex = "1.5.5"
num-bigint = "0.4.0"

sha2 = "0.9.3"

acid_io = { version = "0.1.0", features = ["alloc"] }

# std::error::Error
anyhow = "1.0.52"

better_any = "0.1.1" # impl Traits for Mutex/RwLock, may not be a problem if not used;
fail = "0.4.0"

# members

move-vm-runtime = { path = "language/move-vm/runtime"}
move-vm-types = { path = "language/move-vm/types"}
move-binary-format = { path = "language/move-binary-format"}
move-symbol-pool = { path = "language/move-symbol-pool"}
move-ir-types = { path = "language/move-ir/types"}
move-stdlib = { path = "language/move-stdlib/"}
move-core-types = { path = "language/move-core/types"}
move-bytecode-verifier = { path = "language/move-bytecode-verifier"}
move-borrow-graph = { path = "language/move-borrow-graph"}

[profile.bench]
debug = true
Expand Down
15 changes: 8 additions & 7 deletions language/move-binary-format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ publish = ["crates-io"]
edition = "2021"

[dependencies]
anyhow = "1.0.52"
once_cell = "1.7.2"
anyhow.workspace = true
ref-cast.workspace = true
variant_count.workspace = true
serde.workspace = true
hashbrown.workspace = true
arbitrary = { version = "1.1.7", optional = true, features = ["derive"] }
proptest = { version = "1.0.0", optional = true }
proptest-derive = { version = "0.3.0", optional = true }
ref-cast = "1.0.6"
variant_count = "1.1.0"
move-core-types = { path = "../move-core/types" }
serde = { version = "1.0.124", default-features = false }
arbitrary = { version = "1.1.7", optional = true, features = ["derive"] }

move-core-types.workspace = true

[dev-dependencies]
proptest = "1.0.0"
Expand Down
3 changes: 2 additions & 1 deletion language/move-binary-format/src/proptest_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use crate::proptest_types::{
signature::SignatureGen,
types::{StDefnMaterializeState, StructDefinitionGen, StructHandleGen},
};
use std::collections::{BTreeSet, HashMap};
use hashbrown::HashMap;
use std::collections::BTreeSet;

/// Represents how large [`CompiledModule`] tables can be.
pub type TableSize = u16;
Expand Down
6 changes: 2 additions & 4 deletions language/move-binary-format/src/proptest_types/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ use crate::{
TableSize,
},
};
use hashbrown::{HashMap, HashSet};
use move_core_types::u256::U256;
use proptest::{
collection::{vec, SizeRange},
prelude::*,
sample::{select, Index as PropIndex},
};
use std::{
collections::{BTreeSet, HashMap, HashSet},
hash::Hash,
};
use std::{collections::BTreeSet, hash::Hash};

#[derive(Debug, Default)]
struct SignatureState {
Expand Down
16 changes: 7 additions & 9 deletions language/move-bytecode-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ publish = false
edition = "2021"

[dependencies]
anyhow = "1.0.52"
petgraph = "0.5.1"
anyhow.workspace = true
petgraph.workspace = true
fail.workspace = true
hashbrown.workspace = true

move-borrow-graph = { path = "../move-borrow-graph" }
move-binary-format = { path = "../move-binary-format" }
move-core-types = { path = "../move-core/types" }

[dev-dependencies]
hex-literal = "0.3.4"
invalid-mutations = { path = "invalid-mutations" }
move-borrow-graph.workspace = true
move-binary-format.workspace = true
move-core-types.workspace = true

[features]
default = []
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//! - No missing resources (any resource acquired must be present)
//! - No additional resources (no extraneous resources not actually acquired)
use std::collections::{BTreeSet, HashMap};
use std::collections::{BTreeSet};
use hashbrown::HashMap;

use move_binary_format::{
access::ModuleAccess,
Expand Down
3 changes: 2 additions & 1 deletion language/move-bytecode-verifier/src/check_duplication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! - struct and field definitions are consistent
//! - the handles in struct and function definitions point to the self module index
//! - all struct and function handles pointing to the self module index have a definition
use hashbrown::HashSet;
use move_binary_format::{
access::{ModuleAccess, ScriptAccess},
errors::{verification_error, Location, PartialVMResult, VMResult},
Expand All @@ -22,7 +23,7 @@ use move_binary_format::{
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, vm_status::StatusCode,
};
use std::{collections::HashSet, hash::Hash};
use std::hash::Hash;

pub struct DuplicationChecker<'a> {
module: &'a CompiledModule,
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/code_unit_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use move_binary_format::{
IndexKind,
};
use move_core_types::vm_status::StatusCode;
use std::collections::HashMap;
use hashbrown::HashMap;

pub struct CodeUnitVerifier<'a> {
resolver: BinaryIndexedView<'a>,
Expand Down
5 changes: 3 additions & 2 deletions language/move-bytecode-verifier/src/control_flow_v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
//! - All "breaks" (forward, loop-exiting jumps) go to the "end" of the loop
//! - All "continues" (back jumps in a loop) are only to the current loop
use crate::verifier::VerifierConfig;
use core::convert::TryInto;
use hashbrown::HashSet;
use move_binary_format::{
errors::{PartialVMError, PartialVMResult},
file_format::{Bytecode, CodeOffset, CodeUnit, FunctionDefinitionIndex},
safe_unwrap,
};
use move_core_types::vm_status::StatusCode;
use std::{collections::HashSet, convert::TryInto};

pub fn verify(
verifier_config: &VerifierConfig,
Expand Down Expand Up @@ -275,7 +276,7 @@ fn count_loop_depth(labels: &[Label]) -> Vec<usize> {
count += 1
}
counts.push(count);
if last_continues.contains(&idx.try_into().unwrap()) {
if last_continues.contains(&u16::try_from(idx).unwrap()) {
count -= 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/instantiation_loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use petgraph::{
visit::EdgeRef,
Graph,
};
use std::collections::{hash_map, HashMap, HashSet};
use hashbrown::{hash_map, HashMap, HashSet};

/// Data attached to each node.
/// Each node corresponds to a type formal of a generic function in the module.
Expand Down
3 changes: 2 additions & 1 deletion language/move-bytecode-verifier/src/reference_safety/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod abstract_state;

use crate::absint::{AbstractInterpreter, TransferFunctions};
use abstract_state::{AbstractState, AbstractValue};
use hashbrown::HashMap;
use move_binary_format::{
binary_views::{BinaryIndexedView, FunctionView},
errors::{PartialVMError, PartialVMResult},
Expand All @@ -22,7 +23,7 @@ use move_binary_format::{
safe_assert, safe_unwrap,
};
use move_core_types::vm_status::StatusCode;
use std::collections::{BTreeSet, HashMap};
use std::collections::BTreeSet;

struct ReferenceSafetyAnalysis<'a> {
resolver: &'a BinaryIndexedView<'a>,
Expand Down
22 changes: 11 additions & 11 deletions language/move-core/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ publish = ["crates-io"]
edition = "2021"

[dependencies]
anyhow = "1.0.52"
hex = "0.4.3"
once_cell = "1.7.2"
anyhow.workspace = true
hex.workspace = true
ref-cast.workspace = true
serde.workspace = true
serde_bytes.workspace = true
primitive-types.workspace = true
uint.workspace = true
num.workspace = true
ethnum.workspace = true
spin.workspace = true
arbitrary = { version = "1.1.7", features = [ "derive_arbitrary"], optional = true }
proptest = { version = "1.0.0", default-features = false, optional = true }
proptest-derive = { version = "0.3.0", default-features = false, optional = true }
rand = "0.8.3"
ref-cast = "1.0.6"
serde = { version = "1.0.124", default-features = false }
serde_bytes = "0.11.5"
primitive-types = {version = "0.10.1", features = ["impl-serde"]}
uint = "0.9.4"
num = "0.4.0"
ethnum = "1.0.4"
arbitrary = { version = "1.1.7", features = [ "derive_arbitrary"], optional = true }

bcs.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion language/move-core/types/src/unit_tests/identifier_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::identifier::{IdentStr, Identifier, ALLOWED_IDENTIFIERS, ALLOWED_NO_SELF_IDENTIFIERS};
use bcs::test_helpers::assert_canonical_encode_decode;
use once_cell::sync::Lazy;
use spin::Lazy;
use proptest::prelude::*;
use regex::Regex;
use std::borrow::Borrow;
Expand Down
2 changes: 1 addition & 1 deletion language/move-core/types/src/vm_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub mod known_locations {
language_storage::{ModuleId, CORE_CODE_ADDRESS},
vm_status::AbortLocation,
};
use once_cell::sync::Lazy;
use spin::Lazy;

/// The Identifier for the Account module.
pub const CORE_ACCOUNT_MODULE_IDENTIFIER: &IdentStr = ident_str!("Account");
Expand Down
14 changes: 8 additions & 6 deletions language/move-ir/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.52"
serde = { version = "1.0.124", features = ["derive"] }
hex = "0.4.3"
once_cell = "1.7.2"
anyhow.workspace = true
serde = { workspace = true, features = ["derive"] }
hex.workspace = true
sha2.workspace = true
spin.workspace = true
hashbrown.workspace = true

move-core-types = { path = "../../move-core/types" }
move-symbol-pool = { path = "../../move-symbol-pool" }
move-core-types.workspace = true
move-symbol-pool.workspace = true
move-command-line-common = { path = "../../move-command-line-common" }
12 changes: 7 additions & 5 deletions language/move-ir/types/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

use crate::{
location::*,
no_std::*,
spec_language_ast::{Condition, Invariant, SyntheticDefinition},
};
use alloc::{
collections::{BTreeSet, VecDeque},
fmt,
};
use hashbrown::HashSet;
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, language_storage::ModuleId,
value::MoveValue,
};
use move_symbol_pool::Symbol;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use std::{
collections::{BTreeSet, HashSet, VecDeque},
fmt,
};
use spin::Lazy;

//**************************************************************************************************
// Program
Expand Down
11 changes: 11 additions & 0 deletions language/move-ir/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

//! Base types for the Move IR.
#![no_std]
#[macro_use]
extern crate alloc;
#[allow(unused_imports)]
pub(crate) mod no_std {
pub use alloc::borrow::ToOwned;
pub use alloc::boxed::Box;
pub use alloc::string::String;
pub use alloc::string::ToString;
pub use alloc::vec::Vec;
}
pub mod ast;
pub mod location;
pub mod spec_language_ast;
10 changes: 5 additions & 5 deletions language/move-ir/types/src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use move_command_line_common::files::FileHash;
use serde::{Deserialize, Serialize};
use std::{
use alloc::fmt;
use core::{
cmp::Ordering,
fmt,
hash::{Hash, Hasher},
ops::Range,
};
use move_command_line_common::files::FileHash;
use serde::{Deserialize, Serialize};

//**************************************************************************************************
// Loc
Expand Down Expand Up @@ -135,7 +135,7 @@ impl<T: Ord> Ord for Spanned<T> {
}

impl<T: fmt::Display> fmt::Display for Spanned<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", &self.value)
}
}
Expand Down
1 change: 1 addition & 0 deletions language/move-ir/types/src/spec_language_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::{
ast::{BinOp, CopyableVal_, Field_, QualifiedStructIdent, Type},
location::*,
no_std::*,
};
use move_core_types::account_address::AccountAddress;
use move_symbol_pool::Symbol;
Expand Down
6 changes: 4 additions & 2 deletions language/move-symbol-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ publish = false
edition = "2021"

[dependencies]
once_cell = "1.7.2"
serde = { version = "1.0.124", features = ["derive"] }
spin.workspace = true
hashbrown.workspace = true

serde = { workspace = true, features = ["derive"] }


[dev-dependencies]
Expand Down
Loading

0 comments on commit 654d7e3

Please sign in to comment.