Skip to content

Commit

Permalink
Feature gate permissioned signer
Browse files Browse the repository at this point in the history
  • Loading branch information
runtian-zhou committed Dec 17, 2024
1 parent 60ce91a commit 6494f73
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
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 @@ -133,6 +133,7 @@ pub enum FeatureFlag {
CollectionOwner,
NativeMemoryOperations,
EnableLoaderV2,
PermissionedSigner,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -351,6 +352,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::CollectionOwner => AptosFeatureFlag::COLLECTION_OWNER,
FeatureFlag::NativeMemoryOperations => AptosFeatureFlag::NATIVE_MEMORY_OPERATIONS,
FeatureFlag::EnableLoaderV2 => AptosFeatureFlag::ENABLE_LOADER_V2,
FeatureFlag::PermissionedSigner => AptosFeatureFlag::PERMISSIONED_SIGNER,
}
}
}
Expand Down Expand Up @@ -496,6 +498,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::COLLECTION_OWNER => FeatureFlag::CollectionOwner,
AptosFeatureFlag::NATIVE_MEMORY_OPERATIONS => FeatureFlag::NativeMemoryOperations,
AptosFeatureFlag::ENABLE_LOADER_V2 => FeatureFlag::EnableLoaderV2,
AptosFeatureFlag::PERMISSIONED_SIGNER => FeatureFlag::PermissionedSigner,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/// After introducing the core functionality, examples are provided for withdraw limit on accounts, and
/// for blind signing.
module aptos_framework::permissioned_signer {
use std::features;
use std::signer;
use std::error;
use std::vector;
Expand Down Expand Up @@ -62,6 +63,9 @@ module aptos_framework::permissioned_signer {
/// given master signer.
const E_NOT_ACTIVE: u64 = 8;

/// Permissioned signer feature is not activated.
const EPERMISSION_SIGNER_DISABLED: u64 = 9;

const U256_MAX: u256 =
115792089237316195423570985008687907853269984665640564039457584007913129639935;

Expand Down Expand Up @@ -210,6 +214,10 @@ module aptos_framework::permissioned_signer {
/// signer interacts with various framework functions, it would subject to permission checks
/// and would abort if check fails.
public fun signer_from_permissioned_handle(p: &PermissionedHandle): signer {
assert!(
features::is_permissioned_signer_enabled(),
error::permission_denied(EPERMISSION_SIGNER_DISABLED)
);
signer_from_permissioned_handle_impl(
p.master_account_addr, p.permissions_storage_addr
)
Expand All @@ -219,6 +227,10 @@ module aptos_framework::permissioned_signer {
public(friend) fun signer_from_storable_permissioned_handle(
p: &StorablePermissionedHandle
): signer {
assert!(
features::is_permissioned_signer_enabled(),
error::permission_denied(EPERMISSION_SIGNER_DISABLED)
);
assert!(
timestamp::now_seconds() < p.expiration_time,
error::permission_denied(E_PERMISSION_EXPIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,14 @@ module std::features {
is_enabled(COLLECTION_OWNER)
}

const PERMISSIONED_SIGNER: u64 = 82;

public fun get_permissioned_signer_feature(): u64 { PERMISSIONED_SIGNER }

public fun is_permissioned_signer_enabled(): bool acquires Features {
is_enabled(PERMISSIONED_SIGNER)
}

// ============================================================================================
// Feature Flag Implementation

Expand Down
2 changes: 2 additions & 0 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub enum FeatureFlag {
/// AIP-105 (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-105.md)
NATIVE_MEMORY_OPERATIONS = 80,
ENABLE_LOADER_V2 = 81,
PERMISSIONED_SIGNER = 82,
}

impl FeatureFlag {
Expand Down Expand Up @@ -179,6 +180,7 @@ impl FeatureFlag {
FeatureFlag::NATIVE_MEMORY_OPERATIONS,
FeatureFlag::COLLECTION_OWNER,
FeatureFlag::ENABLE_LOADER_V2,
FeatureFlag::PERMISSIONED_SIGNER,
]
}
}
Expand Down

0 comments on commit 6494f73

Please sign in to comment.