Skip to content
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

cln: update to v23.08 to allow self payments #2960

Closed

Conversation

vincenzopalazzo
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo commented Aug 15, 2023

This include the recent version of core lightning to
allow self-payments.

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (0a67d55) 59.76% compared to head (daa3292) 59.77%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2960      +/-   ##
==========================================
+ Coverage   59.76%   59.77%   +0.01%     
==========================================
  Files         197      197              
  Lines       41149    41147       -2     
==========================================
+ Hits        24593    24596       +3     
+ Misses      16556    16551       -5     
Files Coverage Δ
gateway/ln-gateway/src/bin/cln_extension.rs 0.00% <0.00%> (ø)

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vincenzopalazzo vincenzopalazzo changed the title wip: working for a self payments cln: update to v23.08 to allow self payments Aug 24, 2023
@vincenzopalazzo vincenzopalazzo marked this pull request as ready for review August 24, 2023 10:16
@vincenzopalazzo vincenzopalazzo requested a review from a team as a code owner August 24, 2023 10:16
@m1sterc001guy
Copy link
Contributor

This should be relatively straightforward if you want to take a shot at writing a test. See test_gateway_pay_valid_invoice in gateway/ln_gateway/src/ng/tests.rs as an example of a test that uses fedimint to pay an invoice.

The main thing that you'll need to change, is that instead of generating an invoice with other_lightning_client, you'll need to generate the invoice with CLN and then try to pay it with fedimint when CLN is set as the lightning gateway.

dpc
dpc previously approved these changes Aug 24, 2023
@elsirion
Copy link
Contributor

This breaks our CI, probably some CLN command that changed.

@vincenzopalazzo
Copy link
Contributor Author

This should be relatively straightforward if you want to take a shot at writing a test. See test_gateway_pay_valid_invoice in gateway/ln_gateway/src/ng/tests.rs as an example of a test that uses fedimint to pay an invoice.

Thanks to point me in the correct file, but test_gateway_pay_valid_invoice is not there.

The main thing that you'll need to change, is that instead of generating an invoice with other_lightning_client, you'll need to generate the invoice with CLN and then try to pay it with fedimint when CLN is set as the lightning gateway.

I see, I assume that CLN in this case is the user_client?

The use case that I would like to test is generate an invoice with fedi -> pay with user client

This breaks our CI, probably some CLN command that changed.

Yeah, I am not able to reproduce on my machine because my remote build machine apparently will OOM :/

@elsirion
Copy link
Contributor

I think you can reproduce one (of potentially more) problems in just mprocs. It takes a ridiculous time to get read, apparently because the LND node doesn't return any route hints and lnd-gw keeps retrying.

2023-08-25T09:46:53.870439Z  INFO connect_fed: ln_gateway: LN node returned no route hints, trying again in 2s num_retries=16

After 30 retries it starts without route hints, leading to the user shell becoming read after over 160s. When checking the output of fedimint-cli list-gateways one of them doesn't have any route hints as predicted by this theory.

On master both the CLN and the LND gateway register quickly and have route hints. Is it possible that some CLN change lead to LND not recognizing a channel as active? The route hint filtering for LND is implemented here:

async fn routehints(&self) -> Result<GetRouteHintsResponse, LightningRpcError> {
let mut client = Self::connect(
self.address.clone(),
self.tls_cert.clone(),
self.macaroon.clone(),
)
.await?;
let channels = client
.lightning()
.list_channels(ListChannelsRequest {
active_only: true,
inactive_only: false,
public_only: false,
private_only: false,
peer: vec![],
})
.await
.map_err(|status| LightningRpcError::FailedToGetRouteHints {
failure_reason: format!("Failed to list channels {status:?}"),
})?
.into_inner();
let mut route_hints: Vec<RouteHint> = vec![];
for chan in channels.channels {
let info = client
.lightning()
.get_chan_info(ChanInfoRequest {
chan_id: chan.chan_id,
})
.await
.map_err(|status| LightningRpcError::FailedToGetRouteHints {
failure_reason: format!("Failed to get channel info {status:?}"),
})?
.into_inner();
let policy = match info.node1_policy.clone() {
Some(policy) => policy,
None => continue,
};
let src_node_id = PublicKey::from_str(&chan.remote_pubkey)
.unwrap()
.serialize()
.to_vec();
let short_channel_id = chan.chan_id;
let base_msat = policy.fee_base_msat as u32;
let proportional_millionths = policy.fee_rate_milli_msat as u32;
let cltv_expiry_delta = policy.time_lock_delta;
let htlc_maximum_msat = Some(policy.max_htlc_msat);
let htlc_minimum_msat = Some(policy.min_htlc as u64);
let route_hint_hop = RouteHintHop {
src_node_id,
short_channel_id,
base_msat,
proportional_millionths,
cltv_expiry_delta,
htlc_minimum_msat,
htlc_maximum_msat,
};
route_hints.push(RouteHint {
hops: vec![route_hint_hop],
});
}
Ok(GetRouteHintsResponse { route_hints })
}

If you are running out of memory when compiling for just mprocs you can limit cargo's parallelism by applying the following patch:

