Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
22a2dcd
update rewards and governed pool MIP-124 (#227)
0xmovses Oct 17, 2025
57a210c
fix: ensure bkwd compatibility and feature flag script
0xmovses Oct 22, 2025
1ec5c92
fix: restore features to target branch
0xmovses Oct 23, 2025
113ca16
fix: add stake reward feature
0xmovses Oct 23, 2025
701c048
fix: bump feat val to match base branch implemantaion
0xmovses Oct 23, 2025
e9c2034
chore: fmt
0xmovses Oct 23, 2025
d87dccf
chore: gen scripts, correct stake.move
0xmovses Oct 23, 2025
74f2188
change fee burn to a ggp treasury transfer. Remove the storage refund
musitdev Oct 29, 2025
194e811
Only abort tx when the STORAGE_DELETION_REFUND is activated
musitdev Oct 29, 2025
a6cb116
remove unfinished test
musitdev Oct 29, 2025
fedf8a4
correct transaction-fee specs
musitdev Oct 29, 2025
ff452c5
feat: disable storage refund feat
0xmovses Oct 29, 2025
81c648f
re enable storage fee refund and add the STORAGE_DELETION_REFUND feat…
musitdev Oct 29, 2025
4be8b6a
Merge branch 'cherry-pick-mip-124' of github.com:movementlabsxyz/apto…
musitdev Oct 29, 2025
7682d9a
chore: remove dup feature, correct numerical val
0xmovses Oct 29, 2025
5992cec
fix: typo
0xmovses Oct 29, 2025
f2c1a07
fix: getter name
0xmovses Oct 29, 2025
56600dd
chore: add init ggp script
0xmovses Oct 30, 2025
31049b7
chore: gen new upgrade scripts with staking and rewards changes
0xmovses Oct 30, 2025
c450164
fix: correct features.move values to tally with movement mainnet state
0xmovses Oct 30, 2025
5b7aebc
chore: gen new upgrade scripts
0xmovses Oct 30, 2025
50c05e1
fix: feature should not be commented out
0xmovses Oct 30, 2025
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
40 changes: 27 additions & 13 deletions aptos-move/framework/aptos-framework/sources/transaction_fee.move
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This module provides an interface to burn or collect and redistribute transaction fees.
module aptos_framework::transaction_fee {
use aptos_framework::coin::{Self, AggregatableCoin, BurnCapability, MintCapability};
use aptos_framework::aptos_account;
use aptos_framework::aptos_coin::AptosCoin;
use aptos_framework::fungible_asset::BurnRef;
use aptos_framework::system_addresses;
use aptos_framework::governed_gas_pool;
use std::error;
use std::features;
use std::option::{Self, Option};
Expand Down Expand Up @@ -77,17 +77,31 @@ module aptos_framework::transaction_fee {
}

/// Burn transaction fees in epilogue.
public(friend) fun burn_fee(account: address, fee: u64) {
governed_gas_pool::deposit_gas_fee_v2(account, fee)
public(friend) fun burn_fee(account: address, fee: u64) acquires AptosFABurnCapabilities, AptosCoinCapabilities {
if (exists<AptosFABurnCapabilities>(@aptos_framework)) {
let burn_ref = &borrow_global<AptosFABurnCapabilities>(@aptos_framework).burn_ref;
aptos_account::burn_from_fungible_store_for_gas(burn_ref, account, fee);
} else {
let burn_cap = &borrow_global<AptosCoinCapabilities>(@aptos_framework).burn_cap;
if (features::operations_default_to_fa_apt_store_enabled()) {
let (burn_ref, burn_receipt) = coin::get_paired_burn_ref(burn_cap);
aptos_account::burn_from_fungible_store_for_gas(&burn_ref, account, fee);
coin::return_paired_burn_ref(burn_ref, burn_receipt);
} else {
coin::burn_from_for_gas<AptosCoin>(
account,
fee,
burn_cap,
);
};
};
}

/// Mint refund in epilogue.
public(friend) fun mint_and_refund(_account: address, refund: u64) {
// refund is 0 when the STORAGE_DELETION_REFUND feature is desactivated.
// STORAGE_DELETION_REFUND is not implemented.
if (refund > 0) {
abort error::not_implemented(ENO_LONGER_SUPPORTED)
}
public(friend) fun mint_and_refund(account: address, refund: u64) acquires AptosCoinMintCapability {
let mint_cap = &borrow_global<AptosCoinMintCapability>(@aptos_framework).mint_cap;
let refund_coin = coin::mint(refund, mint_cap);
coin::deposit_for_gas_fee(account, refund_coin);
}

/// Only called during genesis.
Expand Down Expand Up @@ -163,16 +177,16 @@ module aptos_framework::transaction_fee {
#[deprecated]
struct CopyCapabilitiesOneShot has key {}

// Copy Mint and Burn capabilities over to bridge
// Can only be called once after which it will assert
/// Copy Mint and Burn capabilities over to bridge
/// Can only be called once after which it will assert
#[deprecated]
public fun copy_capabilities_for_bridge(_aptos_framework: &signer) : (MintCapability<AptosCoin>, BurnCapability<AptosCoin>){
public fun copy_capabilities_for_bridge(aptos_framework: &signer) : (MintCapability<AptosCoin>, BurnCapability<AptosCoin>){
abort error::not_implemented(ENO_LONGER_SUPPORTED)
}

/// Copy Mint and Burn capabilities over to bridge
/// Can only be called once after which it will assert
public fun copy_capabilities_for_native_bridge(_aptos_framework: &signer) : (MintCapability<AptosCoin>, BurnCapability<AptosCoin>){
public fun copy_capabilities_for_native_bridge(aptos_framework: &signer) : (MintCapability<AptosCoin>, BurnCapability<AptosCoin>){
abort error::not_implemented(ENO_LONGER_SUPPORTED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,29 @@ spec aptos_framework::transaction_fee {
ensures coin::supply<AptosCoin> == old(coin::supply<AptosCoin>) - amount;
}

spec mint_and_refund(_account: address, refund: u64) {
aborts_if (refund != 0);
spec mint_and_refund(account: address, refund: u64) {
use aptos_std::type_info;
use aptos_framework::aptos_coin::AptosCoin;
use aptos_framework::coin::{CoinInfo, CoinStore};
use aptos_framework::coin;
// TODO(fa_migration)
pragma verify = false;
// pragma opaque;

let aptos_addr = type_info::type_of<AptosCoin>().account_address;

aborts_if (refund != 0) && !exists<CoinInfo<AptosCoin>>(aptos_addr);
include coin::CoinAddAbortsIf<AptosCoin> { amount: refund };

aborts_if !exists<CoinStore<AptosCoin>>(account);
// modifies global<CoinStore<AptosCoin>>(account);

aborts_if !exists<AptosCoinMintCapability>(@aptos_framework);

let supply = coin::supply<AptosCoin>;
let post post_supply = coin::supply<AptosCoin>;
aborts_if [abstract] supply + refund > MAX_U128;
ensures post_supply == supply + refund;
}

/// Ensure caller is admin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,20 +619,28 @@ module aptos_framework::transaction_validation {
);
};

if (transaction_fee_amount > storage_fee_refunded) {
let burn_amount = transaction_fee_amount - storage_fee_refunded;
if (features::storage_deletion_refund_enabled()){
if (transaction_fee_amount > storage_fee_refunded) {
let burn_amount = transaction_fee_amount - storage_fee_refunded;
if (features::governed_gas_pool_enabled()){
governed_gas_pool::deposit_gas_fee_v2(gas_payer, burn_amount);
} else {
transaction_fee::burn_fee(gas_payer, burn_amount);
}
} else if (transaction_fee_amount < storage_fee_refunded) {
let mint_amount = storage_fee_refunded - transaction_fee_amount;
// TODO: we cannot mint to do storage refund. We need to have a storage refund pool
if (!features::governed_gas_pool_enabled()){
transaction_fee::mint_and_refund(gas_payer, mint_amount);
}
};
} else {
if (features::governed_gas_pool_enabled()){
governed_gas_pool::deposit_gas_fee_v2(gas_payer, burn_amount);
governed_gas_pool::deposit_gas_fee_v2(gas_payer, transaction_fee_amount);
} else {
transaction_fee::burn_fee(gas_payer, burn_amount);
transaction_fee::burn_fee(gas_payer, transaction_fee_amount);
}
} else if (transaction_fee_amount < storage_fee_refunded) {
let mint_amount = storage_fee_refunded - transaction_fee_amount;
// TODO: we cannot mint to do storage refund. We need to have a storage refund pool
if (!features::governed_gas_pool_enabled()){
transaction_fee::mint_and_refund(gas_payer, mint_amount);
}
};
}
};

// Increment sequence number
Expand Down
10 changes: 10 additions & 0 deletions aptos-move/framework/move-stdlib/sources/configs/features.move
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,16 @@ module std::features {
is_enabled(STAKE_REWARD_USING_TREASURY)
}

/// Whether the Storage fee is refund on deletion (enable) or never refund (disable).
///
/// Lifetime: permanent
const STORAGE_DELETION_REFUND: u64 = 225;

public fun get_storage_deletion_refund_feature(): u64 { STORAGE_DELETION_REFUND }

public fun storage_deletion_refund_enabled(): bool acquires Features {
is_enabled(STORAGE_DELETION_REFUND)
}
Comment thread
0xmovses marked this conversation as resolved.
Outdated
// ============================================================================================
// Feature Flag Implementation

Expand Down