Skip to content

Commit 1424610

Browse files
committed
Refactor bytecode verifier and runtime components
- Change `code` parameter type from `&Vec<Bytecode>` to `&[Bytecode]` in `verify_fallthrough` function in control flow verifier. - Update documentation formatting in `script_signature.rs` for clarity. - Modify `native_sub_string` to directly use `s_str.as_bytes()` instead of creating a slice from `s_ref`. - Replace conditional logic with `saturating_sub` for calculating `before` in the interpreter. - Adjust vector-related bytecode verification logic for better readability and efficiency in `loader.rs`. - Simplify error logging by removing unnecessary reference in `expect_no_verification_errors`. - Optimize module iteration in `runtime.rs` by removing unnecessary `into_iter()` calls. - Remove redundant `.write(true)` from logging file options. - Enhance control flow documentation for better understanding. - Add bits per second calculation in `DurationFormatter` for throughput metrics. - Implement default trait for `ProcessTime` struct for improved usability.
1 parent 239a5f7 commit 1424610

418 files changed

Lines changed: 3779 additions & 3175 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

third_party/move/Cargo.toml

Lines changed: 106 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -21,119 +21,134 @@ members = [
2121
# "move-execution/$CUT/crates/move-vm-runtime",
2222
"move-execution/v0/crates/move-stdlib-natives",
2323
"move-execution/v1/crates/move-stdlib-natives",
24-
"move-execution/v2/crates/move-stdlib-natives", "tools/criterion-cpu-time",
24+
"move-execution/v2/crates/move-stdlib-natives",
25+
"tools/criterion-cpu-time",
2526
# "move-execution/$CUT/crates/move-stdlib-natives",
2627
]
2728

