Skip to content
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

Update full_stack_target to take an arbitrary config object #2810

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

@TheBlueMatt TheBlueMatt commented Dec 29, 2023

Built on #2808 and #2809, this updates the full_stack_target to read in an arbitrary config object, which ultimately was able to reproduce #2804 rather trivially.

@TheBlueMatt TheBlueMatt added this to the 0.0.120 milestone Dec 29, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (3751398) 89.18% compared to head (7377cc9) 89.17%.
Report is 4 commits behind head on main.

Files Patch % Lines
lightning/src/ln/channelmanager.rs 82.92% 6 Missing and 1 partial ⚠️
lightning/src/chain/channelmonitor.rs 93.75% 1 Missing ⚠️
lightning/src/routing/scoring.rs 85.71% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2810      +/-   ##
==========================================
- Coverage   89.18%   89.17%   -0.01%     
==========================================
  Files         116      116              
  Lines       93252    93268      +16     
  Branches    93252    93268      +16     
==========================================
+ Hits        83166    83171       +5     
- Misses       7560     7570      +10     
- Partials     2526     2527       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheBlueMatt TheBlueMatt force-pushed the 2023-12-arbitrary-fuzz-config branch 2 times, most recently from 727887f to f693ff3 Compare January 2, 2024 02:49
@TheBlueMatt
Copy link
Collaborator Author

Rebased.

Copy link

coderabbitai bot commented Jan 11, 2024

Walkthrough

The changes across the lightning project focus on enhancing consistency and maintainability by standardizing the initialization of hash maps and sets. This includes the introduction of custom functions like new_hash_map() and adjustments in handling hash-related functionalities, particularly with the addition of the ahash crate for hashing algorithms. These modifications aim to improve codebase efficiency and reliability, especially under fuzz testing conditions, and reflect a careful consideration of performance and security implications.

Changes

Files Change Summaries
.../chain/chainmonitor.rs, .../channelmonitor.rs, .../onchaintx.rs, .../bump_transaction.rs, .../routing/..., .../sync/debug_sync.rs, .../util/test_utils.rs Replaced direct HashMap::new() and HashSet::new() with new_hash_map() and new_hash_set().
.../lib.rs, .../events/..., .../ln/..., .../onion_message/messenger.rs, .../sign/mod.rs, .../util/... Introduced or modified logic for hash map/set initialization and handling, including ahash support.
fuzz/src/peer_crypt.rs Modified slice access and copying logic.
.github/workflows/build.yml, ci/check-cfg-flags.py Updated CI configurations to include ahash feature and updated toolchain and dependencies.

"In the realm of code where the data streams flow,
🐇 A rabbit hopped, with changes in tow.
Hash maps and sets, now sprightly and new,
With ahash in hand, our performance flew."
🌟🚀🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4b70921 and 9a01841.
Files ignored due to filter (3)
  • fuzz/Cargo.toml
  • lightning-invoice/Cargo.toml
  • lightning/Cargo.toml
