Skip to content

Commit

Permalink
[compiler-v2 native] Change framework name
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Sep 27, 2024
1 parent 883c3e2 commit b2f3715
Show file tree
Hide file tree
Showing 156 changed files with 3,099 additions and 3,099 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ pub enum EntryFunctionCall {

/// Used in on-chain governances to update the major version for the next epoch.
/// Example usage:
/// - `aptos_framework::version::set_for_next_epoch(&framework_signer, new_version);`
/// - `aptos_framework::aptos_governance::reconfigure(&framework_signer);`
/// - `starcoin_framework::version::set_for_next_epoch(&framework_signer, new_version);`
/// - `starcoin_framework::aptos_governance::reconfigure(&framework_signer);`
VersionSetForNextEpoch {
major: u64,
},
Expand Down Expand Up @@ -4133,8 +4133,8 @@ pub fn transaction_fee_convert_to_aptos_fa_burn_ref() -> TransactionPayload {

/// Used in on-chain governances to update the major version for the next epoch.
/// Example usage:
/// - `aptos_framework::version::set_for_next_epoch(&framework_signer, new_version);`
/// - `aptos_framework::aptos_governance::reconfigure(&framework_signer);`
/// - `starcoin_framework::version::set_for_next_epoch(&framework_signer, new_version);`
/// - `starcoin_framework::aptos_governance::reconfigure(&framework_signer);`
pub fn version_set_for_next_epoch(major: u64) -> TransactionPayload {
TransactionPayload::ScriptFunction(ScriptFunction::new(
ModuleId::new(
Expand Down
4 changes: 2 additions & 2 deletions vm/framework/move-stdlib/sources/configs/features.move
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ module std::features {
is_enabled(BN254_STRUCTURES)
}

/// Deprecated by `aptos_framework::randomness_config::RandomnessConfig`.
/// Deprecated by `starcoin_framework::randomness_config::RandomnessConfig`.
const RECONFIGURE_WITH_DKG: u64 = 45;

public fun get_reconfigure_with_dkg_feature(): u64 { RECONFIGURE_WITH_DKG }
Expand Down Expand Up @@ -390,7 +390,7 @@ module std::features {
is_enabled(KEYLESS_BUT_ZKLESS_ACCOUNTS)
}

/// Deprecated by `aptos_framework::jwk_consensus_config::JWKConsensusConfig`.
/// Deprecated by `starcoin_framework::jwk_consensus_config::JWKConsensusConfig`.
const JWK_CONSENSUS: u64 = 49;

public fun get_jwk_consensus_feature(): u64 { JWK_CONSENSUS }
Expand Down
2 changes: 1 addition & 1 deletion vm/framework/starcoin-framework/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ core_resources = "0xA550C18"
vm_reserved = "0x0"

[dependencies]
AptosStdlib = { local = "../aptos-stdlib" }
StarcoinStdlib = { local = "../starcoin-stdlib" }
MoveStdlib = { local = "../move-stdlib" }
58 changes: 29 additions & 29 deletions vm/framework/starcoin-framework/sources/account.move
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
module aptos_framework::account {
module starcoin_framework::account {
use std::bcs;
use std::error;
use std::hash;
use std::option::{Self, Option};
use std::signer;
use std::vector;
use aptos_framework::chain_id;
use aptos_framework::create_signer::create_signer;
use aptos_framework::event::{Self, EventHandle};
use aptos_framework::guid;
use aptos_framework::system_addresses;
use starcoin_framework::chain_id;
use starcoin_framework::create_signer::create_signer;
use starcoin_framework::event::{Self, EventHandle};
use starcoin_framework::guid;
use starcoin_framework::system_addresses;
use aptos_std::ed25519;
use aptos_std::from_bcs;
use aptos_std::multi_ed25519;
use aptos_std::table::{Self, Table};
use aptos_std::type_info::{Self, TypeInfo};

friend aptos_framework::aptos_account;
friend aptos_framework::coin;
friend aptos_framework::genesis;
friend aptos_framework::multisig_account;
friend aptos_framework::resource_account;
friend aptos_framework::transaction_validation;
friend starcoin_framework::aptos_account;
friend starcoin_framework::coin;
friend starcoin_framework::genesis;
friend starcoin_framework::multisig_account;
friend starcoin_framework::resource_account;
friend starcoin_framework::transaction_validation;

#[event]
struct KeyRotation has drop, store {
Expand Down Expand Up @@ -178,9 +178,9 @@ module aptos_framework::account {
public fun create_signer_for_test(addr: address): signer { create_signer(addr) }

/// Only called during genesis to initialize system resources for this module.
public(friend) fun initialize(aptos_framework: &signer) {
system_addresses::assert_aptos_framework(aptos_framework);
move_to(aptos_framework, OriginatingAddress {
public(friend) fun initialize(starcoin_framework: &signer) {
system_addresses::assert_aptos_framework(starcoin_framework);
move_to(starcoin_framework, OriginatingAddress {
address_map: table::new(),
});
}
Expand All @@ -200,7 +200,7 @@ module aptos_framework::account {

// NOTE: @core_resources gets created via a `create_account` call, so we do not include it below.
assert!(
new_address != @vm_reserved && new_address != @aptos_framework && new_address != @aptos_token,
new_address != @vm_reserved && new_address != @starcoin_framework && new_address != @aptos_token,
error::invalid_argument(ECANNOT_RESERVED_ADDRESS)
);

Expand Down Expand Up @@ -654,7 +654,7 @@ module aptos_framework::account {
account_resource: &mut Account,
new_auth_key_vector: vector<u8>,
) acquires OriginatingAddress {
let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
let address_map = &mut borrow_global_mut<OriginatingAddress>(@starcoin_framework).address_map;
let curr_auth_key = from_bcs::to_address(account_resource.authentication_key);

// Checks `OriginatingAddress[curr_auth_key]` is either unmapped, or mapped to `originating_address`.
Expand Down Expand Up @@ -888,7 +888,7 @@ module aptos_framework::account {
#[test]
/// Assert correct signer creation.
fun test_create_signer_for_test() {
assert!(signer::address_of(&create_signer_for_test(@aptos_framework)) == @0x1, 0);
assert!(signer::address_of(&create_signer_for_test(@starcoin_framework)) == @0x1, 0);
assert!(signer::address_of(&create_signer_for_test(@0x123)) == @0x123, 0);
}

Expand Down Expand Up @@ -1042,7 +1042,7 @@ module aptos_framework::account {
///////////////////////////////////////////////////////////////////////////

#[test(alice = @0xa11ce)]
#[expected_failure(abort_code = 65537, location = aptos_framework::ed25519)]
#[expected_failure(abort_code = 65537, location = starcoin_framework::ed25519)]
public entry fun test_empty_public_key(alice: signer) acquires Account, OriginatingAddress {
create_account(signer::address_of(&alice));
let pk = vector::empty<u8>();
Expand Down Expand Up @@ -1260,7 +1260,7 @@ module aptos_framework::account {
//
// Tests for offering rotation capabilities
//
#[test(bob = @0x345, framework = @aptos_framework)]
#[test(bob = @0x345, framework = @starcoin_framework)]
public entry fun test_valid_offer_rotation_capability(bob: signer, framework: signer) acquires Account {
chain_id::initialize_for_test(&framework, 4);
let (alice_sk, alice_pk) = ed25519::generate_keys();
Expand Down Expand Up @@ -1292,7 +1292,7 @@ module aptos_framework::account {
assert!(option::contains(&alice_resource.rotation_capability_offer.for, &bob_addr), 0);
}

#[test(bob = @0x345, framework = @aptos_framework)]
#[test(bob = @0x345, framework = @starcoin_framework)]
#[expected_failure(abort_code = 65544, location = Self)]
public entry fun test_invalid_offer_rotation_capability(bob: signer, framework: signer) acquires Account {
chain_id::initialize_for_test(&framework, 4);
Expand Down Expand Up @@ -1323,7 +1323,7 @@ module aptos_framework::account {
);
}

#[test(bob = @0x345, framework = @aptos_framework)]
#[test(bob = @0x345, framework = @starcoin_framework)]
public entry fun test_valid_revoke_rotation_capability(bob: signer, framework: signer) acquires Account {
chain_id::initialize_for_test(&framework, 4);
let (alice_sk, alice_pk) = ed25519::generate_keys();
Expand Down Expand Up @@ -1353,7 +1353,7 @@ module aptos_framework::account {
revoke_rotation_capability(&alice, signer::address_of(&bob));
}

#[test(bob = @0x345, charlie = @0x567, framework = @aptos_framework)]
#[test(bob = @0x345, charlie = @0x567, framework = @starcoin_framework)]
#[expected_failure(abort_code = 393234, location = Self)]
public entry fun test_invalid_revoke_rotation_capability(
bob: signer,
Expand Down Expand Up @@ -1393,7 +1393,7 @@ module aptos_framework::account {
// Tests for key rotation
//

#[test(account = @aptos_framework)]
#[test(account = @starcoin_framework)]
public entry fun test_valid_rotate_authentication_key_multi_ed25519_to_multi_ed25519(
account: signer
) acquires Account, OriginatingAddress {
Expand Down Expand Up @@ -1428,13 +1428,13 @@ module aptos_framework::account {
multi_ed25519::signature_to_bytes(&from_sig),
multi_ed25519::signature_to_bytes(&to_sig),
);
let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
let address_map = &mut borrow_global_mut<OriginatingAddress>(@starcoin_framework).address_map;
let expected_originating_address = table::borrow(address_map, new_address);
assert!(*expected_originating_address == alice_addr, 0);
assert!(borrow_global<Account>(alice_addr).authentication_key == new_auth_key, 0);
}

#[test(account = @aptos_framework)]
#[test(account = @starcoin_framework)]
public entry fun test_valid_rotate_authentication_key_multi_ed25519_to_ed25519(
account: signer
) acquires Account, OriginatingAddress {
Expand Down Expand Up @@ -1473,14 +1473,14 @@ module aptos_framework::account {
ed25519::signature_to_bytes(&to_sig),
);

let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
let address_map = &mut borrow_global_mut<OriginatingAddress>(@starcoin_framework).address_map;
let expected_originating_address = table::borrow(address_map, new_addr);
assert!(*expected_originating_address == alice_addr, 0);
assert!(borrow_global<Account>(alice_addr).authentication_key == new_auth_key, 0);
}


#[test(account = @aptos_framework)]
#[test(account = @starcoin_framework)]
public entry fun test_simple_rotation(account: &signer) acquires Account {
initialize(account);

Expand All @@ -1497,7 +1497,7 @@ module aptos_framework::account {
}


#[test(account = @aptos_framework)]
#[test(account = @starcoin_framework)]
#[expected_failure(abort_code = 0x20014, location = Self)]
public entry fun test_max_guid(account: &signer) acquires Account {
let addr = signer::address_of(account);
Expand Down
38 changes: 19 additions & 19 deletions vm/framework/starcoin-framework/sources/account.spec.move
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
spec aptos_framework::account {
spec starcoin_framework::account {
/// <high-level-req>
/// No.: 1
/// Requirement: The initialization of the account module should result in the proper system initialization with valid
/// and consistent resources.
/// Criticality: High
/// Implementation: Initialization of the account module creates a valid address_map table and moves the resources
/// to the OriginatingAddress under the aptos_framework account.
/// to the OriginatingAddress under the starcoin_framework account.
/// Enforcement: Audited that the address_map table is created and populated correctly with the expected initial
/// values.
///
Expand Down Expand Up @@ -109,10 +109,10 @@ spec aptos_framework::account {
pragma aborts_if_is_strict;
}

/// Only the address `@aptos_framework` can call.
/// OriginatingAddress does not exist under `@aptos_framework` before the call.
spec initialize(aptos_framework: &signer) {
let aptos_addr = signer::address_of(aptos_framework);
/// Only the address `@starcoin_framework` can call.
/// OriginatingAddress does not exist under `@starcoin_framework` before the call.
spec initialize(starcoin_framework: &signer) {
let aptos_addr = signer::address_of(starcoin_framework);
aborts_if !system_addresses::is_aptos_framework_address(aptos_addr);
aborts_if exists<OriginatingAddress>(aptos_addr);
ensures exists<OriginatingAddress>(aptos_addr);
Expand All @@ -124,7 +124,7 @@ spec aptos_framework::account {

aborts_if !exists<Account>(account_address) && (
account_address == @vm_reserved
|| account_address == @aptos_framework
|| account_address == @starcoin_framework
|| account_address == @aptos_token
|| !(len(authentication_key) == 32)
);
Expand All @@ -134,10 +134,10 @@ spec aptos_framework::account {

/// Check if the bytes of the new address is 32.
/// The Account does not exist under the new address before creating the account.
/// Limit the new account address is not @vm_reserved / @aptos_framework / @aptos_toke.
/// Limit the new account address is not @vm_reserved / @starcoin_framework / @aptos_toke.
spec create_account(new_address: address): signer {
include CreateAccountAbortsIf {addr: new_address};
aborts_if new_address == @vm_reserved || new_address == @aptos_framework || new_address == @aptos_token;
aborts_if new_address == @vm_reserved || new_address == @starcoin_framework || new_address == @aptos_token;
ensures signer::address_of(result) == new_address;
/// [high-level-req-2]
ensures exists<Account>(new_address);
Expand Down Expand Up @@ -303,10 +303,10 @@ spec aptos_framework::account {
let originating_addr = addr;
let new_auth_key_vector = spec_assert_valid_rotation_proof_signature_and_get_auth_key(to_scheme, to_public_key_bytes, cap_update_table, challenge);

let address_map = global<OriginatingAddress>(@aptos_framework).address_map;
let address_map = global<OriginatingAddress>(@starcoin_framework).address_map;
let new_auth_key = from_bcs::deserialize<address>(new_auth_key_vector);

aborts_if !exists<OriginatingAddress>(@aptos_framework);
aborts_if !exists<OriginatingAddress>(@starcoin_framework);
aborts_if !from_bcs::deserializable<address>(account_resource.authentication_key);
aborts_if table::spec_contains(address_map, curr_auth_key) &&
table::spec_get(address_map, curr_auth_key) != originating_addr;
Expand Down Expand Up @@ -354,10 +354,10 @@ spec aptos_framework::account {
};

let new_auth_key_vector = spec_assert_valid_rotation_proof_signature_and_get_auth_key(new_scheme, new_public_key_bytes, cap_update_table, challenge);
let address_map = global<OriginatingAddress>(@aptos_framework).address_map;
let address_map = global<OriginatingAddress>(@starcoin_framework).address_map;

// Verify all properties in update_auth_key_and_originating_address_table
aborts_if !exists<OriginatingAddress>(@aptos_framework);
aborts_if !exists<OriginatingAddress>(@starcoin_framework);
aborts_if !from_bcs::deserializable<address>(offerer_account_resource.authentication_key);
aborts_if table::spec_contains(address_map, curr_auth_key) &&
table::spec_get(address_map, curr_auth_key) != rotation_cap_offerer_address;
Expand Down Expand Up @@ -385,13 +385,13 @@ spec aptos_framework::account {
let source_address = signer::address_of(account);
let account_resource = global<Account>(source_address);
let proof_challenge = RotationCapabilityOfferProofChallengeV2 {
chain_id: global<chain_id::ChainId>(@aptos_framework).id,
chain_id: global<chain_id::ChainId>(@starcoin_framework).id,
sequence_number: account_resource.sequence_number,
source_address,
recipient_address,
};

aborts_if !exists<chain_id::ChainId>(@aptos_framework);
aborts_if !exists<chain_id::ChainId>(@starcoin_framework);
aborts_if !exists<Account>(recipient_address);
aborts_if !exists<Account>(source_address);

Expand Down Expand Up @@ -665,24 +665,24 @@ spec aptos_framework::account {
account_resource: &mut Account,
new_auth_key_vector: vector<u8>,
) {
modifies global<OriginatingAddress>(@aptos_framework);
modifies global<OriginatingAddress>(@starcoin_framework);
include UpdateAuthKeyAndOriginatingAddressTableAbortsIf;
}
spec schema UpdateAuthKeyAndOriginatingAddressTableAbortsIf {
originating_addr: address;
account_resource: Account;
new_auth_key_vector: vector<u8>;
let address_map = global<OriginatingAddress>(@aptos_framework).address_map;
let address_map = global<OriginatingAddress>(@starcoin_framework).address_map;
let curr_auth_key = from_bcs::deserialize<address>(account_resource.authentication_key);
let new_auth_key = from_bcs::deserialize<address>(new_auth_key_vector);
aborts_if !exists<OriginatingAddress>(@aptos_framework);
aborts_if !exists<OriginatingAddress>(@starcoin_framework);
aborts_if !from_bcs::deserializable<address>(account_resource.authentication_key);
aborts_if table::spec_contains(address_map, curr_auth_key) &&
table::spec_get(address_map, curr_auth_key) != originating_addr;
aborts_if !from_bcs::deserializable<address>(new_auth_key_vector);
aborts_if curr_auth_key != new_auth_key && table::spec_contains(address_map, new_auth_key);

ensures table::spec_contains(global<OriginatingAddress>(@aptos_framework).address_map, from_bcs::deserialize<address>(new_auth_key_vector));
ensures table::spec_contains(global<OriginatingAddress>(@starcoin_framework).address_map, from_bcs::deserialize<address>(new_auth_key_vector));
}

spec verify_signed_message<T: drop>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// operation and should be avoided as much as possible because it reduces the
/// parallelism. Moreover, **aggregators can only be created by Aptos Framework (0x1)
/// at the moment.**
module aptos_framework::aggregator {
module starcoin_framework::aggregator {

/// The value of aggregator overflows. Raised by native code.
const EAGGREGATOR_OVERFLOW: u64 = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spec aptos_framework::aggregator {
spec starcoin_framework::aggregator {
/// <high-level-req>
/// No.: 1
/// Requirement: For a given aggregator, it should always be possible to: Return the limit value of the aggregator.
Expand Down
Loading

0 comments on commit b2f3715

Please sign in to comment.