From 366137e04516679be0c492a152d181f8fda89c5d Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Sat, 11 Jan 2025 09:40:20 +0000 Subject: [PATCH] comments: calrify is_valid_txn_arg docstring --- .../src/verifier/transaction_arg_validation.rs | 5 ++++- third_party/move/move-vm/runtime/src/loader/mod.rs | 2 +- .../move-vm/runtime/src/storage/ty_tag_cache.rs | 14 +++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/aptos-move/aptos-vm/src/verifier/transaction_arg_validation.rs b/aptos-move/aptos-vm/src/verifier/transaction_arg_validation.rs index beda18da89ddb..1e39e0eb333ed 100644 --- a/aptos-move/aptos-vm/src/verifier/transaction_arg_validation.rs +++ b/aptos-move/aptos-vm/src/verifier/transaction_arg_validation.rs @@ -195,7 +195,10 @@ pub fn validate_combine_signer_and_txn_args( Ok(combined_args) } -// Return whether the argument is valid/allowed and whether it needs construction. +/// Returns true if the argument is valid (that is, it is a primitive type or a struct with a +/// known constructor function). Otherwise, (for structs without constructors, signers or +/// references) returns false. An error is returned in cases when a struct type is encountered and +/// its name cannot be queried for some reason. pub(crate) fn is_valid_txn_arg( session: &SessionExt, module_storage: &impl AptosModuleStorage, diff --git a/third_party/move/move-vm/runtime/src/loader/mod.rs b/third_party/move/move-vm/runtime/src/loader/mod.rs index bf6367bc97b88..e4404dd58a0cb 100644 --- a/third_party/move/move-vm/runtime/src/loader/mod.rs +++ b/third_party/move/move-vm/runtime/src/loader/mod.rs @@ -13,8 +13,8 @@ use crate::{ loader::LoaderV2, module_storage::{FunctionValueExtensionAdapter, ModuleStorage}, ty_cache::StructInfoCache, + ty_tag_cache::TypeTagBuilder, }, - ty_tag_cache::TypeTagBuilder, CodeStorage, }; use hashbrown::Equivalent; diff --git a/third_party/move/move-vm/runtime/src/storage/ty_tag_cache.rs b/third_party/move/move-vm/runtime/src/storage/ty_tag_cache.rs index c6b70e8edbc58..b9c46defd2774 100644 --- a/third_party/move/move-vm/runtime/src/storage/ty_tag_cache.rs +++ b/third_party/move/move-vm/runtime/src/storage/ty_tag_cache.rs @@ -7,7 +7,7 @@ use move_core_types::{ language_storage::{StructTag, TypeTag}, vm_status::StatusCode, }; -use move_vm_types::loaded_data::runtime_types::{StructNameIndex, Type}; +use move_vm_types::loaded_data::{runtime_types::Type, struct_name_indexing::StructNameIndex}; use parking_lot::RwLock; use std::collections::{hash_map::Entry, HashMap}; @@ -238,24 +238,26 @@ mod tests { fn test_type_tag_cache() { let cache = TypeTagCache::empty(); assert!(cache.cache.read().is_empty()); - assert!(cache.get_struct_tag(&StructNameIndex(0), &[]).is_none()); + assert!(cache + .get_struct_tag(&StructNameIndex::new(0), &[]) + .is_none()); let tag = PricedStructTag { struct_tag: StructTag::from_str("0x1::foo::Foo").unwrap(), pseudo_gas_cost: 10, }; - assert!(cache.insert_struct_tag(&StructNameIndex(0), &[], &tag)); + assert!(cache.insert_struct_tag(&StructNameIndex::new(0), &[], &tag)); let tag = PricedStructTag { struct_tag: StructTag::from_str("0x1::foo::Foo").unwrap(), // Set different cost to check. pseudo_gas_cost: 100, }; - assert!(!cache.insert_struct_tag(&StructNameIndex(0), &[], &tag)); + assert!(!cache.insert_struct_tag(&StructNameIndex::new(0), &[], &tag)); assert_eq!(cache.cache.read().len(), 1); let cost = cache - .get_struct_tag(&StructNameIndex(0), &[]) + .get_struct_tag(&StructNameIndex::new(0), &[]) .unwrap() .pseudo_gas_cost; assert_eq!(cost, 10); @@ -343,8 +345,6 @@ mod tests { constraints: AbilitySet::EMPTY, is_phantom: false, }], - name: Identifier::new("Foo").unwrap(), - module: ModuleId::new(AccountAddress::TWO, Identifier::new("foo").unwrap()), }; let generic_struct_ty = ty_builder .create_struct_instantiation_ty(&struct_ty, &[Type::TyParam(0)], &[bool_vec_ty])