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

multi: remove Pool, Loop and Faraday deps from main LNC module #66

Merged
merged 10 commits into from
Jan 12, 2023

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Jan 10, 2023

The main goal of this PR is to remove the Pool, Loop and Faraday dependencies from the main LNC module.
This is done by converting the mobile package into a go module and then letting it and the wasm-client module import Litd permissions and JSON callback registrations from Litd itself rather from the core package. The core package is then removed.

Depends on lightninglabs/lightning-terminal#476
Replaces #65

@ellemouton ellemouton force-pushed the lncModulesRefactor branch 8 times, most recently from 63a4c71 to ceda9eb Compare January 10, 2023 13:51
@ellemouton ellemouton force-pushed the lncModulesRefactor branch 2 times, most recently from ceda9eb to 0c3ee4e Compare January 10, 2023 14:43
@ellemouton
Copy link
Member Author

@guggero & @kaloudis , any idea how to fix the android build issue? have tried a bunch of things without any luck.

Also still trying to figure out how fix the linter which now linting all code in the repo instead of just the code from the PR

@kaloudis
Copy link
Contributor

@ellemouton I would try to see if I could update the version of gomobile used here: https://github.com/lightninglabs/lightning-node-connect/blob/master/.github/workflows/main.yml#L52

@ellemouton
Copy link
Member Author

@kaloudis, thanks but I tried using @latest but that still results in the same issue of the import not being found

@ellemouton ellemouton force-pushed the lncModulesRefactor branch 3 times, most recently from b2b871f to a2d30b7 Compare January 11, 2023 08:17
@ellemouton
Copy link
Member Author

ok, managed to get the linter working by making use of new-from-rev and by fixing one linter error that it insisted on for some reason. Now just need to figure out the bind stuff

@ellemouton ellemouton force-pushed the lncModulesRefactor branch 6 times, most recently from 70e0b79 to 6d3cf8e Compare January 11, 2023 14:03
To prevent version incompatabilities in upcoming commits, we change the
aperture version here to a version that uses a tor version supported by
lnd v0.15.5-beta.
In this commit, the MailboxRPCConnection function is renamed and moved
out of the core package and into the mailbox package.
Update the go version used by Dockerfile-wasm along with the go version
used by Github actions.
@kaloudis
Copy link
Contributor

Nice job! WASM and Android appear to be building now

Copy link
Contributor

@kaloudis kaloudis left a comment

Choose a reason for hiding this comment

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

LGTM

@ellemouton
Copy link
Member Author

cool - updated this to point to the merged Lit PR 👍

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice! Only two comments around init().


func init() {
var err error
permsMgr, err = perms.NewManager(true)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure init() works correctly with WASM. Can we do that at the beginning of main() instead?
I guess we should also test the changes with the demo HTTP page.

mobile/mobile.go Outdated

func init() {
var err error
permsMgr, err = perms.NewManager(true)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, not sure if the mobile framework calls init(). Could be in InitLNC (after the mutex, with a nil check in case it was already initialized).

@ellemouton
Copy link
Member Author

@guggero , I did test the wasm client with the example page to make sure that the permissions manager works as expected 👍 So is it ok to leave the init function in that case or have you experienced that the init function does not consistently work in wasm?

@kaloudis - could you test if the mobile package's HasPermissions function works as expected with this PR?

@guggero
Copy link
Member

guggero commented Jan 12, 2023

@guggero , I did test the wasm client with the example page to make sure that the permissions manager works as expected +1 So is it ok to leave the init function in that case or have you experienced that the init function does not consistently work in wasm?

Hmm, I remember there being an issue with init() in some cases, but can't seem to find it anymore. Not sure if it was WASM or mobile, or something else. But since we have a main() method anyway, I think it would be cleaner to do the initialization there.

In this commit, the dependency on the core package is removed and hence
the imports of loop, pool and faraday are also removed from LNC. The
mobile and wasm-clients now instead import the permissions and
JsonCallbacks that they need from Litd.
@ellemouton
Copy link
Member Author

cool cool - updated to remove the init funcs :)

@ellemouton ellemouton requested a review from guggero January 12, 2023 09:44
@guggero
Copy link
Member

guggero commented Jan 12, 2023

Very nice! Waiting with merge until we have a confirmation that everything works on mobile as expected.

@ellemouton
Copy link
Member Author

^ cc @kaloudis 🙏 📱

@kaloudis
Copy link
Contributor

Tested in Android using a modified version of the lnc-rn connect demo:

I used a read-only session and called the hasPerms call for the last two values below:

Screenshot_1673539435

@guggero
Copy link
Member

guggero commented Jan 12, 2023

Awesome, thanks for confirming!

@guggero guggero merged commit ee29cbd into lightninglabs:master Jan 12, 2023
@ellemouton ellemouton deleted the lncModulesRefactor branch January 12, 2023 17:52
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.

3 participants