Skip to content

Commit

Permalink
[move] Cleanup lingering global ops (MystenLabs#14665)
Browse files Browse the repository at this point in the history
## Description 

- Remove some lingering global storage ops 

## Test Plan 

- Ran tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
tnowacki authored Nov 6, 2023
1 parent ef217cb commit d4db615
Show file tree
Hide file tree
Showing 53 changed files with 62 additions and 2,357 deletions.
18 changes: 0 additions & 18 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ exclude = [
"external-crates/move/crates/move-prover-boogie-backend",
"external-crates/move/crates/move-prover-test-utils",
"external-crates/move/crates/move-read-write-set-types",
"external-crates/move/crates/move-resource-viewer",
"external-crates/move/crates/move-stackless-bytecode",
"external-crates/move/crates/move-stackless-bytecode-interpreter",
"external-crates/move/crates/move-stdlib",
Expand Down
2 changes: 0 additions & 2 deletions crates/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ move-package = { path = "../../external-crates/move/crates/move-package", defaul
move-prover = { path = "../../external-crates/move/crates/move-prover", default-features = false }
move-prover-boogie-backend = { path = "../../external-crates/move/crates/move-prover-boogie-backend", default-features = false }
move-read-write-set-types = { path = "../../external-crates/move/crates/move-read-write-set-types", default-features = false }
move-resource-viewer = { path = "../../external-crates/move/crates/move-resource-viewer", default-features = false }
move-stackless-bytecode = { path = "../../external-crates/move/crates/move-stackless-bytecode", default-features = false }
move-stackless-bytecode-interpreter = { path = "../../external-crates/move/crates/move-stackless-bytecode-interpreter", default-features = false }
move-stdlib = { path = "../../external-crates/move/crates/move-stdlib", features = ["testing"] }
Expand Down Expand Up @@ -1256,7 +1255,6 @@ move-proc-macros = { path = "../../external-crates/move/crates/move-proc-macros"
move-prover = { path = "../../external-crates/move/crates/move-prover", default-features = false }
move-prover-boogie-backend = { path = "../../external-crates/move/crates/move-prover-boogie-backend", default-features = false }
move-read-write-set-types = { path = "../../external-crates/move/crates/move-read-write-set-types", default-features = false }
move-resource-viewer = { path = "../../external-crates/move/crates/move-resource-viewer", default-features = false }
move-stackless-bytecode = { path = "../../external-crates/move/crates/move-stackless-bytecode", default-features = false }
move-stackless-bytecode-interpreter = { path = "../../external-crates/move/crates/move-stackless-bytecode-interpreter", default-features = false }
move-stdlib = { path = "../../external-crates/move/crates/move-stdlib", features = ["testing"] }
Expand Down
17 changes: 0 additions & 17 deletions external-crates/move/Cargo.lock

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

1 change: 0 additions & 1 deletion external-crates/move/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ move-prover = { path = "crates/move-prover" }
move-prover-boogie-backend = { path = "crates/move-prover-boogie-backend" }
move-prover-test-utils = { path = "crates/move-prover-test-utils" }
move-read-write-set-types = { path = "crates/move-read-write-set-types" }
move-resource-viewer = { path = "crates/move-resource-viewer" }
move-stackless-bytecode = { path = "crates/move-stackless-bytecode" }
move-stackless-bytecode-interpreter = { path = "crates/move-stackless-bytecode-interpreter" }
move-stdlib = { path = "crates/move-stdlib" }
Expand Down
1 change: 0 additions & 1 deletion external-crates/move/crates/move-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ move-vm-runtime.workspace = true
move-vm-profiler.workspace = true
move-vm-test-utils.workspace = true
move-read-write-set-types.workspace = true
move-resource-viewer.workspace = true
move-binary-format.workspace = true
move-package.workspace = true
move-prover.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions external-crates/move/crates/move-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub const DEFAULT_STORAGE_DIR: &str = "storage";
/// Default directory for build output
pub const DEFAULT_BUILD_DIR: &str = ".";

/// Extension for resource and event files, which are in BCS format
const BCS_EXTENSION: &str = "bcs";

use anyhow::Result;
use clap::Parser;
use move_core_types::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ use move_bytecode_utils::Modules;
use move_core_types::vm_status::StatusCode;

use anyhow::{bail, Result};
use std::{ffi::OsStr, path::Path};

/// Run sanity checks on storage and build dirs. This is primarily intended for testing the CLI;
/// doctor should never fail unless `publish --ignore-breaking changes` is used or files under
/// `storage` or `build` are modified manually. This runs the following checks:
/// (1) all modules pass the bytecode verifier
/// (2) all modules pass the linker
/// (3) all resources can be deserialized
/// (4) all events can be deserialized
/// (5) build/mv_interfaces is consistent with the global storage (TODO?)
/// (3) build/mv_interfaces is consistent with the global storage (TODO?)
pub fn doctor(state: &OnDiskStateView) -> Result<()> {
fn parent_addr(p: &Path) -> &OsStr {
p.parent().unwrap().parent().unwrap().file_name().unwrap()
}

// verify and link each module
let all_modules = state.get_all_modules()?;
let code_cache = Modules::new(&all_modules);
Expand Down Expand Up @@ -57,17 +50,6 @@ pub fn doctor(state: &OnDiskStateView) -> Result<()> {
)
}
}
// deserialize each event
for event_path in state.event_paths() {
let event = state.view_events(&event_path);
if event.is_err() {
bail!(
"Failed to deserialize event {:?} stored under address {:?}",
event_path.file_name().unwrap(),
parent_addr(&event_path)
)
}
}

Ok(())
}
15 changes: 6 additions & 9 deletions external-crates/move/crates/move-cli/src/sandbox/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use crate::{
sandbox::utils::{
contains_module, explain_execution_effects, explain_execution_error, get_gas_status,
is_bytecode_file, maybe_commit_effects, on_disk_state_view::OnDiskStateView,
contains_module, explain_execution_error, get_gas_status, is_bytecode_file,
on_disk_state_view::OnDiskStateView,
},
NativeFunctionRecord,
};
Expand Down Expand Up @@ -41,8 +41,8 @@ pub fn run(
txn_args: &[TransactionArgument],
vm_type_tags: Vec<TypeTag>,
gas_budget: Option<u64>,
dry_run: bool,
verbose: bool,
_dry_run: bool,
_verbose: bool,
) -> Result<()> {
if !try_exists(script_path)? {
bail!("Script file {:?} does not exist", script_path)
Expand Down Expand Up @@ -143,10 +143,7 @@ move run` must be applied to a module inside `storage/`",
txn_args,
)
} else {
let (changeset, events) = session.finish().0.map_err(|e| e.into_vm_status())?;
if verbose {
explain_execution_effects(&changeset, &events, state)?
}
maybe_commit_effects(!dry_run, changeset, events, state)
let (_changeset, _events) = session.finish().0.map_err(|e| e.into_vm_status())?;
Ok(())
}
}
43 changes: 1 addition & 42 deletions external-crates/move/crates/move-cli/src/sandbox/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use move_compiler::{
};
use move_core_types::{
account_address::AccountAddress,
effects::{ChangeSet, Event, Op},
effects::{ChangeSet, Op},
errmap::ErrorMapping,
language_storage::{ModuleId, TypeTag},
transaction_argument::TransactionArgument,
Expand Down Expand Up @@ -101,47 +101,6 @@ pub(crate) fn explain_publish_changeset(changeset: &ChangeSet) {
)
}

pub(crate) fn explain_execution_effects(
changeset: &ChangeSet,
events: &[Event],
_state: &OnDiskStateView,
) -> Result<()> {
// execution effects should contain no modules
assert!(changeset.modules().next().is_none());
assert!(changeset.resources().next().is_none());
if !events.is_empty() {
println!("Emitted {:?} events:", events.len());
// TODO: better event printing
for (event_key, event_sequence_number, _event_type, event_data) in events {
println!(
"Emitted {:?} as the {}th event to stream {:?}",
event_data, event_sequence_number, event_key
)
}
}
Ok(())
}

/// Commit the resources and events modified by a transaction to disk
pub(crate) fn maybe_commit_effects(
commit: bool,
changeset: ChangeSet,
events: Vec<Event>,
state: &OnDiskStateView,
) -> Result<()> {
// similar to explain effects, all module publishing happens via save_modules(), so effects
// shouldn't contain modules
if commit {
for (event_key, event_sequence_number, event_type, event_data) in events {
state.save_event(&event_key, event_sequence_number, event_type, event_data)?
}
} else if !(changeset.resources().next().is_none() && events.is_empty()) {
println!("Discarding changes; re-run without --dry-run if you would like to keep them.")
}

Ok(())
}

pub(crate) fn explain_type_error(
script_params: &[SignatureToken],
signers: &[AccountAddress],
Expand Down
Loading

0 comments on commit d4db615

Please sign in to comment.