2829
# Dependencies that should be kept in sync through the whole workspace
2930
[workspace.dependencies]
30-
aes-gcm = "0.8.0"
31-
anyhow = "1.0.52"
32-
arbitrary = { version = "1.1.7", features = ["derive", "derive_arbitrary"] }
33-
async-trait = "0.1.42"
34-
bcs = "0.1.4"
31+
aes-gcm = "0.10.3"
32+
anyhow = "1.0.102"
33+
arbitrary = { version = "1.4.2", features = ["derive", "derive_arbitrary"] }
34+
async-trait = "0.1.89"
35+
bcs = "0.2.1"
3536
better_any = { version = "0.2.1", features = ["derive"] }
36-
bitvec = "0.19.4"
37-
byteorder = "1.4.3"
38-
bytes = "1.0.1"
39-
chrono = "0.4.19"
40-
clap = { version = "4", features = ["derive"] }
41-
codespan = "0.11.1"
42-
codespan-reporting = "0.11.1"
43-
colored = "2.0.0"
44-
criterion = "0.6.0"
37+
bitvec = "1.0.1"
38+
byteorder = "1.5.0"
39+
bytes = "1.11.1"
40+
chrono = "0.4.45"
41+
clap = { version = "4.6.1", features = ["derive"] }
42+
codespan = "0.13.1"
43+
codespan-reporting = "0.13.1"
44+
colored = "3.1.1"
45+
criterion = "0.8.2"
4546
criterion-cpu-time = { path = "tools/criterion-cpu-time" }
46-
crossbeam = "0.8"
47-
crossbeam-channel = "0.5.0"
48-
crossterm = "0.25.0"
49-
curve25519-dalek = { version = "0.1.0", package = "curve25519-dalek-fiat", default-features = false, features = ["std", "u64_backend"] }
50-
datatest-stable = "0.1.1"
47+
crossbeam = "0.8.4"
48+
crossbeam-channel = "0.5.15"
49+
crossterm = "0.29.0"
50+
curve25519-dalek = { version = "0.1.0", package = "curve25519-dalek-fiat", default-features = false, features = [
51+
"std",
52+
"u64_backend",
53+
] }
54+
datatest-stable = "0.3.3"
5155
derivative = "2.2.0"
5256
difference = "2.0.0"
53-
digest = "0.9.0"
57+
digest = "0.11.3"
5458
dir-diff = "0.3.2"
5559
dirs-next = "2.0.0"
56-
dunce = "1.0.2"
57-
ed25519-dalek = { version = "0.1.0", package = "ed25519-dalek-fiat", default-features = false, features = ["std", "serde", "u64_backend"] }
58-
ethnum = "1.0.4"
59-
fail = "0.4.0"
60+
dunce = "1.0.5"
61+
ed25519-dalek = { version = "0.1.0", package = "ed25519-dalek-fiat", default-features = false, features = [
62+
"std",
63+
"serde",
64+
"u64_backend",
65+
] }
66+
ethnum = "1.5.3"
67+
fail = "0.5.1"
6068
file_diff = "1.0.0"
61-
futures = "0.3.12"
62-
getrandom = "0.2.9"
63-
heck = "0.3.2"
69+
futures = "0.3.32"
70+
getrandom = "0.4.2"
71+
heck = "0.5.0"
6472
hex = "0.4.3"
65-
hex-literal = "0.3.4"
66-
hkdf = "0.10.0"
73+
hex-literal = "1.1.0"
74+
hkdf = "0.13.0"
6775
im = "15.1.0"
68-
internment = { version = "0.5.0", features = [ "arc"] }
69-
itertools = "0.10.0"
70-
leb128 = "0.2.5"
71-
libfuzzer-sys = "0.4"
72-
log = { version = "0.4.14", features = ["serde"] }
73-
lsp-server = "0.5.1"
74-
lsp-types = "0.90.1"
76+
internment = { version = "0.8.6", features = ["arc"] }
77+
itertools = "0.14.0"
78+
leb128 = "0.2.6"
79+
libfuzzer-sys = "0.4.13"
80+
log = { version = "0.4.32", features = ["serde"] }
81+
lsp-server = "0.7.9"
82+
lsp-types = "0.97.0"
7583
memory-stats = "1.0.0"
76-
mirai-annotations = "1.10.1"
77-
named-lock = "0.2.0"
78-
num = "0.4.0"
79-
num-bigint = "0.4.0"
80-
num_cpus = "1.13.0"
81-
once_cell = "1.7.2"
82-
ouroboros = "0.17.2"
83-
parking_lot = "0.11.1"
84-
paste = "1.0.5"
85-
petgraph = "0.5.1"
86-
phf = { version = "0.11", features = ["macros"] }
87-
plotters = { version = "0.3.0", default_features = false, features = ["evcxr", "line_series", "histogram"]}
88-
pretty = "0.10.0"
89-
prettydiff = "0.4.0"
90-
primitive-types = { version = "0.10.1", features = ["impl-serde"]}
91-
proc-macro2 = "1.0.24"
92-
proptest = "1.0.0"
93-
proptest-derive = "0.3.0"
94-
quote = "1.0.9"
95-
rand = "0.8.0"
96-
rayon = "1.5.0"
97-
ref-cast = "1.0.6"
98-
regex = "1.5.5"
99-
ripemd160 = "0.9.1"
100-
serde = { version = "1.0.124", features = ["derive"] }
101-
serde-name = "0.1.1"
102-
serde-reflection = "0.3.2"
103-
serde_bytes = "0.11.5"
104-
serde_json = "1.0.64"
105-
serde_yaml = "0.8.26"
106-
sha2 = "0.9.3"
107-
sha3 = "0.9.1"
84+
mirai-annotations = "1.12.0"
85+
named-lock = "0.4.1"
86+
num = "0.4.3"
87+
num-bigint = "0.4.6"
88+
num_cpus = "1.17.0"
89+
once_cell = "1.21.4"
90+
ouroboros = "0.18.5"
91+
parking_lot = "0.12.5"
92+
paste = "1.0.15"
93+
petgraph = "0.8.3"
94+
phf = { version = "0.13.1", features = ["macros"] }
95+
plotters = { version = "0.3.7", default_features = false, features = [
96+
"evcxr",
97+
"line_series",
98+
"histogram",
99+
] }
100+
pretty = "0.12.5"
101+
prettydiff = "0.9.0"
102+
primitive-types = { version = "0.14.0", features = ["impl-serde"] }
103+
proc-macro2 = "1.0.106"
104+
proptest = "1.11.0"
105+
proptest-derive = "0.8.0"
106+
quote = "1.0.45"
107+
rand = "0.10.1"
108+
rayon = "1.12.0"
109+
ref-cast = "1.0.25"
110+
regex = "1.12.4"
111+
ripemd = "0.2.0"
112+
serde = { version = "1.0.228", features = ["derive"] }
113+
serde-name = "0.3.0"
114+
serde-reflection = "0.6.0"
115+
serde_bytes = "0.11.19"
116+
serde_json = "1.0.150"
117+
serde_yaml = "=0.9.34"
118+
sha2 = "0.11.0"
119+
sha3 = "0.12.0"
108120
shell-words = "1.0.0"
109-
simplelog = "0.9.0"
110-
similar = "2.4.0"
111-
smallvec = "1.6.1"
112-
stacker = "0.1.15"
121+
simplelog = "0.12.2"
122+
similar = "=3.1.1"
123+
smallvec = "1.15.2"
124+
stacker = "0.1.24"
113125
static_assertions = "1.1.0"
114-
syn = { version = "1.0.64", features = ["derive"] }
115-
tempfile = "3.2.0"
116-
tera = "1.16.0"
117-
thiserror = "1.0.24"
126+
syn = { version = "2.0.117", features = ["derive"] }
127+
tempfile = "3.27.0"
128+
tera = "1.20.1"
129+
thiserror = "2.0.18"
118130
tiny-keccak = { version = "2.0.2", features = ["sha3"] }
119-
tokio = { version = "1.18.2", features = ["full"] }
120-
toml = "0.5.8"
121-
toml_edit = { version = "0.14.3", features = ["easy"] }
122-
tracing = "0.1.26"
131+
tokio = { version = "1.52.3", features = ["full"] }
132+
toml = "1.1.2"
133+
toml_edit = { version = "0.25.12"}
134+
tracing = "0.1.44"
123135
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
124136
treeline = "0.1.0"
125137
tui = "0.19.0"
126-
uint = "0.9.4"
138+
uint = "0.10.0"
127139
url = "2.2.2"
128140
variant_count = "1.1.0"
129-
vfs = "0.10.0"
130-
walkdir = "2.3.1"
131-
whoami = { version = "1.2.1" }
132-
x25519-dalek = { version = "0.1.0", package = "x25519-dalek-fiat", default-features = false, features = ["std", "u64_backend"] }
133-
z3tracer = "0.8.0"
141+
vfs = "0.13.0"
142+
walkdir = "2.5.0"
143+
whoami = { version = "2.1.2" }
144+
x25519-dalek = { version = "0.1.0", package = "x25519-dalek-fiat", default-features = false, features = [
145+
"std",
146+
"u64_backend",
147+
] }
148+
z3tracer = "0.11.2"
134149

