-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[gas] introduce new mechanism to charge storage fees based on fixed APT prices & per-category gas/fee limits #6683
Conversation
}, | ||
}, | ||
), | ||
), | ||
events: [], | ||
gas_used: 650, | ||
gas_used: 50841, |
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.
This is expected because we set the gas unit price to 1 in this test. Shall we change it to 100 so that it looks more similar to the range of numbers we had?
0c4c309
to
bf56dd6
Compare
bf56dd6
to
2107352
Compare
); | ||
let gas_consumed_internal = InternalGas::new( | ||
if gas_consumed_internal > u64::MAX as u128 { | ||
u64::MAX |
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.
hmm.... shall we put in a error!()
?
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.
Unless we put in some really crazy numbers in the gas schedule, this should not happen at all...
I can try to put in an error!
, but I bet we'll run into some nasty cyclic dependency issues so I won't push it hard this time.
let mut fee = Fee::zero(); | ||
let mut new_slots = NumSlots::zero(); | ||
|
||
for (key, op) in ops { |
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.
This loop is fairly similar to calculate_write_set_gas()
, can we combine them? -- let calculate_write_set_gas()
return (io_gas, storage_fee)
-- I think it's better that way because it'll be very obvious for what we charge both the io and the storage and for what we charge io only, etc.
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.
Tried. That didn't work well.
charge_write_set_gas
andcharge_storage_fee
use different contexts (StorageGas
vsTransactionGasParameters
), so combining them would require you to create a function that takes in both, which seems unnecessarily complicated.- It would also make the versioning logic more messy.
Not exactly :-P |
@msmouse man you are dead serious about this. I've updated the description to say that only some of the fees will be replaced by deposits. |
d8607fe
to
8b33806
Compare
8b33806
to
e600470
Compare
@@ -265,7 +265,13 @@ impl AptosVM { | |||
.finish(&mut (), gas_meter.change_set_configs()) | |||
.map_err(|e| e.into_vm_status())?; | |||
// Charge gas for write set | |||
gas_meter.charge_write_set_gas(user_txn_change_set_ext.write_set().iter())?; | |||
gas_meter.charge_write_set_gas_for_io(user_txn_change_set_ext.write_set().iter())?; | |||
gas_meter.charge_storage_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.
This needs to be gated
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.
It's gated inside charge_write_set_gas_for_io
and charge_storage_fee
.
self.charge(amount)?; | ||
|
||
self.io_gas_used += amount; | ||
if self.feature_version >= 7 && self.io_gas_used > self.gas_params.txn.max_io_gas { |
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.
Can this break upgradability of aptos-framework package? We already have to add a mechanism to bypass tx size limit. Now that there's an io gas limit, how much headroom do we have before we need to bypass that limit as well?
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.
This is a great question but conceptually, I don't think this is going to break framework upgrades. Our goal here is to reduce transaction costs, not increasing them. Having separate limits for each individual limits will likely result in more transactions being allowed -- old transactions should be able to pass as long as we configure the new limits no stricter than the old one.
[ | ||
storage_fee_per_state_slot_create: FeePerSlot, | ||
{ 7.. => "storage_fee_per_state_slot_create" }, | ||
50000, |
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.
How did you come up with these numbers?
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.
@msmouse has a doc that explains the logic.
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.
This appears to be a significant change. How should we update our docs to reflect it? Please let me help. Thanks!
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.
@clay-aptos thank you so much for helping! We're still in the process of figuring out the actual value changes, but I anticipate the doc work to cover the following:
- Explaining the new system to our users, especially how the flat-APT prices are converted back to gas units to maintain compatibility
- Making it clear that this is part of the effort to reduce cost (certainly not increasing it)
- What would come in the future (deposits)
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.
Adding the release-notes tag so we consider highlighting this.
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.
Can we do benchmarking here? I'd also suggest a replay/analysis of past testnet/mainnet txs to understand how many txs would hit these limit.
5e459af
to
6eb71e7
Compare
@@ -104,7 +104,7 @@ crate::natives::define_gas_parameters_for_natives!(GasParameters, "aptos_framewo | |||
[.code.request_publish.per_byte, "code.request_publish.per_byte", 2 * MUL], | |||
|
|||
// Note(Gas): These are storage operations so the values should not be multiplied. | |||
[.event.write_to_event_store.base, "event.write_to_event_store.base", 500_000], | |||
[.event.write_to_event_store.base, "event.write_to_event_store.base", 300_000], |
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.
is this intended?
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.
Yes, this is set according to Alden's doc. Although it should be clear that we still haven't finalized those values and they are subject to change
@@ -41,7 +41,7 @@ use std::{ | |||
use tokio::{runtime::Handle, task::JoinHandle, time}; | |||
|
|||
// Max is 100k TPS for a full day. | |||
const MAX_TXNS: u64 = 10_000_000_000; | |||
const MAX_TXNS: u64 = 100_000_000; |
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.
this seems unnecessary change after updating the MAX_GAS_AMOUNT?
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.
Reverted.
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.
can we do a quick cleanup of the numbers? so that we're roughly back at the same state we were before?
@@ -45,7 +53,7 @@ crate::params::define_gas_parameters!( | |||
[ | |||
maximum_number_of_gas_units: Gas, | |||
"maximum_number_of_gas_units", | |||
2_000_000 | |||
200_000_000 |
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.
why did we increase this? where is the maximum execution units? I thought we were focusing on max execution units and then max gas units would be the additional available for storage?
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.
My bad, it looks like I forgot to replace this with MAX_GAS_AMOUNT, which is now gated by a cargo feature flag.
803adb2
to
eaa21f0
Compare
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.
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.
awesome work!
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.
eaa21f0
to
efd350b
Compare
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.
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.
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.
✅ Forge suite
|
✅ Forge suite
|
❌ Forge suite
|
This makes a few additions to the gas metering system:
Note that I'm still waiting for @msmouse to come up with the correct prices. Should also mention that it might look like we're double charging (intrinsic, write set gas for io v.s. storage fees) but that is not the case. Going forward, the former group will cover transient costs only, leaving the more permanent portion to the latter. We will adjust the gas parameters to make sure we make transactions significantly cheaper, NOT more expensive.
Some of the storage fees will be replaced by deposits in the future: #6514