Skip to content

Commit 60d617d

Browse files
committed
gl-plugin: Upgrade cln_grpc and cln_rpc
Upgrade to the current version and, adjust the wrapper and other messages to the changes. Need to fill out the streams after we made NotificationStream - respectively the server module public. Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
1 parent dc11818 commit 60d617d

8 files changed

Lines changed: 611 additions & 96 deletions

File tree

libs/gl-plugin/Cargo.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
name = "gl-plugin"
33
version = "0.3.0"
44
edition = "2021"
5-
authors = [
6-
"Christian Decker",
7-
"The Greenlight Team"
8-
]
5+
authors = ["Christian Decker", "The Greenlight Team"]
96
description = "Python bindings for the Greenlight client library."
107
repository = "https://github.com/Blockstream/greenlight"
118
license = "MIT"
@@ -33,17 +30,17 @@ lazy_static = "^1.4.0"
3330
linemux = "0.2"
3431
log = "0.4"
3532
nix = "^0"
36-
prost = "0.11"
33+
prost = "0.12"
3734
serde = { version = "1.0", features = ["derive"] }
3835
serde_json = "1"
3936
sled = "0.34"
4037
thiserror = "1"
4138
tokio = { version = "1", features = ["full"] }
4239
tokio-stream = { version = "0.1", features = ["net"] }
4340
tokio-util = { version = "0.7", features = ["codec"] }
44-
tonic = { version = "^0.8", features = ["tls", "transport"] }
41+
tonic = { version = "0.11", features = ["tls", "transport"] }
4542
tower = { version = "0.4" }
4643
vls-protocol = { workspace = true }
4744

4845
[build-dependencies]
49-
tonic-build = "^0.8"
46+
tonic-build = "0.11"

