Skip to content

Commit

Permalink
Bump Move version (MystenLabs#5240)
Browse files Browse the repository at this point in the history
* Bump Move version

* fixup! Bump Move version
  • Loading branch information
tnowacki authored Oct 14, 2022
1 parent 87e1314 commit 9633651
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 191 deletions.
76 changes: 38 additions & 38 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ name-variant = "0.1.0"
store = { version = "0.1.0", package = "typed-store" }

# Move dependencies
move-binary-format = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-cli = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-compiler = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-core-types = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1", features = ["address20"] }
move-disassembler = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-package = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-unit-test = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-command-line-common = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-ir-types = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-prover = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "7c8552e0001c0c041c929e050c2d2959935485f1" }
move-binary-format = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-cli = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-compiler = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-core-types = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d", features = ["address20"] }
move-disassembler = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-package = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-stdlib = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-unit-test = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-vm-types = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-command-line-common = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-ir-types = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-prover = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }
move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "c9b5765f816d773618cc12a70a0095f644bbc68d" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "4b7a06fe393003013489990dc2f4d3d2ebb32539" }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-25:
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("ID leak detected in function foo: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some(\"ID leaked through function call.\") } }") } }
created: object(103)
written: object(102)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-25:
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("ID leak detected in function foo: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some(\"ID leaked through function call.\") } }") } }
created: object(103)
written: object(102)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-19:
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("ID leak detected in function foo: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some(\"ID leaked through function return.\") } }") } }
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: UNKNOWN_VERIFICATION_ERROR, sub_status: None, message: Some("Sui Move Bytecode Verification Error: ID leaked through function return."), exec_state: None, location: Module(ModuleId { address: _, name: Identifier("m") }), indices: [], offsets: [] }) } }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-19:
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("ID leak detected in function foo: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some(\"ID leaked through function return.\") } }") } }
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: UNKNOWN_VERIFICATION_ERROR, sub_status: None, message: Some("Sui Move Bytecode Verification Error: ID leaked through function return."), exec_state: None, location: Module(ModuleId { address: _, name: Identifier("m") }), indices: [], offsets: [] }) } }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-20:
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("ID leak detected in function foo: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some(\"ID is leaked into a vector\") } }") } }
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: UNKNOWN_VERIFICATION_ERROR, sub_status: None, message: Some("Sui Move Bytecode Verification Error: ID is leaked into a vector"), exec_state: None, location: Module(ModuleId { address: _, name: Identifier("m") }), indices: [], offsets: [] }) } }
75 changes: 26 additions & 49 deletions crates/sui-verifier/src/id_leak_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@
//! 1. Returned
//! 2. Written into a mutable reference
//! 3. Added to a vector
//! 4. Passed to a function call
use crate::verification_failure;
//! 4. Passed to a function cal::;
use move_binary_format::{
binary_views::{BinaryIndexedView, FunctionView},
errors::PartialVMError,
errors::{Location, PartialVMError, PartialVMResult},
file_format::{
Bytecode, CodeOffset, CompiledModule, FunctionDefinitionIndex, FunctionHandle, LocalIndex,
StructDefinition, StructFieldInformation,
},
};
use move_bytecode_verifier::absint::{
AbstractDomain, AbstractInterpreter, BlockInvariant, BlockPostcondition, JoinResult,
TransferFunctions,
AbstractDomain, AbstractInterpreter, JoinResult, TransferFunctions,
};
use move_core_types::vm_status::StatusCode;
use std::collections::BTreeMap;
use sui_types::{
error::{ExecutionError, ExecutionErrorKind},
id::OBJECT_MODULE_NAME,
SUI_FRAMEWORK_ADDRESS,
};
use sui_types::{error::ExecutionError, id::OBJECT_MODULE_NAME, SUI_FRAMEWORK_ADDRESS};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum AbstractValue {
Expand Down Expand Up @@ -65,26 +59,9 @@ fn verify_id_leak(module: &CompiledModule) -> Result<(), ExecutionError> {
FunctionView::function(module, FunctionDefinitionIndex(index as u16), code, handle);
let initial_state = AbstractState::new(&func_view);
let mut verifier = IDLeakAnalysis::new(&binary_view, &func_view);
let inv_map = verifier.analyze_function(initial_state, &func_view);
// Report all the join failures
for (_block_id, BlockInvariant { post, .. }) in inv_map {
match post {
BlockPostcondition::Error(error) => {
debug_assert_eq!(
error.kind(),
&ExecutionErrorKind::SuiMoveVerificationError,
"Unexpected error type"
);
return Err(verification_failure(format!(
"ID leak detected in function {}: {}",
binary_view.identifier_at(handle.name),
error
)));
}
// Block might be unprocessed if all predecessors had an error
BlockPostcondition::Unprocessed | BlockPostcondition::Success => (),
}
}
verifier
.analyze_function(initial_state, &func_view)
.map_err(|e| e.finish(Location::Module(module.self_id())))?;
}

Ok(())
Expand Down Expand Up @@ -147,17 +124,15 @@ impl<'a> IDLeakAnalysis<'a> {

impl<'a> TransferFunctions for IDLeakAnalysis<'a> {
type State = AbstractState;
type AnalysisError = ExecutionError;

fn execute(
&mut self,
state: &mut Self::State,
bytecode: &Bytecode,
index: CodeOffset,
_: CodeOffset,
) -> Result<(), Self::AnalysisError> {
execute_inner(self, state, bytecode, index)?;
Ok(())
) -> PartialVMResult<()> {
execute_inner(self, state, bytecode, index)
}
}

Expand Down Expand Up @@ -190,19 +165,14 @@ fn is_call_safe_to_leak(verifier: &IDLeakAnalysis, function_handle: &FunctionHan
== "delete_child_object")
}

fn call(
verifier: &mut IDLeakAnalysis,
function_handle: &FunctionHandle,
) -> Result<(), ExecutionError> {
fn call(verifier: &mut IDLeakAnalysis, function_handle: &FunctionHandle) -> PartialVMResult<()> {
let guaranteed_safe = is_call_safe_to_leak(verifier, function_handle);
let parameters = verifier
.binary_view
.signature_at(function_handle.parameters);
for _ in 0..parameters.len() {
if verifier.stack.pop().unwrap() == AbstractValue::ID && !guaranteed_safe {
return Err(verification_failure(
"ID leaked through function call.".to_string(),
));
move_verification_error("ID leaked through function call.");
}
}

Expand Down Expand Up @@ -256,7 +226,7 @@ fn execute_inner(
state: &mut AbstractState,
bytecode: &Bytecode,
_: CodeOffset,
) -> Result<(), ExecutionError> {
) -> PartialVMResult<()> {
// TODO: Better dianostics with location
match bytecode {
Bytecode::Pop => {
Expand Down Expand Up @@ -323,7 +293,7 @@ fn execute_inner(
// Top of stack is the reference, and the second element is the value.
verifier.stack.pop().unwrap();
if verifier.stack.pop().unwrap() == AbstractValue::ID {
return Err(verification_failure("ID is leaked to a reference.".to_string()));
return Err(move_verification_error("ID is leaked to a reference."));
}
}

Expand Down Expand Up @@ -365,7 +335,7 @@ fn execute_inner(
Bytecode::Ret => {
for _ in 0..verifier.function_view.return_().len() {
if verifier.stack.pop().unwrap() == AbstractValue::ID {
return Err(verification_failure("ID leaked through function return.".to_string()));
return Err(move_verification_error("ID leaked through function return."));
}
}
}
Expand Down Expand Up @@ -401,15 +371,15 @@ fn execute_inner(
Bytecode::VecPack(_, num) => {
for _ in 0..*num {
if verifier.stack.pop().unwrap() == AbstractValue::ID {
return Err(verification_failure("ID is leaked into a vector".to_string()));
return Err(move_verification_error("ID is leaked into a vector"));
}
}
verifier.stack.push(AbstractValue::NonID);
}

Bytecode::VecPushBack(_) => {
if verifier.stack.pop().unwrap() == AbstractValue::ID {
return Err(verification_failure("ID is leaked into a vector".to_string()));
return Err(move_verification_error("ID is leaked into a vector"));
}
verifier.stack.pop().unwrap();
}
Expand All @@ -431,7 +401,7 @@ fn execute_inner(
Ok(())
}

fn expect_ok<T>(res: Result<T, PartialVMError>) -> Result<T, ExecutionError> {
fn expect_ok<T>(res: Result<T, PartialVMError>) -> PartialVMResult<T> {
match res {
Ok(x) => Ok(x),
Err(partial_vm_error) => {
Expand All @@ -441,7 +411,14 @@ fn expect_ok<T>(res: Result<T, PartialVMError>) -> Result<T, ExecutionError> {
Got error: {partial_vm_error:?}"
);
// This is an internal error, but we cannot accept the module as safe
Err(ExecutionErrorKind::SuiMoveVerificationError.into())
Err(PartialVMError::new(
StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR,
))
}
}
}

fn move_verification_error(msg: impl std::fmt::Display) -> PartialVMError {
PartialVMError::new(StatusCode::UNKNOWN_VERIFICATION_ERROR)
.with_message(format!("Sui Move Bytecode Verification Error: {}", msg))
}
Loading

0 comments on commit 9633651

Please sign in to comment.