Jun 21, 2022, 6 PM UTC, #review-club on LDK Slack.
lightningdevkit/rust-lightning#1507
Host: ariard PR author: ViktorTigerstrom
The PR branch HEAD was ae665ce at the time of this review club meeting.
- The core component of LDK is the
ChannelManager. This structure gathers the channels states and the pending messages (forward HTLCs, outbound payments, inbound payments) to be applied triggering a state transition. - Beyond,
ChannelManagerholds on-chain data (e.g best block seen) and user setting (node config) as those fields alter the processing of the state transitions (e.g rejectOpenChannelbecausefunding_satoshisis under user'smin_funding_satoshis). - Zooming, 2 notable members of
ChannelManagerarechannel_stateandper_peer_state.ChannelHodlerstores currently few different elements such as the channels, the HTLC to be forwarded and the LDK internal processing events.PeerStateonly stores the per-peer features flag for now. - As of today,
ChannelHolderis protected by a singleMutexrequiring in-order processing of the events, and thus only one channel can execute state transition at the same time. #1507 and the split-off #1542 are WIP enabling better parallelization of LDK channel processing.
- What's the current processing flow from receiving an inbound message in
handle_message()to sending to the appropriateChannel's method ? How many locks are taken and when ? - This PR is moving the
HashMap<[u8; 32], Channel<Signer>>fromChannelHoldertoPeerState. What's the purpose of this move ? Does it change anything for a LDK user ? - Why introducing a new
id_to_peerinChannelManager? - What is backward compatibility and what is LDK's project policy on structure serialization backward compatibility ?
- The PR is using
FairRwLockto protectPeerState. What are the advantages ofFairRwLockcompare to Rust's traditionalRwLock. - What could be the future internal refactoring after this PR to achieve #422 ?
- Apart of HTLC/message processing, what are the other perfomance bottlenecks of a LN node ?
Awesome, great work :)!
Just some minor corrections to the Notes and Questions:
As of today, ChannelHolder is protected by a
RwLockShould be changed to:
As of today, ChannelHolder is protected by a single
MutexWhat are the advantages of
FairRwLockcompare to the traditional Rust'sFairRwLockShould be changed to:
What are the advantages of
FairRwLockcompared to Rust's traditionalRwLock