-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Replicates AccountsDataMeter
in TransactionContext
#26438
Replicates AccountsDataMeter
in TransactionContext
#26438
Conversation
584b144
to
0c977b7
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
@@ -249,6 +254,18 @@ impl TransactionContext { | |||
pub fn get_instruction_trace(&self) -> &InstructionTrace { | |||
&self.instruction_trace | |||
} | |||
|
|||
/// Returns (in bytes) how much data can still be allocated | |||
pub fn get_total_resize_remaining(&self) -> u64 { |
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.
If used incorrectly, this method could lead to indeterminism due to how the total_resize_limit
is set when the bank constructs the TransactionContext
.
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 method is not accessible to BPF programs yet anyway. And for builtin programs we could mark it as do not use / only for testing.
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.
The "limit" part of the AccountsDataMeter (and this move into TransactionContext) will be removed, so this fn will be removed. Since instructions will not check/throw errors based on the global accounts data size, the "how much is remaining" won't need to be checked.
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.
And for builtin programs we could mark it as do not use / only for testing.
This would be great, can you please do that for now?
The "limit" part of the AccountsDataMeter (and this move into TransactionContext) will be removed, so this fn will be removed
Ok, then why did we add this fn 2 days ago if we are about to remove 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.
And for builtin programs we could mark it as do not use / only for testing.
This would be great, can you please do that for now?
I think it would be better to instead remove the "limit" part from TransactionContext, and thus remove get_total_resize_remaining()
.
The "limit" part of the AccountsDataMeter (and this move into TransactionContext) will be removed, so this fn will be removed
Ok, then why did we add this fn 2 days ago if we are about to remove it?
Just ordering. I was looking at this PR and #25899 before #26439.
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.
PR #26504 will remove get_total_resize_remaining()
and total_resize_limit
from TransactionContext
.
(The similar code needs to be removed from AccountsDataMeter as well. That is not part of this PR on purpose to keep it smaller. (Plus all of AccountsDataMeter will be removed, not just the "limit" parts.))
I don't understand how this change helps, what's the purpose of it? I think we should hold off on changes related to the accounts data meter until the indeterminism issues are solved. |
Problem
Spin-off from #25899.
Summary of Changes
Adds these two properties to
TransactionContext
:total_resize_limit
: Maximum number of bytes which can be allocated in this transaction (measured at the beginning of the transaction).total_resize_delta
: Negative bytes numbers mean the total allocation decreased, positive bytes numbers mean it increased.Also adds the method
TransactionContext::get_total_resize_remaining()
which calculates the difference between these two properties.