-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Take the header size into account for the total block size #10804
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?
Conversation
Differential Tests Results (PolkaVM)Specified Tests
Counts
FailuresThe test specifiers seen in this section have the format 'path::case_idx::compilation_mode' and they're compatible with the revive differential tests framework and can be specified to it directly in the same way that they're provided through the The failures are provided in an expandable section to ensure that the PR does not get polluted with information. Please click on the section below for more information Detailed Differential Tests Failure Information
|
| if env::var("RUN_TEST").is_ok() { | ||
| let (client, parent_head) = create_test_client(); | ||
|
|
||
| let digest_data_exceeding_max_head_data_size = vec![0u8; 1_048_576 + 1024]; |
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.
Can we use MAX_HEAD_DATA_SIZE + 1 here instead of this hardcoded value?
cumulus/test/runtime/src/lib.rs
Outdated
| pub const Version: RuntimeVersion = VERSION; | ||
| pub RuntimeBlockLength: BlockLength = | ||
| BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); | ||
| BlockLength::max_with_normal_ratio(12 * 1024 * 1024, NORMAL_DISPATCH_RATIO); |
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.
Why?
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.
So that we can test the assert in validate_block. Otherwise the digests there are too big :D
substrate/frame/system/src/lib.rs
Outdated
| let overhead = digest_size.saturating_add(empty_header_size) as u32; | ||
| AllExtrinsicsLen::<T>::put(overhead); | ||
|
|
||
| // Ensure inherent digests don't exceed 20% of the max block size. |
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.
Is this 20% arbitrary or we had this rule already?
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.
Arbitrary. Should be more than enough space for inherent digests. Everything we are doing is not bigger than some bytes, so getting ~2MiB for 10MiB sounds more than enough.
e6359a9 to
52afdef
Compare
| BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); | ||
| BlockLength::builder() | ||
| .max_length(5 * 1024 * 1024) | ||
| .modify_max_length_for_class(DispatchClass::Normal, |m| { *m = NORMAL_DISPATCH_RATIO * *m; }) |
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.
Can't you also reuse m on the other places where you copied and pasted the max length?
substrate/frame/system/src/limits.rs
Outdated
| @@ -40,22 +40,39 @@ pub struct BlockLength { | |||
| /// In the worst case, the total block length is going to be: | |||
| /// `MAX(max)` | |||
| pub max: PerDispatchClass<u32>, | |||
| /// Optional maximum header size in bytes. | |||
| /// | |||
| /// It is still possible that a header goes above this limit, if the runtime deposits to may | |||
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 still possible that a header goes above this limit, if the runtime deposits to may | |
| /// It is still possible that a header goes above this limit, if the runtime deposits too many |
substrate/frame/system/src/lib.rs
Outdated
| /// In contrast to its name it also includes the header overhead and digest size to accurately | ||
| /// track block size. |
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.
Do we want to change the name? Too much of a breaking change?
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.
Yea, I dont think anyone is reading this anyway, besides frame_system or?
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 I can change if you like.
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
| block_data.header.len() + | ||
| block_data.body.iter().map(|ex| ex.len()).sum::<usize>() + | ||
| block_data.indexed_body.iter().map(|ex| ex.len()).sum::<usize>(); | ||
| block_data.indexed_body.iter().map(|ex| ex.len()).sum::<usize>() + | ||
| block_data.justification.len() + | ||
| block_data.justifications.len(); |
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.
Why do you have to go through these manually instead of something like block_data.encoded_size()?
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.
Good question. Just kept it as it was before.
| assert_eq!(net.peer(1).client.info().best_number, 33); | ||
| } | ||
|
|
||
| /// Test syncing 512 blocks with ~1.2 MiB headers (empty bodies) to test large header handling. |
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 see 900 KiB digests, where are the other 300 KiB coming from in the header?
substrate/frame/system/src/lib.rs
Outdated
| /// In contrast to its name it also includes the header overhead and digest size to accurately | ||
| /// track block size. |
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.
Yea, I dont think anyone is reading this anyway, besides frame_system or?
| let empty_header = <<T as Config>::Block as traits::Block>::Header::new( | ||
| *number, | ||
| Default::default(), | ||
| Default::default(), | ||
| *parent_hash, | ||
| Default::default(), | ||
| ); | ||
| let empty_header_size = empty_header.encoded_size(); |
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 guess we cannot hard-code an upper bound and have an integrity test for this encoded size since it is generic over the runtime types? hm...
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 not super perfect, but also not that much better solvable.
substrate/frame/system/src/limits.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl BlockLength { | ||
| /// Create new `BlockLength` with `max` for every class. | ||
| #[deprecated(since = "TBD", note = "Use `BlockLength::builder().max(value).build()` instead")] |
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.
| #[deprecated(since = "TBD", note = "Use `BlockLength::builder().max(value).build()` instead")] | |
| #[deprecated(note = "`BlockLength::max(value)` will be removed after July 2026. Use `BlockLength::builder().max(value).build()` instead")] |
Or do you want to put a version?
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.
We don't have any proper version? :D
substrate/frame/system/src/limits.rs
Outdated
| } | ||
|
|
||
| /// Create new `BlockLength` with `max` for `Operational` & `Mandatory` | ||
| /// and `normal * max` for `Normal`. | ||
| #[deprecated( | ||
| since = "TBD", |
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.
ditto
No description provided.