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 11, 2023
1 parent 0151500 commit 524e6e1
Show file tree
Hide file tree
Showing 51 changed files with 1,733 additions and 1,344 deletions.
2,626 changes: 1,440 additions & 1,186 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,50 @@ 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"


# 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"

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/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use move_core_types::{
account_address::AccountAddress, identifier::Identifier, metadata::Metadata, state::VMState,
vm_status::StatusCode,
};
use std::{collections::HashSet, convert::TryInto, io::Read};
use std::{ convert::TryInto, io::Read};
use hashbrown::HashSet;

impl CompiledScript {
/// Deserializes a &[u8] slice into a `CompiledScript` instance.
Expand Down
13 changes: 7 additions & 6 deletions language/move-bytecode-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ publish = false
edition = "2021"

[dependencies]
anyhow = "1.0.52"
petgraph = "0.5.1"
fail = "0.4.0"
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" }
move-borrow-graph.workspace = true
move-binary-format.workspace = true
move-core-types.workspace = true

[dev-dependencies]
hex-literal = "0.3.4"
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/absint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use move_binary_format::{
errors::PartialVMResult,
file_format::{Bytecode, CodeOffset},
};
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;

/// Trait for finite-height abstract domains. Infinite height domains would require a more complex
/// trait with widening and a partial order.
Expand Down
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 alloc::collections::BTreeSet;
use hashbrown::HashMap;

use crate::meter::Meter;
use move_binary_format::{
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,8 @@
//! - 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 core::hash::Hash;
use hashbrown::HashSet;
use move_binary_format::{
access::{ModuleAccess, ScriptAccess},
errors::{verification_error, Location, PartialVMResult, VMResult},
Expand All @@ -22,7 +24,6 @@ use move_binary_format::{
use move_core_types::{
account_address::AccountAddress, identifier::Identifier, vm_status::StatusCode,
};
use std::{collections::HashSet, 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 @@ -26,7 +26,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
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
meter::Meter,
verifier::VerifierConfig,
};
use alloc::collections::BTreeSet;
use move_binary_format::{
access::{ModuleAccess, ScriptAccess},
binary_views::FunctionView,
Expand All @@ -28,7 +29,6 @@ use move_binary_format::{
CompiledModule,
};
use move_core_types::vm_status::StatusCode;
use std::collections::BTreeSet;

/// Perform control flow verification on the compiled function, returning its `FunctionView` if
/// verification was successful.
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 @@ -14,7 +14,8 @@ use move_binary_format::{
safe_unwrap,
};
use move_core_types::vm_status::StatusCode;
use std::{collections::HashSet, convert::TryInto};
use core::{ convert::TryInto};
use hashbrown::HashSet;

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(&CodeOffset::try_from(idx).unwrap()) {
count -= 1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion language/move-bytecode-verifier/src/cyclic_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// SPDX-License-Identifier: Apache-2.0

//! This module contains verification of usage of dependencies for modules
use alloc::collections::BTreeSet;
use move_binary_format::{
access::ModuleAccess,
errors::{Location, PartialVMError, PartialVMResult, VMResult},
file_format::CompiledModule,
};
use move_core_types::{language_storage::ModuleId, vm_status::StatusCode};
use std::collections::BTreeSet;


// This function performs a DFS in the module graph starting from each node in `items_to_explore`
// and explores the neighbors of a node using the `immediate_nexts` closure.
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use move_binary_format::{
safe_unwrap, IndexKind,
};
use move_core_types::{identifier::Identifier, language_storage::ModuleId, vm_status::StatusCode};
use std::collections::{BTreeMap, BTreeSet};
use alloc::collections::{BTreeMap, BTreeSet};

struct Context<'a, 'b> {
resolver: BinaryIndexedView<'a>,
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
2 changes: 2 additions & 0 deletions language/move-bytecode-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

//! Verifies bytecode sanity.
extern crate alloc;

// Bounds checks are implemented in the `vm` crate.
pub mod ability_field_requirements;
pub mod absint;
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/loop_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use move_binary_format::control_flow_graph::{BlockId, ControlFlowGraph, VMControlFlowGraph};
use std::collections::{btree_map::Entry, BTreeMap, BTreeSet};
use alloc::collections::{btree_map::Entry, BTreeMap, BTreeSet};

/// Dense index into nodes in the same `LoopSummary`
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::VerifierConfig;
use move_binary_format::errors::{PartialVMError, PartialVMResult};
use move_core_types::vm_status::StatusCode;
use std::ops::Mul;
use core::ops::Mul;

/// Scope of meterinng
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use move_binary_format::{
};
use move_borrow_graph::references::RefID;
use move_core_types::vm_status::StatusCode;
use std::collections::{BTreeMap, BTreeSet};
use alloc::collections::{BTreeMap, BTreeSet};

type BorrowGraph = move_borrow_graph::graph::BorrowGraph<(), Label>;

Expand Down Expand Up @@ -62,8 +62,8 @@ enum Label {
}

// Needed for debugging with the borrow graph
impl std::fmt::Display for Label {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl alloc::fmt::Display for Label {
fn fmt(&self, f: &mut alloc::fmt::Formatter<'_>) -> alloc::fmt::Result {
match self {
Label::Local(i) => write!(f, "local#{}", i),
Label::Global(i) => write!(f, "resource@{}", i),
Expand Down Expand Up @@ -324,7 +324,7 @@ impl AbstractState {
offset: CodeOffset,
local: LocalIndex,
) -> PartialVMResult<AbstractValue> {
let old_value = std::mem::replace(
let old_value = core::mem::replace(
safe_unwrap!(self.locals.get_mut(local as usize)),
AbstractValue::NonReference,
);
Expand All @@ -344,7 +344,7 @@ impl AbstractState {
new_value: AbstractValue,
) -> PartialVMResult<()> {
let old_value =
std::mem::replace(safe_unwrap!(self.locals.get_mut(local as usize)), new_value);
core::mem::replace(safe_unwrap!(self.locals.get_mut(local as usize)), new_value);
match old_value {
AbstractValue::Reference(id) => {
self.release(id);
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 @@ -18,6 +18,8 @@ use crate::{
},
};
use abstract_state::{AbstractState, AbstractValue};
use alloc::collections::BTreeSet;
use hashbrown::HashMap;
use move_binary_format::{
binary_views::{BinaryIndexedView, FunctionView},
errors::{PartialVMError, PartialVMResult},
Expand All @@ -28,7 +30,6 @@ use move_binary_format::{
safe_assert, safe_unwrap,
};
use move_core_types::vm_status::StatusCode;
use std::collections::{BTreeSet, HashMap};

struct ReferenceSafetyAnalysis<'a> {
resolver: &'a BinaryIndexedView<'a>,
Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/src/struct_defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use move_binary_format::{
};
use move_core_types::vm_status::StatusCode;
use petgraph::{algo::toposort, graphmap::DiGraphMap};
use std::collections::{BTreeMap, BTreeSet};
use alloc::collections::{BTreeMap, BTreeSet};

pub struct RecursiveStructDefChecker<'a> {
module: &'a CompiledModule,
Expand Down
24 changes: 12 additions & 12 deletions language/move-core/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ 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 All @@ -33,6 +32,7 @@ proptest-derive = "0.3.0"
regex = "1.5.5"
serde_json = "1.0.64"
arbitrary = { version = "1.1.7", features = [ "derive_arbitrary"] }
rand = "*"

[features]
address20 = []
Expand Down
2 changes: 2 additions & 0 deletions language/move-core/types/src/account_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

use hex::FromHex;
#[cfg(test)]
use rand::{rngs::OsRng, Rng};
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
use std::{convert::TryFrom, fmt, str::FromStr};
Expand Down Expand Up @@ -49,6 +50,7 @@ impl AccountAddress {
Self(addr)
}

#[cfg(test)]
pub fn random() -> Self {
let mut rng = OsRng;
let buf: [u8; Self::LENGTH] = rng.gen();
Expand Down
Loading

0 comments on commit 524e6e1

Please sign in to comment.