-
Notifications
You must be signed in to change notification settings - Fork 22
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
build(fee): define valid resources bounds enum #503
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @nimrod-starkware and the rest of your teammates on Graphite |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #503 +/- ##
==========================================
- Coverage 76.58% 76.53% -0.06%
==========================================
Files 348 348
Lines 36771 36804 +33
Branches 36771 36804 +33
==========================================
+ Hits 28162 28168 +6
- Misses 6284 6314 +30
+ Partials 2325 2322 -3 ☔ View full report in Codecov by Sentry. |
58bda33
to
d6c1477
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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @nimrod-starkware and @TzahiTaub)
a discussion (no related file):
you added todo!
s here, so please open a python side PR (I am concerned about the OS test mainly)
crates/starknet_api/src/transaction.rs
line 870 at r1 (raw file):
#[serde(rename = "L2_GAS")] L2Gas, L1DataGas,
Suggestion:
#[serde(rename = "L2_GAS")]
L2Gas,
#[serde(rename = "L1_DATA_GAS")]
L1DataGas,
crates/starknet_api/src/transaction.rs
line 891 at r1 (raw file):
pub fn is_zero(&self) -> bool { self.max_amount == 0 && self.max_price_per_unit == 0 }
name is a bit ambiguous - if one of the two fields is zero, the effective bound is zero.
consider another name / a docstring?
Code quote:
pub fn is_zero(&self) -> bool {
self.max_amount == 0 && self.max_price_per_unit == 0
}
crates/starknet_api/src/transaction.rs
line 953 at r1 (raw file):
pub enum ValidResourceBounds { L1Gas(ResourceBounds), // Pre 0.13.3. L2 bounds are signed but never used.
Suggestion:
L1Gas(ResourceBounds), // Pre 0.13.3. Only L1 gas. L2 bounds are signed but never used.
crates/starknet_api/src/transaction.rs
line 961 at r1 (raw file):
pub l2_gas: ResourceBounds, pub l1_data_gas: ResourceBounds, }
define and implement this, to enforce the connection between AllResourceBounds
and the Resource
enum
Suggestion:
pub struct AllResourceBounds {
pub l1_gas: ResourceBounds,
pub l2_gas: ResourceBounds,
pub l1_data_gas: ResourceBounds,
}
impl AllResourceBounds {
fn get_bound(&self, resource: Resource) -> ResourceBounds { ... }
}
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
fn try_from( raw_resource_bounds: HashMap<Resource, ResourceBounds>, ) -> Result<Self, Self::Error> {
suggestion: while the ResourceBoundsMapping
is still alive, make it clear that it converts to the new type.
may be useful in refactoring.
WDYT? (non-blocking, you may have other design plans)
Suggestion:
impl TryFrom<ResourceBoundsMapping> for ValidResourceBounds {
type Error = StarknetApiError;
fn try_from(
raw_resource_bounds: ResourceBoundsMapping,
) -> Result<Self, Self::Error> {
crates/starknet_api/src/transaction.rs
line 984 at r1 (raw file):
"{:?}", raw_resource_bounds )))
more information please
Suggestion:
Err(StarknetApiError::InvalidResourceMappingInitializer(format!(
"Missing DA gas bound, but L2 gas bound is not zero: {:?}",
raw_resource_bounds
)))
crates/starknet_api/src/transaction.rs
line 984 at r1 (raw file):
"{:?}", raw_resource_bounds )))
I prefer inlining the variable in the formatted string (non-blocking), it is more readable when you have several variables in the string
Suggestion:
Err(StarknetApiError::InvalidResourceMappingInitializer(format!(
"{raw_resource_bounds:?}"
)))
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, 8 unresolved discussions (waiting on @nimrod-starkware and @TzahiTaub)
a discussion (no related file):
Previously, dorimedini-starkware wrote…
you added
todo!
s here, so please open a python side PR (I am concerned about the OS test mainly)
you can open such a PR for the top of your stack if you want, maybe better
d6c1477
to
4de6e17
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: 3 of 4 files reviewed, 7 unresolved discussions (waiting on @dorimedini-starkware and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 870 at r1 (raw file):
#[serde(rename = "L2_GAS")] L2Gas, L1DataGas,
Done.
crates/starknet_api/src/transaction.rs
line 891 at r1 (raw file):
Previously, dorimedini-starkware wrote…
name is a bit ambiguous - if one of the two fields is zero, the effective bound is zero.
consider another name / a docstring?
added a docstring
crates/starknet_api/src/transaction.rs
line 953 at r1 (raw file):
pub enum ValidResourceBounds { L1Gas(ResourceBounds), // Pre 0.13.3. L2 bounds are signed but never used.
Done.
crates/starknet_api/src/transaction.rs
line 961 at r1 (raw file):
Previously, dorimedini-starkware wrote…
define and implement this, to enforce the connection between
AllResourceBounds
and theResource
enum
Done.
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
Previously, dorimedini-starkware wrote…
suggestion: while the
ResourceBoundsMapping
is still alive, make it clear that it converts to the new type.
may be useful in refactoring.
WDYT? (non-blocking, you may have other design plans)
I want to use ResourceBoundsMapping
as little as possible (it will be easier to remove it later)...
crates/starknet_api/src/transaction.rs
line 984 at r1 (raw file):
Previously, dorimedini-starkware wrote…
I prefer inlining the variable in the formatted string (non-blocking), it is more readable when you have several variables in the string
Done
crates/starknet_api/src/transaction.rs
line 984 at r1 (raw file):
Previously, dorimedini-starkware wrote…
more information please
Done.
4de6e17
to
b64b716
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 r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nimrod-starkware and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
Previously, nimrod-starkware wrote…
I want to use
ResourceBoundsMapping
as little as possible (it will be easier to remove it later)...
but this TryFrom
is coupled to this type. enforcing this coupling will keep code stable in intermediate phases, and the final search for usages will remind you to update this to the relevant input type / move the logic to the general tx deserialization code / delete this TryFrom
entirely
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, 1 unresolved discussion (waiting on @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
Previously, dorimedini-starkware wrote…
but this
TryFrom
is coupled to this type. enforcing this coupling will keep code stable in intermediate phases, and the final search for usages will remind you to update this to the relevant input type / move the logic to the general tx deserialization code / delete thisTryFrom
entirely
Done
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, 1 unresolved discussion (waiting on @nimrod-starkware and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
Previously, nimrod-starkware wrote…
Done
pushed?
b64b716
to
d9382db
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: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @TzahiTaub)
crates/starknet_api/src/transaction.rs
line 967 at r1 (raw file):
Previously, dorimedini-starkware wrote…
pushed?
now pushed, sorry :)
d9382db
to
a8a48f5
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 r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @TzahiTaub)
d3d02ab
to
3b7454f
Compare
3b7454f
to
2f91ef5
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: all files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware and @TzahiTaub)
2f91ef5
to
ac66153
Compare
ac66153
to
df36dc5
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 @TzahiTaub)
Merge activity
|
This change is