-
Notifications
You must be signed in to change notification settings - Fork 177
feat: Add ingest check for non-zero node account balance #21707
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #21707 +/- ##
============================================
- Coverage 71.84% 71.83% -0.02%
+ Complexity 24570 24568 -2
============================================
Files 2673 2673
Lines 103932 103948 +16
Branches 10868 10872 +4
============================================
- Hits 74670 74666 -4
- Misses 25223 25245 +22
+ Partials 4039 4037 -2
... and 19 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/HapiSpec.java
Outdated
Show resolved
Hide resolved
|
|
||
| public static boolean isSystemAccount(@NonNull Account account) { | ||
| requireNonNull(account); | ||
| return account.accountIdOrThrow().accountNumOrThrow() <= 1000L; |
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 don't like that we are hard coding the number of the system accounts like this. It should have its own dynamic property. I see that contract service is using it as 750 in ProcessorModule instead of 1000! Lets do the following:
- Confirm what the right value is.
- File and issue to make the range of system accounts a dynamic property and scrub the codebase to make that it is used everywhere. Making it a dynamic property will be useful in the case of spheres.
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.
Scratch that. There is a dynamic property already. LedgerConfig.numSystemAccounts we should use it instead. I will file a bug against contract service.
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.
LedgerConfig.numSystemAccounts default value is 100, we should probably use numReservedSystemEntities in the same class which is 750
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.
There are a lot of accounts and other entities below numReservedSystemEntities that should not be able to bypass this check. Even in the System Accounts (at least on Hedera) there are 20-30 Node accounts that probably shouldn't have this privilege.
Checking below numSystemAccounts is OK, but we might be better off checking if the account is a privileged account specifically (I believe those are, for Hedera, 2 and 42-60, they'll vary for other Hiero networks, the exact value is, or perhaps should be, defined in api-permissions.properties).
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 switched it to use AccountsConfig.isSuperUser() so only the treasury and system admin accounts are privileged for that. This should be fine as this is mostly for funding accounts after genesis which will be done by the treasury because its the only account with balance.
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.
Since we already know which accounts are privileged for each transaction type in PrivilegesVerifier, we can re-use that and call PrivilegesVerifier.hasPrivileges here. If its privileged account, we can by pass that check?
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.
Switched to using Authorizer
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ingest/IngestChecker.java
Outdated
Show resolved
Hide resolved
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ingest/IngestChecker.java
Outdated
Show resolved
Hide resolved
Signed-off-by: ibankov <ivan.bankov@limechain.tech>
# Conflicts: # hapi/hedera-protobuf-java-api/src/main/proto/services/response_code.proto
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.
Makes sense to me. Thanks @ibankov
Description:
Related issue(s):
Fixes #
#21377
Notes for reviewer:
Checklist