Skip to content

Commit eea1447

Browse files
committed
f Revert "Send warning instead of error when we incounter bogus gossip"
This reverts commit a29975d.
1 parent a29975d commit eea1447

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

lightning/src/ln/msgs.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ pub enum DecodeError {
5959
/// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
6060
/// syntactically incorrect, etc
6161
InvalidValue,
62-
/// Same as [`InvalidValue`], however this is set for gossip messages where we may not want to
63-
/// force-close our channels with a counterparty and can instead send a [`Warning`] message.
64-
InvalidGossipValue,
6562
/// Buffer too short
6663
ShortRead,
6764
/// A length descriptor in the packet didn't describe the later data correctly
@@ -72,17 +69,6 @@ pub enum DecodeError {
7269
/// The message included zlib-compressed values, which we don't support.
7370
UnsupportedCompression,
7471
}
75-
impl DecodeError {
76-
/// Map errors which may indicate a malformed message to `InvalidGossipValue` for use when
77-
/// decoding gossip messages.
78-
fn to_err_gossip_msg(self) -> Self {
79-
match self {
80-
DecodeError::Io(ioe) => DecodeError::Io(ioe),
81-
DecodeError::UnsupportedCompression => self,
82-
_ => DecodeError::InvalidGossipValue,
83-
}
84-
}
85-
}
8672

8773
/// An init message to be sent or received from a peer
8874
#[derive(Clone, Debug, PartialEq)]
@@ -992,7 +978,6 @@ impl fmt::Display for DecodeError {
992978
DecodeError::UnknownVersion => f.write_str("Unknown realm byte in Onion packet"),
993979
DecodeError::UnknownRequiredFeature => f.write_str("Unknown required feature preventing decode"),
994980
DecodeError::InvalidValue => f.write_str("Nonsense bytes didn't map to the type they were interpreted as"),
995-
DecodeError::InvalidGossipValue => f.write_str("Nonsense bytes didn't map to the type they were interpreted as in a gossip message"),
996981
DecodeError::ShortRead => f.write_str("Packet extended beyond the provided bytes"),
997982
DecodeError::BadLengthDescriptor => f.write_str("A length descriptor in the packet didn't describe the later data correctly"),
998983
DecodeError::Io(ref e) => e.fmt(f),
@@ -1453,8 +1438,8 @@ impl Writeable for UnsignedChannelAnnouncement {
14531438
}
14541439
}
14551440

1456-
impl UnsignedChannelAnnouncement {
1457-
fn do_read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1441+
impl Readable for UnsignedChannelAnnouncement {
1442+
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
14581443
Ok(Self {
14591444
features: Readable::read(r)?,
14601445
chain_hash: Readable::read(r)?,
@@ -1467,11 +1452,6 @@ impl UnsignedChannelAnnouncement {
14671452
})
14681453
}
14691454
}
1470-
impl Readable for UnsignedChannelAnnouncement {
1471-
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1472-
Self::do_read(r).map_err(|e| e.to_err_gossip_msg())
1473-
}
1474-
}
14751455

14761456
impl_writeable!(ChannelAnnouncement, {
14771457
node_signature_1,
@@ -1502,8 +1482,8 @@ impl Writeable for UnsignedChannelUpdate {
15021482
}
15031483
}
15041484

1505-
impl UnsignedChannelUpdate {
1506-
fn do_read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1485+
impl Readable for UnsignedChannelUpdate {
1486+
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
15071487
let has_htlc_maximum_msat;
15081488
Ok(Self {
15091489
chain_hash: Readable::read(r)?,
@@ -1524,11 +1504,6 @@ impl UnsignedChannelUpdate {
15241504
})
15251505
}
15261506
}
1527-
impl Readable for UnsignedChannelUpdate {
1528-
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1529-
Self::do_read(r).map_err(|e| e.to_err_gossip_msg())
1530-
}
1531-
}
15321507

15331508
impl_writeable!(ChannelUpdate, {
15341509
signature,
@@ -1609,8 +1584,8 @@ impl Writeable for UnsignedNodeAnnouncement {
16091584
}
16101585
}
16111586

1612-
impl UnsignedNodeAnnouncement {
1613-
fn do_read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1587+
impl Readable for UnsignedNodeAnnouncement {
1588+
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
16141589
let features: NodeFeatures = Readable::read(r)?;
16151590
let timestamp: u32 = Readable::read(r)?;
16161591
let node_id: PublicKey = Readable::read(r)?;
@@ -1670,11 +1645,6 @@ impl UnsignedNodeAnnouncement {
16701645
})
16711646
}
16721647
}
1673-
impl Readable for UnsignedNodeAnnouncement {
1674-
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
1675-
Self::do_read(r).map_err(|e| e.to_err_gossip_msg())
1676-
}
1677-
}
16781648

16791649
impl_writeable!(NodeAnnouncement, {
16801650
signature,

lightning/src/ln/peer_handler.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,11 +917,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
917917
}
918918
msgs::DecodeError::BadLengthDescriptor => return Err(PeerHandleError { no_connection_possible: false }),
919919
msgs::DecodeError::Io(_) => return Err(PeerHandleError { no_connection_possible: false }),
920-
msgs::DecodeError::InvalidGossipValue => {
921-
log_gossip!(self.logger, "Got an invalid value while deserializing a gossip message");
922-
self.enqueue_message(peer, &msgs::WarningMessage { channel_id: [0; 32], data: "You send a bogus/unreadable gossip message".to_owned() });
923-
continue;
924-
}
925920
msgs::DecodeError::UnsupportedCompression => {
926921
log_gossip!(self.logger, "We don't support zlib-compressed message fields, sending a warning and ignoring message");
927922
self.enqueue_message(peer, &msgs::WarningMessage { channel_id: [0; 32], data: "Unsupported message compression: zlib".to_owned() });

0 commit comments

Comments
 (0)