libs/gl-plugin/src/awaitables.rs

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use cln_rpc::{
22
model::{
3-
requests::{
4-
ConnectRequest, GetinfoRequest, GetrouteRequest, ListpeerchannelsRequest,
5-
ListpeersRequest,
6-
},
3+
requests::{ConnectRequest, GetinfoRequest, GetrouteRequest, ListpeerchannelsRequest},
74
responses::GetrouteResponse,
85
},
96
primitives::{Amount, PublicKey, ShortChannelId},
@@ -311,7 +308,6 @@ async fn billboard(
311308
.await
312309
.map_err(|e| Error::Rpc(e))?
313310
.channels
314-
.ok_or(Error::Channel("No channels found"))?
315311
.into_iter()
316312
.filter(|c| {
317313
c.short_channel_id == Some(scid)
@@ -324,28 +320,10 @@ async fn billboard(
324320
.status
325321
.ok_or(Error::Channel("Status not found"))?)
326322
} else {
327-
#[allow(deprecated)]
328-
Ok(rpc
329-
.call_typed(&ListpeersRequest {
330-
id: Some(peer_id),
331-
level: None,
332-
})
333-
.await
334-
.map_err(|e| Error::Rpc(e))?
335-
.peers
336-
.into_iter()
337-
.nth(0)
338-
.ok_or(Error::Channel("Has no peers list"))?
339-
.channels
340-
.into_iter()
341-
.nth(0)
342-
.ok_or(Error::Channel("Has no channels list"))?
343-
.into_iter()
344-
.filter(|c| c.short_channel_id == Some(scid))
345-
.nth(0)
346-
.ok_or(Error::Channel("No channel with scid"))?
347-
.status
348-
.ok_or(Error::Channel("No amount found"))?)
323+
return Err(Error::Service(format!(
324+
"Not supported in this version of core-lightning: {}, need at least v23.05gl1",
325+
version,
326+
)));
349327
}
350328
}
351329

@@ -381,7 +359,6 @@ async fn spendable_msat(
381359
.await
382360
.map_err(|e| Error::Rpc(e))?
383361
.channels
384-
.ok_or(Error::Channel("No channels found"))?
385362
.into_iter()
386363
.filter(|c| {
387364
c.short_channel_id == Some(scid)
@@ -394,28 +371,10 @@ async fn spendable_msat(
394371
.spendable_msat
395372
.ok_or(Error::Channel("No amount found"))?)
396373
} else {
397-
#[allow(deprecated)]
398-
Ok(rpc
399-
.call_typed(&ListpeersRequest {
400-
id: Some(peer_id),
401-
level: None,
402-
})
403-
.await
404-
.map_err(|e| Error::Rpc(e))?
405-
.peers
406-
.into_iter()
407-
.nth(0)
408-
.ok_or(Error::Channel("Has no peers list"))?
409-
.channels
410-
.into_iter()
411-
.nth(0)
412-
.ok_or(Error::Channel("Has no channels list"))?
413-
.into_iter()
414-
.filter(|c| c.short_channel_id == Some(scid))
415-
.nth(0)
416-
.ok_or(Error::Channel("No channel with scid"))?
417-
.spendable_msat
418-
.ok_or(Error::Channel("No amount found"))?)
374+
return Err(Error::Service(format!(
375+
"Not supported in this version of core-lightning: {}, need at least v23.05gl1",
376+
version,
377+
)));
419378
}
420379
}
421380

libs/gl-plugin/src/bin/plugin.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ async fn main() -> Result<(), Error> {
2121
let config = Config::new().context("loading config")?;
2222
let stage = Arc::new(Stage::new());
2323
let (events, _) = tokio::sync::broadcast::channel(16);
24+
let (notifications, _) = tokio::sync::broadcast::channel(16);
2425
let state_store = get_signer_store().await?;
2526

2627
start_hsm_server(config.clone(), stage.clone())?;
27-
start_node_server(config, stage.clone(), events.clone(), state_store).await?;
28+
start_node_server(
29+
config,
30+
stage.clone(),
31+
events.clone(),
32+
notifications,
33+
state_store,
34+
)
35+
.await?;
2836

2937
let plugin = gl_plugin::init(stage, events).await?;
3038
if let Some(plugin) = plugin.start().await? {
@@ -38,6 +46,7 @@ async fn start_node_server(
3846
config: Config,
3947
stage: Arc<Stage>,
4048
events: tokio::sync::broadcast::Sender<Event>,
49+
notifications: tokio::sync::broadcast::Sender<cln_rpc::notifications::Notification>,
4150
signer_state_store: Box<dyn StateStore>,
4251
) -> Result<(), Error> {
4352
let addr: SocketAddr = config
@@ -62,6 +71,7 @@ async fn start_node_server(
6271
stage.clone(),
6372
config.clone(),
6473
events.clone(),
74+
notifications.clone(),
6575
signer_state_store,
6676
)
6777
.await?;

libs/gl-plugin/src/node/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{stager, tramp};
66
use anyhow::{Context, Error, Result};
77
use base64::{engine::general_purpose, Engine as _};
88
use bytes::BufMut;
9+
use cln_rpc::Notification;
910
use gl_client::persist::State;
1011
use governor::{
1112
clock::MonotonicClock, state::direct::NotKeyed, state::InMemoryState, Quota, RateLimiter,
@@ -85,13 +86,15 @@ pub struct PluginNodeServer {
8586
grpc_binding: String,
8687
signer_state_store: Arc<Mutex<Box<dyn StateStore>>>,
8788
pub ctx: crate::context::Context,
89+
notifications: tokio::sync::broadcast::Sender<Notification>,
8890
}
8991

9092
impl PluginNodeServer {
9193
pub async fn new(
9294
stage: Arc<stager::Stage>,
9395
config: Config,
9496
events: tokio::sync::broadcast::Sender<super::Event>,
97+
notifications: tokio::sync::broadcast::Sender<Notification>,
9598
signer_state_store: Box<dyn StateStore>,
9699
) -> Result<Self, Error> {
97100
let tls = ServerTlsConfig::new()
@@ -126,6 +129,7 @@ impl PluginNodeServer {
126129
signer_state: Arc::new(Mutex::new(signer_state)),
127130
signer_state_store: Arc::new(Mutex::new(signer_state_store)),
128131
grpc_binding: config.node_grpc_binding,
132+
notifications,
129133
};
130134

131135
tokio::spawn(async move {

libs/gl-plugin/src/node/rpcwait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use tonic::transport::NamedService;
21
use log::warn;
2+
use tonic::server::NamedService;
33
use tower::Service;
44

55
/// The RPC socket will not be available right away, so we wrap the

0 commit comments

Comments
 (0)