135150
bytecode-interpreter-crypto = { path = "crates/bytecode-interpreter-crypto" }
136-
enum-compat-util = { path = "crates/enum-compat-util"}
151+
enum-compat-util = { path = "crates/enum-compat-util" }
137152
invalid-mutations = { path = "crates/invalid-mutations" }
138153
module-generation = { path = "crates/module-generation" }
139154
move-abstract-stack = { path = "crates/move-abstract-stack" }
@@ -158,7 +173,7 @@ move-ir-to-bytecode-syntax = { path = "crates/move-ir-to-bytecode-syntax" }
158173
move-ir-types = { path = "crates/move-ir-types" }
159174
move-model = { path = "crates/move-model" }
160175
move-package = { path = "crates/move-package" }
161-
move-proc-macros = { path = "crates/move-proc-macros"}
176+
move-proc-macros = { path = "crates/move-proc-macros" }
162177
move-prover = { path = "crates/move-prover" }
163178
move-prover-test-utils = { path = "crates/move-prover-test-utils" }
164179
move-read-write-set-types = { path = "crates/move-read-write-set-types" }
@@ -174,7 +189,7 @@ move-vm-profiler = { path = "crates/move-vm-profiler" }
174189
move-vm-runtime = { path = "crates/move-vm-runtime" }
175190
move-vm-test-utils = { path = "crates/move-vm-test-utils" }
176191
move-vm-types = { path = "crates/move-vm-types" }
177-
prover_bytecode = { path = "crates/move-stackless-bytecode", package="move-stackless-bytecode" }
192+
prover_bytecode = { path = "crates/move-stackless-bytecode", package = "move-stackless-bytecode" }
178193