diff --git a/scripts/build.sh b/scripts/build.sh
index 2dfae4e581..374e43f06f 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -38,6 +38,6 @@ cd $SRC_DIR || exit 1
 # Note: Respect 'CARGO_PROFILE' that crane uses
 
 if [ -z "${SKIP_CARGO_BUILD:-}" ]; then
-  cargo build --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}}
+  cargo build -j 2 --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}}
 fi
 export PATH="$PWD/target/${CARGO_PROFILE:-debug}:$PATH"

@dpc
Copy link
Contributor

dpc commented Aug 25, 2023

@vincenzopalazzo @elsirion There's also CARGO_BUILD_JOBS

@vincenzopalazzo
Copy link
Contributor Author

vincenzopalazzo commented Sep 1, 2023

Ok this should be ready now! Just waiting for the CI

@vincenzopalazzo vincenzopalazzo force-pushed the macros/cln-self-pay branch 4 times, most recently from 3043131 to 1242052 Compare September 4, 2023 09:26
@@ -65,8 +65,7 @@ async fn main() -> Result<(), anyhow::Error> {
.serve_with_shutdown(listen, async {
// Wait for plugin to signal it's shutting down
// Shut down everything else via TaskGroup regardless of error
let result = plugin.join().await;
assert!(result.is_ok(), "{:?}", result);
let _ = plugin.join().await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if expecting here would be useful or not. I'm ok with it. If anything panics we should normally see it anyway.

@elsirion
Copy link
Contributor

elsirion commented Sep 7, 2023

Just saw that the changes were single fixup commits, could you squash them please?

@vincenzopalazzo
Copy link
Contributor Author

Just saw that the changes were single fixup commits, could you squash them please?

Yeah sorry I was just collecting all the review and the squash them

Now should be done :)

elsirion
elsirion previously approved these changes Sep 8, 2023
@dpc dpc self-assigned this Sep 21, 2023
@justinmoon
Copy link
Contributor

justinmoon commented Oct 2, 2023

When I run just mprocs on this branch I get the following in the cln tab:

lightningd: Config file /var/folders/19/h_y32l8s1lxfrpxctd1673p00000gn/T/nix-shell.wNptoj/fm-INjH/cln/config line 2: bitcoin-rpcuser=bitcoin: unknown option

Also, I notice that flake.nix is trying to pin the lightningd version to 23.08 but in the terminal I'm seeing:

$ lightningd --version
v23.05

Perhaps this change isn't having the desired effect ...

@vincenzopalazzo
Copy link
Contributor Author

vincenzopalazzo commented Oct 2, 2023

Yeah, this was something that I was looking into.

We could drop https://github.com/fedimint/fedimint/pull/2960/files#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0R66-R73 because cln nix package get updated (?)

I will try to drop it and made a rebase now

When I run just mprocs on this branch I get the following in the cln tab:

Regarding this, I am not sure about it the fedi flake nix is quite complex to understand what it is going on, sorry

auto-merge was automatically disabled October 2, 2023 19:21

Head branch was pushed to by a user without write access

@justinmoon
Copy link
Contributor

@dpc could you look into this issue? #2960 (comment). It doesn't seem like the patch lightningd is actually showing up at all. We expect lightningd --version to say v23.08 but it says v23.05.

@dpc
Copy link
Contributor

dpc commented Oct 4, 2023

When I run just mprocs on this branch I get the following in the cln tab:

lightningd: Config file /var/folders/19/h_y32l8s1lxfrpxctd1673p00000gn/T/nix-shell.wNptoj/fm-INjH/cln/config line 2: bitcoin-rpcuser=bitcoin: unknown option

Also, I notice that flake.nix is trying to pin the lightningd version to 23.08 but in the terminal I'm seeing:

$ lightningd --version
v23.05

Perhaps this change isn't having the desired effect ...

Instead of having it as a separate package, try overwriting the existing one in pkgs. to make sure all clightnings everywhere will be patched.

I was planning to do it anyway. Otherwise only places that refer to this variable get this patched binary. It could be that where you're trying it is actually using pkgs.clightning and not this variable.

@dpc
Copy link
Contributor

dpc commented Oct 6, 2023

#3336

@vincenzopalazzo
Copy link
Contributor Author

Thanks, when it is merged #3336 (review) I will rebase on it

@dpc
Copy link
Contributor

dpc commented Oct 6, 2023

Please @ me in case of issue, or even ping me on Discord.

@vincenzopalazzo
Copy link
Contributor Author

Rebased now to see what the CI tell us, thanks for the fix

flake.nix Outdated Show resolved Hide resolved
@vincenzopalazzo vincenzopalazzo force-pushed the macros/cln-self-pay branch 2 times, most recently from 3759a9c to cf244ba Compare October 6, 2023 19:32
@dpc
Copy link
Contributor

dpc commented Oct 6, 2023

just format it

This include the recent version of core lightning to
allow self-payments.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@dpc
Copy link
Contributor

dpc commented Mar 15, 2024

Last time I tried updating tests were failing. I also remember manmeet pinning cln-rpc because it was introducing backward-incompat changes.

What do we do about it?

I'm closing as it just lags in the PR backlog. If anyone feels like moving it forward, feel free to reopen.

@dpc dpc closed this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants