-
Notifications
You must be signed in to change notification settings - Fork 20
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
goverened gas pool spec #118
base: l-monninger/governed-gas-pool
Are you sure you want to change the base?
Changes from all commits
2e441ef
e14fb8e
b67a258
0e2f96f
c7eb934
202ac61
706bfd1
568af1c
483f867
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
spec aptos_framework::governed_gas_pool { | ||
use aptos_framework::coin::CoinStore; | ||
use aptos_framework::coin::EINSUFFICIENT_BALANCE; | ||
use aptos_framework::error; | ||
|
||
/// <high-level-req> | ||
/// No.: 1 | ||
/// Requirement: The GovernedGasPool resource must exist at the aptos_framework address after initialization. | ||
/// Criticality: Critical | ||
/// Implementation: The initialize function ensures the resource is created at the aptos_framework address. | ||
/// Enforcement: Formally verified via [high-level-req-1](initialize). | ||
/// | ||
/// No.: 2 | ||
/// Requirement: Only the aptos_framework address is allowed to initialize the GovernedGasPool. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
/// Criticality: Critical | ||
/// Implementation: The initialize function verifies the signer is the aptos_framework address. | ||
/// Enforcement: Formally verified via [high-level-req-2](initialize). | ||
/// | ||
/// No.: 3 | ||
/// Requirement: Deposits into the GovernedGasPool must be reflected in the pool's balance. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say you want to prove above that initialization creates a resource account distinct from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I try to to do |
||
/// Criticality: High | ||
/// Implementation: The deposit and deposit_from functions update the pool's balance. | ||
/// Enforcement: Formally verified via [high-level-req-3](deposit), [high-level-req-3.1](deposit_from). | ||
/// | ||
/// No.: 4 | ||
/// Requirement: Only the aptos_framework address can fund accounts from the GovernedGasPool. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
/// Criticality: High | ||
/// Implementation: The fund function verifies the signer is the aptos_framework address. | ||
/// Enforcement: Formally verified via [high-level-req-4](fund). | ||
/// | ||
/// No.: 5 | ||
/// Requirement: Gas fees must be deposited into the GovernedGasPool whenever specified by the configuration. | ||
0xmovses marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// Criticality: High | ||
/// Implementation: The deposit_gas_fee function ensures gas fees are deposited correctly. | ||
/// Enforcement: Formally verified via [high-level-req-5](deposit_gas_fee). | ||
/// </high-level-req> | ||
|
||
spec module { | ||
/// [high-level-req-1] | ||
/// The GovernedGasPool resource must exist at aptos_framework after initialization. | ||
invariant exists<GovernedGasPool>(@aptos_framework); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's passing though, I think because of spec initialize(aptos_framework: &signer, delegation_pool_creation_seed: vector<u8>) {
requires system_addresses::is_aptos_framework_address(signer::address_of(aptos_framework));
/// [high-level-req-1]
ensures exists<GovernedGasPool>(@aptos_framework);
}
``` There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can remove it if you we prefer. I suppose we would need to be doing an |
||
} | ||
|
||
spec initialize(aptos_framework: &signer, delegation_pool_creation_seed: vector<u8>) { | ||
requires system_addresses::is_aptos_framework_address(signer::address_of(aptos_framework)); | ||
/// [high-level-req-1] | ||
ensures exists<GovernedGasPool>(@aptos_framework); | ||
} | ||
|
||
spec fund<CoinType>(aptos_framework: &signer, account: address, amount: u64) { | ||
pragma aborts_if_is_partial = true; | ||
|
||
/// [high-level-req-4] | ||
// Abort if the caller is not the Aptos framework | ||
aborts_if !system_addresses::is_aptos_framework_address(signer::address_of(aptos_framework)); | ||
|
||
/// Abort if the governed gas pool has insufficient funds | ||
aborts_with coin::EINSUFFICIENT_BALANCE, error::invalid_argument(EINSUFFICIENT_BALANCE), 0x1, 0x5, 0x7; | ||
} | ||
|
||
spec deposit<CoinType>(coin: Coin<CoinType>) { | ||
pragma aborts_if_is_partial = true; | ||
|
||
/// [high-level-req-3] | ||
/// Ensure the deposit increases the value in the CoinStore | ||
|
||
//@TODO: Calling governed_gas_pool_adddress() doesn't work as the boogie gen cant check the signer | ||
// created for the resource account created at runtime | ||
|
||
/// Ensure the governed gas pool resource account exists | ||
//aborts_if !exists<CoinStore<CoinType>>(governed_gas_pool_address()); | ||
|
||
//ensures global<CoinStore<CoinType>>(aptos_framework_address).coin.value == | ||
//old(global<CoinStore<CoinType>>(aptos_framework_address).coin.value) + coin.value; | ||
} | ||
|
||
spec deposit_gas_fee(gas_payer: address, gas_fee: u64) { | ||
/// [high-level-req-5] | ||
// ensures governed_gas_pool_balance<AptosCoin> == old(governed_gas_pool_balance<AptosCoin>) + gas_fee; | ||
// ensures gas_payer_balance<AptosCoin> == old(gas_payer_balance<AptosCoin>) - gas_fee; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.