-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add entity type filtering in Token and Account kv states #9863
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kristiyan Selveliev <[email protected]>
@@ -92,6 +93,7 @@ protected Account readFromDataSource(@Nonnull AccountID key) { | |||
final var timestamp = ContractCallContext.get().getTimestamp(); | |||
return commonEntityAccessor | |||
.get(key, timestamp) | |||
.filter(entity -> entity.getType() != TOKEN) |
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 if we use this filter .filter(entity -> entity.getType() == ACCOUNT)
a couple of hundred tests start failing,
This is covering the case described in the issue that this pr fixes.
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 we may filter entities different than token directly in the DB. This optimisation can be added in additional PR.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9863 +/- ##
=========================================
Coverage 92.26% 92.26%
- Complexity 7771 7774 +3
=========================================
Files 951 951
Lines 32472 32473 +1
Branches 4118 4118
=========================================
+ Hits 29961 29962 +1
Misses 1546 1546
Partials 965 965 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Kristiyan Selveliev <[email protected]>
@@ -163,6 +167,14 @@ void setup() { | |||
entity.setMaxAutomaticTokenAssociations(MAX_AUTOMATIC_TOKEN_ASSOCIATIONS); | |||
entity.setType(EntityType.ACCOUNT); | |||
|
|||
token = new Entity(); | |||
token.setId(TOKEN_NUM); |
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.
To be precise we should use EntityIdUtils to construct the ID based on SHARD, REALM, TOKEN_NUM and aggregate their values. The result will equal TOKEN_NUM but once we have shards and realms the values will differ.
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.
Comment addressed
@@ -70,6 +70,8 @@ class TokenReadableKVStateTest { | |||
|
|||
private static final TokenID TOKEN_ID = | |||
TokenID.newBuilder().shardNum(0L).realmNum(0L).tokenNum(1252L).build(); | |||
private static final TokenID TOKEN_ID_ACCOUNT = |
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.
We can just name it like TOKEN_ID_FOR_NEGATIVE_TEST or TOKEN_ID_SECOND or something like this.
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.
Comment addressed
Signed-off-by: Kristiyan Selveliev <[email protected]>
Signed-off-by: Kristiyan Selveliev <[email protected]>
Quality Gate passedIssues Measures |
Description:
This PR adds filtering for entity type in the account and token readable kv states.
This PR modifies ... in order to support ...
TokenReadableKVState - return token only if the entity type return from entity table is of type token
AccountReadableKVState - return the account when the entity type is not token
Unit test for the new cases
Related issue(s):
Fixes #9862
Notes for reviewer:
Checklist