Skip to content

fix: Add ingest throttle for inner batch transactions #19103

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

ibankov
Copy link
Contributor

@ibankov ibankov commented May 8, 2025

Description:
Introducing an ingest throttling mechanism specifically for inner batch transactions within the consensus node.

Fixes #
#19031

@ibankov ibankov added this to the v0.63 milestone May 8, 2025
@ibankov ibankov self-assigned this May 8, 2025
@ibankov ibankov marked this pull request as ready for review May 9, 2025 08:32
@ibankov ibankov requested review from a team as code owners May 9, 2025 08:32
Copy link
Contributor

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A critical aspect of this implementation is making sure that ingest throttles are applied "all-or-nothing" for the entire batch; see comment. 🙏

throw new PreCheckException(BUSY);
checkThrottles(state, configuration, txInfo);
// If the transaction is a batch transaction, we need to check the throttling for each inner transaction
if (functionality == HederaFunctionality.ATOMIC_BATCH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Suppose the batch has three inner transactions A, B, C. Assume that checkThrottles() passes for A and B, but fails for C.

Then this implementation will not "refund" the capacity used for A and B, even though those transactions are never actually handled.

This lets an attacker consume ingest throttle capacity without paying fees at consensus for that usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I did miss that. Can you re-review the fix.

ibankov added 3 commits May 13, 2025 15:08
Signed-off-by: ibankov <[email protected]>
Signed-off-by: ibankov <[email protected]>
Copy link

codacy-production bot commented May 16, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 91.89%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9f14b14) 100660 73778 73.29%
Head commit (4a50290) 100691 (+31) 73804 (+26) 73.30% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#19103) 37 34 91.89%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copy link

codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 81.08108% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...edera/node/app/workflows/ingest/IngestChecker.java 85.71% 1 Missing and 4 partials ⚠️
.../app/throttle/SynchronizedThrottleAccumulator.java 0.00% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #19103   +/-   ##
=========================================
  Coverage     69.35%   69.35%           
- Complexity    23268    23272    +4     
=========================================
  Files          2645     2645           
  Lines        100710   100741   +31     
  Branches      10409    10414    +5     
=========================================
+ Hits          69846    69868   +22     
- Misses        26902    26907    +5     
- Partials       3962     3966    +4     
Files with missing lines Coverage Δ Complexity Δ
...service/util/impl/handlers/AtomicBatchHandler.java 87.28% <ø> (ø) 19.00 <0.00> (ø)
.../app/throttle/SynchronizedThrottleAccumulator.java 80.00% <0.00%> (-12.31%) 4.00 <0.00> (ø)
...edera/node/app/workflows/ingest/IngestChecker.java 92.42% <85.71%> (-1.76%) 28.00 <6.00> (+6.00) ⬇️

... and 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ibankov added 2 commits May 19, 2025 11:49
# Conflicts:
#	hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip551/AtomicBatchNegativeTest.java
Signed-off-by: ibankov <[email protected]>
Signed-off-by: ibankov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Atomic batch transactions don't throttle inner transactions at ingest
3 participants