-
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
[storage fee] adjustments #6816
Conversation
48baac9
to
bcdb4f2
Compare
[ | ||
free_event_bytes_quota: NumBytes, | ||
{ 7.. => "free_event_bytes_quota" }, | ||
1024, // 1KB free event bytes per transaction |
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.
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
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.
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 |
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.
Shouldn't this change be gated for replayability?
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 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.
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 calculate_event_storage_fee already used? If so, wouldn't .checked_sub(self.free_event_bytes_quota) lead to new behavior?
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.
No all the "storage_fee" related functions and parameters were new with @vgao1996 's PR.
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.
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) |
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 are we enforcing large_transaction_cutoff now?
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.
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)); |
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.
What is 300_000 - 1?
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.
300_000 is the gas charge for a single load_resource (see the comment above)
b13ff0a
to
0c74353
Compare
@@ -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 |
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.
These are so broken but I'd fix them separately.
0c74353
to
9367761
Compare
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.
LGTM
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.
9367761
to
c2a6fc2
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.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
hey great work, was curious is there a small md file or writeup on how this works? |
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