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

deprecate stale fee collection implementation #12800

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

igor-aptos
Copy link
Contributor

Current implementation is stale, and cannot be used as defined. So better to remove it, and add it back later if needed.

Let me know if you have preference on whether to keep or remove stake related changes, as those might be more similar for future stake changes. Removed them in this PR, as adding them back should be as easy as this removal is.

Description

Type of Change

  • Refactoring

Which Components or Systems Does This Change Impact?

  • Aptos Framework

How Has This Been Tested?

Key Areas to Review

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Apr 4, 2024

⏱️ 1s total CI duration on this PR

Job Cumulative Duration Recent Runs
rust-targeted-unit-tests 1s

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.8%. Comparing base (57257a9) to head (3ee5b46).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (57257a9) and HEAD (3ee5b46). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (57257a9) HEAD (3ee5b46)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #12800       +/-   ##
===========================================
- Coverage    72.8%    59.8%    -13.1%     
===========================================
  Files        2397      852     -1545     
  Lines      483043   207730   -275313     
===========================================
- Hits       352056   124362   -227694     
+ Misses     130987    83368    -47619     
Flag Coverage Δ
59.8% <ø> (-13.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@georgemitenkov georgemitenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

public fun collect_and_distribute_gas_fees(): bool acquires Features {
is_enabled(COLLECT_AND_DISTRIBUTE_GAS_FEES)
/// Deprecated feature
public fun get_collect_and_distribute_gas_fees_feature(): u64 { abort error::invalid_argument(EINVALID_FEATURE) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use #[deprecated] as well here?

// is tested and is fully proven to work well.
transaction_fee_amount
};
let amount_to_burn = transaction_fee_amount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just replace amount_to_burn with transaction_fee_amount? No need to create extra variables because we do not have an optimizer right now :/

} else {
transaction_fee_amount - storage_fee_refunded
};
let amount_to_burn= transaction_fee_amount - storage_fee_refunded;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amount_to_burn= ==> amount_to_burn =

@@ -285,23 +285,14 @@ spec aptos_framework::transaction_validation {


// Check fee collection.
let collect_fee_enabled = features::spec_is_enabled(features::COLLECT_AND_DISTRIBUTE_GAS_FEES);
let collected_fees = global<CollectedFeesPerBlock>(@aptos_framework).amount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this with assertion that !features::spec_is_enabled(features::COLLECT_AND_DISTRIBUTE_GAS_FEES) or just remove it completely

@@ -78,122 +78,20 @@ module aptos_framework::transaction_fee {
/// distribution. Should be called by on-chain governance.
public fun initialize_fee_collection_and_distribution(aptos_framework: &signer, burn_percentage: u8) {
system_addresses::assert_aptos_framework(aptos_framework);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not replace the whole body with abort error::invalid_argument(ENO_LONGER_SUPPORTED)? or even better EINVALID_FEATURE is defined in featres.move. Maybe we can add a public function unsupported_feature(code: u8) which will be more similar to the already used convention?

@@ -247,169 +134,4 @@ module aptos_framework::transaction_fee {

#[test_only]
use aptos_framework::aggregator_factory;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need this either?

@@ -1242,14 +1242,6 @@ module aptos_framework::stake {
};

let cur_fee = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove cur_fee?

/// the coin in every transaction avoiding read-modify-write conflicts. Only
/// used for gas fees distribution by Aptos Framework (0x1).
#[deprecated]
/// DEPRECATED
struct AggregatableCoin<phantom CoinType> has store {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is incompatible to remove, I wonder. Structs are private, so if there are no functions which can create one, they cannot be used outside. So we should be able to remove resources if they only have private or friend APIs, in theory?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is truly private that only bypass function calls can access it, it might be, but that's such a special exception, I can see why no one would code for that case :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not safe to remove private struct that has "store", as you would be able to create a new one with different fields, and deserialize into it - breaking all type invariants

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not safe to remove private struct that has "store", as you would be able to create a new one with different fields, and deserialize into it - breaking all type invariants

I think my original statement was in context to it being part of the framework, but the general statement is definitely true! Type confusion can happen sooo easily...

Copy link
Contributor

@georgemitenkov georgemitenkov Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why it seemed safe for me to remove: it is part of framework, and has private APIs, so even if you deserialise into it what do you do after? And in any case you cannot deserialise because it is a private type

Copy link
Contributor

github-actions bot commented Jun 8, 2024

This issue is stale because it has been open 45 days with no activity. Remove the stale label, comment or push a commit - otherwise this will be closed in 15 days.

@github-actions github-actions bot added the Stale label Jun 8, 2024
@github-actions github-actions bot closed this Jun 23, 2024
@igor-aptos igor-aptos removed the Stale label Aug 29, 2024
@igor-aptos igor-aptos reopened this Aug 29, 2024
@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from 1a77376 to 34ee1b0 Compare August 29, 2024 02:06
@igor-aptos igor-aptos requested a review from lightmark August 29, 2024 15:25
@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from 34ee1b0 to 501391f Compare August 29, 2024 15:42
@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from 501391f to abd907a Compare September 5, 2024 21:11
@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from abd907a to f856e1f Compare September 12, 2024 18:34
// If checks did not pass, simply burn all collected coins and return none.
burn_coin_fraction(&mut coin, 100);
coin::destroy_zero(coin)
_aptos_framework: &signer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[deprecated] is missing here, maybe remove the comment and use /// DEPRECATED.

@@ -85,126 +85,19 @@ module aptos_framework::transaction_fee {
storage_fee_refund_octas: u64,
}

#[deprecated]
/// Initializes the resource storing information about gas fees collection and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add /// DEPRECATED.?

@gelash
Copy link
Contributor

gelash commented Sep 26, 2024

I think it's fine to remove and add it back

Copy link
Contributor

@lightmark lightmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaning is always favorable.

@@ -44,6 +43,7 @@ module aptos_framework::transaction_fee {
mint_cap: MintCapability<AptosCoin>,
}

#[deprecated]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we move the deprecated fields to the bottom of the file?

public fun get_collect_and_distribute_gas_fees_feature(): u64 { COLLECT_AND_DISTRIBUTE_GAS_FEES }
#[deprecated]
/// Deprecated feature
public fun get_collect_and_distribute_gas_fees_feature(): u64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure abort here is a good practice since anyone can call this func even it is not used by us.

@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from 3ef1e13 to 3ee5b46 Compare September 30, 2024 16:58
@igor-aptos igor-aptos enabled auto-merge (squash) September 30, 2024 18:03

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@igor-aptos igor-aptos force-pushed the igor/deprecate_fee_collection branch from 3ee5b46 to df83de3 Compare October 24, 2024 16:24

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on df83de33f3a8dfcd19561434ed38c846b12c9086

two traffics test: inner traffic : committed: 12903.52 txn/s, latency: 3078.63 ms, (p50: 2700 ms, p70: 3000, p90: 3500 ms, p99: 9000 ms), latency samples: 4906220
two traffics test : committed: 100.04 txn/s, latency: 1754.99 ms, (p50: 1500 ms, p70: 1600, p90: 1800 ms, p99: 9400 ms), latency samples: 1800
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 2.172, avg: 1.740", "ConsensusProposalToOrdered: max: 0.327, avg: 0.317", "ConsensusOrderedToCommit: max: 0.424, avg: 0.405", "ConsensusProposalToCommit: max: 0.742, avg: 0.722"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 1.16s no progress at version 2120253 (avg 0.22s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 8.02s no progress at version 2120251 (avg 8.02s) [limit 15].
Test Ok

Copy link
Contributor

✅ Forge suite framework_upgrade success on b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086

Compatibility test results for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086 (PR)
Upgrade the nodes to version: df83de33f3a8dfcd19561434ed38c846b12c9086
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1281.69 txn/s, submitted: 1285.98 txn/s, failed submission: 4.29 txn/s, expired: 4.29 txn/s, latency: 2408.84 ms, (p50: 2100 ms, p70: 2600, p90: 3900 ms, p99: 5000 ms), latency samples: 113480
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1263.58 txn/s, submitted: 1265.57 txn/s, failed submission: 1.99 txn/s, expired: 1.99 txn/s, latency: 2385.07 ms, (p50: 2200 ms, p70: 2700, p90: 3600 ms, p99: 5300 ms), latency samples: 114320
5. check swarm health
Compatibility test for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086 passed
Upgrade the remaining nodes to version: df83de33f3a8dfcd19561434ed38c846b12c9086
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1215.65 txn/s, submitted: 1218.33 txn/s, failed submission: 2.68 txn/s, expired: 2.68 txn/s, latency: 2452.71 ms, (p50: 2100 ms, p70: 2700, p90: 3700 ms, p99: 4900 ms), latency samples: 108920
Test Ok

Copy link
Contributor

✅ Forge suite compat success on b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086

Compatibility test results for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086 (PR)
1. Check liveness of validators at old version: b29f09f57e898d8d211c8bc3e303f6e50bba2266
compatibility::simple-validator-upgrade::liveness-check : committed: 12686.53 txn/s, latency: 2266.52 ms, (p50: 1800 ms, p70: 1900, p90: 2200 ms, p99: 22900 ms), latency samples: 506500
2. Upgrading first Validator to new version: df83de33f3a8dfcd19561434ed38c846b12c9086
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 6911.79 txn/s, latency: 3964.70 ms, (p50: 4600 ms, p70: 4900, p90: 5100 ms, p99: 5600 ms), latency samples: 123900
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6863.22 txn/s, latency: 4610.37 ms, (p50: 4900 ms, p70: 5100, p90: 6500 ms, p99: 6700 ms), latency samples: 229740
3. Upgrading rest of first batch to new version: df83de33f3a8dfcd19561434ed38c846b12c9086
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 5905.11 txn/s, latency: 4853.56 ms, (p50: 5600 ms, p70: 5900, p90: 6000 ms, p99: 6100 ms), latency samples: 113180
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6064.98 txn/s, latency: 5375.20 ms, (p50: 6000 ms, p70: 6100, p90: 6300 ms, p99: 6600 ms), latency samples: 204420
4. upgrading second batch to new version: df83de33f3a8dfcd19561434ed38c846b12c9086
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 7991.67 txn/s, latency: 3567.26 ms, (p50: 4000 ms, p70: 4300, p90: 4600 ms, p99: 5400 ms), latency samples: 143940
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 7480.26 txn/s, latency: 4255.67 ms, (p50: 4200 ms, p70: 4600, p90: 6600 ms, p99: 7000 ms), latency samples: 261800
5. check swarm health
Compatibility test for b29f09f57e898d8d211c8bc3e303f6e50bba2266 ==> df83de33f3a8dfcd19561434ed38c846b12c9086 passed
Test Ok

@igor-aptos igor-aptos merged commit 63a91dc into main Oct 24, 2024
48 checks passed
@igor-aptos igor-aptos deleted the igor/deprecate_fee_collection branch October 24, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants