-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(blockifier): enforce fee for allresourcebounds when l1 gas is 0 #846
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #846 +/- ##
==========================================
+ Coverage 74.18% 75.52% +1.33%
==========================================
Files 359 87 -272
Lines 36240 11120 -25120
Branches 36240 11120 -25120
==========================================
- Hits 26886 8398 -18488
+ Misses 7220 2311 -4909
+ Partials 2134 411 -1723
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 1 files reviewed, all discussions resolved (waiting on @aner-starkware)
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 r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @nimrod-starkware, and @TzahiTaub)
crates/blockifier/src/transaction/objects.rs
line 120 at r1 (raw file):
+ u128::from(l1_data_gas.max_amount) * l1_data_gas.max_price_per_unit > 0 }
I think ValidResourceBounds
should have a max_possible_fee
method that returns the scalar product of the amounts and the prices; this will replace the two match
arms here
Code quote:
ValidResourceBounds::L1Gas(l1_bounds) => {
let max_amount: u128 = l1_bounds.max_amount.into();
max_amount * l1_bounds.max_price_per_unit > 0
}
ValidResourceBounds::AllResources(AllResourceBounds {
l1_gas,
l2_gas,
l1_data_gas,
}) => {
u128::from(l1_gas.max_amount) * l1_gas.max_price_per_unit
+ u128::from(l2_gas.max_amount) * l2_gas.max_price_per_unit
+ u128::from(l1_data_gas.max_amount) * l1_data_gas.max_price_per_unit
> 0
}
crates/blockifier/src/transaction/objects.rs
line 121 at r1 (raw file):
> 0 } },
flatten the match
please (or, see comment above)
Suggestion:
TransactionInfo::Current(ValidResourceBounds::L1Gas(l1_bounds)) => {
let max_amount: u128 = l1_bounds.max_amount.into();
max_amount * l1_bounds.max_price_per_unit > 0
}
TransactionInfo::Current(ValidResourceBounds::AllResources(AllResourceBounds {
l1_gas,
l2_gas,
l1_data_gas,
})) => {
u128::from(l1_gas.max_amount) * l1_gas.max_price_per_unit
+ u128::from(l2_gas.max_amount) * l2_gas.max_price_per_unit
+ u128::from(l1_data_gas.max_amount) * l1_data_gas.max_price_per_unit
> 0
},
9710f0e
to
eff81e9
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: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware, @nimrod-starkware, and @TzahiTaub)
crates/blockifier/src/transaction/objects.rs
line 120 at r1 (raw file):
Previously, dorimedini-starkware wrote…
I think
ValidResourceBounds
should have amax_possible_fee
method that returns the scalar product of the amounts and the prices; this will replace the twomatch
arms here
Done.
crates/blockifier/src/transaction/objects.rs
line 121 at r1 (raw file):
Previously, dorimedini-starkware wrote…
flatten the
match
please (or, see comment above)
Took the above option.
eff81e9
to
4c57e9e
Compare
Benchmark movements: |
4c57e9e
to
78e7053
Compare
e9676fc
to
f07cd9a
Compare
78e7053
to
90b89c5
Compare
Benchmark movements: |
f07cd9a
to
27a1fe9
Compare
90b89c5
to
0082793
Compare
27a1fe9
to
c95598e
Compare
0082793
to
e6feb76
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 r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @aner-starkware, @nimrod-starkware, and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 998 at r3 (raw file):
} } }
wrap in this type, for clarity
Suggestion:
pub fn max_possible_fee(&self) -> Fee {
Fee(match self {
ValidResourceBounds::L1Gas(l1_bounds) => {
let max_amount: u128 = l1_bounds.max_amount.into();
max_amount * l1_bounds.max_price_per_unit
}
ValidResourceBounds::AllResources(AllResourceBounds {
l1_gas,
l2_gas,
l1_data_gas,
}) => {
u128::from(l1_gas.max_amount) * l1_gas.max_price_per_unit
+ u128::from(l2_gas.max_amount) * l2_gas.max_price_per_unit
+ u128::from(l1_data_gas.max_amount) * l1_data_gas.max_price_per_unit
}
})
}
e6feb76
to
f745dd0
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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware, @nimrod-starkware, and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 998 at r3 (raw file):
Previously, dorimedini-starkware wrote…
wrap in this type, for clarity
Done. Though the name fn name is probably clear enough ;)
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 r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @nimrod-starkware and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 998 at r3 (raw file):
Previously, aner-starkware wrote…
Done. Though the name fn name is probably clear enough ;)
it's clear, but type enforcement is better.
it enforces that we don't perform addition/subtraction on different numeric types, for example (basic physics, can't add meters to seconds :) )
c95598e
to
9e106e9
Compare
9e106e9
to
c3fbb1e
Compare
f745dd0
to
641d5ce
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 r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @nimrod-starkware and @TzahiTaub)
This change is