Skip to content

Commit

Permalink
[move] Split bytecode's absint into its own crate (#17459)
Browse files Browse the repository at this point in the history
## Description 

- Moved the absint and control_flow_graph modules into their own crate,
`move-abstract-interpreter`
- Added the crate to the execution cut. The `absint` module was in the
bytecode verifier, so this was already versioned for the existing cuts.
However `control_flow_graph` was in the binary format, so this version
cut is new. As a result, I have just made one cut for v2 and used it for
v0 and v1. I think this is a bit un-orthodox, but preserves the existing
behavior just fine (which is the intention of the execution cuts)

## Test plan 

- Ran the execution cut script

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
tnowacki authored May 8, 2024
1 parent f37f592 commit 15cb9c7
Show file tree
Hide file tree
Showing 64 changed files with 606 additions and 57 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exclude = [
"external-crates/move/crates/invalid-mutations",
"external-crates/move/crates/language-benchmarks",
"external-crates/move/crates/module-generation",
"external-crates/move/crates/move-abstract-interpreter",
"external-crates/move/crates/move-abstract-stack",
"external-crates/move/crates/move-analyzer",
"external-crates/move/crates/move-binary-format",
Expand Down Expand Up @@ -64,6 +65,7 @@ exclude = [
"external-crates/move/move-execution/v1/crates/move-bytecode-verifier",
"external-crates/move/move-execution/v1/crates/move-stdlib-natives",
"external-crates/move/move-execution/v1/crates/move-vm-runtime",
"external-crates/move/move-execution/v2/crates/move-abstract-interpreter",
"external-crates/move/move-execution/v2/crates/move-bytecode-verifier",
"external-crates/move/move-execution/v2/crates/move-stdlib-natives",
"external-crates/move/move-execution/v2/crates/move-vm-runtime",
Expand Down Expand Up @@ -557,6 +559,7 @@ move-ir-types = { path = "external-crates/move/crates/move-ir-types" }
move-prover = { path = "external-crates/move/crates/move-prover" }
move-stackless-bytecode = { path = "external-crates/move/crates/move-stackless-bytecode" }
move-symbol-pool = { path = "external-crates/move/crates/move-symbol-pool" }
move-abstract-interpreter = { path = "external-crates/move/crates/move-abstract-interpreter" }
move-abstract-stack = { path = "external-crates/move/crates/move-abstract-stack" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "878492bd2541dce1491791bcadf3cc855ddcdc05" }
Expand Down
27 changes: 27 additions & 0 deletions external-crates/move/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions external-crates/move/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ members = [
"move-execution/v1/crates/move-stdlib-natives",
"move-execution/v2/crates/move-stdlib-natives",
# "move-execution/$CUT/crates/move-stdlib-natives",
"move-execution/v2/crates/move-abstract-interpreter",
# "move-execution/$CUT/crates/move-abstract-interpreter",
]

# Dependencies that should be kept in sync through the whole workspace
Expand Down Expand Up @@ -132,6 +134,7 @@ bytecode-interpreter-crypto = { path = "crates/bytecode-interpreter-crypto" }
enum-compat-util = { path = "crates/enum-compat-util"}
invalid-mutations = { path = "crates/invalid-mutations" }
module-generation = { path = "crates/module-generation" }
move-abstract-interpreter = { path = "crates/move-abstract-interpreter" }
move-abstract-stack = { path = "crates/move-abstract-stack" }
move-binary-format = { path = "crates/move-binary-format" }
move-borrow-graph = { path = "crates/move-borrow-graph" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ move-bytecode-verifier = { path = "../move-bytecode-verifier" }
move-bytecode-verifier-meter.workspace = true
move-core-types.workspace = true
move-vm-config.workspace = true
move-abstract-interpreter.workspace = true

[features]
fuzzing = ["move-binary-format/fuzzing"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use move_binary_format::{control_flow_graph::VMControlFlowGraph, file_format::Bytecode};
use move_abstract_interpreter::control_flow_graph::VMControlFlowGraph;
use move_binary_format::file_format::Bytecode;
use move_bytecode_verifier::loop_summary::{LoopPartition, LoopSummary};

macro_rules! assert_node {
Expand Down
15 changes: 15 additions & 0 deletions external-crates/move/crates/move-abstract-interpreter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "move-abstract-interpreter"
version = "0.1.0"
authors = ["The Move Contributors"]
description = "Move abstract interpreter"
license = "Apache-2.0"
publish = false
edition = "2021"

[dependencies]
move-binary-format.workspace = true
move-bytecode-verifier-meter.workspace = true

[features]
default = []
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::control_flow_graph::{BlockId, ControlFlowGraph, VMControlFlowGraph};
use move_binary_format::{
control_flow_graph::{BlockId, ControlFlowGraph, VMControlFlowGraph},
errors::PartialVMResult,
file_format::{
AbilitySet, Bytecode, CodeOffset, CodeUnit, FunctionDefinitionIndex, FunctionHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

//! This module defines the control-flow graph uses for bytecode verification.
use crate::file_format::{Bytecode, CodeOffset};
use move_binary_format::file_format::{Bytecode, CodeOffset};
use std::collections::{btree_map::Entry, BTreeMap, BTreeSet};

// BTree/Hash agnostic type wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

pub mod absint;
pub mod control_flow_graph;

#[cfg(test)]
mod unit_tests;
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::{
control_flow_graph::{BlockId, ControlFlowGraph, VMControlFlowGraph},
file_format::Bytecode,
};
use crate::control_flow_graph::{BlockId, ControlFlowGraph, VMControlFlowGraph};
use move_binary_format::file_format::Bytecode;

#[test]
fn traversal_no_loops() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

mod control_flow_graph_tests;
1 change: 0 additions & 1 deletion external-crates/move/crates/move-binary-format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod compatibility;
#[macro_use]
pub mod errors;
pub mod constant;
pub mod control_flow_graph;
pub mod deserializer;
pub mod file_format;
pub mod file_format_common;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
mod binary_limits_tests;
mod binary_tests;
mod compatibility_tests;
mod control_flow_graph_tests;
mod deserializer_tests;
mod number_tests;
mod signature_token_tests;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ move-bytecode-verifier-meter.workspace = true
move-core-types.workspace = true
move-vm-config.workspace = true
move-abstract-stack.workspace = true
move-abstract-interpreter.workspace = true

[dev-dependencies]
hex-literal.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
//! The overall verification is split between stack_usage_verifier.rs and
//! abstract_interpreter.rs. CodeUnitVerifier simply orchestrates calls into these two files.
use crate::{
absint::FunctionContext, acquires_list_verifier::AcquiresVerifier, control_flow, locals_safety,
reference_safety, stack_usage_verifier::StackUsageVerifier, type_safety,
acquires_list_verifier::AcquiresVerifier, control_flow, locals_safety, reference_safety,
stack_usage_verifier::StackUsageVerifier, type_safety,
};
use move_abstract_interpreter::{absint::FunctionContext, control_flow_graph::ControlFlowGraph};
use move_binary_format::{
control_flow_graph::ControlFlowGraph,
errors::{Location, PartialVMError, PartialVMResult, VMResult},
file_format::{
CompiledModule, FunctionDefinition, FunctionDefinitionIndex, IdentifierIndex, TableIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
//!
//! For bytecode versions 5 and below, delegates to `control_flow_v5`.
use crate::{
absint::FunctionContext,
control_flow_v5,
loop_summary::{LoopPartition, LoopSummary},
};
use move_abstract_interpreter::absint::FunctionContext;
use move_binary_format::{
errors::{PartialVMError, PartialVMResult},
file_format::{CodeOffset, CodeUnit, FunctionDefinition, FunctionDefinitionIndex},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Bounds checks are implemented in the `vm` crate.
pub mod ability_field_requirements;
pub mod absint;
pub mod check_duplication;
pub mod code_unit_verifier;
pub mod constants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! This module defines the abstract state for the local safety analysis.
use crate::absint::{AbstractDomain, FunctionContext, JoinResult};
use move_abstract_interpreter::absint::{AbstractDomain, FunctionContext, JoinResult};
use move_binary_format::{
errors::{PartialVMError, PartialVMResult},
file_format::{AbilitySet, CodeOffset, FunctionDefinitionIndex, LocalIndex},
Expand Down
Loading

0 comments on commit 15cb9c7

Please sign in to comment.