Skip to content

Commit

Permalink
comments: calrify is_valid_txn_arg docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Jan 15, 2025
1 parent f782aca commit 366137e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion third_party/move/move-vm/runtime/src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions third_party/move/move-vm/runtime/src/storage/ty_tag_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 366137e

Please sign in to comment.