-
Notifications
You must be signed in to change notification settings - Fork 961
Remove data dependency from from core module in `consensus/types
#8694
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: unstable
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,3 +170,43 @@ impl From<SszError> for DataColumnSidecarError { | |
| Self::SszError(e) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use crate::core::{MainnetEthSpec, max_data_columns_by_root_request_common}; | ||
| use fixed_bytes::FixedBytesExtended; | ||
| use ssz_types::RuntimeVariableList; | ||
|
|
||
| // This is the "correct" implementation of max_data_columns_by_root_request. | ||
| // This test ensures that the simplified implementation doesn't deviate from it. | ||
| fn max_data_columns_by_root_request_implementation<E: EthSpec>( | ||
| max_request_blocks: u64, | ||
| ) -> usize { | ||
| let max_request_blocks = max_request_blocks as usize; | ||
|
|
||
| let empty_data_columns_by_root_id = DataColumnsByRootIdentifier { | ||
| block_root: Hash256::zero(), | ||
| columns: VariableList::repeat_full(0), | ||
| }; | ||
|
|
||
| RuntimeVariableList::<DataColumnsByRootIdentifier<E>>::new( | ||
| vec![empty_data_columns_by_root_id; max_request_blocks], | ||
| max_request_blocks, | ||
| ) | ||
| .expect("creating a RuntimeVariableList of size `max_request_blocks` should succeed") | ||
| .as_ssz_bytes() | ||
| .len() | ||
| } | ||
|
|
||
| #[test] | ||
| fn max_data_columns_by_root_request_matches_simplified() { | ||
| for n in [0, 1, 2, 8, 16, 32, 64, 128, 256, 512, 1024] { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can make sure it also works for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the value that actually gets used |
||
| assert_eq!( | ||
| max_data_columns_by_root_request_common::<MainnetEthSpec>(n), | ||
| max_data_columns_by_root_request_implementation::<MainnetEthSpec>(n), | ||
| "Mismatch at n={n}" | ||
| ); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.