179194
[profile.bench]
180195
debug = true
@@ -190,6 +205,6 @@ opt-level = 3
190205
# use release settings to reduce memory pressure in the linking step in CI
191206
[profile.ci]
192207
inherits = "test"
193-
debug = 0 # for saving disk space during linking
208+
debug = 0 # for saving disk space during linking
194209
incremental = false
195210
codegen-units = 16

third_party/move/clippy.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
too-many-arguments-threshold = 13
2+
type-complexity-threshold = 1000
3+
enum-variant-size-threshold = 1024
4+
large-error-threshold = 1024

third_party/move/crates/bytecode-interpreter-crypto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "bytecode-interpreter-crypto"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2021"
6+
edition = "2024"
77
license = "Apache-2.0"
88

99
[dependencies]

third_party/move/crates/bytecode-interpreter-crypto/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
//! diem-framework) and be passed into the VM for execution. In this way we no
1313
//! longer need to worry about depending on diem-crypto.
1414
15-
use anyhow::{bail, Result};
15+
use anyhow::{Result, bail};
1616
use ed25519_dalek::{
17-
PublicKey as Ed25519PublicKey, Signature as Ed25519Signature,
18-
PUBLIC_KEY_LENGTH as ED25519_PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH as ED25519_SIGNATURE_LENGTH,
17+
PUBLIC_KEY_LENGTH as ED25519_PUBLIC_KEY_LENGTH, PublicKey as Ed25519PublicKey,
18+
SIGNATURE_LENGTH as ED25519_SIGNATURE_LENGTH, Signature as Ed25519Signature,
1919
};
2020
use sha2::{Digest, Sha256};
2121
use sha3::Sha3_256;

third_party/move/crates/bytecode-interpreter-testsuite/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "bytecode-interpreter-testsuite"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2021"
6+
edition = "2024"
77
license = "Apache-2.0"
88

99
[dev-dependencies]

third_party/move/crates/bytecode-interpreter-testsuite/tests/concrete_check_testsuite.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use move_stdlib::move_stdlib_files;
1010
use move_unit_test::UnitTestingConfig;
1111

