Git Product home page Git Product logo

rust-lightning's People

Contributors

arik-so avatar bmancini55 avatar casey avatar ccdle12 avatar d4nte avatar devrandom avatar dongcarl avatar dr-orlovsky avatar dspicher avatar elichai avatar erasmospunk avatar jeandudey avatar jkczyz avatar joemphilips avatar moneyball avatar murtyjones avatar naumenkogs avatar philipr-za avatar rcasatta avatar rex4539 avatar rloomba avatar rrybarczyk avatar savil avatar sgeisler avatar stevenroose avatar swvheerden avatar tamasblummer avatar thebluematt avatar valentinewallace avatar yuntai avatar

rust-lightning's Issues

[Peers] Add doc/transport_module.md

As a new dev to the transport layer, I want to quickly read about the objects, interfaces, and tests so I can understand the code and add features with minimal ramp up time.

Definition of Done:

  • Add additional documentation about the separate transport layer, the interfaces, objects, and potential use cases in the future.

Tech Discussion:
This separate module could have uses outside of peers. Document it once the final code is in and list the potential use cases. Suggested here.

[Peers] Testing: Simplify unit tests of the event handling code

As a developer, I want to modify the event handling code in peers/ with the safety of unit tests and that have their dependencies minimized so that I have confidence in the changes and the features are easy to write.

Definition of Done:

  • Unit tests are refactored from peers/handler.rs to a new module responsible for the event handling
  • Unit tests do not require a full PeerManager/Transport (even test double versions)

Tech Discussion:
The current tests of this code include the full PeerManager which adds other dependent objects that aren’t really necessary for true unit tests. Instead, this behavior can be factored out into an event_handler module that just takes in an event and the required dependencies and verifies the correct state change.

This likely involves splitting out an interface for retrieving an initialized peer by node_id (InitializedPeerProvider?/PeerIterator?). The PeerHolder can implement this in the real code and tests can have a simple wrapper around a HashMap.

Most of the existing tests of this in handler.rs can be removed in favor of a few sanity tests to make sure any interface breakdowns are caught early.

End result will look something like this:

#[test]
Fn example_test() {
	// create dependencies:
	// channel handler spy, route handler stub, initialized node provider
	
	process_event(XYZ);

	// validate spys, stubs, and outbound queues of peers match the expected behavior
}

[Peers] Feature: Add Channel/Node/Update forwarding

As a message handler, I want to forward certain messages to known initialized peers if the route_handler allows it.

Definition of Done:

  • Unit tests are updated to include tests that validate message is forwarded to (non-source?) initialized peers for:
    • wire::Message::ChannelAnnouncement
    • wire::Message::NodeAnnouncement
    • wire::Message::ChannelUpdate
  • Unit tests exist for the negative case as well when route_handler does not allow it.

Tech Discussion:
TODO from the codebase. Similar to the event path, if the route_handler allows it, broadcast the message to all known initialized peers.

Route handler stubs already exist so the testing should be straight forward. A little bit of work to create multiple initialized peers.

Recommend this is done AFTER the unit test work on message handling to get the testing in a better place. Will require a dependency update due to needing an InitializedPeerProvider instead of just the Peer, but should be straight forward.

[Peers] Tech Debt: Rename node_id/their_node_id

As a developer, I want variable names to be consistent across the codebase so that it is easier to jump around and understand the code.

Definition of Done:

  • decide on name (counterparty_id/counterparty_node_id?)
  • do the rename

Tech Discussion:

[Peers] Tech Debt: Move Transport code to separate folder

As a developer, I want the Transport code to be in a separate folder so that the folder structure matches the dependencies (making scope creep harder) and it is easier to separate it out if/when it is needed for other use cases (watchtowers?).

Definition of Done:

  • transport/ subfolder containing all items transport related (encryption/handshakes/etc)

Tech Discussion:
Move Transport code and all its dependencies to a sub-folder.
This can live under peer/ for now, but cleaning up the file structure to match the dependencies can make it easier to maintain.

[Peers] Docs: Rewrite peers/ module documentation

As a user of LDK, I want easy to follow documentation for the PeerManager so that I can integrate into my application seamlessly.

Definition of Done:

  • Another pass at public docs for peers/handler.rs
  • Optional: Update of tokio to make it more readable in reference public docs

