Skip to content

Peer storage feature #2943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ mod tests {
use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
use lightning::routing::router::{CandidateRouteHop, DefaultRouter, Path, RouteHop};
use lightning::routing::scoring::{ChannelUsage, LockableScore, ScoreLookUp, ScoreUpdate};
use lightning::sign::{ChangeDestinationSource, InMemorySigner, KeysManager};
use lightning::sign::{ChangeDestinationSource, InMemorySigner, KeysManager, NodeSigner};
use lightning::util::config::UserConfig;
use lightning::util::persist::{
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
Expand Down Expand Up @@ -1219,6 +1219,7 @@ mod tests {
Arc<test_utils::TestLogger>,
IgnoringMessageHandler,
Arc<KeysManager>,
IgnoringMessageHandler,
>,
>,
chain_monitor: Arc<ChainMonitor>,
Expand Down Expand Up @@ -1579,6 +1580,7 @@ mod tests {
logger.clone(),
fee_estimator.clone(),
kv_store.clone(),
keys_manager.get_peer_storage_key(),
));
let best_block = BestBlock::from_network(network);
let params = ChainParameters { network, best_block };
Expand Down Expand Up @@ -1632,6 +1634,7 @@ mod tests {
route_handler: Arc::new(test_utils::TestRoutingMessageHandler::new()),
onion_message_handler: messenger.clone(),
custom_message_handler: IgnoringMessageHandler {},
send_only_message_handler: IgnoringMessageHandler {},
};
let peer_manager = Arc::new(PeerManager::new(
msg_handler,
Expand Down
5 changes: 5 additions & 0 deletions lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ mod tests {
fn handle_tx_init_rbf(&self, _their_node_id: PublicKey, _msg: &TxInitRbf) {}
fn handle_tx_ack_rbf(&self, _their_node_id: PublicKey, _msg: &TxAckRbf) {}
fn handle_tx_abort(&self, _their_node_id: PublicKey, _msg: &TxAbort) {}
fn handle_peer_storage(&self, _their_node_id: PublicKey, _msg: &PeerStorageMessage) {}
fn handle_your_peer_storage(&self, _their_node_id: PublicKey, _msg: &YourPeerStorageMessage) {}
fn peer_disconnected(&self, their_node_id: PublicKey) {
if their_node_id == self.expected_pubkey {
self.disconnected_flag.store(true, Ordering::SeqCst);
Expand Down Expand Up @@ -835,6 +837,7 @@ mod tests {
route_handler: Arc::clone(&a_handler),
onion_message_handler: Arc::new(IgnoringMessageHandler {}),
custom_message_handler: Arc::new(IgnoringMessageHandler {}),
send_only_message_handler: Arc::new(IgnoringMessageHandler {}),
};
let a_manager = Arc::new(PeerManager::new(
a_msg_handler,
Expand All @@ -858,6 +861,7 @@ mod tests {
route_handler: Arc::clone(&b_handler),
onion_message_handler: Arc::new(IgnoringMessageHandler {}),
custom_message_handler: Arc::new(IgnoringMessageHandler {}),
send_only_message_handler: Arc::new(IgnoringMessageHandler {}),
};
let b_manager = Arc::new(PeerManager::new(
b_msg_handler,
Expand Down Expand Up @@ -920,6 +924,7 @@ mod tests {
onion_message_handler: Arc::new(IgnoringMessageHandler {}),
route_handler: Arc::new(lightning::ln::peer_handler::IgnoringMessageHandler {}),
custom_message_handler: Arc::new(IgnoringMessageHandler {}),
send_only_message_handler: Arc::new(IgnoringMessageHandler {}),
};
let a_manager = Arc::new(PeerManager::new(
a_msg_handler,
Expand Down
24 changes: 22 additions & 2 deletions lightning-types/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) for more information).
//! - `DnsResolver` - supports resolving DNS names to TXT DNSSEC proofs for BIP 353 payments
//! (see [bLIP 32](https://github.com/lightning/blips/blob/master/blip-0032.md) for more information).
//! - `ProvidePeerBackupStorage` - Indicates that we offer the capability to store data of our peers
//! (see https://github.com/lightning/bolts/pull/1110 for more info).
//!
//! LDK knows about the following features, but does not support them:
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
Expand Down Expand Up @@ -150,7 +152,7 @@ mod sealed {
// Byte 4
OnionMessages,
// Byte 5
ChannelType | SCIDPrivacy,
ProvidePeerBackupStorage | ChannelType | SCIDPrivacy,
// Byte 6
ZeroConf,
// Byte 7
Expand All @@ -171,7 +173,7 @@ mod sealed {
// Byte 4
OnionMessages,
// Byte 5
ChannelType | SCIDPrivacy,
ProvidePeerBackupStorage | ChannelType | SCIDPrivacy,
// Byte 6
ZeroConf | Keysend,
// Byte 7
Expand Down Expand Up @@ -522,6 +524,16 @@ mod sealed {
supports_onion_messages,
requires_onion_messages
);
define_feature!(
43,
ProvidePeerBackupStorage,
[InitContext, NodeContext],
"Feature flags for `provide_peer_backup_storage`.",
set_provide_peer_backup_storage_optional,
set_provide_peer_backup_storage_required,
supports_provide_peer_storage,
requires_provide_peer_storage
);
define_feature!(
45,
ChannelType,
Expand Down Expand Up @@ -1104,6 +1116,14 @@ mod tests {
assert!(!features1.requires_unknown_bits_from(&features2));
assert!(!features2.requires_unknown_bits_from(&features1));

features1.set_provide_peer_backup_storage_required();
assert!(features1.requires_unknown_bits_from(&features2));
assert!(!features2.requires_unknown_bits_from(&features1));

features2.set_provide_peer_backup_storage_optional();
assert!(!features1.requires_unknown_bits_from(&features2));
assert!(!features2.requires_unknown_bits_from(&features1));

features1.set_data_loss_protect_required();
assert!(features1.requires_unknown_bits_from(&features2));
assert!(!features2.requires_unknown_bits_from(&features1));
Expand Down
Loading