Files selected for processing (25)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (1 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (22 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (4 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review due to trivial changes (3)
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/ln/channel.rs
  • lightning/src/util/test_utils.rs
Additional comments: 83
ci/check-cfg-flags.py (1)
  • 16-17: The addition of the "ahash" feature condition in the check_feature function is consistent with the existing structure and is correctly implemented.
lightning/src/util/indexed_map.rs (2)
  • 37-37: The replacement of HashMap::new() with new_hash_map() and HashMap::with_capacity(capacity) with hash_map_with_capacity(capacity) is consistent and follows the DRY principle by centralizing the creation of hash maps.

Also applies to: 45-45

  • 179-179: The replacement of hash_map::VacantEntry and hash_map::OccupiedEntry with VacantHashMapEntry and OccupiedHashMapEntry is consistent with the new import changes and maintains the clarity of the code.

Also applies to: 188-188

lightning/src/lib.rs (2)
  • 168-234: The conditional compilation logic for including the ahash crate and using different hash map and hash set implementations based on feature flags is complex. Ensure that the logic is thoroughly tested to prevent any issues due to incorrect feature flag combinations.

  • 222-234: The introduction of functions for creating hash maps and hash sets with specific capacities is a good practice, as it encapsulates the creation logic and allows for easy adjustments in the future.

lightning/src/sync/debug_sync.rs (1)
  • 60-60: The use of new_hash_map() for initializing HashMap instances for LOCKS_HELD, locked_before, and LOCKS is consistent with the changes in other files and follows the DRY principle.

Also applies to: 116-116, 125-125

lightning/src/routing/utxo.rs (1)
  • 310-310: The change to use new_hash_map for initializing channels and nodes in the PendingChecks struct is consistent with the PR's objective to standardize the creation of these data structures. This should improve the maintainability of the code by using a single function to create hash maps, which could be beneficial if the initialization logic needs to be updated or extended in the future.
lightning/src/events/bump_transaction.rs (2)
  • 394-394: The change to use new_hash_map() instead of HashMap::new() is consistent with the PR's objective to standardize the creation of hash maps across the codebase. This change should be safe as long as new_hash_map() is correctly implemented to return an empty HashMap. However, ensure that new_hash_map() is indeed a drop-in replacement for HashMap::new() in terms of performance and behavior.

  • 392-396: The introduction of new_hash_map() is used here to initialize locked_utxos. It's important to verify that the new_hash_map() function has been defined and is accessible within this scope. Additionally, ensure that the new_hash_map() function does not introduce any unexpected side effects that could affect the locking mechanism of UTXOs.

Verification successful

The new_hash_map function is defined in lightning/src/lib.rs and is accessible within the scope of bump_transaction.rs since it is marked as pub(crate), meaning it is public within the crate. The implementation of new_hash_map is a simple wrapper around HashMap::new(), which should not introduce any unexpected side effects.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the existence and implementation of new_hash_map function.
rg "fn new_hash_map" --type rust

Length of output: 205

lightning/src/util/config.rs (4)
  • 16-17: The addition of the Readable trait for fuzzing is a good practice as it allows fuzzers to generate a wide range of inputs to test the system's robustness. However, ensure that this trait is only available when the fuzzing feature is enabled to prevent its use in production code.

  • 220-235: The implementation of Readable for ChannelHandshakeConfig looks correct and follows the pattern of reading each field in order. It's important to ensure that the types of each field implement Readable themselves, which is a safe assumption given the standard types used here.

  • 346-361: Similarly, the implementation of Readable for ChannelHandshakeLimits is consistent with the previous implementation for ChannelHandshakeConfig. It's good to see consistency in the approach to these implementations.

  • 834-847: The Readable implementation for UserConfig is also consistent with the other Readable implementations. It's crucial to ensure that the Readable trait is not exposed in production as it can lead to security issues if external entities can influence configuration.

lightning/src/onion_message/messenger.rs (2)
  • 708-708: The use of new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. This change is good as it abstracts the creation of a HashMap and can be easily modified in the future if needed.

  • 837-837: Again, the use of new_hash_map() here is consistent with the PR's objective. It's good to see that the abstraction is being used in multiple places, which will make future changes to the hash map creation process easier.

lightning/src/util/ser.rs (3)
  • 752-752: The change to use hash_map_with_capacity(len) in the impl_for_map! macro for HashMap is noted. Ensure that the hash_map_with_capacity function is defined and correctly handles the capacity allocation.
Verification successful

The output from the rg command confirms that the function hash_map_with_capacity is indeed defined within the lightning/src/lib.rs file. This definition is consistent with the change noted in the review comment, where the impl_for_map! macro for HashMap now uses hash_map_with_capacity(len).

Given this information, the review comment is consistent with the codebase, as the function required by the macro is present and presumably handles the capacity allocation as intended.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the function `hash_map_with_capacity` is defined and properly handles capacity.
rg 'fn hash_map_with_capacity'

Length of output: 226

* 774-774: The initialization of `HashSet` with `hash_set_with_capacity` using `cmp::min(len.0 as usize, MAX_BUF_SIZE / core::mem::size_of::())` is a good practice to avoid re-allocations. However, ensure that `MAX_BUF_SIZE` and `core::mem::size_of::()` are used correctly to prevent integer overflows and that `MAX_BUF_SIZE` is defined and appropriate for this context.
Verification successful

Based on the script output, MAX_BUF_SIZE is defined in the ser.rs file, and the usage of core::mem::size_of::<T>() is consistent with the context of setting HashSet capacity. The use of cmp::min in the capacity calculation is a safeguard against potential integer overflows by ensuring the capacity does not exceed MAX_BUF_SIZE. The review comment has been verified and the code appears to be using these constants correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that MAX_BUF_SIZE is defined and check for potential integer overflow issues.
rg 'MAX_BUF_SIZE'
# Check for the correct usage of core::mem::size_of::<T>() in the context of HashSet capacity.
ast-grep --lang rust --pattern $'core::mem::size_of::<$_>()'

Length of output: 1338

* 774-774: The error handling for duplicate insertions in the `HashSet` is correct, returning `DecodeError::InvalidValue` if an insert fails. This ensures that the deserialization process fails fast on invalid data.
lightning/src/chain/onchaintx.rs (6)
  • 377-383: The use of hash_map_with_capacity is introduced to initialize pending_claim_requests and claimable_outpoints. This change seems to be part of a refactoring effort to standardize the creation of hash maps. Ensure that the hash_map_with_capacity function is correctly defined elsewhere and that it behaves as expected, especially with regards to memory allocation limits defined by MAX_ALLOC_SIZE.

  • 448-449: The initialization of pending_claim_requests and claimable_outpoints within the OnchainTxHandler struct has been updated to use new_hash_map. This change is consistent with the refactoring pattern observed in the previous hunk. It's important to verify that new_hash_map is properly defined and that all instances of HashMap::new have been replaced where intended.

  • 689-689: The removal of the reference operator & before outpoint in the removal of claimable outpoints is a subtle but important change. This change should be correct as long as the remove method expects a borrowed reference, which is the usual case with HashMap. However, it's worth double-checking to ensure that this change does not introduce any issues with the types expected by the remove method.

  • 811-811: The introduction of a debug_assert! with a conditional compilation check for fuzzing is a good practice to avoid panics during fuzz testing. However, it's important to ensure that this does not mask potential issues during normal execution. The use of cfg!(fuzzing) should be verified to ensure it's defined correctly in the build configuration.

Verification successful

The search results indicate that the fuzzing configuration is indeed used throughout the codebase, particularly within conditional compilation attributes. The flag is used to differentiate behavior during fuzz testing from normal execution, as seen in various files including lib.rs, config.rs, mod.rs, and others.

The presence of the fuzzing flag in the lib.rs file suggests that it is a recognized compilation flag within the project. It is used in conjunction with cfg_attr and cfg to conditionally compile code for fuzzing. This confirms that the fuzzing flag is defined and used correctly in the build configuration.

Given this information, the review comment about the introduction of a debug_assert! with a conditional compilation check for fuzzing is consistent with the codebase's use of the fuzzing flag. The flag is used to ensure that certain assertions are only enabled during normal execution and not during fuzz testing, which is a common practice to avoid false positives when fuzzing.

Based on the evidence from the search results, the use of cfg!(fuzzing) in the debug_assert! is verified to be defined correctly in the build configuration, and the review comment is consistent with the practices observed in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the build configuration for the fuzzing flag
rg "cfg!(fuzzing)" --type rust

Length of output: 32



Script:

#!/bin/bash
# Search for the definition of the 'fuzzing' feature flag in Cargo.toml files
rg 'fuzzing' --glob 'Cargo.toml'

# Search for the usage of the 'fuzzing' flag without the cfg! macro in case it's used differently
rg 'fuzzing' --type rust

Length of output: 17504

* 837-837: The initialization of `bump_candidates` using `new_hash_map` in the `update_claims_view` function is consistent with the refactoring pattern. As with previous instances, ensure that `new_hash_map` is defined and used correctly throughout the codebase.
  • 1023-1023: Similarly, the initialization of bump_candidates in the handle_onchain_events function has been updated to use new_hash_map. This change should be reviewed in the context of the entire function to ensure that it aligns with the intended behavior and that new_hash_map is the appropriate choice here.
lightning/src/chain/chainmonitor.rs (1)
  • 422-422: The initialization of the monitors field has been refactored to use new_hash_map() instead of HashMap::new(). This is a good practice for standardizing the creation of hash maps across the codebase. Ensure that the new_hash_map() function is implemented correctly and performs as expected.
Verification successful

The change to initialize the monitors field using new_hash_map() has been verified and is consistent with the codebase. The new_hash_map() function is correctly implemented as a wrapper for HashMap::new() in lightning/src/lib.rs.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that new_hash_map is defined and check its implementation.
rg "fn new_hash_map"

Length of output: 193

fuzz/src/full_stack.rs (3)
  • 52-56: The imports are well-organized and follow Rust's convention of grouping imports by the crate. This is good for readability and maintainability.

  • 442-451: The function do_test now includes logic to parse a UserConfig from the input data. It's important to ensure that the input data is of sufficient length and properly formatted to avoid panics due to slicing errors or failed parsing. The current guard clause for data length at the beginning of the function is a good practice.

  • 1050-1050: The test code here is using a hardcoded hex string to simulate input data. This is a common practice in fuzz testing to provide a deterministic input for testing purposes. However, it's important to ensure that this input data is representative of real-world scenarios to make the fuzz testing effective.

lightning/src/sign/mod.rs (1)
  • 353-353: The initialization of output_set has been changed to use hash_set_with_capacity. Ensure that this custom function is implemented correctly and provides the same or improved functionality over the standard HashSet::with_capacity. Also, verify that this change is consistent across the entire codebase.
lightning/src/ln/outbound_payment.rs (5)
  • 169-169: The replacement of HashSet::new() with new_hash_set() is consistent with the PR's objective to standardize the creation of hash sets. This change looks good and follows the DRY principle by using a dedicated function for initialization.

  • 184-184: The use of new_hash_set() for initializing our_session_privs is in line with the changes made in the rest of the file. It's good to see consistency in the use of the new initialization function.

  • 193-193: Again, the initialization of session_privs with new_hash_set() is consistent with the other changes. This maintains the uniformity of the codebase.

  • 673-673: The change to initialize pending_outbound_payments with new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. This is a good refactor that improves the maintainability of the code.

  • 1266-1266: The initialization of session_privs with new_hash_set() here is consistent with the other changes in the file. It's good to see the new function being used throughout the file, which improves the readability and maintainability of the code.

lightning/src/routing/gossip.rs (2)
  • 1356-1357: The replacement of HashMap::new() with new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. This change should ensure that any custom logic or default configurations needed for hash maps are centralized in the new_hash_map() function.

  • 1401-1402: The initialization of last_rapid_gossip_sync_timestamp with None represents a change in the default state of NetworkGraph. This change should be verified to ensure that it aligns with the intended logic, especially since it was previously initialized with a variable that might have held a different value.

lightning/src/ln/peer_handler.rs (2)
  • 948-949: The replacement of direct HashMap::new() calls with new_hash_map() is consistent with the PR's objective to standardize the initialization of hash maps. This change should be checked for correctness in the context of the PeerManager struct initialization.

  • 1942-1942: The use of new_hash_map() for initializing peers_to_disconnect is in line with the changes made in the rest of the file. It's important to ensure that new_hash_map() is implemented correctly and that it does not introduce any performance regressions or unexpected behavior.

lightning/src/ln/monitor_tests.rs (1)
  • 2575-2575: The replacement of direct HashMap instantiation with new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. Ensure that new_hash_map() is properly defined and used consistently across the codebase.
Verification successful

The occurrences of HashMap::new() found in the output are in test files, fuzzing files, and utility files. This suggests that the main codebase has been refactored to use new_hash_map() as intended by the PR, and the remaining usages of HashMap::new() are likely intentional and appropriate for their specific contexts. The PR's objective to standardize hash map creation in the main codebase appears to have been met.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that new_hash_map() is defined.
rg --type rust 'fn new_hash_map'
# Verify that new_hash_map() is used consistently instead of HashMap::new().
rg --type rust 'HashMap::new' --files-without-match

Length of output: 9757



Script:

#!/bin/bash
# Check for occurrences of `HashMap::new` to see if there are any that should have been replaced by `new_hash_map()`.
rg --type rust 'HashMap::new'

Length of output: 1652

lightning/src/ln/functional_test_utils.rs (5)
  • 588-588: The replacement of HashMap::new() with new_hash_map() seems consistent with the PR's objective to standardize the creation of hash maps. Ensure that the new_hash_map() function is defined and behaves as expected.

  • 1018-1018: The use of new_hash_map() here is consistent with the changes in the rest of the codebase. However, it's important to ensure that the assert! statement retains its intended functionality with the new map creation method.

  • 3011-3011: The introduction of new_hash_set() is consistent with the PR's refactoring goals. The logic within the retain method appears to be unchanged, which is good for maintaining existing functionality.

  • 3076-3076: Again, new_hash_set() is used here to replace HashSet::new(). The subsequent logic seems to be intact. It's important to verify that new_hash_set() is properly defined and accessible in this context.

  • 3176-3176: The macro get_chan_reestablish_msgs now uses new_hash_set() which aligns with the PR's refactoring strategy. Ensure that the macro's behavior is consistent with the new set creation method.

lightning/src/routing/scoring.rs (7)
  • 656-656: The replacement of HashMap::new() with new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. This change should be checked for correctness in the context of the ProbabilisticScoringFeeParameters struct.

  • 698-698: The change in the clear_manual_penalties method reflects the same standardization as above. Ensure that the new_hash_map() function is properly defined and accessible in this context.

  • 712-712: Again, the initialization of manual_node_penalties within the new method of ProbabilisticScorer has been updated to use new_hash_map(). This change is consistent with the rest of the PR's changes and should be checked for correctness.

  • 822-822: The initialization of channel_liquidities with new_hash_map() in the ProbabilisticScorer struct is another instance of the same refactoring pattern. This change should be checked for correctness.

  • 1333-1333: The update to the retrieval of penalty from manual_node_penalties by removing the reference operator & is a change in how keys are accessed in the map. This should be checked to ensure that it does not affect the intended behavior, especially since Rust's HashMap allows for key access without a reference.

  • 1363-1363: Similarly, the change in the retrieval of channel_liquidities by removing the reference operator & should be checked for correctness. This change is consistent with the previous one and should be verified to ensure it aligns with Rust's HashMap key access patterns.

  • 2076-2076: The introduction of new_hash_map() in the ReadableArgs implementation for ProbabilisticScoringDecayParameters is consistent with the other changes in this PR. Ensure that the new_hash_map() function is properly defined and accessible in this context.

lightning/src/routing/router.rs (8)
  • 285-285: The replacement of HashMap::new() with new_hash_map() in the InFlightHtlcs::new function is consistent with the PR's objective to standardize hash map initialization.

  • 1938-1938: The use of hash_map_with_capacity instead of HashMap::with_capacity is a good practice to encapsulate the creation logic, which can be beneficial for future modifications or optimizations.

  • 1957-1957: The initialization of private_hop_key_cache with hash_map_with_capacity is correctly using the sum of the lengths of the unblinded route hints as the initial capacity, which should optimize memory allocation.

  • 1978-1978: Replacing HashMap::new() with hash_map_with_capacity for dist and using network_nodes.len() as the initial capacity is a good optimization, as it likely approximates the number of nodes that will be inserted.

  • 2019-2019: The used_liquidities hash map is also initialized with hash_map_with_capacity, using the length of network_nodes for capacity. This change is consistent with the other refactoring efforts and should help with performance.

  • 2537-2537: The check for first_channels.iter().any(...) is a good use of iterators to efficiently determine if any channel matches the condition. This is a clean and readable way to perform the check.

  • 2547-2547: The use of and_then and map for chaining option transformations is idiomatic Rust and is used correctly here to handle the network_channels lookup and subsequent operation.

  • 2588-2588: The call to sort_first_hop_channels within the if let Some(first_channels) block is a good example of conditional logic that only executes if the first_hop_targets contains the target. This ensures that the sorting only happens when necessary.

lightning/src/ln/functional_tests.rs (2)
  • 3322-3322: The replacement of HashSet::new() with new_hash_set() is consistent with the refactoring effort described in the summary. Ensure that new_hash_set() is properly defined and accessible in this context.

  • 7336-7336: The change from HashMap::new() to new_hash_map() is consistent with the refactoring effort. Ensure that new_hash_map() is properly defined and accessible in this context.

lightning/src/ln/channelmanager.rs (22)
  • 2421-2428: The replacement of direct Mutex::new(HashSet::new()) and Mutex::new(HashMap::new()) calls with new_hash_set() and new_hash_map() is a good practice for maintainability and consistency. It abstracts the creation logic and allows for future optimizations or changes in one place.

  • 2440-2440: The use of new_hash_map() for initializing per_peer_state under a FairRwLock is consistent with the other changes and promotes the same benefits of maintainability and potential optimizations.

  • 3673-3673: The introduction of hash_map_with_capacity(first_hops.len()) is a performance optimization that pre-allocates space for the expected number of elements, reducing the need for rehashing as elements are inserted.

  • 4224-4224: Using new_hash_map() to initialize forward_htlcs before swapping it with self.forward_htlcs is a logical change that aligns with the rest of the refactoring. However, ensure that the mem::swap operation is still valid and that the forward_htlcs Mutex guard is dropped immediately after the swap to avoid potential deadlocks.

Verification successful

The review comment is concerned with ensuring that the Mutex guard is dropped immediately after the mem::swap operation to avoid potential deadlocks. The provided script output shows that the mem::swap is called within a block, and since the Mutex guard is not assigned to a variable, it will be dropped at the end of the statement, which is the behavior desired to prevent deadlocks. This confirms that the implementation is correct regarding the Mutex guard's scope and its release.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Mutex guard is dropped immediately after the swap to avoid deadlocks.
rg --type rust --context 5 'mem::swap\(&mut forward_htlcs, &mut self.forward_htlcs.lock\(\).unwrap\(\)\);'

Length of output: 980

* 5919-5919: The code snippet provided does not show any changes, but it is related to the `outpoint_to_peer` map which was mentioned earlier in the summary. Without the context of what changed, it's difficult to provide a specific comment. If this is meant to show the usage of `outpoint_to_peer`, then it seems to be correctly accessing the map.
  • 8970-8970: The initialization of channel_by_id and inbound_channel_request_by_id with new_hash_map() is consistent with the refactoring pattern and is approved.

  • 10014-10014: The use of new_hash_map() for initializing pending_outbound_payments_no_retry is consistent with the refactoring pattern. Ensure that the rest of the code correctly handles the new structure.

  • 10042-10042: The conditional initialization of in_flight_monitor_updates with new_hash_map() is a good practice to avoid unnecessary memory allocation. However, ensure that the is_none() check is the desired logic and that there are no cases where an existing map should be used or modified instead.

Verification successful

Based on the context provided by the script output, the in_flight_monitor_updates variable is correctly initialized with new_hash_map() only when necessary, which is when there are updates to be inserted. The lazy initialization pattern using is_none() check before the assignment is a standard practice to avoid unnecessary memory allocation. There are no indications from the provided context that an existing map should be used or modified instead. The logic appears to be correct as per the current usage shown.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that there are no cases where an existing in_flight_monitor_updates map should be used or modified.
rg --type rust --context 5 'in_flight_monitor_updates.is_none\(\)'

Length of output: 990

* 10278-10281: Pre-allocating hash maps and sets with `hash_set_with_capacity()` and `hash_map_with_capacity()` based on `channel_count` is a performance optimization. Ensure that the `cmp::min` logic is correct and that it does not under-allocate for the expected number of channels.
  • 10368-10368: The use of new_hash_map() for initializing by_id_map within a match arm is consistent with the refactoring pattern and is approved.

  • 10413-10413: The use of hash_map_with_capacity() for initializing forward_htlcs with a pre-allocated capacity is a performance optimization. Ensure that the cmp::min logic is correct and that it does not under-allocate for the expected number of HTLCs.

  • 10439-10439: The initialization of inbound_channel_request_by_id with new_hash_map() is consistent with the refactoring pattern and is approved.

  • 10450-10453: The use of hash_map_with_capacity() for initializing per_peer_state with a pre-allocated capacity is a performance optimization. Ensure that the cmp::min logic and the MAX_ALLOC_SIZE constant are correctly used to avoid over-allocation or under-allocation.

Verification successful

The verification process has confirmed that the cmp::min logic and the MAX_ALLOC_SIZE constant are correctly used in the hash_map_with_capacity function call for initializing per_peer_state in the channelmanager.rs file. The code snippet provided in the output shows the intended performance optimization is in place.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the cmp::min logic and the MAX_ALLOC_SIZE constant are correctly used.
rg --type rust --context 5 'hash_map_with_capacity\(cmp::min\(peer_count as usize, MAX_ALLOC_SIZE/mem::size_of::<\(PublicKey, Mutex<PeerState<SP>>\)>())\)'

Length of output: 458



Script:

#!/bin/bash
# Correcting the regex pattern by escaping special characters to verify the usage of cmp::min and MAX_ALLOC_SIZE.
rg --type rust --context 5 'hash_map_with_capacity\(cmp::min\(peer_count as usize, MAX_ALLOC_SIZE\/mem::size_of::<\(PublicKey, Mutex<PeerState<SP>>\)>())\)'

Length of output: 421



Script:

#!/bin/bash
# Simplifying the regex pattern to avoid parse errors and verify the usage of cmp::min and MAX_ALLOC_SIZE.
rg --type rust --context 5 'hash_map_with_capacity\(cmp::min'

Length of output: 11405

* 10487-10487: The use of `hash_map_with_capacity()` for initializing `pending_inbound_payments` with a pre-allocated capacity is a performance optimization. Ensure that the `cmp::min` logic is correct and that it does not under-allocate for the expected number of payments.
Verification successful

The output from the script has provided the relevant line of code from channelmanager.rs that uses hash_map_with_capacity() for initializing various hash maps, including pending_inbound_payments. The line of interest is:

let mut pending_inbound_payments: HashMap<PaymentHash, PendingInboundPayment> = hash_map_with_capacity(cmp::min(pending_inbound_payment_count as usize, MAX_ALLOC_SIZE/(3*32)));

This line shows that the cmp::min function is used to determine the smaller of two values: the pending_inbound_payment_count cast to a usize, and MAX_ALLOC_SIZE/(3*32). This logic ensures that the capacity of the hash map is not pre-allocated to be larger than necessary, which is a performance optimization to avoid excessive memory allocation.

The MAX_ALLOC_SIZE/(3*32) part of the expression seems to be a calculation to prevent over-allocation based on a maximum allocation size constant (MAX_ALLOC_SIZE) and the size of the elements that will be stored in the hash map (assuming each PaymentHash and PendingInboundPayment takes up 3*32 bytes).

Given this information, the cmp::min logic appears to be correctly implemented to allocate enough space for the expected number of inbound payments without exceeding a maximum memory allocation threshold. The specific numbers used in the calculation would be based on the expected size of the data structures and the constraints of the system.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the cmp::min logic correctly allocates enough space for the expected number of inbound payments.
rg --type rust --context 5 'hash_map_with_capacity\(cmp::min\(pending_inbound_payment_count as usize, MAX_ALLOC_SIZE/\(3*32\)\)\)'

Length of output: 132



Script:

#!/bin/bash
# Attempt a broader search for the usage of `hash_map_with_capacity()` in the `channelmanager.rs` file.
rg --type rust 'hash_map_with_capacity' lightning/src/ln/channelmanager.rs

Length of output: 1099

* 10496-10496: The use of `hash_map_with_capacity()` for initializing `pending_outbound_payments_compat` with a pre-allocated capacity is a performance optimization. Ensure that the `cmp::min` logic is correct and that it does not under-allocate for the expected number of payments.
Verification successful

The output from the script shows that the hash_map_with_capacity() function is used with cmp::min to determine the initial capacity of the HashMap for pending_outbound_payments_compat. The capacity is set to the minimum of pending_outbound_payments_count_compat as usize and MAX_ALLOC_SIZE/32. This is a safeguard to prevent over-allocation while also ensuring that there is enough space allocated for the expected number of outbound payments.

To further verify the correctness of this logic, we would need to understand the typical values of pending_outbound_payments_count_compat and the value of MAX_ALLOC_SIZE. However, based on the context provided, it seems that the logic is designed to balance performance with memory safety by using cmp::min to set a reasonable upper limit on the initial capacity of the HashMap.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the cmp::min logic correctly allocates enough space for the expected number of outbound payments.
rg --type rust --context 5 'hash_map_with_capacity\(cmp::min\(pending_outbound_payments_count_compat as usize, MAX_ALLOC_SIZE/32\)\)'

Length of output: 1019

* 10510-10510: The initialization of `pending_intercepted_htlcs` with `Some(new_hash_map())` is consistent with the refactoring pattern and is approved. Ensure that the `Some` wrapper is the intended logic and that there are no cases where this should be `None`.
Verification successful

Based on the search results, the initialization of pending_intercepted_htlcs with Some(new_hash_map()) is consistent with the rest of the code. The Option type is used intentionally, and there are mechanisms to handle both Some and None states. The use of Some for initialization aligns with the expected logic in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Some wrapper is the intended logic for pending_intercepted_htlcs.
rg --type rust --context 5 'let mut pending_intercepted_htlcs: Option<HashMap<InterceptId, PendingAddHTLCInfo>> = Some\(new_hash_map\(\)\);'

Length of output: 1133



Script:

#!/bin/bash
# Search for any assignments to `pending_intercepted_htlcs` that might set it to None or rely on it being None.
rg --type rust 'pending_intercepted_htlcs' lightning/src/ln/channelmanager.rs

Length of output: 1211

* 10553-10553: The use of `new_hash_map()` for initializing `outbounds` within a conditional block is consistent with the refactoring pattern. Ensure that the logic for handling `pending_outbound_payments_no_retry` is correct and that the `unwrap().drain()` operation is safe.
Verification successful

The conditional logic in channelmanager.rs ensures that pending_outbound_payments_no_retry.unwrap().drain() is called only when pending_outbound_payments_no_retry is not None, which makes the unwrap() call safe. The drain() operation is correctly used to move the contents into a new hash map, which is then assigned to pending_outbound_payments. This aligns with the refactoring pattern and the logic appears to be correctly implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the logic for handling pending_outbound_payments_no_retry is correct.
rg --type rust --context 5 'pending_outbound_payments_no_retry.unwrap\(\).drain\(\)'

Length of output: 985

* 10660-10660: The use of `new_hash_map()` for initializing a new `peer_state` within the `or_insert_with` closure is consistent with the refactoring pattern and is approved. Ensure that the `or_insert_with` logic is correct and that it is the desired behavior to create a new `peer_state` if one does not exist.
Verification successful

The verification process has confirmed that the use of or_insert_with for initializing a new peer_state within the per_peer_state map is correct. This ensures that a new peer_state is created if one does not exist for the given counterparty_id, which aligns with the standard Rust practice for handling absent keys in a map.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the or_insert_with logic is correct for creating a new peer_state.
rg --type rust --context 5 'per_peer_state.entry\(counterparty_id\).or_insert_with\(\|\)'

Length of output: 91



Script:

#!/bin/bash
# Broaden the search to find the usage of `or_insert_with` related to `per_peer_state`.
rg --type rust 'per_peer_state.*\.or_insert_with'

Length of output: 172


Script:

#!/bin/bash
# If the above does not yield results, find occurrences of `per_peer_state` to understand its usage.
rg --type rust 'per_peer_state'

Length of output: 25970

* 10845-10845: The use of `hash_map_with_capacity()` for initializing `claimable_payments` with a pre-allocated capacity is a performance optimization. Ensure that the `claimable_htlcs_list.len()` is the correct basis for the capacity and that the error handling for mismatched lengths is appropriate.
Verification successful

Based on the provided context, the use of claimable_htlcs_list.len() as the capacity for claimable_payments is justified by the subsequent check that ensures purposes.len() matches claimable_htlcs_list.len(). If they do not match, an error is returned, which is appropriate error handling for mismatched lengths. Therefore, the review comment is consistent with the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the claimable_htlcs_list.len() is the correct basis for the capacity.
rg --type rust --context 5 'hash_map_with_capacity\(claimable_htlcs_list.len\(\)\)'

Length of output: 950

* 10918-10918: The use of `new_hash_set()` for initializing `outbound_scid_aliases` is consistent with the refactoring pattern and is approved. Ensure that the rest of the code correctly handles the new structure.
  • 11023-11023: The code snippet provided does not show any changes, but it is related to the per_peer_state map which was mentioned earlier in the summary. Without the context of what changed, it's difficult to provide a specific comment. If this is meant to show the usage of per_peer_state, then it seems to be correctly accessing the map.

  • 12451-12451: The use of new_hash_map() for initializing forward_htlcs and inserting dummy HTLCs is consistent with the refactoring pattern and is approved. Ensure that the dummy HTLCs are correctly used for testing or example purposes.

lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
Comment on lines 49 to 58
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
use lightning::routing::utxo::UtxoLookup;
use lightning::routing::router::{InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router};
use lightning::util::config::{UserConfig, MaxDustHTLCExposure};
use lightning::util::config::UserConfig;
use lightning::util::errors::APIError;
use lightning::util::test_channel_signer::{TestChannelSigner, EnforcementState};
use lightning::util::logger::Logger;
use lightning::util::ser::{ReadableArgs, Writeable};
use lightning::util::ser::{Readable, ReadableArgs, Writeable};

use crate::utils::test_logger;
use crate::utils::test_persister::TestPersister;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [3-3]

The comments across these lines are consistent in providing examples of input data formats. While they are helpful, the recommendation to document these examples outside of the code still stands. Additionally, it's important to ensure that these comments are kept up-to-date with any changes to the input data format to prevent confusion.

Also applies to: 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10, 11-11, 12-12, 13-13, 14-14

@@ -2532,9 +2532,9 @@ where L::Target: Logger {
let mut aggregate_path_contribution_msat = path_value_msat;

for (idx, (hop, prev_hop_id)) in hop_iter.zip(prev_hop_iter).enumerate() {
let target = private_hop_key_cache.get(&prev_hop_id).unwrap();
let target = private_hop_key_cache.get(prev_hop_id).unwrap();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing the private_hop_key_cache with unwrap() assumes that the entry exists. It would be safer to handle the potential None case explicitly to avoid panics at runtime.

- let target = private_hop_key_cache.get(prev_hop_id).unwrap();
+ let target = private_hop_key_cache.get(prev_hop_id).expect("Expected previous hop ID to exist in private_hop_key_cache");

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
let target = private_hop_key_cache.get(prev_hop_id).unwrap();
let target = private_hop_key_cache.get(prev_hop_id).expect("Expected previous hop ID to exist in private_hop_key_cache");

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9a01841 and 48a5c0d.
Files selected for processing (1)
  • lightning/src/ln/functional_tests.rs (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • lightning/src/ln/functional_tests.rs

@TheBlueMatt
Copy link
Collaborator Author

This needs to land so we can keep fuzzing, but it doesn't need to land for a specific release.

@TheBlueMatt TheBlueMatt removed this from the 0.0.120 milestone Jan 17, 2024
@TheBlueMatt TheBlueMatt force-pushed the 2023-12-arbitrary-fuzz-config branch 2 times, most recently from fd0ef78 to dfa113e Compare January 17, 2024 01:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fbeb7ac and dfa113e.
Files ignored due to path filters (3)
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (25)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (1 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (22 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/sync/debug_sync.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 11
lightning/src/util/indexed_map.rs (5)
  • 3-3: The previous comment regarding the wildcard import is still valid.
  • 37-37: The change from HashMap::new() to new_hash_map() is consistent with the PR's objective to abstract the hash map implementation.
  • 45-45: The change from HashMap::with_capacity() to hash_map_with_capacity() is consistent with the PR's objective to abstract the hash map implementation.
  • 179-179: The update to VacantEntry to use VacantHashMapEntry is consistent with the PR's objective to abstract the hash map implementation.
  • 188-188: The update to OccupiedEntry to use OccupiedHashMapEntry is consistent with the PR's objective to abstract the hash map implementation.
fuzz/src/full_stack.rs (2)
  • 451-451: The configuration for the test is read from the input data, which allows for dynamic test setups. This is a good practice for fuzz testing as it increases the variety of tests that can be run automatically.
let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };
  • 1050-1050: The test logger is being used correctly to capture log entries during the test. This is useful for debugging and ensuring that the test outputs can be analyzed after the test runs.
let logger = Arc::new(TrackingLogger { lines: Mutex::new(HashMap::new()) });
lightning/src/ln/functional_tests.rs (4)
  • 3322-3322: The change from HashSet::new() to new_hash_set() is consistent with the PR's objective to standardize the creation of hash sets.
  • 5399-5403: The variable name correction and the change from HashSet::new() to new_hash_set() are appropriate and align with the PR's objective to standardize the creation of hash sets.
  • 5425-5429: The change from HashSet::new() to new_hash_set() is consistent with the PR's objective to standardize the creation of hash sets.
  • 7336-7336: The change from HashMap::new() to new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps.

@wpaulino
Copy link
Contributor

LGTM but CI is failing

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and 9ca367f.
Files ignored due to path filters (3)
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (25)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (1 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (22 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/sync/debug_sync.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 27
lightning/src/util/indexed_map.rs (4)
  • 37-37: The change from HashMap::new() to new_hash_map() is good as it abstracts the specific map implementation, which can be beneficial for testing or future changes to the underlying data structure.
  • 45-45: Similarly, replacing HashMap::with_capacity(capacity) with hash_map_with_capacity(capacity) is a positive change for the same reasons as the previous comment.
  • 179-179: The change from hash_map::VacantEntry to VacantHashMapEntry is consistent with the abstraction of the underlying hash map implementation. Ensure that the new VacantHashMapEntry type is correctly defined and behaves as expected.
Verification successful

The search results from lightning/src/lib.rs reveal that VacantHashMapEntry is a type alias within the lightning codebase. It is conditionally defined based on the compilation feature flags. The alias points to different types of VacantEntry depending on whether the hashbrown feature is enabled and whether it is in a fuzzing context:

  • Without the hashbrown feature, it aliases to std::collections::hash_map::VacantEntry.
  • With the hashbrown feature, it aliases to hashbrown::hash_map::VacantEntry with a default hash builder.
  • With both hashbrown feature and fuzzing, it aliases to hashbrown::hash_map::VacantEntry with a RandomState.

This conditional compilation ensures that the VacantHashMapEntry type is consistent with the underlying hash map implementation being used in the build. The VacantEntry type from both the standard library and hashbrown crate is a well-defined and expected part of a hash map's API, which handles the case when an entry is vacant (i.e., no value is associated with the key in the map).

Given this information, we can confirm that the change from hash_map::VacantEntry to VacantHashMapEntry in the indexed_map.rs file is consistent with the abstraction of the underlying hash map implementation, and the VacantHashMapEntry type is correctly defined and behaves as expected within the context of the codebase's conditional compilation strategy.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that VacantHashMapEntry is defined and has the expected methods and properties.
rg "struct VacantHashMapEntry"

Length of output: 32



Script:

#!/bin/bash
# Broaden the search to find the definition or alias of VacantHashMapEntry, and check for use statements that might bring it into scope.
rg "VacantHashMapEntry"

Length of output: 316


Script:

#!/bin/bash
# Check if VacantHashMapEntry is brought into scope from an external crate.
rg "use .*VacantHashMapEntry"

Length of output: 31



Script:

#!/bin/bash
# Look at the lines in `lightning/src/lib.rs` where `VacantHashMapEntry` is mentioned to understand its nature.
rg "VacantHashMapEntry" lightning/src/lib.rs -C 3

Length of output: 890

* 188-188: The update from `hash_map::OccupiedEntry` to `OccupiedHashMapEntry` is also consistent with the abstraction of the underlying hash map implementation. Similar to the previous comment, ensure that `OccupiedHashMapEntry` is correctly defined and behaves as expected.
Verification successful

The search results indicate that OccupiedHashMapEntry is indeed present in the codebase, but it seems to be a type alias or re-export defined in lightning/src/lib.rs. To understand what OccupiedHashMapEntry is an alias for and to verify its properties and methods, we should look at the lines in lib.rs where it is defined.


The OccupiedHashMapEntry type is defined in lightning/src/lib.rs and is an alias for std::collections::hash_map::OccupiedEntry in the standard library's HashMap implementation. Additionally, there are conditional compilations for different versions of the OccupiedHashMapEntry, one using the hashbrown crate with a DefaultHashBuilder and another with a RandomState.

This confirms that the OccupiedHashMapEntry is correctly defined and is expected to behave as the standard OccupiedEntry from the Rust standard library or the hashbrown crate, depending on the compilation context.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that OccupiedHashMapEntry is defined and has the expected methods and properties.
rg "struct OccupiedHashMapEntry"

Length of output: 34



Script:

#!/bin/bash
# Search for the definition of OccupiedHashMapEntry using ast-grep
ast-grep --lang rust --pattern 'struct OccupiedHashMapEntry { $$$ }'

Length of output: 70



Script:

#!/bin/bash
# Search for any type aliases or re-exports that might point to the actual definition of OccupiedHashMapEntry
rg "type OccupiedHashMapEntry"

Length of output: 248



Script:

#!/bin/bash
# Look at the lines in lib.rs where OccupiedHashMapEntry is defined to understand what it is an alias for
rg "type OccupiedHashMapEntry" lightning/src/lib.rs -C 3

Length of output: 1067

fuzz/src/full_stack.rs (1)
  • 442-451: The changes in lines 442-451 address a previously raised concern about slicing the input data without checking its length. The added check ensures that there is at least 32 bytes of data before attempting to create a SecretKey from the slice, which prevents potential panics due to slicing with an out-of-bounds index.
lightning/src/ln/channelmanager.rs (22)
  • 2427-2434: The replacement of direct HashSet and HashMap instantiations with new_hash_set() and new_hash_map() is consistent with the PR's objective to standardize the creation of these data structures. This should not affect the logic but could impact memory allocation and performance.
  • 2446-2446: The use of new_hash_map() for per_peer_state is in line with the refactoring pattern observed in the rest of the file.
  • 3680-3680: The introduction of hash_map_with_capacity is a good practice to pre-allocate memory based on expected size, which can improve performance.
  • 4231-4231: Using new_hash_map() and then swapping with self.forward_htlcs is a thread-safe way to handle the forward_htlcs map. Ensure that this change is reflected wherever forward_htlcs is used.
Verification successful

The output from the script shows consistent use of new_hash_map() for initializing forward_htlcs across the codebase. The Mutex is used to ensure thread safety when accessing or modifying forward_htlcs. The changes made to forward_htlcs are in line with the PR objectives and comments, which aim to standardize the initialization of hash maps and ensure thread safety.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new_hash_map usage for forward_htlcs is consistent across the codebase
rg --type rust "forward_htlcs" --context 5

Length of output: 30348

* 5926-5926: The code here is unchanged, but it's worth noting that the comment suggests future refactoring. Ensure that the `outpoint_to_peer` map is still required and that the comment is still relevant.
Verification successful

The outpoint_to_peer map is still required in the codebase, as evidenced by its usage in various parts of the code, including tests that verify its state during channel operations. The comments regarding future refactoring suggest that it may become redundant once certain changes are made, but these changes have not yet been implemented. Therefore, the comment about future refactoring remains relevant.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the outpoint_to_peer map is still required and if there are any plans to refactor it as suggested by the comment.
rg --type rust "outpoint_to_peer" --context 5

Length of output: 28755

* 8977-8978: The initialization of `channel_by_id` and `inbound_channel_request_by_id` with `new_hash_map()` is consistent with the refactoring pattern. This is a good practice for maintainability. * 10023-10023: The use of `new_hash_map()` for `pending_outbound_payments_no_retry` is consistent with the refactoring pattern and improves the readability of the code. * 10051-10051: The conditional initialization of `in_flight_monitor_updates` with `new_hash_map()` is a good practice to avoid unnecessary memory allocation. * 10287-10290: Pre-allocating memory for hash maps and sets with `hash_map_with_capacity` and `hash_set_with_capacity` is a performance optimization that should be beneficial given the context. * 10377-10377: The use of `new_hash_map()` for `by_id_map` is consistent with the refactoring pattern and improves the readability of the code. * 10422-10422: Pre-allocating memory for `forward_htlcs` with `hash_map_with_capacity` is a performance optimization that should be beneficial given the context. * 10448-10448: The initialization of `inbound_channel_request_by_id` with `new_hash_map()` is consistent with the refactoring pattern and improves the readability of the code. * 10459-10462: Pre-allocating memory for `per_peer_state` with `hash_map_with_capacity` is a performance optimization that should be beneficial given the context. * 10496-10496: Pre-allocating memory for `pending_inbound_payments` with `hash_map_with_capacity` is a performance optimization that should be beneficial given the context. * 10505-10505: Pre-allocating memory for `pending_outbound_payments_compat` with `hash_map_with_capacity` is a performance optimization that should be beneficial given the context. * 10519-10519: The conditional initialization of various hash maps with `new_hash_map()` is consistent with the refactoring pattern and improves the readability of the code. * 10562-10562: The use of `new_hash_map()` for `outbounds` is consistent with the refactoring pattern and improves the readability of the code. * 10669-10669: The use of `new_hash_map()` within `or_insert_with` is a good practice to avoid unnecessary memory allocation unless it's needed. * 10854-10854: Pre-allocating memory for `claimable_payments` with `hash_map_with_capacity` is a performance optimization that should be beneficial given the context. * 10927-10927: The use of `new_hash_set()` for `outbound_scid_aliases` is consistent with the refactoring pattern and improves the readability of the code. * 11032-11032: This code segment is unchanged, but it's worth noting that the comment suggests future refactoring. Ensure that the `per_peer_state` map is still required and that the comment is still relevant.
Verification successful

Based on the search results, there are no explicit comments in the codebase suggesting future refactoring plans for the per_peer_state map. The map is currently in use and serves its purpose within the system as indicated by the comments and code structure.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the per_peer_state map is still required and if there are any plans to refactor it as suggested by the comment.
rg --type rust "per_peer_state" --context 5

Length of output: 149828



Script:

#!/bin/bash
# Search for comments related to `per_peer_state` that might suggest refactoring plans.
rg --type rust "//" -A 5 "per_peer_state"

Length of output: 94



Script:

#!/bin/bash
# Corrected search for comments related to `per_peer_state` within the files.
rg --type rust "//.*per_peer_state" -A 5

Length of output: 5297

* 12460-12460: The use of `new_hash_map()` for `forward_htlcs` in a test context is consistent with the refactoring pattern and improves the readability of the code.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and a1a6f52.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (25)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (1 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (22 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 12
lightning/src/util/indexed_map.rs (4)
  • 37-37: The change from HashMap::new() to new_hash_map() suggests a custom implementation for hash map creation. Ensure that new_hash_map() is thoroughly tested and benchmarked against HashMap::new() to avoid performance regressions.
  • 45-45: Similar to the previous comment, the change from HashMap::with_capacity(capacity) to hash_map_with_capacity(capacity) should be verified for performance implications, especially since this method is often used for optimization purposes.
  • 179-179: The change from hash_map::VacantEntry to VacantHashMapEntry abstracts away the specific hash map entry type. Ensure that VacantHashMapEntry maintains the same API contract and performance characteristics as the original.
  • 188-188: The same verification for OccupiedHashMapEntry as for VacantHashMapEntry applies here. Confirm that the abstraction does not introduce any unexpected behavior or performance issues.
lightning/src/sync/debug_sync.rs (3)
  • 60-60: The replacement of HashMap::new() with new_hash_map() in the thread-local LOCKS_HELD is noted. As with the previous file, ensure that new_hash_map() is properly tested and does not introduce performance regressions.
  • 116-116: The change to new_hash_map() in the locked_before field initialization within LockMetadata struct should be verified for performance and correctness, similar to previous instances.
  • 125-125: The introduction of new_hash_map() in the LOCKS_INIT call_once lambda should be verified to ensure that the initialization logic is correct and does not introduce thread-safety issues.
fuzz/src/full_stack.rs (5)
  • 442-451: The previous comment regarding the potential panic when slicing data for SecretKey creation has been addressed with a length check.
  • 451-451: The configuration object UserConfig is now being read from the input data. Ensure that the input data format is well-documented and that the Readable trait implementation for UserConfig is robust against malformed input.
  • 788-788: The previous comment about documenting the input data format outside of the code is still valid. Ensure that this documentation is created and maintained.
  • 798-798: The previous comment about documenting the input data format outside of the code is still valid. Ensure that this documentation is created and maintained.
  • 846-846: The previous comment about documenting the input data format outside of the code is still valid. Ensure that this documentation is created and maintained.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and d521777.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (1 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (23 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (21)
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 23
lightning/src/util/indexed_map.rs (5)
  • 3-3: The previous comment regarding the wildcard import use crate::prelude::*; is still valid.
  • 37-37: The use of new_hash_map() instead of HashMap::new() is consistent with the PR's objective to abstract the HashMap type.
  • 45-45: The use of hash_map_with_capacity(capacity) instead of HashMap::with_capacity(capacity) is consistent with the PR's objective to abstract the HashMap type.
  • 179-179: The change from hash_map::VacantEntry to VacantHashMapEntry is consistent with the PR's objective to abstract the HashMap type.
  • 188-188: The change from hash_map::OccupiedEntry to OccupiedHashMapEntry is consistent with the PR's objective to abstract the HashMap type.
.github/workflows/build.yml (1)
  • 113-113: The addition of the ahash feature to the cargo test command is consistent with the PR's objective to enable different hashing algorithms.
lightning/src/sync/debug_sync.rs (4)
  • 17-17: The previous comment regarding the wildcard import use crate::prelude::*; is still valid.
  • 60-60: The use of new_hash_map() instead of HashMap::new() is consistent with the PR's objective to abstract the HashMap type.
  • 116-116: The use of new_hash_map() instead of HashMap::new() within the LockMetadata struct is consistent with the PR's objective to abstract the HashMap type.
  • 125-125: The initialization of LOCKS with new_hash_map() is consistent with the PR's objective to abstract the HashMap type.
fuzz/src/full_stack.rs (6)
  • 442-451: The previous comment about checking the length of data before slicing it for SecretKey creation has been addressed with a length check on line 443.
  • 451-451: The configuration object UserConfig is now being read from the input data, which aligns with the PR's objective to enable full_stack_target to read an arbitrary configuration object.
  • 788-788: The comment block at line 788 provides an example of the input data format. Since this is a test file and the comment is providing context for the test data, it seems appropriate to keep it inline for easy reference by developers working on or debugging the tests.
  • 798-798: The comment block at line 798 is similar to the one at line 788, providing an example of the input data format. The same reasoning applies here; it is useful for context within the test file.
  • 846-846: The comment block at line 846, like the previous ones, provides an example of the input data format. It remains useful for context and should be kept inline in the test file.
  • 1050-1050: The hardcoded hex string used for simulating a fuzzing input is still present. This is acceptable in the context of a fuzzing test, where specific byte sequences are used to simulate various scenarios. However, it's important to ensure that these strings are well-documented and, if they represent specific test cases, that they are kept up-to-date with the test scenarios they are meant to simulate.
lightning/src/routing/scoring.rs (7)
  • 656-656: The change from HashMap::new() to new_hash_map() for manual_node_penalties is consistent with the PR's objective to standardize hash map creation.
  • 698-698: Replacing HashMap::new() with new_hash_map() in the clear_manual_penalties method aligns with the refactoring pattern and is approved.
  • 712-712: The initialization of manual_node_penalties with new_hash_map() in this context is also consistent with the PR's refactoring goals.
  • 822-822: The use of new_hash_map() for initializing channel_liquidities is in line with the PR's aim to standardize the creation of hash maps.
  • 1333-1333: The retrieval of manual_node_penalties using get is correct and does not alter the logic of penalty application.
  • 1363-1363: The access pattern for channel_liquidities remains unchanged, and the use of new_hash_map() does not affect the existing logic.
  • 2076-2076: The deserialization of channel_liquidities using new_hash_map() is appropriate and maintains the consistency of the refactoring effort.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d521777 and 3d3d1f6.
Files selected for processing (1)
  • .github/workflows/build.yml (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build.yml

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and 6902370.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (24 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (23)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 15
lightning/src/util/indexed_map.rs (5)
  • 3-3: The previous comment regarding the wildcard import use crate::prelude::*; is still valid.
  • 37-37: The change from HashMap::new() to new_hash_map() is consistent with the PR's objective to abstract the HashMap type.
  • 45-45: The change from HashMap::with_capacity(capacity) to hash_map_with_capacity(capacity) aligns with the PR's objective and ensures consistency in map creation.
  • 179-179: The change in the VacantEntry struct to use VacantHashMapEntry instead of hash_map::VacantEntry is consistent with the PR's objective to support different underlying hash map implementations.
  • 188-188: The change in the OccupiedEntry struct to use OccupiedHashMapEntry instead of hash_map::OccupiedEntry is consistent with the PR's objective to support different underlying hash map implementations.
lightning/src/sync/debug_sync.rs (4)
  • 17-17: The previous comment regarding the wildcard import use crate::prelude::*; is still valid.
  • 60-60: The change to initialize LOCKS_HELD with new_hash_map() instead of HashMap::new() is consistent with the PR's objective to abstract the HashMap type.
  • 116-116: The change to initialize locked_before with new_hash_map() instead of HashMap::new() is consistent with the PR's objective to abstract the HashMap type.
  • 125-125: The change to initialize LOCKS with new_hash_map() instead of HashMap::new() is consistent with the PR's objective to abstract the HashMap type.
fuzz/src/full_stack.rs (6)
  • 442-451: The changes made to the do_test function include a check for the length of data before attempting to slice it for the SecretKey. This is a good addition for preventing panics due to slicing with an out-of-bounds index.
  • 451-451: The configuration object UserConfig is now being read from the data slice. Ensure that the Readable trait implementation for UserConfig properly handles arbitrary data without causing panics or other issues.
  • 788-788: The comment block at line 788 provides an example of the input data format. As previously noted, this should be documented outside of the code for better visibility and maintainability.
  • 798-798: The comment block at line 798 is similar to the one at line 788, providing an example of the input data format. The recommendation to document this outside of the code still stands.
  • 846-846: The comment block at line 846 also provides an example of the input data format. The same recommendation to document this information in a more formal and discoverable manner applies here as well.
  • 1050-1050: The hardcoded hex string used for simulating a fuzzing input is still present. It's recommended to refactor this to use a more dynamic approach for generating test cases.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and 2cab60e.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (24 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 19
lightning/src/util/indexed_map.rs (4)
  • 37-37: The change from HashMap::new() to new_hash_map() in the new() method is approved as it abstracts the specific map implementation, which could be beneficial for future flexibility or optimizations.
  • 45-45: The change from HashMap::with_capacity() to hash_map_with_capacity() in the with_capacity() method is approved for the same reasons as the change in the new() method.
  • 179-179: The change in the VacantEntry struct to use VacantHashMapEntry instead of hash_map::VacantEntry is approved as it aligns with the abstraction of the underlying map implementation.
  • 188-188: Similarly, the change in the OccupiedEntry struct to use OccupiedHashMapEntry instead of hash_map::OccupiedEntry is approved for consistency with the VacantEntry changes.
lightning/src/sync/debug_sync.rs (3)
  • 60-60: The initialization of LOCKS_HELD using new_hash_map() instead of HashMap::new() is approved for the same reasons as in indexed_map.rs.
  • 116-116: The change to initialize locked_before with new_hash_map() is consistent with the other changes and is approved.
  • 125-125: The initialization of LOCKS within LOCKS_INIT.call_once() using new_hash_map() is approved, maintaining consistency with the other changes.
fuzz/src/full_stack.rs (5)
  • 442-451: The previous comment about checking the length of data before slicing it for SecretKey creation has been addressed with a length check on line 443.
  • 788-788: The previous comment about documenting the input data format outside of the code is still valid. The comment block at line 788 should be moved to a more formal documentation.
  • 798-798: The previous comment about documenting the input data format outside of the code is still valid. The comment block at line 798 should be moved to a more formal documentation.
  • 846-846: The previous comment about documenting the input data format outside of the code is still valid. The comment block at line 846 should be moved to a more formal documentation.
  • 1050-1050: The hardcoded hex string used for simulating a fuzzing input is still present. Consider refactoring this to use a more dynamic approach for generating test cases.
lightning/src/routing/scoring.rs (7)
  • 656-656: The replacement of HashMap::new() with new_hash_map() in the initialization of manual_node_penalties is consistent with the PR's objective to standardize the creation of hash maps.
  • 698-698: The change in clear_manual_penalties method to use new_hash_map() aligns with the refactoring pattern and is a straightforward substitution.
  • 712-712: Again, the use of new_hash_map() for initializing manual_node_penalties within a different context is consistent with the rest of the changes and follows the PR's theme.
  • 822-822: The initialization of channel_liquidities with new_hash_map() is another instance of the refactoring pattern applied in this PR. It's a simple replacement and maintains consistency.
  • 1333-1333: The access pattern for manual_node_penalties remains unchanged, which is good as only the initialization method has been refactored. No action is needed here.
  • 1363-1363: The access to channel_liquidities using .get() is unaffected by the change in initialization method. This ensures that the existing logic is preserved.
  • 2076-2076: The introduction of new_hash_map() in the decode method for channel_liquidities is consistent with the changes made elsewhere in the file. It's important to ensure that the custom new_hash_map() function is compatible with the deserialization process.
Verification successful

The new_hash_map function is defined in lightning/src/lib.rs and simply returns a new instance of HashMap using HashMap::new(). There is no custom implementation of the Readable trait for HashMap found in the codebase. Therefore, the use of new_hash_map in the decode method for channel_liquidities should be compatible with the deserialization process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new_hash_map function is compatible with the deserialization process.
# This script assumes that the new_hash_map function is defined in a file that can be located by its name.
fd new_hash_map.rs | xargs cat | grep -A 10 -B 10 "fn new_hash_map"
# Additionally, check for any custom deserialization logic that might be affected by this change.
rg "impl Readable for HashMap" --type rust

Length of output: 114



Script:

#!/bin/bash
# Search for the definition of new_hash_map function across the entire codebase.
rg "fn new_hash_map" --type rust

# Search for any implementation of the Readable trait for HashMap without specifying the file type.
rg "impl Readable for HashMap"

Length of output: 238

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5592378 and 1f56738.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (24 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (23)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/sync/debug_sync.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 17
lightning/src/util/indexed_map.rs (4)
  • 37-37: The new() function now uses new_hash_map() instead of HashMap::new(). This change abstracts away the specific hash map implementation, which is good for modularity and flexibility. Ensure that the new_hash_map() function is properly tested to handle the creation of hash maps as expected.
  • 45-45: The with_capacity() function now uses hash_map_with_capacity() instead of HashMap::with_capacity(). Similar to the new() function, this change abstracts the hash map creation and should be tested to ensure that the capacity is set correctly in the new hash maps.
  • 179-179: The VacantEntry struct now uses VacantHashMapEntry instead of hash_map::VacantEntry. This change is consistent with the abstraction of the hash map implementation. Verify that VacantHashMapEntry maintains the same contract and behavior as the previous implementation to avoid any unexpected behavior.
  • 188-188: The OccupiedEntry struct now uses OccupiedHashMapEntry instead of hash_map::OccupiedEntry. As with VacantEntry, ensure that OccupiedHashMapEntry is a suitable replacement and that it behaves as expected in all scenarios where OccupiedEntry is used.
fuzz/src/full_stack.rs (6)
  • 442-451: The changes made to the do_test function include a check for the length of data before attempting to slice it for the SecretKey. This is a good addition for preventing potential panics due to slicing with an out-of-bounds index.
  • 451-451: The configuration object UserConfig is now being read from the data slice. Ensure that the Readable trait implementation for UserConfig properly handles any potential errors and that the data slice contains a correctly formatted UserConfig object.
  • 788-788: The comment block at line 788 provides an example of the input data format. As previously noted, this should be documented outside of the code for better visibility and maintainability.
  • 798-798: The comment block at line 798 is similar to the one at line 788, providing an example of the input data format. The recommendation to document this outside of the code still stands.
  • 846-846: The comment block at line 846 also provides an example of the input data format. The same recommendation to document this information in a more formal and discoverable manner applies here.
  • 1050-1050: The hardcoded hex string used for simulating a fuzzing input is still present. Consider refactoring this to use a more dynamic approach for generating test cases.
lightning/src/routing/scoring.rs (7)
  • 656-656: The replacement of HashMap::new() with new_hash_map() is consistent with the PR's objective to standardize the creation of hash maps. Ensure that new_hash_map() is properly defined and imported in this context.
  • 698-698: The use of new_hash_map() in clear_manual_penalties method is appropriate for resetting the manual_node_penalties. Verify that the new_hash_map function is available in the scope and that its behavior is as expected.
  • 712-712: Again, the use of new_hash_map() is consistent with the PR's objectives. Confirm that new_hash_map() is correctly implemented and that it does not introduce any unexpected behavior.
  • 822-822: The initialization of channel_liquidities with new_hash_map() should be checked for correctness and consistency with the rest of the codebase.
  • 1333-1333: The retrieval of manual_node_penalties using get is standard practice. Ensure that the manual_node_penalties map is correctly populated before this point to avoid logic errors.
  • 1363-1363: The use of unwrap_or with ChannelLiquidity::new(Duration::ZERO) is a safe default. However, confirm that this default value is appropriate for all cases where channel_liquidities might not have an entry for scid.
  • 2076-2076: The deserialization of channel_liquidities using new_hash_map() followed by read_tlv_fields! macro is a critical operation. Ensure that the macro and the new_hash_map() function work together without issues, and that the deserialization process is robust.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4bab9c8 and 3cf6d0a.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (24 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (23)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 9
lightning/src/util/indexed_map.rs (4)
  • 37-37: The change from HashMap::new() to new_hash_map() suggests a move towards a more standardized way of creating hash maps. Ensure that the new_hash_map function is implemented correctly and that it does not introduce any performance regressions or unexpected behavior.
  • 45-45: Similar to the previous comment, the change from HashMap::with_capacity(capacity) to hash_map_with_capacity(capacity) should be verified for correctness and performance implications.
  • 179-179: The change in the type of underlying_entry from hash_map::VacantEntry to VacantHashMapEntry indicates an abstraction over the underlying hash map implementation. Verify that the new VacantHashMapEntry type maintains the expected behavior and interfaces.
  • 188-188: As with the VacantEntry, the OccupiedEntry's underlying_entry type change to OccupiedHashMapEntry should be verified for compatibility and correctness.
lightning/src/sync/debug_sync.rs (3)
  • 60-60: The initialization of LOCKS_HELD has been changed to use new_hash_map(). As with the previous file, ensure that the new_hash_map function is correctly implemented and does not introduce any regressions.
  • 116-116: The locked_before field in LockMetadata now uses new_hash_map() for initialization. Verify that this change is consistent with the intended use of the LockMetadata structure and that the new_hash_map function is suitable for this context.
  • 125-125: The initialization of LOCKS within the LOCKS_INIT call_once lambda has been changed to use new_hash_map(). Ensure that this change does not affect the thread safety and initialization guarantees provided by call_once.
fuzz/src/full_stack.rs (2)
  • 442-451: The changes in the do_test function include a check for the minimum length of data before proceeding, which is a good practice to avoid panics due to slicing errors. The use of Readable::read to deserialize a UserConfig from data is also a safe operation assuming the Readable trait is implemented correctly for UserConfig.
  • 442-451: The do_test function has been updated to include a length check for the input data and to deserialize a UserConfig object. This is a good practice to ensure that the input data is of a sufficient length before attempting to slice it and that the configuration is correctly deserialized before use.

@wpaulino
Copy link
Contributor

The fuzz build is still failing.

@TheBlueMatt TheBlueMatt force-pushed the 2023-12-arbitrary-fuzz-config branch 2 times, most recently from 1e8d804 to cf2a175 Compare January 30, 2024 23:27
@TheBlueMatt
Copy link
Collaborator Author

Rebased and fixed CI.

@TheBlueMatt TheBlueMatt force-pushed the 2023-12-arbitrary-fuzz-config branch 2 times, most recently from 15a0900 to d0465b6 Compare January 31, 2024 01:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5bf58f0 and d0465b6.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (26)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (25 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (22)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 15
lightning/src/util/indexed_map.rs (4)
  • 37-37: Replacing HashMap::new() with new_hash_map() abstracts the specific hash map implementation used. This change enhances modularity and allows for easier adjustments to the hash map's behavior or characteristics globally. Ensure that the new_hash_map() function is implemented correctly and efficiently to avoid any performance regressions.
  • 45-45: The change from HashMap::with_capacity(capacity) to hash_map_with_capacity(capacity) is consistent with the abstraction strategy for hash map creation. This approach allows for pre-allocating space in the underlying data structure, potentially improving performance for known large datasets. Verify that hash_map_with_capacity is implemented to leverage the capacity hint effectively.
  • 179-179: The VacantEntry struct's underlying_entry field type change from a specific hash_map::VacantEntry to a more abstract VacantHashMapEntry aligns with the overall goal of abstracting away from concrete hash map implementations. This change should facilitate easier swaps or modifications to the underlying hash map logic. Confirm that VacantHashMapEntry provides a compatible API and maintains the expected behavior.
  • 188-188: Similar to VacantEntry, the modification in OccupiedEntry to use OccupiedHashMapEntry instead of a specific hash_map::OccupiedEntry type supports the abstraction of hash map details. This consistency in abstracting entry types is crucial for maintaining a uniform approach throughout the module. Ensure that OccupiedHashMapEntry adequately mirrors the functionality and performance characteristics of the original entry type.
lightning/src/sync/debug_sync.rs (3)
  • 60-60: The initialization of LOCKS_HELD with new_hash_map() instead of HashMap::new() is consistent with the abstraction approach seen in indexed_map.rs. This change allows for a centralized way to modify the hash map behavior across the codebase. Ensure that new_hash_map() is optimized for the expected usage patterns in debug_sync.rs.
  • 116-116: Using new_hash_map() for initializing locked_before within LockMetadata::new() maintains the abstraction layer for hash map creation. This consistency in using a custom function for hash map instantiation is crucial for modular and maintainable code. Verify that the performance and functionality of new_hash_map() meet the requirements for lock metadata management.
  • 125-125: The call to new_hash_map() within the LOCKS_INIT initialization block further demonstrates the consistent application of the hash map abstraction strategy throughout the debug_sync.rs file. This approach simplifies potential future changes to the hash map implementation used by the locking mechanism. Confirm that the use of new_hash_map() here does not introduce any performance or functionality regressions.
fuzz/src/full_stack.rs (2)
  • 441-450: The changes made to the do_test function, specifically the handling of the SecretKey::from_slice call, correctly address the previously raised concern about ensuring the input data slice is of the correct length before attempting to create a SecretKey. This change prevents potential panics due to incorrect slice lengths, improving the robustness of the fuzz testing setup.
  • 441-451: The introduction of a conditional check for the length of data before attempting to extract a SecretKey and the subsequent configuration parsing is a good practice for ensuring data integrity before processing. This approach enhances error handling by gracefully exiting the function if the data does not meet the expected criteria, thereby avoiding potential runtime errors.
lightning/src/routing/scoring.rs (6)
  • 653-659: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [656-698]

The change from HashMap::new() to new_hash_map() for initializing manual_node_penalties in ProbabilisticScoringFeeParameters and ProbabilisticScoringDecayParameters is consistent with the summary provided. This standardizes the creation of hash maps across the codebase, potentially allowing for future optimizations or custom behavior in hash map creation.

  • 712-712: The same change from HashMap::new() to new_hash_map() for initializing manual_node_penalties in the zero_penalty method of ProbabilisticScoringFeeParameters is also consistent and aligns with the objective of standardizing hash map creation.
  • 822-822: The introduction of new_hash_map() in the ProbabilisticScorer constructor for initializing channel_liquidities aligns with the changes mentioned and the overall goal of standardizing hash map creation across the codebase.
  • 1333-1333: The use of new_hash_map() for re-initializing manual_node_penalties within the ProbabilisticScoringFeeParameters struct when clearing manual penalties is consistent with the changes described and further supports the standardization effort.
  • 1363-1363: The use of new_hash_map() for initializing channel_liquidities in the ProbabilisticScorer aligns with the described changes and the goal of standardizing hash map creation. This change ensures consistency across the codebase.
  • 2076-2076: The re-initialization of channel_liquidities using new_hash_map() in the deserialization process of ProbabilisticScorer is consistent with the changes described. This ensures that the standardization of hash map creation is maintained even when objects are deserialized.

Comment on lines 438 to 454
}

#[inline]
pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
if data.len() < 32 { return; }

let our_network_key = match SecretKey::from_slice(&data[..32]) {
Ok(key) => key,
Err(e) => return,
};
data = &data[32..];

let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };

let input = Arc::new(InputData {
data: data.to_vec(),
read_pos: AtomicUsize::new(0),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [441-1049]

The do_test function is quite lengthy and handles multiple responsibilities, from setting up the testing environment to processing various types of input data for fuzz testing. While the changes made within this function are appropriate and improve its functionality, consider refactoring it into smaller, more manageable functions. This could enhance readability, maintainability, and make it easier to identify and isolate specific behaviors for testing or further modification.

@@ -14,7 +14,7 @@ use std::sync::Condvar as StdCondvar;

pub use std::sync::WaitTimeoutResult;

use crate::prelude::HashMap;
use crate::prelude::*;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch to a wildcard import from crate::prelude::* in debug_sync.rs mirrors the change observed in indexed_map.rs. While this can simplify imports by reducing verbosity, it also risks namespace pollution and obscures the origin of imported entities. Consider using explicit imports for better code clarity and to prevent potential conflicts.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d0465b6 and bd85396.
Files selected for processing (1)
  • fuzz/src/peer_crypt.rs (1 hunks)
Additional comments: 2
fuzz/src/peer_crypt.rs (2)
  • 86-86: The change from buf.copy_from_slice(&get_slice!(len as usize + 16)) to buf[..len as usize + 16].copy_from_slice(&get_slice!(len as usize + 16)) improves the clarity and precision of the slice operation by explicitly defining the slice range before copying. This modification ensures that only the intended portion of buf is overwritten, which could prevent potential out-of-bounds errors or unintended data manipulation. This change aligns with best practices for handling slices in Rust, enhancing code safety and maintainability.
  • 83-89: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-92]

Overall, the file peer_crypt.rs demonstrates a careful approach to handling cryptographic operations and buffer management. The use of macros for slice access (get_slice!) and the structured error handling (early returns on errors) contribute to the code's robustness. However, it's crucial to ensure comprehensive testing, especially given the cryptographic context and the potential for subtle bugs. The use of unsafe in peer_crypt_run is justified by the need to interface with C code but requires careful attention to buffer bounds and data validity to prevent security vulnerabilities.

wpaulino
wpaulino previously approved these changes Jan 31, 2024
Because of txid conflicts, a txid can match both a local and remote
commitment transaction when fuzzing. Thus, we disable this
assertion when fuzzing.
As we've added more and more configuration parameters which change
our behavior, we're increasingly missing coverage in the general
`full_stack_target` fuzzer. Sadly, a reachable `unwrap` slipped in
uncaught that should have been stopped by the `full_stack_target`.

Here, we update the `full_stack_target` fuzzer to read a full
config object to substantially increase coverage.
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for constructors
instead of calling the tables directly to make the version bump
changeset smaller.
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for `FromIterator`
constructors instead of calling the tables directly to make the
version bump changeset smaller.
While this isn't expected to materially improve performance, it
does get us ahash 0.8, which allows us to reduce fuzzing
randomness, making our fuzzers much happier.

Sadly, by default `ahash` no longer tries to autodetect a
randomness source, so we cannot simply rely on `hashbrown` to do
randomization for us, but rather have to also explicitly depend on
`ahash`.
This has apparently been broken for quite some time...I guess
`peer_crypt_target` doesn't get much CPU anymore.
@TheBlueMatt
Copy link
Collaborator Author

Ugh, had to rebase again.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 7

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7c94636 and 7377cc9.
Files ignored due to path filters (4)
  • bench/Cargo.toml is excluded by: !**/*.toml
  • fuzz/Cargo.toml is excluded by: !**/*.toml
  • lightning-invoice/Cargo.toml is excluded by: !**/*.toml
  • lightning/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (27)
  • .github/workflows/build.yml (3 hunks)
  • ci/check-cfg-flags.py (1 hunks)
  • fuzz/src/full_stack.rs (15 hunks)
  • fuzz/src/peer_crypt.rs (1 hunks)
  • lightning/src/chain/chainmonitor.rs (4 hunks)
  • lightning/src/chain/channelmonitor.rs (13 hunks)
  • lightning/src/chain/onchaintx.rs (6 hunks)
  • lightning/src/events/bump_transaction.rs (1 hunks)
  • lightning/src/lib.rs (1 hunks)
  • lightning/src/ln/channel.rs (3 hunks)
  • lightning/src/ln/channelmanager.rs (25 hunks)
  • lightning/src/ln/functional_test_utils.rs (5 hunks)
  • lightning/src/ln/functional_tests.rs (5 hunks)
  • lightning/src/ln/monitor_tests.rs (1 hunks)
  • lightning/src/ln/outbound_payment.rs (5 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/onion_message/messenger.rs (2 hunks)
  • lightning/src/routing/gossip.rs (2 hunks)
  • lightning/src/routing/router.rs (8 hunks)
  • lightning/src/routing/scoring.rs (7 hunks)
  • lightning/src/routing/utxo.rs (1 hunks)
  • lightning/src/sign/mod.rs (1 hunks)
  • lightning/src/sync/debug_sync.rs (4 hunks)
  • lightning/src/util/config.rs (4 hunks)
  • lightning/src/util/indexed_map.rs (4 hunks)
  • lightning/src/util/ser.rs (2 hunks)
  • lightning/src/util/test_utils.rs (12 hunks)
Files not summarized due to errors (1)
  • fuzz/src/full_stack.rs: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (25)
  • .github/workflows/build.yml
  • ci/check-cfg-flags.py
  • fuzz/src/peer_crypt.rs
  • lightning/src/chain/chainmonitor.rs
  • lightning/src/chain/channelmonitor.rs
  • lightning/src/chain/onchaintx.rs
  • lightning/src/events/bump_transaction.rs
  • lightning/src/lib.rs
  • lightning/src/ln/channel.rs
  • lightning/src/ln/channelmanager.rs
  • lightning/src/ln/functional_test_utils.rs
  • lightning/src/ln/functional_tests.rs
  • lightning/src/ln/monitor_tests.rs
  • lightning/src/ln/outbound_payment.rs
  • lightning/src/ln/peer_handler.rs
  • lightning/src/onion_message/messenger.rs
  • lightning/src/routing/gossip.rs
  • lightning/src/routing/router.rs
  • lightning/src/routing/scoring.rs
  • lightning/src/routing/utxo.rs
  • lightning/src/sign/mod.rs
  • lightning/src/sync/debug_sync.rs
  • lightning/src/util/config.rs
  • lightning/src/util/ser.rs
  • lightning/src/util/test_utils.rs
Additional comments: 4
lightning/src/util/indexed_map.rs (4)
  • 37-37: The change to use new_hash_map() for creating a new IndexedMap instance is a good practice for abstracting the specific hash map implementation. This allows for easier changes in the future if the underlying hash map needs to be swapped or configured differently.
  • 45-45: Using hash_map_with_capacity(capacity) for initializing IndexedMap with a specific capacity is consistent with the abstraction goal. This ensures that the capacity optimizations are preserved while abstracting the underlying hash map implementation.
  • 179-179: The modification to use VacantHashMapEntry in VacantEntry struct abstracts the underlying vacant entry representation. This is a positive change towards making the IndexedMap more flexible and less tied to a specific hash map implementation.
  • 188-188: Similarly, the change to use OccupiedHashMapEntry in OccupiedEntry struct aligns with the abstraction goals of the PR. It ensures that the IndexedMap can be adapted more easily to different hash map implementations without significant refactoring.

@@ -1,6 +1,6 @@
//! This module has a map which can be iterated in a deterministic order. See the [`IndexedMap`].

use crate::prelude::{HashMap, hash_map};
use crate::prelude::*;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of a wildcard import from crate::prelude::* introduces potential namespace pollution and makes it harder to identify where certain types or functions are coming from. Consider explicitly importing only the necessary entities to maintain clarity and avoid potential conflicts.

Comment on lines +441 to +450
pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
if data.len() < 32 { return; }

let our_network_key = match SecretKey::from_slice(&data[..32]) {
Ok(key) => key,
Err(e) => return,
};
data = &data[32..];

let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };
Copy link

@coderabbitai coderabbitai bot Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The do_test function's initial check for data.len() < 32 is a good safeguard to ensure there's enough data for creating a SecretKey. However, this check should be accompanied by a log or error message for better debugging and understanding why the test might be exiting early in certain cases.

Consider adding a log statement before returning to provide insight into the early exit condition:

if data.len() < 32 {
    logger.log("Data length is less than 32 bytes, exiting do_test early.");
    return;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would require a massive factor increase to go through all the valid config/code path combinations?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arik-so, you've raised an important point about the complexity and computational cost associated with testing all valid configuration and code path combinations through fuzz testing. Fuzz testing is indeed a powerful method to automatically generate a wide range of inputs to explore different execution paths in the codebase, aiming to uncover bugs that manual testing might not detect.

The goal of fuzz testing is not necessarily to exhaustively test every single combination of configurations and code paths—such an approach would indeed require a massive increase in resources. Instead, fuzz testing focuses on maximizing code coverage and uncovering bugs with a feasible number of test cases. Techniques like code coverage analysis are often used alongside fuzz testing to identify untested paths, guiding the fuzzing process towards areas of the code that might need more attention.

In practice, this means that while we strive to cover as many scenarios as possible, we also prioritize practicality and efficiency, ensuring that the testing process remains manageable and focused on areas most likely to contain bugs. This balance allows us to explore a broad range of configurations and code paths without the need for an exhaustive and potentially infeasible testing effort.

};
data = &data[32..];

let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration object deserialization from data using Readable::read(&mut data) without a subsequent length check before proceeding with further operations could potentially lead to unexpected behavior if data does not contain enough bytes for the operations that follow.

It's recommended to add a check after deserializing config to ensure data has enough remaining bytes for subsequent operations, similar to the initial length check:

if data.len() < expected_minimum_length {
    logger.log("Not enough data remaining after deserializing config, exiting do_test early.");
    return;
}

Note: expected_minimum_length should be determined based on the minimum expected length of data needed for the operations following the config deserialization.

@@ -782,8 +784,7 @@
// Writing new code generating transactions and see a new failure ? Don't forget to add input for the FuzzEstimator !

// 0100000000000000000000000000000000000000000000000000000000000000 - our network key
// 00000000 - fee_proportional_millionths
// 01 - announce_channels_publicly
// 0000000000900000000000000000640001000000000001ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000 - config
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment explaining the configuration object's hex representation is helpful for understanding the test setup. However, it's placed far from the actual usage of the configuration object, making it less effective for readers trying to understand the code.

Consider moving this comment closer to where the configuration object is actually used or deserialized to improve readability and comprehension.

@@ -793,7 +794,7 @@
// 030012 - inbound read from peer id 0 of len 18
// 0010 03000000000000000000000000000000 - message header indicating message length 16
// 030020 - inbound read from peer id 0 of len 32
// 0010 00021aaa 0008aaaaaaaaaaaa9aaa 03000000000000000000000000000000 - init message (type 16) with static_remotekey required and other bits optional and mac
// 0010 00021aaa 0008aaa20aaa2a0a9aaa 03000000000000000000000000000000 - init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The detailed breakdown of the message handling process, including the noise act and message types, is valuable for understanding the test flow. However, this information is somewhat disconnected from the actual code execution, making it challenging to follow.

To improve clarity, consider adding inline comments within the code at relevant points to directly associate these explanations with the corresponding operations.

@@ -841,7 +842,7 @@
// 030112 - inbound read from peer id 1 of len 18
// 0010 01000000000000000000000000000000 - message header indicating message length 16
// 030120 - inbound read from peer id 1 of len 32
// 0010 00021aaa 0008aaaaaaaaaaaa9aaa 01000000000000000000000000000000 - init message (type 16) with static_remotekey required and other bits optional and mac
// 0010 00021aaa 0008aaa20aaa2a0a9aaa 01000000000000000000000000000000 - init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation of the test sequence involving peer connections and channel creation is crucial for understanding the test's purpose. However, the detailed hex values and operations are described in a comment block far from their actual execution points in the code.

Incorporate brief comments within the code to map these operations to their descriptions in the comment block, enhancing readability and traceability of the test sequence.

@@ -1059,7 +1046,7 @@
// - client now fails the HTLC backwards as it was unable to extract the payment preimage (CHECK 9 duplicate and CHECK 10)

let logger = Arc::new(TrackingLogger { lines: Mutex::new(HashMap::new()) });
super::do_test(&<Vec<u8>>::from_hex("01000000000000000000000000000000000000000000000000000000000000000000000001000300000000000000000000000000000000000000000000000000000000000000020300320003000000000000000000000000000000000000000000000000000000000000000203000000000000000000000000000000030012001003000000000000000000000000000000030020001000021aaa0008aaaaaaaaaaaa9aaa030000000000000000000000000000000300120147030000000000000000000000000000000300fe00206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679000000000000c35000000000000000000000000000000162ffffffffffffffff00000000000002220000000000000000000000fd000601e3030000000000000000000000000000000000000000000000000000000000000001030000000000000000000000000000000000000000000000000000000000000002030000000000000000000000000000000000000000000000000000000000000003030000000000000000000000000000000000000000000000000000000000000004030059030000000000000000000000000000000000000000000000000000000000000005020900000000000000000000000000000000000000000000000000000000000000010000010210000300000000000000000000000000000000fd0300120084030000000000000000000000000000000300940022ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb1819096793d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000210100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000c005e020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0150c3000000000000220020ae00000000000000000000000000000000000000000000000000000000000000000000000c00000c00000c00000c00000c00000c00000c00000c00000c00000c00000c00000c000003001200430300000000000000000000000000000003005300243d0000000000000000000000000000000000000000000000000000000000000002080000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000010301320003000000000000000000000000000000000000000000000000000000000000000703000000000000000000000000000000030142000302000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003000000000000000000000000000000030112001001000000000000000000000000000000030120001000021aaa0008aaaaaaaaaaaa9aaa01000000000000000000000000000000050103020000000000000000000000000000000000000000000000000000000000000000c3500003e800fd0301120112010000000000000000000000000000000301ff00210000000000000000000000000000000000000000000000000000000000000e05000000000000016200000000004c4b4000000000000003e800000000000003e80000000203f000050300000000000000000000000000000000000000000000000000000000000001000300000000000000000000000000000000000000000000000000000000000002000300000000000000000000000000000000000000000000000000000000000003000300000000000000000000000000000000000000000000000000000000000004000300000000000000000000000000000000000000000000000000000000000005000266000000000000000000000000000003012300000000000000000000000000000000000000010000000000000000000000000000000a00fd00fd03011200620100000000000000000000000000000003017200233a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c0001000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000b03011200430100000000000000000000000000000003015300243a000000000000000000000000000000000000000000000000000000000000000267000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e80ff00000000000000000000000000000000000000000000000000000000000000000003f00003000000000000000000000000000000000000000000000000000000000000055511020203e80401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffab000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000fd03001200640300000000000000000000000000000003007400843d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000020b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000700fd00fd03011200640100000000000000000000000000000003017400843a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a00000000000000000000000000000000000000000000000000000000000000660000000000000000000000000000000000000000000000000000000000000002640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000030112004a0100000000000000000000000000000003015a00823a000000000000000000000000000000000000000000000000000000000000000000000000000000ff008888888888888888888888888888888888888888888888888888888888880100000000000000000000000000000003011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a0000000000000000000000000000000000000000000000000000000000000067000000000000000000000000000000000000000000000000000000000000000265000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d0000000000000000000000000000000000000000000000000000000000000000000000000000010000000000003e80ff00000000000000000000000000000000000000000000000000000000000000000003f00003000000000000000000000000000000000000000000000000000000000000055511020203e80401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffab000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000fd03001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020a000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200640300000000000000000000000000000003007400843d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c3010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000b00000000000000000000000000000000000000000000000000000000000000020d00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000700fd00fd03011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000002700000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000030112002c0100000000000000000000000000000003013c00833a00000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000000000000000000000000003011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a000000000000000000000000000000000000000000000000000000000000006500000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000703001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200640300000000000000000000000000000003007400843d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000032010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d00000000000000000000000000000000000000000000000000000000000000000000000000000200000000000b0838ff00000000000000000000000000000000000000000000000000000000000000000003f0000300000000000000000000000000000000000000000000000000000000000005551202030927c00401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff53000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000fd03001200a4030000000000000000000000000000000300b400843d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007501000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006705000000000000000000000000000000000000000000000000000000000000060300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000d00000000000000000000000000000000000000000000000000000000000000020f00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000700fd00fd0c007d02000000013a000000000000000000000000000000000000000000000000000000000000000000000000000000800258020000000000002200204b0000000000000000000000000000000000000000000000000000000000000014c00000000000001600142800000000000000000000000000000000000000050000200c005e0200000001730000000000000000000000000000000000000000000000000000000000000000000000000000000001a701000000000000220020b200000000000000000000000000000000000000000000000000000000000000000000000c00000c00000c00000c00000c000007").unwrap(), &(Arc::clone(&logger) as Arc<dyn Logger>));
super::do_test(&<Vec<u8>>::from_hex("01000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000640001000000000001ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000000300000000000000000000000000000000000000000000000000000000000000020300320003000000000000000000000000000000000000000000000000000000000000000203000000000000000000000000000000030012001003000000000000000000000000000000030020001000021aaa0008aaa20aaa2a0a9aaa030000000000000000000000000000000300120147030000000000000000000000000000000300fe00206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679000000000000c35000000000000000000000000000000162ffffffffffffffff00000000000002220000000000000000000000fd000601e3030000000000000000000000000000000000000000000000000000000000000001030000000000000000000000000000000000000000000000000000000000000002030000000000000000000000000000000000000000000000000000000000000003030000000000000000000000000000000000000000000000000000000000000004030059030000000000000000000000000000000000000000000000000000000000000005020900000000000000000000000000000000000000000000000000000000000000010000010210000300000000000000000000000000000000fd0300120084030000000000000000000000000000000300940022ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb1819096793d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000210100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000c005e020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0150c3000000000000220020ae00000000000000000000000000000000000000000000000000000000000000000000000c00000c00000c00000c00000c00000c00000c00000c00000c00000c00000c00000c000003001200430300000000000000000000000000000003005300243d0000000000000000000000000000000000000000000000000000000000000002080000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000010301320003000000000000000000000000000000000000000000000000000000000000000703000000000000000000000000000000030142000302000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003000000000000000000000000000000030112001001000000000000000000000000000000030120001000021aaa0008aaa20aaa2a0a9aaa01000000000000000000000000000000050103020000000000000000000000000000000000000000000000000000000000000000c3500003e800fd0301120112010000000000000000000000000000000301ff00210000000000000000000000000000000000000000000000000000000000000e05000000000000016200000000004c4b4000000000000003e800000000000003e80000000203f000050300000000000000000000000000000000000000000000000000000000000001000300000000000000000000000000000000000000000000000000000000000002000300000000000000000000000000000000000000000000000000000000000003000300000000000000000000000000000000000000000000000000000000000004000300000000000000000000000000000000000000000000000000000000000005000266000000000000000000000000000003012300000000000000000000000000000000000000010000000000000000000000000000000a03011200620100000000000000000000000000000003017200233a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c0001000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000b03011200430100000000000000000000000000000003015300243a000000000000000000000000000000000000000000000000000000000000000267000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e80ff00000000000000000000000000000000000000000000000000000000000000000003f00003000000000000000000000000000000000000000000000000000000000000055511020203e80401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffab000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200640300000000000000000000000000000003007400843d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000020b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000703011200640100000000000000000000000000000003017400843a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a00000000000000000000000000000000000000000000000000000000000000660000000000000000000000000000000000000000000000000000000000000002640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000030112004a0100000000000000000000000000000003015a00823a000000000000000000000000000000000000000000000000000000000000000000000000000000ff008888888888888888888888888888888888888888888888888888888888880100000000000000000000000000000003011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a0000000000000000000000000000000000000000000000000000000000000067000000000000000000000000000000000000000000000000000000000000000265000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d0000000000000000000000000000000000000000000000000000000000000000000000000000010000000000003e80ff00000000000000000000000000000000000000000000000000000000000000000003f00003000000000000000000000000000000000000000000000000000000000000055511020203e80401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffab000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020a000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200640300000000000000000000000000000003007400843d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c3010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000b00000000000000000000000000000000000000000000000000000000000000020d00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000703011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000002700000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000030112002c0100000000000000000000000000000003013c00833a00000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000000000000000000000000003011200640100000000000000000000000000000003017400843a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000003011200630100000000000000000000000000000003017300853a000000000000000000000000000000000000000000000000000000000000006500000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000703001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200640300000000000000000000000000000003007400843d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000032010000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001205ac030000000000000000000000000000000300ff00803d00000000000000000000000000000000000000000000000000000000000000000000000000000200000000000b0838ff00000000000000000000000000000000000000000000000000000000000000000003f0000300000000000000000000000000000000000000000000000000000000000005551202030927c00401a0060800000e00000100000a00000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0300c1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff53000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003001200a4030000000000000000000000000000000300b400843d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007501000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006705000000000000000000000000000000000000000000000000000000000000060300000000000000000000000000000003001200630300000000000000000000000000000003007300853d000000000000000000000000000000000000000000000000000000000000000d00000000000000000000000000000000000000000000000000000000000000020f0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000070c007d02000000013a000000000000000000000000000000000000000000000000000000000000000000000000000000800258020000000000002200204b0000000000000000000000000000000000000000000000000000000000000014c00000000000001600142800000000000000000000000000000000000000050000200c005e0200000001730000000000000000000000000000000000000000000000000000000000000000000000000000000001a701000000000000220020b200000000000000000000000000000000000000000000000000000000000000000000000c00000c00000c00000c00000c000007").unwrap(), &(Arc::clone(&logger) as Arc<dyn Logger>));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test function test_no_existing_test_breakage is well-documented with comments explaining each step of the test sequence. This is good practice for complex tests. However, there's a missed opportunity to use assertions more effectively to validate intermediate states and not just the final outcomes.

Consider adding assertions throughout the test to validate the state after each significant operation, such as after sending or receiving messages, to ensure the test's behavior is as expected at each step.

Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, though the commits that are relevant to the PR title seem to only be the first couple.

@@ -3172,7 +3172,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
(htlc, htlc_source.as_ref().map(|htlc_source| htlc_source.as_ref()))
), logger);
} else {
debug_assert!(false, "We should have per-commitment option for any recognized old commitment txn");
// Our fuzzers aren't contrained by pesky things like valid signatures, so can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: constrained

Comment on lines +441 to +450
pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
if data.len() < 32 { return; }

let our_network_key = match SecretKey::from_slice(&data[..32]) {
Ok(key) => key,
Err(e) => return,
};
data = &data[32..];

let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would require a massive factor increase to go through all the valid config/code path combinations?

@@ -5402,11 +5402,11 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno

let as_events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(as_events.len(), if announce_latest { 10 } else { 6 });
let mut as_failds = new_hash_set();
let mut as_faileds = new_hash_set();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're already doing a typo fix, might as well call them a_failures or, better yet (imo), failures_a.

@@ -83,7 +83,7 @@ pub fn do_test(data: &[u8]) {
Ok(len) => len,
Err(_) => return,
};
buf.copy_from_slice(&get_slice!(len as usize + 16));
buf[..len as usize + 16].copy_from_slice(&get_slice!(len as usize + 16));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ 16 might benefit from a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, its a fuzzer, it'll complain if its wrong :)

@TheBlueMatt
Copy link
Collaborator Author

Gonna go ahead and land this, though its gonna have silent merge conflicts I'll fix immediately with the spelling comment above.

@TheBlueMatt TheBlueMatt merged commit e64342a into lightningdevkit:main Feb 5, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants