-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Rpc: filters performance improvement #20185
Rpc: filters performance improvement #20185
Conversation
CI should be fixed after #20182 |
There's a temp fix on master already that you can rebase off of too |
456ba73
to
5a36ad9
Compare
Codecov Report
@@ Coverage Diff @@
## master #20185 +/- ##
=========================================
- Coverage 81.9% 81.9% -0.1%
=========================================
Files 495 495
Lines 137701 137831 +130
=========================================
+ Hits 112832 112914 +82
- Misses 24869 24917 +48 |
|
@fanatid , thanks for the ping. Looks like I missed the review notification when I was off the grid in the mountains last weekend. Sorry about that! |
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 looks great! Just one minor suggestion about a generic DataTooLarge error and nits.
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.
Looking good. Just a few more nits 😉
client/src/rpc_filter.rs
Outdated
bs58::decode(&bytes) | ||
use MemcmpEncodedBytes::*; | ||
match &compare.bytes { | ||
Binary(bytes) if bytes.len() > 128 => { |
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.
Let's just bump this to the base58 max. No harm in relaxing the limit
client/src/rpc_filter.rs
Outdated
} | ||
Base58(bytes) if bytes.len() > 175 => Err(RpcFilterError::DataTooLarge), | ||
Base64(bytes) if bytes.len() > 172 => Err(RpcFilterError::DataTooLarge), | ||
Bytes(bytes) if bytes.len() > 128 => Err(RpcFilterError::DataTooLarge), |
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 need to test this since there's no expensive decoding to follow
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 we should not test this value? Test for this value is not only about expensive decoding but also about a performant filter. Or I'm wrong?
Other comments are fixed.
client/src/rpc_filter.rs
Outdated
.map_err(RpcFilterError::DecodeError), | ||
Base58(bytes) => { | ||
let bytes = bs58::decode(&bytes).into_vec()?; | ||
if bytes.len() > 128 { |
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 check is unnecessary now. Fine to keep it, but let's name the magic number here too
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.
thanks for addressing! lgtm now once CI's happy*
r+
* looks like a rebase on master will get you past the audit failure
match &compare.bytes { | ||
Binary(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => { | ||
Err(RpcFilterError::Base58DataTooLarge) | ||
} | ||
Base58(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => { | ||
Err(RpcFilterError::DataTooLarge) | ||
} | ||
Base64(bytes) if bytes.len() > MAX_DATA_BASE64_SIZE => { | ||
Err(RpcFilterError::DataTooLarge) | ||
} | ||
Bytes(bytes) if bytes.len() > MAX_DATA_SIZE => { | ||
Err(RpcFilterError::DataTooLarge) | ||
} | ||
_ => Ok(()), | ||
}?; | ||
match &compare.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.
I still find it more confusing than helpful to have two match statements, esp since the four cases have to handled separately.
All the other changes look great!
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.
With added changes I find this bit more confusing too 😞 but once MemcmpEncodedBytes::Binary
would be removed statements can be merged and simplified a lot!
Pull request has been modified.
The CI failure is legit now; looks like there's a test that needs a fixup |
Updated. CI is green now 🎉 |
Thanks for all the work here! |
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests (cherry picked from commit e9a427b)
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests (cherry picked from commit e9a427b) Co-authored-by: Kirill Fomichev <[email protected]>
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests (cherry picked from commit e9a427b)
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests (cherry picked from commit e9a427b) Co-authored-by: Kirill Fomichev <[email protected]>
* Add Base58,Base64,Bytes to MemcmpEncodedBytes * Rpc: decode memcmp before filtering accounts * Add deprecated attribute * Add Memcmp::bytes * Fix clippy for deprecated * Another clippy fix * merge RpcFilterError::DataTooLarge * add deprecation for Base58DataTooLarge * change filter data size limit * strict data size len for base58 * add magic numbers * fix tests
This reverts commit 0497972.
Closes #20177