haveno icon indicating copy to clipboard operation
haveno copied to clipboard

Load native libraries [0.75 XMR]

Open woodser opened this issue 1 year ago • 24 comments

This issue requests loading the native libraries for monero-java in Haveno, such that MoneroUtils.loadNativeLibrary() succeeds.

The native libraries should be loaded using proper gradle config.

This will allow us to switch from monero-wallet-rpc to native wallet bindings in the future for better performance.

woodser avatar Feb 18 '24 18:02 woodser

Hello @woodser

I will take a look at this if you don't mind.

niyid avatar Feb 18 '24 20:02 niyid

Ok, thanks @niyid :)

woodser avatar Feb 18 '24 20:02 woodser

There is a bounty on this issue, the amount is in the title. The reward will be awarded to the first person or group of people who resolves this issue.

If you are starting to work on this bounty, please write a comment, so that we can assign the issue to you. We expect contributors to provide a PR in a reasonable time frame or, in case of an extensive work, updates on their progresses. We will unassign the issue if we feel the assignee is not responsive or has abandoned the task.

Read the full conditions and details of our bounty system.

github-actions[bot] avatar Feb 19 '24 14:02 github-actions[bot]

Ok, thanks @niyid :)

@woodser,

Remember to assign.

Do you use a Mac? I will need your help testing on a Mac

Also direct any other open issues with bounties to me. I am having a hard time finding any.

niyid avatar Feb 20 '24 16:02 niyid

Ok I will assign once at my computer.

The static libraries can be assumed to be downloaded to the .localhost directory, alongside the current monerod and monero-wallet-rpc binaries, and can be installed from there in a presumably similar fashion. Later we can update the build script to automatically download to the .localnet folder from a remote repository.

woodser avatar Feb 20 '24 23:02 woodser

Remember to assign.

I've assigned the issue to you. Please let me know if you're not able to complete so we can re-assign based on availability.

Do you use a Mac? I will need your help testing on a Mac

Yes, I can test proper solutions which should be cross-platform for windows, linux, and mac.

Thanks!

woodser avatar Feb 21 '24 01:02 woodser

Ok I will assign once at my computer.

The static libraries can be assumed to be downloaded to the .localhost directory, alongside the current monerod and monero-wallet-rpc binaries, and can be installed from there in a presumably similar fashion. Later we can update the build script to automatically download to the .localnet folder from a remote repository.

I am currently cloning monero-cpp into ${projectDir} - haveno. Does that work? I can then add monero-cpp to .gitignore

niyid avatar Feb 21 '24 01:02 niyid

Remember to assign.

I've assigned the issue to you. Please let me know if you're not able to complete so we can re-assign based on availability.

Do you use a Mac? I will need your help testing on a Mac

Yes, I can test proper solutions which should be cross-platform for windows, linux, and mac.

Thanks!

Well, I don't own a Mac. I do not know any other way to test but on one. If that is an issue, let me know; or simply unassign. No hard feelings.

niyid avatar Feb 21 '24 01:02 niyid

No we don't want to import the projects directly. Instead we should assume that the static libraries built from the projects are downloaded from a remote repository to haveno/.localnet, the same as how monerod and monero-wallet-rc are currently downloaded to that folder and then made available to the application via gradle config and some Java code. Essentially for testing, I want to be able to copy and paste libmonero-cpp.so and libmonero-java.so into .localnet, build, and have them become available on the classpath of app.

woodser avatar Feb 21 '24 01:02 woodser

I don't own a Mac. I do not know any other way to test but on one

A mac shouldn't be necessary to develop the solution, since it should use gradle config and be platform agnostic, except to hardcode the library extensions (i.e. .so, .dylib, .dll).

With that solution, I don't mind to test on mac to ensure it's working the same as on linux and windows.

woodser avatar Feb 21 '24 01:02 woodser

I don't own a Mac. I do not know any other way to test but on one

A mac shouldn't be necessary to develop the solution, since it should use gradle config and be platform agnostic, except to hardcode the library extensions (i.e. .so, .dylib, .dll).

With that solution, I don't mind to test on mac to ensure it's working the same as on linux and windows.

The libs in https://github.com/woodser/monero-java/releases/download/v0.8.10/libmonero-linux-arm64.zip etc will not work unless of course the list of deps are installed -

sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache

...and of course this must be executed in Gradle. I want to be sure this gives a consistent result across OSes.

@woodser Oh wait...are you saying you expect the user to have these manually preinstalled?

niyid avatar Feb 21 '24 02:02 niyid

Thanks for this. I just realized I had the solution already and I was just complicating things. I will continue with the assumption that all setup is complete and the native libraries for Monero-Java are just being copied to the expected path where they are shared.

On Wed, Feb 21, 2024, 2:55 AM woodser @.***> wrote:

I don't own a Mac. I do not know any other way to test but on one

