-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat(starknet_api): remove Ord and PartialOrd from TransactionVersion, implement explicit cmp #1638
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 7 files reviewed, all discussions resolved (waiting on @noaov1)
a discussion (no related file):
Also removed many Ord, PartialOrd
derives; the objects they were derived on don't seem to have a natural order. Unclear why these derives were needed...
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details 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: 0 of 7 files reviewed, all discussions resolved (waiting on @noaov1)
crates/starknet_api/src/transaction.rs
line 862 at r1 (raw file):
pub fn base_lt(&self, other: &Self) -> bool { self.without_query_bit().0 < other.without_query_bit().0
I can do self.base_le(other) && self.without_query_bit() != other.without_query_bit()
but that would be 4 conversions instead of 2
Code quote:
self.without_query_bit().0 < other.without_query_bit().0
33ecad3
to
fdb0065
Compare
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1638 +/- ##
===========================================
+ Coverage 40.10% 73.39% +33.29%
===========================================
Files 26 163 +137
Lines 1895 21889 +19994
Branches 1895 21889 +19994
===========================================
+ Hits 760 16066 +15306
- Misses 1100 4611 +3511
- Partials 35 1212 +1177 ☔ 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.
Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
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.
Note: this is a breaking change that might disrupt users who relied on the partialord behavior (like we did).
Can you involve product.
If this gets the OK, I still think it should be separated into two PRs, one removing unused derived and removing used derives with a replacement that explains why that order was chosen.
Reviewed 3 of 7 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @noaov1)
a discussion (no related file):
Previously, dorimedini-starkware wrote…
Also removed many
Ord, PartialOrd
derives; the objects they were derived on don't seem to have a natural order. Unclear why these derives were needed...
Orphan rule + legacy, if we don't implement PartialOrd/Ord then no-one can (except via newtypes), somebody probably added these all over SNAPI without thinking too much on whether or not it makes sense.
But you are right about the natural order.
crates/starknet_api/src/transaction.rs
line 854 at r2 (raw file):
let mut self_biguint = self.0.to_biguint(); self_biguint.set_bit(QUERY_VERSION_BASE_BIT.into(), false); Self(self_biguint.into())
Seems to expensive for cmp
, biguint is a Vec, can this done on the stack?
Also can you explain what base
here means and about the query_version_base_bit?
Code quote:
let mut self_biguint = self.0.to_biguint();
self_biguint.set_bit(QUERY_VERSION_BASE_BIT.into(), false);
Self(self_biguint.into())
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 @dorimedini-starkware and @noaov1)
crates/starknet_api/src/transaction.rs
line 862 at r1 (raw file):
Previously, dorimedini-starkware wrote…
I can do
self.base_le(other) && self.without_query_bit() != other.without_query_bit()
but that would be 4 conversions instead of 2
Conversions aren't the issue, this allocates two vectors on the heap just to compare two fels
…, implement explicit cmp Signed-off-by: Dori Medini <dori@starkware.co>
fdb0065
to
a242b5c
Compare
Artifacts upload triggered. View details 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, 2 unresolved discussions (waiting on @noaov1)
a discussion (no related file):
Closing this, and will implement a "natural" order on TransactionVersion (ZERO < ZERO_QUERY < ONE < ONE_QUERY ...)
…, implement explicit cmp functions