Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make object directly passable in tx's #7090

Merged
merged 64 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
962d14d
First attempt at making object passable
gerben-stavenga Mar 13, 2023
144a936
add tests
gerben-stavenga Mar 14, 2023
5456eb4
Add tests
gerben-stavenga Mar 14, 2023
259c166
add
gerben-stavenga Mar 17, 2023
3640c4b
saving
gerben-stavenga Mar 17, 2023
6af8d37
compiles
gerben-stavenga Mar 18, 2023
2566af6
Merge branch 'main' into object-gerben
gerben-stavenga Mar 18, 2023
5124032
Recursive construct allowed structs
gerben-stavenga Mar 18, 2023
699ef51
merge move aptos-core
gerben-stavenga Mar 18, 2023
b393226
reverse order
gerben-stavenga Mar 18, 2023
80d6fef
restore
gerben-stavenga Mar 19, 2023
f9f608c
revert changes
gerben-stavenga Mar 19, 2023
6cb8fc8
revert changes
gerben-stavenga Mar 19, 2023
264ec94
revert changes
gerben-stavenga Mar 19, 2023
8a005e1
revert changes
gerben-stavenga Mar 19, 2023
a574a94
rename
gerben-stavenga Mar 19, 2023
34e16b7
rename
gerben-stavenga Mar 19, 2023
ba3970c
fix lint
gerben-stavenga Mar 19, 2023
bbc82dd
Add tests
gerben-stavenga Mar 19, 2023
a9489b3
Fix tests
gerben-stavenga Mar 20, 2023
a516b75
Merge branch 'main' into object-gerben
gerben-stavenga Mar 20, 2023
f6bfdfe
undo multisig
gerben-stavenga Mar 20, 2023
5ade6e0
Refactor
gerben-stavenga Mar 20, 2023
8c2c0d6
Refactor
gerben-stavenga Mar 20, 2023
e395bda
Refactor
gerben-stavenga Mar 20, 2023
c416e70
format
gerben-stavenga Mar 20, 2023
a8ecc41
format
gerben-stavenga Mar 20, 2023
a60e391
format
gerben-stavenga Mar 20, 2023
4231cbe
format
gerben-stavenga Mar 20, 2023
2081ab0
Fix bug in test framework
gerben-stavenga Mar 20, 2023
4164af1
format
gerben-stavenga Mar 20, 2023
0d1024c
format
gerben-stavenga Mar 20, 2023
30e974d
unmetered gas
gerben-stavenga Mar 20, 2023
10cf6c6
Rewrite to be closer to old string
gerben-stavenga Mar 21, 2023
957ea2c
Refactor towards minimal diff
gerben-stavenga Mar 21, 2023
72276c4
Refactor towards minimal diff
gerben-stavenga Mar 21, 2023
8276ba2
Refactor towards minimal diff
gerben-stavenga Mar 21, 2023
567f461
Refactor towards minimal diff
gerben-stavenga Mar 21, 2023
6b9cda1
Refactor towards minimal diff
gerben-stavenga Mar 21, 2023
e5d69c0
Improve code
gerben-stavenga Mar 21, 2023
a558385
Improve code
gerben-stavenga Mar 21, 2023
77c456a
Feature flags
gerben-stavenga Mar 21, 2023
3ae5e46
Add more structs
gerben-stavenga Mar 21, 2023
cf4c079
merge
gerben-stavenga Mar 21, 2023
d783d9f
Add test of complicated nested structs
gerben-stavenga Mar 21, 2023
7749d6f
Add test of complicated nested structs
gerben-stavenga Mar 21, 2023
8c19045
Add test of complicated nested structs
gerben-stavenga Mar 21, 2023
630ca1c
Add test of complicated nested structs
gerben-stavenga Mar 21, 2023
9cd5d7c
format
gerben-stavenga Mar 22, 2023
7102071
Merge branch 'main' into object-gerben
gerben-stavenga Mar 22, 2023
7a4a4ac
Add generic tests
gerben-stavenga Mar 22, 2023
bcf17e4
Comment
gerben-stavenga Mar 22, 2023
67dc652
exhaustive tests
gerben-stavenga Mar 22, 2023
fcacb5d
one more testcase
gerben-stavenga Mar 22, 2023
e57fbe3
Make module/function opaque to outside crate
gerben-stavenga Mar 22, 2023
bc4a4cd
pass error message along
gerben-stavenga Mar 22, 2023
d61234a
Feature gate error message
gerben-stavenga Mar 23, 2023
096fac0
format
gerben-stavenga Mar 23, 2023
41a8149
format
gerben-stavenga Mar 23, 2023
9d2c469
comment
gerben-stavenga Mar 23, 2023
b381cee
comment
gerben-stavenga Mar 23, 2023
a6ab849
Improve error msg
gerben-stavenga Mar 23, 2023
a6ed560
Improve error msg
gerben-stavenga Mar 23, 2023
065ee15
Add victors comment
gerben-stavenga Mar 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum FeatureFlag {
CryptographyAlgebraNatives,
Bls12381Structures,
Ed25519PubkeyValidateReturnFalseWrongLength,
StructConstructors,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -138,6 +139,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::Ed25519PubkeyValidateReturnFalseWrongLength => {
AptosFeatureFlag::ED25519_PUBKEY_VALIDATE_RETURN_FALSE_WRONG_LENGTH
},
FeatureFlag::StructConstructors => AptosFeatureFlag::STRUCT_CONSTRUCTORS,
}
}
}
Expand Down Expand Up @@ -170,6 +172,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::ED25519_PUBKEY_VALIDATE_RETURN_FALSE_WRONG_LENGTH => {
FeatureFlag::Ed25519PubkeyValidateReturnFalseWrongLength
},
AptosFeatureFlag::STRUCT_CONSTRUCTORS => FeatureFlag::StructConstructors,
}
}
}
Expand Down
105 changes: 59 additions & 46 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use move_core_types::{
transaction_argument::convert_txn_args,
value::{serialize_values, MoveValue},
};
use move_vm_runtime::session::SerializedReturnValues;
use move_vm_types::gas::UnmeteredGasMeter;
use num_cpus;
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -328,6 +329,40 @@ impl AptosVM {
))
}