A mac shouldn't be necessary to develop the solution, since it should use gradle config and be platform agnostic, except to hardcode the library extensions (i.e. .so, .dylib, .dll).

With that solution, I don't mind to test on mac to ensure it's working the same as on linux and windows.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/783#issuecomment-1955726220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWR5NBADYKUUCZAZB5D3YUVHX3AVCNFSM6AAAAABDOLHLD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVG4ZDMMRSGA . You are receiving this because you were assigned.Message ID: @.***>

niyid avatar Feb 21 '24 03:02 niyid

The static libs should bundle their dependencies to be executable standalone, afaik.

Yeah fine to assume the libs have been pre-downloaded to the .localnet, and then the build process should install to make them available at runtime, similar to the monerod and monero-wallet-rpc binaries downloaded to .localnet.

woodser avatar Feb 21 '24 14:02 woodser

The static libs should bundle their dependencies to be executable standalone, afaik.

Yeah fine to assume the libs have been pre-downloaded to the .localnet, and then the build process should install to make them available at runtime, similar to the monerod and monero-wallet-rpc binaries downloaded to .localnet.

Let me get this clearly - the final libs you need in .localnet for the proper functioning of MoneroUtils.loadNativeLibrary() are the .a files (static libraries) and not the .so libs? Are you saying you will be producing the .a files and placing them where they can be downloaded to the user's workspace where they will be referenced during the build process?

niyid avatar Feb 21 '24 20:02 niyid

Yes that's correct, though I'll have some work to do to make the libs static with a dynamic lib wrapper to be imported into JNI. I think that's my todo before you can reliably proceed, since otherwise, the dynamic libraries won't be self-contained.

woodser avatar Feb 22 '24 20:02 woodser

OK then. You can create a new issue that this depends on; and tag me so I get notified when it is completed and closed.

On Thu, Feb 22, 2024, 9:19 PM woodser @.***> wrote:

Yes that's correct, though I'll have some work to do to make the libs static with a dynamic lib wrapper to be imported into JNI. I think that's my todo before you can reliably proceed, since otherwise, the dynamic libraries won't be self-contained.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/783#issuecomment-1960236789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWR6BAOZ2QEVFEMMY623YU6R5NAVCNFSM6AAAAABDOLHLD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQGIZTMNZYHE . You are receiving this because you were assigned.Message ID: @.***>

niyid avatar Feb 22 '24 21:02 niyid

Relies on https://github.com/woodser/monero-java/issues/74

woodser avatar Feb 23 '24 15:02 woodser

Probably we need to update the JDK and JFX to make the native libs work.

woodser avatar Mar 02 '24 14:03 woodser

@woodser

If this task cannot wait a few days, please reassign. But if a delay of a few days is OK, then leave as is. I say this because I see everything appears to be ready.

On Sat, Mar 2, 2024, 3:04 PM woodser @.***> wrote:

Probably we need to update the JDK and JFX to make the native libs work.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/783#issuecomment-1974804702, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWRYE67ANX3DB244EEDLYWHMAHAVCNFSM6AAAAABDOLHLD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUHAYDINZQGI . You are receiving this because you were assigned.Message ID: @.***>

niyid avatar Mar 04 '24 20:03 niyid

Any new commits that I am missing in the latest release? I don't see expected files in .localnet after make build.

niyid avatar Mar 05 '24 16:03 niyid

Not yet. We're trying to upgrade the JDK which will allow the native libraries to be used.

woodser avatar Mar 06 '24 21:03 woodser

Ok, thanks for the update. What issues are you getting trying to update the JDK? What version are you targeting?

On Wed, Mar 6, 2024, 10:57 PM woodser @.***> wrote:

Not yet. We're trying to upgrade the JDK which will allow the native libraries to be used.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/783#issuecomment-1981873711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWR46KHJUOVKGJU5LPBTYW6GNZAVCNFSM6AAAAABDOLHLD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRHA3TGNZRGE . You are receiving this because you were assigned.Message ID: @.***>

niyid avatar Mar 06 '24 21:03 niyid

Targeting JDK 21. The only issue now is fixing the Windows installer.

woodser avatar Mar 06 '24 22:03 woodser

Good news @niyid. Upgrading to JDK 21 has resolved the issue loading the native libraries in Haveno. I have a draft PR to load and test the libraries, which I prepared before this was working: https://github.com/haveno-dex/haveno/pull/813. It works if the shared libraries are first copied into the .localnet directory.

A next step will be to download and extract the shared libraries from a remote repository. I'd like to think about this a bit longer, but it should be straight forward once decided, so no action needed at this time.

woodser avatar Mar 11 '24 15:03 woodser

Native libraries are successfully loading and being used with this PR: https://github.com/haveno-dex/haveno/pull/813

woodser avatar Mar 25 '24 17:03 woodser