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

[storage fee] adjustments #6816

Merged
merged 2 commits into from
Feb 28, 2023
Merged

[storage fee] adjustments #6816

merged 2 commits into from
Feb 28, 2023

Conversation

msmouse
Copy link
Contributor

@msmouse msmouse commented Feb 28, 2023

Description

[storage fee] take into account free txn and event bytes quota
[gas] 100x the GAS_SCALING_FACTOR, lowering execution gas charge by 100x

Test Plan

existing test suite

@msmouse msmouse requested review from movekevin, davidiw, a team and lightmark February 28, 2023 04:30
@msmouse msmouse changed the title [storage fee] take into account free txn and event bytes quota [storage fee] adjustments Feb 28, 2023
@msmouse msmouse force-pushed the 0227alden_storage_fee branch 3 times, most recently from 48baac9 to bcdb4f2 Compare February 28, 2023 05:18
[
free_event_bytes_quota: NumBytes,
{ 7.. => "free_event_bytes_quota" },
1024, // 1KB free event bytes per transaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you planning to benchmark 2KB after v1.4 cut? This is still fine actually as it'll be another week or two before we upgrade the gas schedule in testnet

Copy link
Contributor Author

@msmouse msmouse Feb 28, 2023

Choose a reason for hiding this comment

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

The potential 1KB -> 2KB change is for the state write quota (free_write_bytes_quota), orthogonal to this, to make the smart data structures more useful. In this case we don't think it's valid to allow more than 1KB free events to be emitted.

let total_bytes = events.into_iter().fold(NumBytes::zero(), |total, event| {
total + NumBytes::new(event.size() as u64)
});
total_bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this change be gated for replayability?

Copy link
Contributor Author

@msmouse msmouse Feb 28, 2023

Choose a reason for hiding this comment

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

This is for the storage fee only, starting from gas feature version 7, never enabled before. In the introduction of the storage fee, we are lowering the cost for emitting events a bit, including this new free quota.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is calculate_event_storage_fee already used? If so, wouldn't .checked_sub(self.free_event_bytes_quota) lead to new behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No all the "storage_fee" related functions and parameters were new with @vgao1996 's PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. We'll run replay anyway I guess so we'll know if any issues happen due to missed gating.

}

/// New formula to charge storage fee for transaction based on fixed APT costs.
pub fn calculate_transaction_storage_fee(&self, txn_size: NumBytes) -> Fee {
self.storage_fee_per_transaction_byte * txn_size
txn_size
.checked_sub(self.large_transaction_cutoff)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we enforcing large_transaction_cutoff now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make smaller txns storage fee -free (virtually entire txn is close to free when the gas price is low). Again this is for the new "storage fee", although in this case large_transaction_cutoff has been respected for calculating the intrinsic gas

if transaction_size > self.large_transaction_cutoff {

gas_params.txn.max_io_gas = Gas::new(10) * gas_params.txn.gas_unit_scaling_factor
});
// Lower the max io gas to lower than a single load_resource
h.modify_gas_schedule(|gas_params| gas_params.txn.max_io_gas = InternalGas::new(300_000 - 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

What is 300_000 - 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

300_000 is the gas charge for a single load_resource (see the comment above)

@msmouse msmouse force-pushed the 0227alden_storage_fee branch 3 times, most recently from b13ff0a to 0c74353 Compare February 28, 2023 17:33
@@ -1,7 +1,7 @@
processed 4 tasks

task 1 'publish'. lines 4-30:
Error: Transaction discarded. VM status code: MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are so broken but I'd fix them separately.

@msmouse msmouse force-pushed the 0227alden_storage_fee branch from 0c74353 to 9367761 Compare February 28, 2023 17:49
Copy link
Contributor

@vgao1996 vgao1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@msmouse msmouse enabled auto-merge (rebase) February 28, 2023 18:36
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@msmouse msmouse force-pushed the 0227alden_storage_fee branch from 9367761 to c2a6fc2 Compare February 28, 2023 19:34
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

✅ Forge suite framework_upgrade success on cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267

Compatibility test results for cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267 (PR)
Upgrade the nodes to version: c2a6fc2391ef06ad0f656749749b59fa97c5b267
framework_upgrade::framework-upgrade::full-framework-upgrade : 7114 TPS, 5341 ms latency, 8700 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267 passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267 (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 8202 TPS, 4685 ms latency, 6800 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: c2a6fc2391ef06ad0f656749749b59fa97c5b267
compatibility::simple-validator-upgrade::single-validator-upgrade : 4822 TPS, 8100 ms latency, 12300 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: c2a6fc2391ef06ad0f656749749b59fa97c5b267
compatibility::simple-validator-upgrade::half-validator-upgrade : 4883 TPS, 8242 ms latency, 11200 ms p99 latency,no expired txns
4. upgrading second batch to new version: c2a6fc2391ef06ad0f656749749b59fa97c5b267
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7152 TPS, 5367 ms latency, 10400 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c2a6fc2391ef06ad0f656749749b59fa97c5b267 passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite land_blocking success on c2a6fc2391ef06ad0f656749749b59fa97c5b267

performance benchmark with full nodes : 6146 TPS, 6462 ms latency, 8700 ms p99 latency,(!) expired 440 out of 2625140 txns
Test Ok

@msmouse msmouse merged commit 7e5ab62 into main Feb 28, 2023
@msmouse msmouse deleted the 0227alden_storage_fee branch February 28, 2023 20:16
@hydrogenbond007
Copy link

hey great work, was curious is there a small md file or writeup on how this works?

@msmouse
Copy link
Contributor Author

msmouse commented Mar 2, 2023

@hydrogenbond007 aptos-foundation/AIPs#79

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