-
Notifications
You must be signed in to change notification settings - Fork 833
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix for #6296: Deterministic RNG in peer DAS publish block tests #7192
base: unstable
Are you sure you want to change the base?
Conversation
beacon_node/http_api/src/lib.rs
Outdated
@@ -1260,6 +1260,7 @@ pub fn serve<T: BeaconChainTypes>( | |||
BroadcastValidation::default(), | |||
duplicate_block_status_code, | |||
network_globals, | |||
false, |
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 don't really love adding a random bool parameter here. I wonder if a cleaner approach would be to add an rng: Arc<RwLock<Box<dyn RngCore>>>
field to BeaconChain
which is initialised either as the thread_rng
or a seeded RNG depending on config? The BeaconChainHarness
could initialise it in seeded mode, while the BeaconChainBuilder
used in production could initialise it as thread_rng
.
What do you think @SunnysidedJ?
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.
Thank you for making this comment with detailed pointers. I was also wondering a good place to pass RNG instances instead, but I wasn't able to due to my lack of knowledge in the codebase and Rust (I'm a beginner). One thing that I couldn't use was ThreadRng instance for production code because it is a thread-local object which cannot be passed between threads. Would a slight degrading of performance due to the use of OsRng be a concern for you? The logic otherwise seems the same according to its documentation. Nonetheless, I hope the new change is something closer to what you expect!
Issue Addressed
#6296: Deterministic RNG in peer DAS publish block tests
Proposed Changes
Made test functions to call publish-block APIs with true for the deterministic RNG boolean parameter while production code with false. This will deterministically shuffle columns for unit tests under broadcast_validation_tests.rs.
Additional Info