Merge pull request #445 from TheBlueMatt/2020-01-fuzz-enforcer-fix
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Mon, 10 Feb 2020 18:47:44 +0000 (18:47 +0000)
committerGitHub <noreply@github.com>
Mon, 10 Feb 2020 18:47:44 +0000 (18:47 +0000)
Fix EnforcingChannelKeys panic when our counterparty burns their $.

README.md
lightning/src/ln/peer_handler.rs

index fd264c8c2d928459f3c98abd948372ff6f83880d..b8807aad57873e45920b41d5b401226789c95791 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,8 +5,16 @@ Rust-Lightning, not Rusty's Lightning!
 
 Documentation can be found at [docs.rs](https://docs.rs/lightning/)
 
-Currently somewhere near 50% towards usable, published to see if there is any
-real interest from folks in using a lightning rust library.
+The project implements all of the BOLT specifications in the 1.0 spec except
+for [channel queries](https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#query-messages). The
+implementation has pretty good test coverage that is expected to continue to
+improve. There are a number of internal refactorings being done now that will
+make the code base more welcoming to new contributors. It is also anticipated
+that as developers begin using the API, the lessons from that will result in
+changes to the API, so any developer using this API at this stage should be prepared
+to embrace that. The current state is sufficient for a developer or project to
+experiment with it. Recent increased contribution rate to the project is expected
+to lead to a high quality, stable, production-worthy implementation in 2020.
 
 The goal is to provide a full-featured but also incredibly flexible lightning
 implementation, allowing the user to decide how they wish to use it. With that
index e25e50c28b5f1190edea81c429bae659b6a0c092..327664c7fc2420128b0d9d8be3d99b9cf8d8ee7b 100644 (file)
@@ -517,37 +517,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
                                                                }
                                                        }
 
-                                                       macro_rules! try_potential_decodeerror {
-                                                               ($thing: expr) => {
-                                                                       match $thing {
-                                                                               Ok(x) => x,
-                                                                               Err(e) => {
-                                                                                       match e {
-                                                                                               msgs::DecodeError::UnknownVersion => return Err(PeerHandleError{ no_connection_possible: false }),
-                                                                                               msgs::DecodeError::UnknownRequiredFeature => {
-                                                                                                       log_debug!(self, "Got a channel/node announcement with an known required feature flag, you may want to update!");
-                                                                                                       continue;
-                                                                                               },
-                                                                                               msgs::DecodeError::InvalidValue => {
-                                                                                                       log_debug!(self, "Got an invalid value while deserializing message");
-                                                                                                       return Err(PeerHandleError{ no_connection_possible: false });
-                                                                                               },
-                                                                                               msgs::DecodeError::ShortRead => {
-                                                                                                       log_debug!(self, "Deserialization failed due to shortness of message");
-                                                                                                       return Err(PeerHandleError{ no_connection_possible: false });
-                                                                                               },
-                                                                                               msgs::DecodeError::ExtraAddressesPerType => {
-                                                                                                       log_debug!(self, "Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407");
-                                                                                                       continue;
-                                                                                               },
-                                                                                               msgs::DecodeError::BadLengthDescriptor => return Err(PeerHandleError{ no_connection_possible: false }),
-                                                                                               msgs::DecodeError::Io(_) => return Err(PeerHandleError{ no_connection_possible: false }),
-                                                                                       }
-                                                                               }
-                                                                       };
-                                                               }
-                                                       }
-
                                                        macro_rules! insert_node_id {
                                                                () => {
                                                                        match peers.node_id_to_descriptor.entry(peer.their_node_id.unwrap()) {
@@ -613,7 +582,34 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
                                                                                peer.pending_read_is_header = true;
 
                                                                                let mut reader = ::std::io::Cursor::new(&msg_data[..]);
-                                                                               let message = try_potential_decodeerror!(wire::read(&mut reader));
+                                                                               let message_result = wire::read(&mut reader);
+                                                                               let message = match message_result {
+                                                                                       Ok(x) => x,
+                                                                                       Err(e) => {
+                                                                                               match e {
+                                                                                                       msgs::DecodeError::UnknownVersion => return Err(PeerHandleError { no_connection_possible: false }),
+                                                                                                       msgs::DecodeError::UnknownRequiredFeature => {
+                                                                                                               log_debug!(self, "Got a channel/node announcement with an known required feature flag, you may want to update!");
+                                                                                                               continue;
+                                                                                                       }
+                                                                                                       msgs::DecodeError::InvalidValue => {
+                                                                                                               log_debug!(self, "Got an invalid value while deserializing message");
+                                                                                                               return Err(PeerHandleError { no_connection_possible: false });
+                                                                                                       }
+                                                                                                       msgs::DecodeError::ShortRead => {
+                                                                                                               log_debug!(self, "Deserialization failed due to shortness of message");
+                                                                                                               return Err(PeerHandleError { no_connection_possible: false });
+                                                                                                       }
+                                                                                                       msgs::DecodeError::ExtraAddressesPerType => {
+                                                                                                               log_debug!(self, "Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407");
+                                                                                                               continue;
+                                                                                                       }
+                                                                                                       msgs::DecodeError::BadLengthDescriptor => return Err(PeerHandleError { no_connection_possible: false }),
+                                                                                                       msgs::DecodeError::Io(_) => return Err(PeerHandleError { no_connection_possible: false }),
+                                                                                               }
+                                                                                       }
+                                                                               };
+
                                                                                log_trace!(self, "Received message of type {} from {}", message.type_id(), log_pubkey!(peer.their_node_id.unwrap()));
 
                                                                                // Need an Init as first message