Tech Discussion:
This can go hand-in-hand with another review and cleanup of the tokio code. Since the tokio code and tests are the reference implementation for how to use the PeerManager it makes sense for it to help drive the documentation.

[Peers] Feature: Implement optional message dropping in Message send path

As a Transport layer, I want to know which messages are optional and which messages are mandatory so I can make the right policy decision when my queue is full or the SocketDescriptor fails a full write.

Definition of Done:

  • Optimal messages identified
  • Policy decision made on if/when items should be dropped
  • Unit tests updated to drop optional messages during flow control

Tech Discussion:
TODO from the codebase:
DoS vector by announcing channels on another node and flooding the OutboundQueue.

The current OutboundQueue allows the message path to push messages over the soft limit (the sync messages are the only things that care about the soft limit).

Seems like an update to the Transport API makes the most sense. Potentially adding a priority number or classification to each enqueue_message() where the Transport layer can make the policy decision to drop it if necessary.

The Transport unit tests are easily updated to test this behavior.

[Peers] Feature: Send message contained in ErrorAction::DisconnectPeer

As a message handler, I want to attempt to send the inner message from ErrorAction::DisconnectPeer so that my peer could learn why I am disconnecting.

Definition of Done:

  • Inner message is sent to the peer (best effort)

Tech Discussion:

TODO from the codebase. Similar to the event path, we should attempt to push the inner message through the SocketDescriptor before disconnecting.

[Peers] Testing: Simplify unit tests of the message handling code

As a developer, I want to modify the message handling code in peers/ with the safety of unit tests and that have their dependencies minimized so that I have confidence in the changes and the features are easy to write.

Definition of Done:

  • Unit tests are refactored from peers/handler.rs to a new module responsible for the message handling
  • Unit tests do not require a full PeerManager/Transport (even test double versions)

Tech Discussion:

The current tests of this code include the full PeerManager which adds other dependent objects that aren’t really necessary for true unit tests. Instead, this behavior can be factored out into a message_handler module that just takes in a message and the required dependencies and verifies the correct state change.

The existing tests don't need a PeerIterator/InitializedNodeProvider, but it will be required to implement the broadcast message features that are still TODO.

End result might look something like this:

#[test]
Fn example_test() {
	// create dependencies:
	// channel handler spy, route handler stub, Peer
	
	handle_message(XYZ);

	// validate spys, stubs, and outbound queues of peers match the expected behavior
}

[Peers] Tech Debt: Revisit InitialSyncState behavior and object relationships

The sync message generation and subsequent Peer state updates are done as a side effect of flushing the outbound queue.

This could use a cleaner design and is hard to test through the front door of the PeerManager.

Should the OutboundQueue be separated into a SocketDescriptorWriter object that handles the sync generation post-Init so it can be tested?

Should the Peer state updates that happen as a side-effect be replaced by turning InitSyncState into a real object that can be tested in isolation?

from @ariard
Just a side-note, but I think in the future we would like to move the sync status inside NetGraphMsgHandler. IMO this logic doesn't belong to the peer handler as it's already concerned with processing state.

It would be easier to implement more-agressive syncing logic like fetching valid node_announcement and start thinking with them.
lightningdevkit#692 (comment)

[Peers] Testing: Unit test PeerHolder

As a developer, I want to reduce the number of dependencies for tests that surround the PeerHolder behavior to gain confidence in the object and reduce development time for future features that interact with it.

Definition of Done:

  • Unit tests exist for PeerHolder API
  • Optional: PeerHolder is moved to its own file

Tech Discussion:

Refactoring unified a lot of the individual map accesses to a true API in front of the PeerHolder. Aside from code deduplication, one of the benefits was that it can now be tested in isolation.

The tests should be really straight forward using a fake Peer. The only other external dependency is the ChannelHandler callback for disconnect_peer and a spy already exists for this.

[Peers] Security: Initialize act data buffer with random data

As a decryption layer, I want to use non-zero initial ciphertext buffers so that chacha failures biasing towards zero aren't masked.

Definition of Done:

  • Random data is used to fill the initial act buffers
  • Optional: Buffers are set to 0 for tests to remove nondeterminism

Tech Discussion:

Per this discussion, fill with random data to help reduce masking decryption failures. I don't think the nondeterminism is really an issue for tests, but I've included it since it came up in the discussion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.