-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Track nested memory used by xcm::DoubleEncoded
#10747
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: master
Are you sure you want to change the base?
Track nested memory used by xcm::DoubleEncoded
#10747
Conversation
2bf2683 to
351c175
Compare
b4ba120 to
59bccbe
Compare
59bccbe to
ea4fbeb
Compare
xcm::DoubleEncodedxcm::DoubleEncoded
bkchr
left a comment
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 find the current approach hard to follow and it also doesn't forward the left over limit from decoding the extrinsic.
E.g. when executing pallet_xcm::execute it should only leave the rest from the budget for Transact and not give it the full budget again. Also the budgeting right now maybe shares too much. E.g. when I want to load two XCM messages from the storage, they will both use the same limit. This is probably not wanted. We should provide some better "tools" around the bounded limit.
struct DecodeWithLimit {
limit: usize,
decoded: T,
}
impl Decode using DecodeWithLimitThingy {}
fn DecodeWithLimit {
pub use(use: Impl(&mut T) -> R) -> R {
mem::run_with(self.limit, || use(&mut self.decoded))
}
}
Maybe something like this? Then we could use this to load XCM messages from storage?
| //! | ||
| //! There are also cases where there can be multiple nested double-encoded layers. | ||
|
|
||
| use crate::generic::DEFAULT_CALL_SIZE_LIMIT; |
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 we want that to be generic, we should pass the limit as an input value and not use this constant.
| "Dispatch failed" | ||
| ); | ||
| Transact { origin_kind, call, .. } => { | ||
| sp_runtime::nested_mem::using_limiter_once(|| { |
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 problem here is that we will run here without knowing how much the outer extrinsic already used for decoding.
| signature_check, | ||
| select, | ||
| ); | ||
| nested_mem::using_limiter_once(|| { |
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 scope is way too broad here. We only need this for extrinsic applying.
Resolves #8675
The PR introduces a global variable that limits the amount of heap memory available for decoding structures within nested contexts.