-
Notifications
You must be signed in to change notification settings - Fork 110
Check batch budget in RPC #2048
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
giwaov
wants to merge
3
commits into
0xMiden:next
Choose a base branch
from
giwaov:fix/rpc-batch-budget-checks
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is fine for this PR, but I wonder if this should actually live in the protocol repo - i.e., as something like
ProposedBatch::validate_budge().At the same time - don't we already kind of have these checks implemented? I thought these limits are imposed at batch construction time.
cc @PhilippGackstatter
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. I kept it here because this is the RPC boundary for client-submitted batches, and the goal is to return a clear
invalid_argumentbefore forwarding the batch. If protocol grows aProposedBatch::validate_budget()helper, this should just call that instead.I think the normal construction path already enforces the limits, but this keeps the boundary explicit for submitted batches.
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.
It is checked in the constructor yeah, I think the original suggestion was to check the
BatchBudgetwe use in the mempool.Currently the mempool's batch budget is simply the same as these checks so its all a bit redundant.
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.
Yeah, that lines up with how I read the issue: keep the mempool check, but reject the same over-budget batch earlier in RPC before it gets forwarded.
I avoided pulling
BatchBudgetinto the RPC crate because it currently lives in block-producer, so this keeps the boundary check small and local. If you’d rather have this call a shared helper instead, I can adjust it that way.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.
In this case, shouldn't we move the function to some centralized location so that the same function is used in both places? Or maybe we just need it in the RPC but not in the mempool? Basically, we should try to avoid code duplication so that when we update the logic we need to do it only in one place.
Either way, if we keep this, I'd add some comments explaining the intent - otherwise, it is not clear why we need it.
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.
tbh I would just leave it in the mempool until there is an actual reason to move it. As in, not merge this PR.
Its a struct in the mempool, not a function, and its technically configurable. So we could end up with mismatches which would be worse. And this will change completely with fees, or once we change how user batches are allowed.