1212
fn test_runner(path: &Path) -> datatest_stable::Result<()> {
13-
env::set_var("NO_COLOR", "1");
13+
unsafe { env::set_var("NO_COLOR", "1") };
1414

1515
let source_files = vec![path.to_str().unwrap().to_owned()];
1616
let config = UnitTestingConfig {
@@ -37,4 +37,6 @@ fn test_runner(path: &Path) -> datatest_stable::Result<()> {
3737
Ok(())
3838
}
3939

40-
datatest_stable::harness!(test_runner, "tests/concrete_check", r".*\.move$");
40+
datatest_stable::harness! {
41+
{ test = test_runner, root = "tests/concrete_check", pattern = r".*\.move$" },
42+
}

third_party/move/crates/bytecode-verifier-libfuzzer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
license = "Apache-2.0"
66
publish = false
7-
edition = "2018"
7+
edition = "2024"
88

99
[package.metadata]
1010
cargo-fuzz = true

third_party/move/crates/bytecode-verifier-libfuzzer/fuzz_targets/code_unit.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33

44
#![no_main]
55
use move_binary_format::file_format::{
6-
empty_module, AbilitySet, CodeUnit, Constant, FieldDefinition, FunctionDefinition,
7-
FunctionHandle, FunctionHandleIndex, IdentifierIndex, ModuleHandleIndex, Signature,
8-
SignatureIndex,
9-
SignatureToken::{Address, Bool, U128, U64},
6+
AbilitySet, CodeUnit, Constant, FieldDefinition, FunctionDefinition, FunctionHandle,
7+
FunctionHandleIndex, IdentifierIndex, ModuleHandleIndex, Signature, SignatureIndex,
8+
SignatureToken::{Address, Bool, U64, U128},
109
StructDefinition, StructFieldInformation, StructHandle, StructHandleIndex, TypeSignature,
11-
Visibility,
10+
Visibility, empty_module,
1211
};
1312
use move_core_types::{account_address::AccountAddress, identifier::Identifier};
1413
use std::str::FromStr;
1514

1615
use libfuzzer_sys::fuzz_target;
1716

18-
#[no_mangle]
17+
#[unsafe(no_mangle)]
1918
pub extern "C" fn main() -> i32 {
2019
libfuzzer_sys::initialize(std::ptr::null(), std::ptr::null());
21-
return 0;
20+
0
2221
}
2322

2423
fuzz_target!(|code_unit: CodeUnit| {

third_party/move/crates/bytecode-verifier-libfuzzer/fuzz_targets/compiled_module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use libfuzzer_sys::fuzz_target;
66
use move_binary_format::file_format::CompiledModule;
77

8-
#[no_mangle]
8+
#[unsafe(no_mangle)]
99
pub extern "C" fn main() -> i32 {
1010
libfuzzer_sys::initialize(std::ptr::null(), std::ptr::null());
11-
return 0;
11+
0
1212
}
1313

1414
fuzz_target!(|module: CompiledModule| {

third_party/move/crates/bytecode-verifier-libfuzzer/fuzz_targets/mixed.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
#![no_main]
55
use move_binary_format::file_format::{
6-
empty_module, AbilitySet, Bytecode, CodeUnit, Constant, FieldDefinition, FunctionDefinition,
7-
FunctionHandle, FunctionHandleIndex, IdentifierIndex, ModuleHandleIndex, Signature,
8-
SignatureIndex, SignatureToken,
6+
AbilitySet, Bytecode, CodeUnit, Constant, FieldDefinition, FunctionDefinition, FunctionHandle,
7+
FunctionHandleIndex, IdentifierIndex, ModuleHandleIndex, Signature, SignatureIndex,
8+
SignatureToken,
99
SignatureToken::{Address, Bool},
1010
StructDefinition, StructFieldInformation, StructHandle, StructHandleIndex, TypeSignature,
11-
Visibility,
11+
Visibility, empty_module,
1212
};
1313
use move_core_types::{account_address::AccountAddress, identifier::Identifier};
1414
use std::str::FromStr;
@@ -24,10 +24,10 @@ struct Mixed {
2424
return_type: Option<SignatureToken>,
2525
}
2626

27-
#[no_mangle]
27+
#[unsafe(no_mangle)]
2828
pub extern "C" fn main() -> i32 {
2929
libfuzzer_sys::initialize(std::ptr::null(), std::ptr::null());
30-
return 0;
30+
0
3131
}
3232

3333
fuzz_target!(|mix: Mixed| {

0 commit comments

Comments
 (0)