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

Fix spec and add spec for supra governance #63

Open
wants to merge 39 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f2b3a63
Fix move spec files
axiongsupra Aug 30, 2024
fdef1f8
Don't verify committee_map
axiongsupra Aug 30, 2024
3847bfa
Merge branch 'dev' into fix-spec
axiongsupra Aug 30, 2024
2909d36
Merge branch 'dev' into fix-spec
axiongsupra Sep 5, 2024
0530b59
Spec for supra_governance
axiongsupra Aug 30, 2024
0b1709f
Commit spec for merge change from dev
axiongsupra Sep 5, 2024
40ba45e
supra_governance spec
axiongsupra Sep 6, 2024
0f0319a
Commit multisig_voting spec
axiongsupra Sep 6, 2024
af60d2a
Finish a few todos
axiongsupra Sep 6, 2024
e4c58d8
Add empty spec first
axiongsupra Sep 6, 2024
3aa67d6
More spec from voting and need to be adjustied
axiongsupra Sep 6, 2024
0d85241
More spec enabled
axiongsupra Sep 11, 2024
817c27e
Precondition works now
axiongsupra Sep 11, 2024
cc3b105
Merge branch 'dev' into fix-spec
axiongsupra Sep 11, 2024
1ed9dd4
Merge branch 'dev' into fix-spec
axiongsupra Sep 27, 2024
8495dbd
Merge branch 'dev' into fix-spec
axiongsupra Oct 2, 2024
35d31d0
Use original genesis.spec.move
axiongsupra Oct 2, 2024
d8f0058
Merge branch 'dev' into fix-spec
axiongsupra Oct 8, 2024
4023ea1
Merge branch 'dev' into fix-spec
axiongsupra Oct 16, 2024
a042dfb
Merge branch 'dev' into fix-spec
axiongsupra Oct 29, 2024
98898d0
Merge branch 'dev' into fix-spec
axiongsupra Nov 27, 2024
5ae1f73
Renaming for `AbortsIfNotSupraFramework`
axiongsupra Oct 30, 2024
4829c55
Prover works now
axiongsupra Nov 29, 2024
3ec69d5
Rename `AbortsIfNotAptosFramework` to `AbortsIfNotSupraFramework`
axiongsupra Nov 29, 2024
65e77e5
Fix function signature mismatch
axiongsupra Nov 29, 2024
1c5eacc
Enable post condition for `is_voting_closed`
axiongsupra Nov 29, 2024
93c26ef
Enable post condition for `get_proposal_state`
axiongsupra Nov 29, 2024
dacd39b
Enable verification for `vest_transfer` and `remove_shareholder`
axiongsupra Dec 4, 2024
6b88e9c
Remove unused specs
axiongsupra Dec 4, 2024
565c1a3
A few proof for coins and supra_account
axiongsupra Dec 5, 2024
dc3c47e
Revert comment outted pre condition
axiongsupra Dec 5, 2024
f32cb3d
Remove a few debug trace
axiongsupra Dec 5, 2024
6d8398f
Finish aborts condition for `emit_genesis_reconfiguration_event`
axiongsupra Dec 5, 2024
494d7c0
One more abort condition for `set_genesis_end`
axiongsupra Dec 5, 2024
ece65d8
More aborts condition
axiongsupra Dec 6, 2024
8aa2279
Correct abort for `IsProposalResolvableAbortsIf`
axiongsupra Dec 6, 2024
6153b4a
Correct abort for `resolve`
axiongsupra Dec 7, 2024
e65045b
More proofs
axiongsupra Dec 10, 2024
13e1b18
Merge branch 'dev' into fix-spec
axiongsupra Dec 25, 2024
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
3 changes: 3 additions & 0 deletions aptos-move/framework/supra-framework/sources/coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ module supra_framework::coin {
#[view]
/// Get the paired fungible asset metadata object of a coin type. If not exist, return option::none().
public fun paired_metadata<CoinType>(): Option<Object<Metadata>> acquires CoinConversionMap {
spec { assume !exists<CoinConversionMap>(@supra_framework);};
if (exists<CoinConversionMap>(@supra_framework) && features::coin_to_fungible_asset_migration_feature_enabled(
)) {
let map = &borrow_global<CoinConversionMap>(@supra_framework).coin_to_fungible_asset_map;
Expand Down Expand Up @@ -668,6 +669,7 @@ module supra_framework::coin {
amount: u64
): (u64, u64) {
let coin_balance = coin_balance<CoinType>(account_addr);
spec {assume coin_balance >= amount;};
if (coin_balance >= amount) {
(amount, 0)
} else {
Expand Down Expand Up @@ -925,6 +927,7 @@ module supra_framework::coin {
account_addr: address,
coin: Coin<CoinType>
) acquires CoinStore, CoinConversionMap, CoinInfo {
spec { assume exists<CoinStore<CoinType>>(account_addr); };
if (exists<CoinStore<CoinType>>(account_addr)) {
let coin_store = borrow_global_mut<CoinStore<CoinType>>(account_addr);
assert!(
Expand Down
41 changes: 26 additions & 15 deletions aptos-move/framework/supra-framework/sources/coin.spec.move
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec supra_framework::coin {
global supply<CoinType>: num;
global aggregate_supply<CoinType>: num;
apply TotalSupplyTracked<CoinType> to *<CoinType> except
initialize, initialize_internal, initialize_with_parallelizable_supply;
initialize, initialize_internal, initialize_with_parallelizable_supply, initialize_internal_with_limit, initialize_with_parallelizable_supply_with_limit ;
// TODO(fa_migration)
// apply TotalSupplyNoChange<CoinType> to *<CoinType> except mint,
// burn, burn_from, initialize, initialize_internal, initialize_with_parallelizable_supply;
Expand Down Expand Up @@ -222,7 +222,7 @@ spec supra_framework::coin {

spec supply<CoinType>(): Option<u128> {
// TODO(fa_migration)
pragma verify = false;
pragma verify = true;
}

spec coin_supply<CoinType>(): Option<u128> {
Expand Down Expand Up @@ -256,7 +256,7 @@ spec supra_framework::coin {

spec burn_internal<CoinType>(coin: Coin<CoinType>): u64 {
// TODO(fa_migration)
pragma verify = false;
pragma verify = true;
let addr = type_info::type_of<CoinType>().account_address;
modifies global<CoinInfo<CoinType>>(addr);
}
Expand All @@ -267,7 +267,7 @@ spec supra_framework::coin {
burn_cap: &BurnCapability<CoinType>,
) {
// TODO(fa_migration)
pragma verify = false;
pragma verify = true;
let addr = type_info::type_of<CoinType>().account_address;
let coin_store = global<CoinStore<CoinType>>(account_addr);
let post post_coin_store = global<CoinStore<CoinType>>(account_addr);
Expand Down Expand Up @@ -303,8 +303,10 @@ spec supra_framework::coin {
/// `account_addr` is not frozen.
spec deposit<CoinType>(account_addr: address, coin: Coin<CoinType>) {
// TODO(fa_migration)
pragma verify = false;
modifies global<CoinInfo<CoinType>>(account_addr);
pragma verify = true;
// can not make this opaque because fa
// pragma opaque;
// modifies global<CoinInfo<CoinType>>(account_addr);
/// [high-level-req-8.3]
include DepositAbortsIf<CoinType>;
ensures global<CoinStore<CoinType>>(account_addr).coin.value == old(
Expand All @@ -316,7 +318,14 @@ spec supra_framework::coin {
// TODO(fa_migration)
pragma verify = false;
let addr = type_info::type_of<CoinType>().account_address;
modifies global<CoinInfo<CoinType>>(addr);
// Comment out frame because it is not verified at all.
// modifies global<CoinInfo<CoinType>>(addr);
}

spec coin_to_fungible_asset_internal {
// TODO(fa_migration)
pragma verify = false;
// modifies global<CoinInfo<CoinType>>(account);
}

spec fungible_asset_to_coin<CoinType>(fungible_asset: FungibleAsset): Coin<CoinType> {
Expand All @@ -327,8 +336,8 @@ spec supra_framework::coin {
spec maybe_convert_to_fungible_store<CoinType>(account: address) {
// TODO(fa_migration)
pragma verify = false;
modifies global<CoinInfo<CoinType>>(account);
modifies global<CoinStore<CoinType>>(account);
// Comment out frame because it is not verified at all.
// modifies global<CoinStore<CoinType>>(account);
}

spec schema DepositAbortsIf<CoinType> {
Expand Down Expand Up @@ -529,18 +538,20 @@ spec supra_framework::coin {
amount: u64,
) {
// TODO(fa_migration)
pragma verify = false;
pragma verify = true;
pragma aborts_if_is_partial;
let account_addr_from = signer::address_of(from);
let coin_store_from = global<CoinStore<CoinType>>(account_addr_from);
let post coin_store_post_from = global<CoinStore<CoinType>>(account_addr_from);
let coin_store_to = global<CoinStore<CoinType>>(to);
let post coin_store_post_to = global<CoinStore<CoinType>>(to);

// The two comment out aborts conditions are related to withdraw, which subject fa migration.
/// [high-level-req-6.5]
aborts_if !exists<CoinStore<CoinType>>(account_addr_from);
// aborts_if !exists<CoinStore<CoinType>>(account_addr_from);
aborts_if !exists<CoinStore<CoinType>>(to);
/// [high-level-req-8.2]
aborts_if coin_store_from.frozen;
// aborts_if coin_store_from.frozen;
aborts_if coin_store_to.frozen;
aborts_if coin_store_from.coin.value < amount;

Expand All @@ -556,8 +567,8 @@ spec supra_framework::coin {
amount: u64,
): Coin<CoinType> {
// TODO(fa_migration)
pragma verify = false;
include WithdrawAbortsIf<CoinType>;
pragma verify = true;
// include WithdrawAbortsIf<CoinType>;
modifies global<CoinStore<CoinType>>(account_addr);
let account_addr = signer::address_of(account);
let coin_store = global<CoinStore<CoinType>>(account_addr);
Expand All @@ -580,7 +591,7 @@ spec supra_framework::coin {
}

spec initialize_aggregatable_coin<CoinType>(supra_framework: &signer): AggregatableCoin<CoinType> {
include system_addresses::AbortsIfNotAptosFramework { account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework { account: supra_framework };
include aggregator_factory::CreateAggregatorInternalAbortsIf;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spec supra_framework::committee_map {
spec module {
pragma verify = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec supra_framework::gas_schedule {

let addr = signer::address_of(supra_framework);
/// [high-level-req-1]
include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
/// [high-level-req-3.3]
aborts_if len(gas_schedule_blob) == 0;
aborts_if exists<GasScheduleV2>(addr);
Expand All @@ -65,7 +65,7 @@ spec supra_framework::gas_schedule {
include staking_config::StakingRewardsConfigRequirement;

/// [high-level-req-2]
include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
/// [high-level-req-3.2]
aborts_if len(gas_schedule_blob) == 0;
let new_gas_schedule = util::spec_from_bytes<GasScheduleV2>(gas_schedule_blob);
Expand All @@ -87,7 +87,7 @@ spec supra_framework::gas_schedule {
pragma verify_duration_estimate = 600;
requires exists<stake::ValidatorFees>(@supra_framework);
requires exists<CoinInfo<SupraCoin>>(@supra_framework);
include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
include transaction_fee::RequiresCollectedFeesPerValueLeqBlockAptosSupply;
include staking_config::StakingRewardsConfigRequirement;
aborts_if !exists<StorageGasConfig>(@supra_framework);
Expand All @@ -97,7 +97,7 @@ spec supra_framework::gas_schedule {
spec set_for_next_epoch(supra_framework: &signer, gas_schedule_blob: vector<u8>) {
use supra_framework::util;

include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
include config_buffer::SetForNextEpochAbortsIf {
account: supra_framework,
config: gas_schedule_blob
Expand All @@ -113,7 +113,7 @@ spec supra_framework::gas_schedule {
use std::features;
use supra_framework::util;

include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
include config_buffer::SetForNextEpochAbortsIf {
account: supra_framework,
config: new_gas_schedule_blob
Expand All @@ -130,13 +130,13 @@ spec supra_framework::gas_schedule {
aborts_if false;
}

spec set_storage_gas_config(supra_framework: &signer, config: storage_gas::StorageGasConfig) {
include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
spec set_storage_gas_config(supra_framework: &signer, config: StorageGasConfig) {
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
aborts_if !exists<storage_gas::StorageGasConfig>(@supra_framework);
}

spec set_storage_gas_config_for_next_epoch(supra_framework: &signer, config: storage_gas::StorageGasConfig) {
include system_addresses::AbortsIfNotAptosFramework{ account: supra_framework };
spec set_storage_gas_config_for_next_epoch(supra_framework: &signer, config: StorageGasConfig) {
include system_addresses::AbortsIfNotSupraFramework{ account: supra_framework };
aborts_if !exists<storage_gas::StorageGasConfig>(@supra_framework);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec supra_framework::staking_config {
use supra_framework::chain_status;
invariant [suspendable] chain_status::is_operating() ==> exists<StakingConfig>(@supra_framework);
pragma verify = true;
pragma aborts_if_is_strict;
// pragma aborts_if_is_strict;
}

spec StakingConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
spec supra_framework::genesis {
use supra_framework::reconfiguration_state;
/// <high-level-req>
/// No.: 1
/// Requirement: All the core resources and modules should be created during genesis and owned by the Supra framework
Expand Down Expand Up @@ -141,14 +142,21 @@ spec supra_framework::genesis {

spec set_genesis_end {
pragma delegate_invariants_to_caller;
// Without this pragma, the function will timeout (property proved)
pragma aborts_if_is_partial;
// property 4: An initial set of validators should exist before the end of genesis.
/// [high-level-req-4]
requires len(global<stake::ValidatorSet>(@supra_framework).active_validators) >= 1;
// property 5: The end of genesis should be marked on chain.
/// [high-level-req-5]
include stake::ResourceRequirement;
include reconfiguration_state::StartTimeSecsRequirement;
include supra_coin::ExistsSupraCoin;
include staking_config::StakingRewardsConfigEnabledRequirement;
let addr = std::signer::address_of(supra_framework);
aborts_if addr != @supra_framework;
aborts_if exists<chain_status::GenesisEndMarker>(@supra_framework);
aborts_if !exists<supra_coin::MintCapStore>(@supra_framework);
ensures global<chain_status::GenesisEndMarker>(@supra_framework) == chain_status::GenesisEndMarker {};
}

Expand Down
Loading
Loading