@@ -1054,10 +1054,6 @@ impl Readable for NodeAlias {
1054
1054
pub struct NodeInfo {
1055
1055
/// All valid channels a node has announced
1056
1056
pub channels : Vec < u64 > ,
1057
- /// Lowest fees enabling routing via any of the enabled, known channels to a node.
1058
- /// The two fields (flat and proportional fee) are independent,
1059
- /// meaning they don't have to refer to the same channel.
1060
- pub lowest_inbound_channel_fees : Option < RoutingFees > ,
1061
1057
/// More information about a node from node_announcement.
1062
1058
/// Optional because we store a Node entry after learning about it from
1063
1059
/// a channel announcement, but before receiving a node announcement.
@@ -1066,16 +1062,16 @@ pub struct NodeInfo {
1066
1062
1067
1063
impl fmt:: Display for NodeInfo {
1068
1064
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
1069
- write ! ( f, "lowest_inbound_channel_fees: {:?}, channels: {:?}, announcement_info: {:?}" ,
1070
- self . lowest_inbound_channel_fees , & self . channels[ ..] , self . announcement_info) ?;
1065
+ write ! ( f, " channels: {:?}, announcement_info: {:?}" ,
1066
+ & self . channels[ ..] , self . announcement_info) ?;
1071
1067
Ok ( ( ) )
1072
1068
}
1073
1069
}
1074
1070
1075
1071
impl Writeable for NodeInfo {
1076
1072
fn write < W : crate :: util:: ser:: Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
1077
1073
write_tlv_fields ! ( writer, {
1078
- ( 0 , self . lowest_inbound_channel_fees , option ) ,
1074
+ // Note that older versions of LDK wrote the lowest inbound fees here at type 0
1079
1075
( 2 , self . announcement_info, option) ,
1080
1076
( 4 , self . channels, vec_type) ,
1081
1077
} ) ;
@@ -1103,18 +1099,22 @@ impl MaybeReadable for NodeAnnouncementInfoDeserWrapper {
1103
1099
1104
1100
impl Readable for NodeInfo {
1105
1101
fn read < R : io:: Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
1106
- _init_tlv_field_var ! ( lowest_inbound_channel_fees, option) ;
1102
+ // Historically, we tracked the lowest inbound fees for any node in order to use it as an
1103
+ // A* heuristic when routing. Sadly, these days many, many nodes have at least one channel
1104
+ // with zero inbound fees, causing that heuristic to provide little gain. Worse, because it
1105
+ // requires additional complexity and lookups during routing, it ends up being a
1106
+ // performance loss. Thus, we simply ignore the old field here and no longer track it.
1107
+ let mut _lowest_inbound_channel_fees: Option < RoutingFees > = None ;
1107
1108
let mut announcement_info_wrap: Option < NodeAnnouncementInfoDeserWrapper > = None ;
1108
1109
_init_tlv_field_var ! ( channels, vec_type) ;
1109
1110
1110
1111
read_tlv_fields ! ( reader, {
1111
- ( 0 , lowest_inbound_channel_fees , option) ,
1112
+ ( 0 , _lowest_inbound_channel_fees , option) ,
1112
1113
( 2 , announcement_info_wrap, ignorable) ,
1113
1114
( 4 , channels, vec_type) ,
1114
1115
} ) ;
1115
1116
1116
1117
Ok ( NodeInfo {
1117
- lowest_inbound_channel_fees : _init_tlv_based_struct_field ! ( lowest_inbound_channel_fees, option) ,
1118
1118
announcement_info : announcement_info_wrap. map ( |w| w. 0 ) ,
1119
1119
channels : _init_tlv_based_struct_field ! ( channels, vec_type) ,
1120
1120
} )
@@ -1175,22 +1175,6 @@ impl<L: Deref> ReadableArgs<L> for NetworkGraph<L> where L::Target: Logger {
1175
1175
( 1 , last_rapid_gossip_sync_timestamp, option) ,
1176
1176
} ) ;
1177
1177
1178
- // Regenerate inbound fees for all channels. The live-updating of these has been broken in
1179
- // various ways historically, so this ensures that we have up-to-date limits.
1180
- for ( node_id, node) in nodes. iter_mut ( ) {
1181
- let mut best_fees = RoutingFees { base_msat : u32:: MAX , proportional_millionths : u32:: MAX } ;
1182
- for channel in node. channels . iter ( ) {
1183
- if let Some ( chan) = channels. get ( channel) {
1184
- let dir_opt = if * node_id == chan. node_one { & chan. two_to_one } else { & chan. one_to_two } ;
1185
- if let Some ( dir) = dir_opt {
1186
- best_fees. base_msat = cmp:: min ( best_fees. base_msat , dir. fees . base_msat ) ;
1187
- best_fees. proportional_millionths = cmp:: min ( best_fees. proportional_millionths , dir. fees . proportional_millionths ) ;
1188
- }
1189
- } else { return Err ( DecodeError :: InvalidValue ) ; }
1190
- }
1191
- node. lowest_inbound_channel_fees = Some ( best_fees) ;
1192
- }
1193
-
1194
1178
Ok ( NetworkGraph {
1195
1179
secp_ctx : Secp256k1 :: verification_only ( ) ,
1196
1180
genesis_hash,
@@ -1430,7 +1414,6 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1430
1414
BtreeEntry :: Vacant ( node_entry) => {
1431
1415
node_entry. insert ( NodeInfo {
1432
1416
channels : vec ! ( short_channel_id) ,
1433
- lowest_inbound_channel_fees : None ,
1434
1417
announcement_info : None ,
1435
1418
} ) ;
1436
1419
}
@@ -1731,9 +1714,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1731
1714
}
1732
1715
1733
1716
fn update_channel_intern ( & self , msg : & msgs:: UnsignedChannelUpdate , full_msg : Option < & msgs:: ChannelUpdate > , sig : Option < & secp256k1:: ecdsa:: Signature > ) -> Result < ( ) , LightningError > {
1734
- let dest_node_id;
1735
1717
let chan_enabled = msg. flags & ( 1 << 1 ) != ( 1 << 1 ) ;
1736
- let chan_was_enabled;
1737
1718
1738
1719
#[ cfg( all( feature = "std" , not( test) , not( feature = "_test_utils" ) ) ) ]
1739
1720
{
@@ -1781,9 +1762,6 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1781
1762
} else if existing_chan_info. last_update == msg. timestamp {
1782
1763
return Err ( LightningError { err: "Update had same timestamp as last processed update" . to_owned( ) , action: ErrorAction :: IgnoreDuplicateGossip } ) ;
1783
1764
}
1784
- chan_was_enabled = existing_chan_info. enabled;
1785
- } else {
1786
- chan_was_enabled = false ;
1787
1765
}
1788
1766
}
1789
1767
}
@@ -1811,7 +1789,6 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1811
1789
1812
1790
let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. encode( ) [ ..] ) [ ..] ) ;
1813
1791
if msg. flags & 1 == 1 {
1814
- dest_node_id = channel. node_one . clone ( ) ;
1815
1792
check_update_latest ! ( channel. two_to_one) ;
1816
1793
if let Some ( sig) = sig {
1817
1794
secp_verify_sig ! ( self . secp_ctx, & msg_hash, & sig, & PublicKey :: from_slice( channel. node_two. as_slice( ) ) . map_err( |_| LightningError {
@@ -1821,7 +1798,6 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1821
1798
}
1822
1799
channel. two_to_one = get_new_channel_info ! ( ) ;
1823
1800
} else {
1824
- dest_node_id = channel. node_two . clone ( ) ;
1825
1801
check_update_latest ! ( channel. one_to_two) ;
1826
1802
if let Some ( sig) = sig {
1827
1803
secp_verify_sig ! ( self . secp_ctx, & msg_hash, & sig, & PublicKey :: from_slice( channel. node_one. as_slice( ) ) . map_err( |_| LightningError {
@@ -1834,44 +1810,6 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1834
1810
}
1835
1811
}
1836
1812
1837
- let mut nodes = self . nodes . write ( ) . unwrap ( ) ;
1838
- if chan_enabled {
1839
- let node = nodes. get_mut ( & dest_node_id) . unwrap ( ) ;
1840
- let mut base_msat = msg. fee_base_msat ;
1841
- let mut proportional_millionths = msg. fee_proportional_millionths ;
1842
- if let Some ( fees) = node. lowest_inbound_channel_fees {
1843
- base_msat = cmp:: min ( base_msat, fees. base_msat ) ;
1844
- proportional_millionths = cmp:: min ( proportional_millionths, fees. proportional_millionths ) ;
1845
- }
1846
- node. lowest_inbound_channel_fees = Some ( RoutingFees {
1847
- base_msat,
1848
- proportional_millionths
1849
- } ) ;
1850
- } else if chan_was_enabled {
1851
- let node = nodes. get_mut ( & dest_node_id) . unwrap ( ) ;
1852
- let mut lowest_inbound_channel_fees = None ;
1853
-
1854
- for chan_id in node. channels . iter ( ) {
1855
- let chan = channels. get ( chan_id) . unwrap ( ) ;
1856
- let chan_info_opt;
1857
- if chan. node_one == dest_node_id {
1858
- chan_info_opt = chan. two_to_one . as_ref ( ) ;
1859
- } else {
1860
- chan_info_opt = chan. one_to_two . as_ref ( ) ;
1861
- }
1862
- if let Some ( chan_info) = chan_info_opt {
1863
- if chan_info. enabled {
1864
- let fees = lowest_inbound_channel_fees. get_or_insert ( RoutingFees {
1865
- base_msat : u32:: max_value ( ) , proportional_millionths : u32:: max_value ( ) } ) ;
1866
- fees. base_msat = cmp:: min ( fees. base_msat , chan_info. fees . base_msat ) ;
1867
- fees. proportional_millionths = cmp:: min ( fees. proportional_millionths , chan_info. fees . proportional_millionths ) ;
1868
- }
1869
- }
1870
- }
1871
-
1872
- node. lowest_inbound_channel_fees = lowest_inbound_channel_fees;
1873
- }
1874
-
1875
1813
Ok ( ( ) )
1876
1814
}
1877
1815
@@ -3291,7 +3229,6 @@ mod tests {
3291
3229
// 2. Check we can read a NodeInfo anyways, but set the NodeAnnouncementInfo to None if invalid
3292
3230
let valid_node_info = NodeInfo {
3293
3231
channels : Vec :: new ( ) ,
3294
- lowest_inbound_channel_fees : None ,
3295
3232
announcement_info : Some ( valid_node_ann_info) ,
3296
3233
} ;
3297
3234
0 commit comments