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

Add another flavor of permission api #15609

Draft
wants to merge 10 commits into
base: 01-10-create_object_with_permissioned_signer
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -6,7 +6,7 @@
use crate::{
gas_feature_versions::{RELEASE_V1_14, RELEASE_V1_8, RELEASE_V1_9_SKIPPED},
gas_schedule::NativeGasParameters,
ver::gas_feature_versions::{RELEASE_V1_12, RELEASE_V1_13, RELEASE_V1_23},
ver::gas_feature_versions::{RELEASE_V1_12, RELEASE_V1_13, RELEASE_V1_23, RELEASE_V1_26},
};
use aptos_gas_algebra::{
InternalGas, InternalGasPerAbstractValueUnit, InternalGasPerArg, InternalGasPerByte,
Expand All @@ -20,6 +20,11 @@ crate::gas_schedule::macros::define_gas_parameters!(
[account_create_address_base: InternalGas, "account.create_address.base", 1102],
[account_create_signer_base: InternalGas, "account.create_signer.base", 1102],

// Permissioned signer gas parameters
[permission_address_base: InternalGas, { RELEASE_V1_26 => "permissioned_signer.permission_address.base"}, 1102],
[is_permissioned_signer_base: InternalGas, { RELEASE_V1_26 => "permissioned_signer.is_permissioned_signer.base"}, 1102],
[signer_from_permissioned_handle_base: InternalGas, { RELEASE_V1_26 => "permissioned_signer.signer_from_permissioned_handle.base"}, 1102],

// BN254 algebra gas parameters begin.
// Generated at time 1701559125.5498126 by `scripts/algebra-gas/update_bn254_algebra_gas_params.py` with gas_per_ns=209.10511688369482.
[algebra_ark_bn254_fq12_add: InternalGas, { 12.. => "algebra.ark_bn254_fq12_add" }, 809],
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-gas-schedule/src/ver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ pub mod gas_feature_versions {
pub const RELEASE_V1_22: u64 = 26;
pub const RELEASE_V1_23: u64 = 27;
pub const RELEASE_V1_24: u64 = 28;
pub const RELEASE_V1_26: u64 = 29;
}
13 changes: 13 additions & 0 deletions aptos-move/aptos-release-builder/data/permissioned_signer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
remote_endpoint: ~
name: "v1.26-enable-permissioned_signer"
proposals:
- name: feature_flags
metadata:
title: "Enable permissioned signer feature flag"
description: "Enable permissioned signer in the aptos framework"
execution_mode: MultiStep
update_sequence:
- FeatureFlag:
enabled:
- permissioned_signer
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub enum FeatureFlag {
NativeMemoryOperations,
EnableLoaderV2,
DisallowInitModuleToPublishModules,
PermissionedSigner,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -357,6 +358,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::DisallowInitModuleToPublishModules => {
AptosFeatureFlag::DISALLOW_INIT_MODULE_TO_PUBLISH_MODULES
},
FeatureFlag::PermissionedSigner => AptosFeatureFlag::PERMISSIONED_SIGNER,
}
}
}
Expand Down Expand Up @@ -507,6 +509,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::DISALLOW_INIT_MODULE_TO_PUBLISH_MODULES => {
FeatureFlag::DisallowInitModuleToPublishModules
},
AptosFeatureFlag::PERMISSIONED_SIGNER => FeatureFlag::PermissionedSigner,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/e2e-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ fn main() {
repeats: 100,
map_type: MapType::OrderedMap,
},
EntryPoints::APTPermissionedTransfer,
EntryPoints::APTTransfer,
];

