From 1f94920258d1f90a13f0a5aad2cbe621646269e7 Mon Sep 17 00:00:00 2001 From: Bob Ong <2261238+welbon@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:48:49 +0800 Subject: [PATCH] [compiler-v2 framework] Fixed the error of function params signer is reference (#4282) --- abi/decoder/src/lib.rs | 6 +++++- vm/vm-runtime/src/move_vm_ext/session.rs | 3 ++- vm/vm-runtime/src/verifier/transaction_arg_validation.rs | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/abi/decoder/src/lib.rs b/abi/decoder/src/lib.rs index ab9ce968bc..c2ad5db165 100644 --- a/abi/decoder/src/lib.rs +++ b/abi/decoder/src/lib.rs @@ -206,7 +206,11 @@ fn decode_script_function_inner( let arg_abis = func_abi.args(); let first_arg_is_signer = arg_abis .first() - .filter(|abi| abi.type_abi() == &TypeInstantiation::Signer) + .filter(|abi| { + abi.type_abi() == &TypeInstantiation::Signer + || abi.type_abi() + == &TypeInstantiation::Reference(false, Box::new(TypeInstantiation::Signer)) + }) .is_some(); if first_arg_is_signer { &arg_abis[1..] diff --git a/vm/vm-runtime/src/move_vm_ext/session.rs b/vm/vm-runtime/src/move_vm_ext/session.rs index 72c65307d5..ceaf8852a2 100644 --- a/vm/vm-runtime/src/move_vm_ext/session.rs +++ b/vm/vm-runtime/src/move_vm_ext/session.rs @@ -545,10 +545,11 @@ impl<'r, 'l> SessionExt<'r, 'l> { args: Vec>, sender: AccountAddress, ) -> VMResult>> { + let signer_ref = Type::Reference(Box::new(Type::Signer)); let has_signer = func .param_tys() .iter() - .position(|i| matches!(i, &Type::Signer)) + .position(|i| i == &Type::Signer || i == &signer_ref) .map(|pos| { if pos != 0 { Err( diff --git a/vm/vm-runtime/src/verifier/transaction_arg_validation.rs b/vm/vm-runtime/src/verifier/transaction_arg_validation.rs index c821b80660..604a5980f7 100644 --- a/vm/vm-runtime/src/verifier/transaction_arg_validation.rs +++ b/vm/vm-runtime/src/verifier/transaction_arg_validation.rs @@ -99,7 +99,9 @@ pub(crate) fn validate_combine_singer_and_args( match ty { Type::Signer => signer_param_cnt += 1, Type::Reference(inner_type) => { - if matches!(&**inner_type, Type::Signer) { + let signer_ref_type = Type::Reference(Box::new(Type::Signer)); + if matches!(&**inner_type, Type::Signer) || matches!(&**inner_type, signer_ref_type) + { signer_param_cnt += 1; } }