-
Notifications
You must be signed in to change notification settings - Fork 31
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
refactor(starknet_api,blockifier): to_discounted_gas_amount #2874
refactor(starknet_api,blockifier): to_discounted_gas_amount #2874
Conversation
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.
Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @TzahiTaub)
crates/starknet_api/src/execution_resources.rs
line 179 at r1 (raw file):
l1_gas: GasAmount, l1_data_gas: GasAmount, ) -> GasAmount {
this change is to make explicit the fact that L2 gas is ignored here
Code quote:
pub fn to_discounted_l1_gas(
l1_gas_price: NonzeroGasPrice,
l1_data_gas_price: GasPrice,
l1_gas: GasAmount,
l1_data_gas: GasAmount,
) -> GasAmount {
c1695dc
to
486d8d3
Compare
8540cef
to
def2bc0
Compare
486d8d3
to
191993e
Compare
def2bc0
to
a2dcbb4
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.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware)
crates/starknet_api/src/execution_resources.rs
line 167 at r2 (raw file):
} /// Compute l1_gas estimation from gas_vector using the following formula:
Why is this an "estimation"?
Suggestion:
Computes the total l1 gas amount from the different given l1 gas arguments using the following formula:
crates/starknet_api/src/execution_resources.rs
line 185 at r2 (raw file):
l1_data_gas: GasAmount, ) -> GasAmount { let l1_data_gas_fee = l1_data_gas.checked_mul(l1_data_gas_price).unwrap_or_else(|| {
Makes more sense to make the conversion here and have the type as it's in GasPriceVector IMO
Suggestion:
pub fn to_discounted_l1_gas(
l1_gas_price: NonzeroGasPrice,
l1_data_gas_price: NonzeroGasPrice,
l1_gas: GasAmount,
l1_data_gas: GasAmount,
) -> GasAmount {
let l1_data_gas_fee = l1_data_gas.checked_mul(l1_data_gas_price.into()).unwrap_or_else(|| {
crates/blockifier/src/fee/fee_utils.rs
line 47 at r2 (raw file):
let discounted_l1_gas = to_discounted_l1_gas( gas_prices.l1_gas_price, gas_prices.l1_data_gas_price.into(),
Remove if you accept the suggestion below
Suggestion:
gas_prices.l1_data_gas_price,
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @TzahiTaub)
crates/blockifier/src/fee/fee_utils.rs
line 47 at r2 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Remove if you accept the suggestion below
see below
crates/starknet_api/src/execution_resources.rs
line 167 at r2 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Why is this an "estimation"?
maybe the wording is unclear: the actual value returned isn't really an amount of L1 gas, it's a "best effort" conversion, to be able to charge users signing deprecated resource bounds in proportion to actual computation resources / DA gas used.
I used the word "estimation", do you have a suggestion?
(your suggestion implies the returned value is actually L1 gas, when it really isn't..)
crates/starknet_api/src/execution_resources.rs
line 185 at r2 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Makes more sense to make the conversion here and have the type as it's in GasPriceVector IMO
as an API decision: we require the L1 gas price to be nonzero, but the data gas price is allowed to be zero. Why enforce nonzero data gas price?
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)
a discussion (no related file):
py side
191993e
to
e6d14ee
Compare
a2dcbb4
to
ab5576c
Compare
Previously, dorimedini-starkware wrote…
I don't know but that's the type we have here |
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)
crates/starknet_api/src/execution_resources.rs
line 185 at r2 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
I don't know but that's the type we have here
yes, gas prices in general must be non-zero because sometimes we divide by them.
in this specific function, we divide by L1 gas price, but we only multiply by data gas price, so it can be zero
Previously, dorimedini-starkware wrote…
I don't understand, it's illegal for a use to give a 0 DA price, but you want to support it in this specific helper function? |
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)
crates/starknet_api/src/execution_resources.rs
line 185 at r2 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
I don't understand, it's illegal for a use to give a 0 DA price, but you want to support it in this specific helper function?
yes, because this function doesn't care.
GasPriceVector is used in many places, specifically in the block info, where we do not allow zero gas prices
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.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware)
crates/starknet_api/src/execution_resources.rs
line 167 at r2 (raw file):
Previously, dorimedini-starkware wrote…
maybe the wording is unclear: the actual value returned isn't really an amount of L1 gas, it's a "best effort" conversion, to be able to charge users signing deprecated resource bounds in proportion to actual computation resources / DA gas used.
I used the word "estimation", do you have a suggestion?
(your suggestion implies the returned value is actually L1 gas, when it really isn't..)
Computes the total l1 gas amount estimation from the different given l1 gas arguments using the following formula:
ab5576c
to
d56b835
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @dorimedini-starkware)
a discussion (no related file):
Previously, dorimedini-starkware wrote…
passes
e6d14ee
to
7ce4459
Compare
d56b835
to
016c9ea
Compare
Signed-off-by: Dori Medini <dori@starkware.co>
016c9ea
to
1f8d613
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.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @dorimedini-starkware)
No description provided.