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

chore: get rid of DatabaseSource workaround #3781

Closed
wants to merge 1 commit into from

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Nov 29, 2023

It was needed when we were leaking database referencess, which should no longer be the case.

In LN gateway code we should be able to just use an existin Client instead of building new one.

It was needed when we were leaking database referencess,
which should no longer be the case.

In LN gateway code we should be able to just use an existin
`Client` instead of building new one.
@dpc dpc requested review from a team as code owners November 29, 2023 00:34
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

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

Comparison is base (7b48964) 57.65% compared to head (1c7a61c) 57.71%.

Files Patch % Lines
gateway/ln-gateway/src/lib.rs 50.00% 16 Missing ⚠️
fedimint-client/src/lib.rs 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3781       /-   ##
==========================================
  Coverage   57.65%   57.71%    0.05%     
==========================================
  Files         193      193              
  Lines       42053    42044       -9     
==========================================
  Hits        24244    24264       20     
  Misses      17809    17780      -29     

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

@dpc
Copy link
Contributor Author

dpc commented Nov 29, 2023

I'm not entirely sure if LN gateway code had some good reason to build new clients instead of cloning existing ones. @m1sterc001guy @okjodom

@elsirion elsirion marked this pull request as draft November 29, 2023 09:19
@elsirion
Copy link
Contributor

CI is failing

@okjodom
Copy link
Contributor

okjodom commented Nov 29, 2023

I'm not entirely sure if LN gateway code had some good reason to build new clients instead of cloning existing ones. @m1sterc001guy @okjodom

I think needing to inject lnrpc into the client was the reason? Not sure of it though

@dpc
Copy link
Contributor Author

dpc commented Nov 29, 2023

Will debug when I find some energy.

@dpc
Copy link
Contributor Author

dpc commented Dec 1, 2023

@okjodom @m1sterc001guy so it looks like this fails because something hangs in lnd gateawy, 99% because of the ArcClient re-use.

I tried to debug it but I have trouble understanding the code around it (I created #3807 motivated by it), and I don't have a good pre-existing understanding of the gateway architecture.

I don't even undersatnd why the gateway would need multiple client to the same federation, while the code (and my dbg! debugging statements) indicate that this can actually be the case? This is most probably fixable in some way, but hard to tell why without undrestanding the requirements.

@justinmoon
Copy link
Contributor

dev call: dpc is blocked on this one because some lightning stuff is failing cc @okjodom @m1sterc001guy

dpc added a commit to dpc/fedimint that referenced this pull request Dec 11, 2023
This will hopefully help unblocking fedimint#3781 , and prevent
anyone from introducing more places that would depend on it.
dpc added a commit to dpc/fedimint that referenced this pull request Dec 11, 2023
This will hopefully help unblocking fedimint#3781 , and prevent
anyone from introducing more places that would depend on it.
@m1sterc001guy
Copy link
Contributor

m1sterc001guy commented Jan 10, 2024

I think I know the crux of the issue here. Today, we have a number of properties on GatewayClientModule and these properties are setup when the clients are created. One of these properties is a connection to the lightning node (Arc<dyn ILnRpcClient>). So when the connection to the lightning node goes down, we need to re-create this connection. Today we naively re-create all of the clients. I remember running into an issue that indicated we couldn't reopen an already existing connection to the database when re-creating the connection, hence the workaround to have DatabaseSource::Reuse so that we would just re-use the already opened db.

Ideally, I don't think we should be re-creating the clients at all. We should just create the federation clients when the gateway boots up and never again. So instead of passing the lightning node connection Arc<dyn ILnRpcClient> to GatewayClientModule, we should just pass a copy of the Gateway struct. Gateway is already clonable and has convenient methods for checking if the lightning node is online and accessing it. This would allow us to completely delete DatabaseSource::Reuse since we'd only ever open the database once, because we only create the clients once.

@dpc
Copy link
Contributor Author

dpc commented Jan 31, 2024

Was done in another PR

@dpc dpc closed this Jan 31, 2024
@dpc dpc deleted the 23-11-28-refactor-init branch November 12, 2024 04:37
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.

5 participants