Skip to content

Commit

Permalink
comments: runtime_env --> runtime_environment where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Sep 4, 2024
1 parent 21fd820 commit 2a12900
Show file tree
Hide file tree
Showing 26 changed files with 82 additions and 66 deletions.
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm-profiling/src/bins/run_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ fn main() -> Result<()> {
);
Entrypoint::Module(module.self_id())
};
let module_and_script_storage = module_bytes_storage.into_unsync_code_storage(vm.runtime_env());
let module_and_script_storage =
module_bytes_storage.into_unsync_code_storage(vm.runtime_environment());

let mut extensions = NativeContextExtensions::default();
extensions.add(NativeTableContext::new([0; 32], &resource_storage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct AptosCodeStorageAdapter<'s, S> {
impl<'s, S: StateView> AptosCodeStorageAdapter<'s, S> {
fn new(state_view: &'s S, vm: &'s MoveVM) -> Self {
let adapter = StateViewAdapter { state_view };
let storage = adapter.into_unsync_code_storage(vm.runtime_env());
let storage = adapter.into_unsync_code_storage(vm.runtime_environment());
Self { storage }
}
}
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ impl AptosVM {
)
.map_err(|e| e.finish(Location::Undefined))?;
let tmp_module_storage = TemporaryModuleStorage::create(
self.move_vm.runtime_env(),
self.move_vm.runtime_environment(),
write_ops,
module_storage,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn call_non_existent_module() {

let resource_storage = BlankStorage;
let module_storage =
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let module_id = ModuleId::new(TEST_ADDR, Identifier::new("M").unwrap());
Expand Down Expand Up @@ -67,7 +67,7 @@ fn call_non_existent_function() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let fun_name = Identifier::new("foo").unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ fn test_malformed_resource() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(ms.self_addr(), ms.self_name(), ms_blob.into());
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), m_blob.into());
let module_and_script_storage = module_bytes_storage.into_unsync_code_storage(vm.runtime_env());
let module_and_script_storage =
module_bytes_storage.into_unsync_code_storage(vm.runtime_environment());

// Execute the first script to publish a resource Foo.
let mut script_blob = vec![];
Expand Down Expand Up @@ -201,7 +202,8 @@ fn test_malformed_module() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.execute_function_bypass_visibility(
Expand Down Expand Up @@ -235,7 +237,8 @@ fn test_malformed_module() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let err = sess
Expand Down Expand Up @@ -284,7 +287,8 @@ fn test_unverifiable_module() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.execute_function_bypass_visibility(
Expand Down Expand Up @@ -314,7 +318,8 @@ fn test_unverifiable_module() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);

Expand Down Expand Up @@ -372,7 +377,8 @@ fn test_missing_module_dependency() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob_m.into());
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.execute_function_bypass_visibility(
Expand All @@ -397,7 +403,8 @@ fn test_missing_module_dependency() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let err = sess
Expand Down Expand Up @@ -454,7 +461,8 @@ fn test_malformed_module_dependency() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob_m.clone().into());
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.execute_function_bypass_visibility(
Expand Down Expand Up @@ -485,7 +493,8 @@ fn test_malformed_module_dependency() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob_m.into());
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let err = sess
Expand Down Expand Up @@ -545,7 +554,8 @@ fn test_unverifiable_module_dependency() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob_m.into());
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.execute_function_bypass_visibility(
Expand Down Expand Up @@ -576,7 +586,8 @@ fn test_unverifiable_module_dependency() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob_m.into());
module_bytes_storage.add_module_bytes(n.self_addr(), n.self_name(), blob_n.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
let err = sess
Expand Down Expand Up @@ -785,7 +796,8 @@ fn test_storage_returns_bogus_error_when_loading_resource() {
let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), m_blob.clone().into());
module_bytes_storage.add_module_bytes(s.self_addr(), s.self_name(), s_blob.clone().into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let storage = BogusResourceStorage {
module_storage: resource_storage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn test_run_script_with_custom_max_binary_format_version() {
));

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let mut sess = vm.new_session(&resource_storage);
Expand Down Expand Up @@ -160,7 +160,7 @@ fn test_run_script_with_custom_max_binary_format_version() {
);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let mut sess = vm.new_session(&resource_storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn run(
let (resource_storage, module_bytes_storage) = setup(&modules);

let vm = MoveVM::new(vec![]);
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let fun_name = Identifier::new(fun_name).unwrap();
let traversal_storage = TraversalStorage::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn run(

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let fun_name = Identifier::new("foo").unwrap();
let traversal_storage = TraversalStorage::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn merge_borrow_states_infinite_loop() {
let vm = MoveVM::new(vec![]);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let traversal_storage = TraversalStorage::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn leak_with_abort() {
let vm = MoveVM::new(vec![]);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let traversal_storage = TraversalStorage::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Adapter {
let module_storage = self
.module_bytes_storage
.clone()
.into_unsync_module_storage(self.vm.runtime_env());
.into_unsync_module_storage(self.vm.runtime_environment());
scope.spawn(move || {
// It is fine to share the VM: we do not publish modules anyway.
let mut session = self.vm.as_ref().new_session(&resource_storage);
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Adapter {
let module_storage = self
.module_bytes_storage
.clone()
.into_unsync_module_storage(self.vm.runtime_env());
.into_unsync_module_storage(self.vm.runtime_environment());
let mut session = self.vm.new_session(&self.resource_storage);
let traversal_storage = TraversalStorage::new();
session
Expand Down Expand Up @@ -286,7 +286,7 @@ fn load_phantom_module() {
let module_storage = adapter
.module_bytes_storage
.clone()
.into_unsync_module_storage(adapter.vm.runtime_env());
.into_unsync_module_storage(adapter.vm.runtime_environment());
let _ = session
.load_function(&module_storage, &module_id, ident_str!("foo"), &[])
.unwrap();
Expand Down Expand Up @@ -356,7 +356,7 @@ fn load_with_extra_ability() {
let module_storage = adapter
.module_bytes_storage
.clone()
.into_unsync_module_storage(adapter.vm.runtime_env());
.into_unsync_module_storage(adapter.vm.runtime_environment());
let _ = session
.load_function(&module_storage, &module_id, ident_str!("foo"), &[])
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn mutated_accounts() {

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn test_publish_module_with_nested_loops() {

let resource_storage = InMemoryStorage::new();
let module_storage =
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.verify_module_bundle_before_publishing(&[m.clone()], &TEST_ADDR, &module_storage)
Expand All @@ -81,7 +81,7 @@ fn test_publish_module_with_nested_loops() {

let resource_storage = InMemoryStorage::new();
let module_storage =
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);
sess.verify_module_bundle_before_publishing(&[m], &TEST_ADDR, &module_storage)
Expand Down Expand Up @@ -132,7 +132,7 @@ fn test_run_script_with_nested_loops() {
);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let mut sess = vm.new_session(&resource_storage);
Expand Down Expand Up @@ -166,7 +166,7 @@ fn test_run_script_with_nested_loops() {
);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let mut sess = vm.new_session(&resource_storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn script_large_ty() {
module.into(),
);
let module_and_script_storage =
module_bytes_storage.into_unsync_code_storage(move_vm.runtime_env());
module_bytes_storage.into_unsync_code_storage(move_vm.runtime_environment());

// constructs a type with about 25^3 nodes
let num_type_args = 25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn run(

let mut module_bytes_storage = LocalModuleBytesStorage::empty();
module_bytes_storage.add_module_bytes(m.self_addr(), m.self_name(), blob.into());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let mut sess = vm.new_session(&resource_storage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn runtime_reentrancy_check() {
TEST_ADDR.to_hex(),
);
let (resource_storage, module_bytes_storage) = set_up_storage(vec![code_1, code_2, code_3]);
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_env());
let module_storage = module_bytes_storage.into_unsync_module_storage(vm.runtime_environment());

let module_id = ModuleId::new(TEST_ADDR, Identifier::new("A").unwrap());
let fun_name = Identifier::new("foo1").unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn call_script_with_args_ty_args_signers(
let move_vm = MoveVM::new(vec![]);

let module_and_script_storage =
LocalModuleBytesStorage::empty().into_unsync_code_storage(move_vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_code_storage(move_vm.runtime_environment());
let resource_storage = InMemoryStorage::new();

let traversal_storage = TraversalStorage::new();
Expand Down Expand Up @@ -301,7 +301,8 @@ fn call_function_with_args_ty_args_signers(
);

let move_vm = MoveVM::new(vec![]);
let module_storage = module_bytes_storage.into_unsync_module_storage(move_vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(move_vm.runtime_environment());

let traversal_storage = TraversalStorage::new();

Expand Down Expand Up @@ -789,7 +790,7 @@ fn call_missing_item() {
let move_vm = MoveVM::new(vec![]);

let module_storage =
LocalModuleBytesStorage::empty().into_unsync_module_storage(move_vm.runtime_env());
LocalModuleBytesStorage::empty().into_unsync_module_storage(move_vm.runtime_environment());
let mut resource_storage = InMemoryStorage::new();

let traversal_storage = TraversalStorage::new();
Expand Down Expand Up @@ -824,7 +825,8 @@ fn call_missing_item() {
module_id.name(),
module_blob.into(),
);
let module_storage = module_bytes_storage.into_unsync_module_storage(move_vm.runtime_env());
let module_storage =
module_bytes_storage.into_unsync_module_storage(move_vm.runtime_environment());

let traversal_storage = TraversalStorage::new();

Expand Down
Loading

0 comments on commit 2a12900

Please sign in to comment.