You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To ensure deterministic override_random_bytes for each node, I first reverted to the state before commit a3b416a and used keys_manager.get_secure_random_bytes() to retrieve the required values. Then, I restored the current state of the code and assigned the collected values to their respective nodes.
This is my first PR for LDK, so I’d appreciate any feedback on my approach and possible improvements.
I think post-#3302 we should focus on making the test robust in that it doesn't rely on the output of the RNG, rather than trying to fix the RNG output (which #3302 largely already did).
Ok, thanks for the feedback! Quick question—would it make more sense to reduce the RNG dependency just enough so override_random_bytes doesn’t break the test so easily, or should I focus on keeping override_random_bytes and minimizing the test’s reliance on RNG? Sorry if I’m being redundant with my question, still getting familiar with the project.
In an ideal world I think we can drop the override_random_bytes and also the set_counter lines above. I think that would be the goal to close the issue.
I updated the code as suggested. I removed the set_counter call from do_test_restored_packages_retry and changed serialized_monitor to match the node under test. To do this, I reverted to the code state before commit a3b416a, adjusted the override_random_bytes to reflect the current implementation, and used get_monitor to obtain the updated serialized_monitor value.
Could you please confirm if this reasoning is correct or if there's anything else needed?
Doh! When I did #3302 and commented above I had not actually bothered to look into why the test needed specific RNG output. Having to have the RNG output match the hard-coded ChannelMonitor is really the annoying part here. Ideally we'd have a way to override the keys selected themselves so that we're not relying on the RNG at all. I think that would mean having a variant to create_chanmon_cfgs which allows us to specify the node's seed and then hooking TestKeysInterface::generate_channel_keys_id to let us specify the next keys-id that will be used so that it matches the one we want.
Thanks a lot! I saw your comment—I was trying to tackle the RNG issue in a different way, but I realized I was way off and getting stuck. I had already gone back and modified serialized_monitor, but I started questioning if I was just overcomplicating things. I'll start making the suggested changes now. Appreciate the guidance!
I've implemented the requested changes. I removed set_account and introduced override_next_keys_id, allowing generate_channel_keys_id to return a predefined value if set. Otherwise, it follows the normal flow. The override resets to None after use to prevent duplicate IDs.
I also added create_chanmon_cfgs_with_keys, which works like create_chanmon_cfgs but allows predefined keys_id values to be set in chan_mon_cfgs, ensuring predictable key generation when needed. Additionally, I used set_counter to track generate_channel_keys_id outputs, preserving the original keys_id values and avoiding changes to serialized_monitor.
I believe the test now relies less on RNG manipulation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes#2827
To ensure deterministic
override_random_bytesfor each node, I first reverted to the state before commit a3b416a and usedkeys_manager.get_secure_random_bytes()to retrieve the required values. Then, I restored the current state of the code and assigned the collected values to their respective nodes.This is my first PR for LDK, so I’d appreciate any feedback on my approach and possible improvements.