let mut failures = Vec::new();
Expand Down
10 changes: 7 additions & 3 deletions aptos-move/e2e-move-tests/src/tests/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use aptos_types::{
transaction::{EntryFunction, TransactionPayload},
};
use aptos_vm_environment::prod_configs::set_paranoid_type_checks;
use move_core_types::{identifier::Identifier, language_storage::ModuleId};
use move_core_types::{identifier::Identifier, language_storage::ModuleId, value::MoveValue};
use rand::{rngs::StdRng, SeedableRng};
use sha3::{Digest, Sha3_512};
use std::path::Path;
Expand All @@ -55,7 +55,9 @@ fn test_modify_gas_schedule_check_hash() {
"set_for_next_epoch_check_hash",
vec![],
vec![
bcs::to_bytes(&CORE_CODE_ADDRESS).unwrap(),
MoveValue::Signer(CORE_CODE_ADDRESS)
.simple_serialize()
.unwrap(),
bcs::to_bytes(&old_hash).unwrap(),
bcs::to_bytes(&bcs::to_bytes(&gas_schedule).unwrap()).unwrap(),
],
Expand All @@ -64,7 +66,9 @@ fn test_modify_gas_schedule_check_hash() {
harness
.executor
.exec("reconfiguration_with_dkg", "finish", vec![], vec![
bcs::to_bytes(&CORE_CODE_ADDRESS).unwrap(),
MoveValue::Signer(CORE_CODE_ADDRESS)
.simple_serialize()
.unwrap(),
]);

let (_, gas_params) = harness.get_gas_params();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "test"
version = "0.0.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
script {
fun main(s1: &signer, u: u64, s2: &signer) {}
}
43 changes: 41 additions & 2 deletions aptos-move/e2e-move-tests/src/tests/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use aptos_language_e2e_tests::account::TransactionBuilder;
use aptos_types::{
account_address::AccountAddress,
on_chain_config::FeatureFlag,
transaction::{Script, TransactionArgument},
transaction::{Script, TransactionArgument, TransactionStatus},
};
use move_core_types::language_storage::TypeTag;
use move_core_types::{language_storage::TypeTag, value::MoveValue};

#[test]
fn test_script_with_object_parameter() {
Expand Down Expand Up @@ -146,6 +146,45 @@ fn test_script_with_type_parameter() {
assert_success!(status);
}

#[test]
fn test_script_with_signer_parameter() {
let mut h = MoveHarness::new();

let alice = h.new_account_at(AccountAddress::from_hex_literal("0xa11ce").unwrap());

let package = build_package(
common::test_dir_path("script_with_signer.data/pack"),
aptos_framework::BuildOptions::default(),
)
.expect("building package must succeed");

let code = package.extract_script_code().into_iter().next().unwrap();

let txn = TransactionBuilder::new(alice.clone())
.script(Script::new(code, vec![], vec![
TransactionArgument::U64(0),
TransactionArgument::Serialized(
MoveValue::Signer(*alice.address())
.simple_serialize()
.unwrap(),
),
]))
.sequence_number(10)
.max_gas_amount(1_000_000)
.gas_unit_price(1)
.sign();

let status = h.run(txn);
assert_eq!(
status,
TransactionStatus::Keep(
aptos_types::transaction::ExecutionStatus::MiscellaneousError(Some(
aptos_types::vm_status::StatusCode::INVALID_MAIN_FUNCTION_SIGNATURE
))
)
);
}

#[test]
fn test_two_to_two_transfer() {
let mut h = MoveHarness::new();
Expand Down
17 changes: 14 additions & 3 deletions aptos-move/e2e-tests/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ use move_core_types::{
identifier::Identifier,
language_storage::{ModuleId, StructTag, TypeTag},
move_resource::{MoveResource, MoveStructType},
value::MoveValue,
};
use move_vm_runtime::{
module_traversal::{TraversalContext, TraversalStorage},
Expand Down Expand Up @@ -1042,13 +1043,23 @@ impl FakeExecutor {
let mut arg = args.clone();
match &dynamic_args {
ExecFuncTimerDynamicArgs::DistinctSigners => {
arg.insert(0, bcs::to_bytes(&extra_accounts.pop().unwrap()).unwrap());
arg.insert(
0,
MoveValue::Signer(extra_accounts.pop().unwrap())
.simple_serialize()
.unwrap(),
);
},
ExecFuncTimerDynamicArgs::DistinctSignersAndFixed(signers) => {
for signer in signers.iter().rev() {
arg.insert(0, bcs::to_bytes(&signer).unwrap());
arg.insert(0, MoveValue::Signer(*signer).simple_serialize().unwrap());
}
arg.insert(0, bcs::to_bytes(&extra_accounts.pop().unwrap()).unwrap());
arg.insert(
0,
MoveValue::Signer(extra_accounts.pop().unwrap())
.simple_serialize()
.unwrap(),
);
},
_ => {},
}
Expand Down
Loading
Loading