-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Return error for excluded secondary-index keys #17193
Conversation
@mvines , if you wouldn't mind, does the rpc error seem satisfactory? |
@@ -1746,13 +1755,22 @@ impl JsonRpcRequestProcessor { | |||
.account_indexes |
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 think the way you did this is ok. However, the .account_indexes is specified in the config to rpc also from validator. I specifically had to chop out the include/exclude info. So, you could just keep a copy of the include/exclude info in rpc directly. There are 2 sources of truth then, but we already do that with account_indexes.
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.
here is where I exclude the include/exclude info
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.
Ah, I failed to track where the verbose/concise account_indexes were split. Yeah, let's do that; saves any runtime helpers needed.
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.
@jeffwashington done here: 32118af
Can you take a look?
I considered changing the type to Arc<AccountSecondaryIndexes>
to reduce to only one source of truth, but the level of churn was very high. Let me know if you prefer that, though.
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.
perfect.
I prefer not an arc myself. The secondary config is created once at startup and never changed and looked up on each modification to the accounts index. 2 copies is ok with me.
Codecov Report
@@ Coverage Diff @@
## master #17193 +/- ##
=========================================
- Coverage 82.7% 82.7% -0.1%
=========================================
Files 421 421
Lines 117859 117892 +33
=========================================
+ Hits 97509 97522 +13
- Misses 20350 20370 +20 |
a7d1812
to
32118af
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.
lgtm
* Add runtime helpers to check secondary indexes for key * Add custom rpc error * Check secondary-index key inclusion in rpc * Clone complete AccountSecondaryIndexes into rpc to avoid bank query (cherry picked from commit 27004f1) # Conflicts: # core/src/rpc.rs
) * Return error for excluded secondary-index keys (#17193) * Add runtime helpers to check secondary indexes for key * Add custom rpc error * Check secondary-index key inclusion in rpc * Clone complete AccountSecondaryIndexes into rpc to avoid bank query (cherry picked from commit 27004f1) # Conflicts: # core/src/rpc.rs * Fix conflicts Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Tyera Eulberg <tyera@solana.com>
Problem
As of #17110, nodes running with secondary account indexes can explicitly exclude/include keys from the index. If a key is excluded, a full account scan will run. But since these keys are being excluded explicitly because there are too many indexed values for callers to handle, a full account scan is impractical -- it can only perform worse.
Summary of Changes
solana/runtime/src/accounts_db.rs
Line 2283 in 597373f