fn validate_and_execute_entry_function<SS: MoveResolverExt>(
&self,
session: &mut SessionExt<SS>,
gas_meter: &mut AptosGasMeter,
senders: Vec<AccountAddress>,
script_fn: &EntryFunction,
) -> Result<SerializedReturnValues, VMStatus> {
let function = session.load_function(
script_fn.module(),
script_fn.function(),
script_fn.ty_args(),
)?;
let struct_constructors = self
.0
.get_features()
.is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS);
let args = verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
session,
senders,
script_fn.args().to_vec(),
&function,
struct_constructors,
)?;
session
.execute_entry_function(
script_fn.module(),
script_fn.function(),
script_fn.ty_args().to_vec(),
args,
gas_meter,
)
.map_err(|e| e.into_vm_status())
}

fn execute_script_or_entry_function<S: MoveResolverExt, SS: MoveResolverExt>(
&self,
storage: &S,
Expand Down Expand Up @@ -359,51 +394,36 @@ impl AptosVM {
session.load_script(script.code(), script.ty_args().to_vec())?;
let args =
verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
&session,
&mut session,
senders,
convert_txn_args(script.args()),
&loaded_func,
self.0
.get_features()
.is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS),
)?;
session.execute_script(
script.code(),
script.ty_args().to_vec(),
args,
gas_meter,
)
session
.execute_script(script.code(), script.ty_args().to_vec(), args, gas_meter)
.map_err(|e| e.into_vm_status())?;
},
TransactionPayload::EntryFunction(script_fn) => {
let mut senders = vec![txn_data.sender()];

senders.extend(txn_data.secondary_signers());

let function = session.load_function(
script_fn.module(),
script_fn.function(),
script_fn.ty_args(),
)?;
let args =
verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
&session,
senders,
script_fn.args().to_vec(),
&function,
)?;
session.execute_entry_function(
script_fn.module(),
script_fn.function(),
script_fn.ty_args().to_vec(),
args,
self.validate_and_execute_entry_function(
&mut session,
gas_meter,
)
senders,
script_fn,
)?;
},

// Not reachable as this function should only be invoked for entry or script
// transaction payload.
_ => {
return Err(VMStatus::Error(StatusCode::UNREACHABLE, None));
},
}
.map_err(|e| e.into_vm_status())?;
};

self.resolve_pending_code_publish(
&mut session,
Expand Down Expand Up @@ -575,26 +595,14 @@ impl AptosVM {
payload: &EntryFunction,
new_published_modules_loaded: &mut bool,
) -> Result<(), VMStatus> {
let function =
session.load_function(payload.module(), payload.function(), payload.ty_args())?;
// This transaction is now being executed as the multisig account.
movekevin marked this conversation as resolved.
Show resolved Hide resolved
// If txn args are not valid, we'd still consider the multisig transaction as executed but
// If txn args are not valid, we'd still consider the transaction as executed but
// failed. This is primarily because it's unrecoverable at this point.
let args = verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
self.validate_and_execute_entry_function(
session,
gas_meter,
vec![multisig_address],
payload.args().to_vec(),
&function,
payload,
)?;
session
.execute_entry_function(
payload.module(),
payload.function(),
payload.ty_args().to_vec(),
args,
gas_meter,
)
.map_err(|e| e.into_vm_status())?;

// Resolve any pending module publishes in case the multisig transaction is deploying
// modules.
Expand Down Expand Up @@ -1115,10 +1123,13 @@ impl AptosVM {
.map_err(|e| Err(e.into_vm_status()))?;
let args =
verifier::transaction_arg_validation::validate_combine_signer_and_txn_args(
&tmp_session,
&mut tmp_session,
senders,
convert_txn_args(script.args()),
&loaded_func,
self.0
.get_features()
.is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS),
)
.map_err(Err)?;

Expand Down Expand Up @@ -1290,11 +1301,13 @@ impl AptosVM {
let func_inst = session.load_function(&module_id, &func_name, &type_args)?;
let metadata = vm.0.extract_module_metadata(&module_id);
let arguments = verifier::view_function::validate_view_function(
&session,
&mut session,
arguments,
func_name.as_ident_str(),
&func_inst,
metadata.as_ref(),
vm.0.get_features()
.is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS),
)?;

Ok(session
Expand Down
Loading