Skip to content

Conversation

@sstone
Copy link
Member

@sstone sstone commented Mar 10, 2025

See ACINQ/secp256k1-kmp#120 for limitations.
I checked that phoenixd starts correctly on an AWS arm64 machine (with AWS Linux 2023).

@sstone sstone requested a review from pm47 March 10, 2025 20:51
@sstone sstone added the enhancement New feature or request label Mar 13, 2025
@sstone sstone linked an issue Mar 13, 2025 that may be closed by this pull request
pm47 added a commit that referenced this pull request Mar 18, 2025
The Alpine base image causes systematic crash for some libsecp256k1
operations. JNI-related issues related to the use of `musl` instead of
`glibc` are well documented.

The issue is fixed by switching alpine for ubuntu, which is
`glibc`-based. Note that it makes the final image significantly larger
(502MB vs 313MB).

The goal of using the JVM on docker was for compatibility with ARM. Once
we support native ARM on Linux (#157), we could potentially move back to
Alpine with native phoenixd, an even smaller footprint than before.

Fixes #159.
pm47 added a commit that referenced this pull request Mar 18, 2025
The Alpine base image causes systematic crash for some libsecp256k1
operations. JNI-related issues related to the use of `musl` instead of
`glibc` are well documented.

The issue is fixed by switching alpine for ubuntu, which is
`glibc`-based. Note that it makes the final image significantly larger
(502MB vs 313MB).

The goal of using the JVM on docker was for compatibility with ARM. Once
we support native ARM on Linux (#157), we could potentially move back to
Alpine with native phoenixd, an even smaller footprint than before.

Fixes #159.
@pm47
Copy link
Member

pm47 commented Mar 18, 2025

This builds and runs, but we get an SSL error immediately:

kotlin.IllegalStateException: 
TLS verification failed for request: 
CurlRequestData(url='https://mempool.space/testnet/api/v1/fees/recommended', method='GET', content: 0 bytes). 
Reason: SSL peer certificate or SSH remote key was not OK

@sethforprivacy
Copy link
Contributor

This builds and runs, but we get an SSL error immediately:

kotlin.IllegalStateException: 
TLS verification failed for request: 
CurlRequestData(url='https://mempool.space/testnet/api/v1/fees/recommended', method='GET', content: 0 bytes). 
Reason: SSL peer certificate or SSH remote key was not OK

Very likely the switch to Ubuntu also means you need to install the ca-certificates package in the final image if you were testing using Docker!

Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

Needs rebase, otherwise LGTM.

Starblocks is running on arm64.

@pm47
Copy link
Member

pm47 commented Apr 16, 2025

This builds and runs, but we get an SSL error immediately:

kotlin.IllegalStateException: 
TLS verification failed for request: 
CurlRequestData(url='https://mempool.space/testnet/api/v1/fees/recommended', method='GET', content: 0 bytes). 
Reason: SSL peer certificate or SSH remote key was not OK

Very likely the switch to Ubuntu also means you need to install the ca-certificates package in the final image if you were testing using Docker!

The SSL issue was due to https://youtrack.jetbrains.com/issue/KTOR-8339, we added a workaround in ACINQ/lightning-kmp#769.

@pm47 pm47 marked this pull request as ready for review April 16, 2025 16:03
@pm47
Copy link
Member

pm47 commented Apr 16, 2025

I went ahead and rebased.

@pm47
Copy link
Member

pm47 commented Apr 16, 2025

@sethforprivacy Do you know how to create a cross-platform dockerfile for native phoenixd?

@pm47 pm47 merged commit 583991a into master Apr 16, 2025
@pm47 pm47 deleted the linux-arm64 branch April 16, 2025 16:33
@sethforprivacy
Copy link
Contributor

@sethforprivacy
Copy link
Contributor

This Dockerfile was working before for arm64 builds so should form a good base, I'll re-test it once you cut a release with the fixes in this PR:

https://github.com/sethforprivacy/phoenixd-docker/blob/1ac2de4c5b3e32408f21d2627ddc04efcac6374a/Dockerfile

@chrisguida
Copy link

What am I doing wrong?

2025-04-16 11:16:14 cguida@cg-carbon:~/code/phoenixd$ ./gradlew linuxArm64DistZip
Downloading https://services.gradle.org/distributions/gradle-8.9-bin.zip
............10%.............20%.............30%.............40%.............50%.............60%.............70%.............80%.............90%.............100%

Welcome to Gradle 8.9!

Here are the highlights of this release:
 - Enhanced Error and Warning Messages
 - IDE Integration Improvements
 - Daemon JVM Information

For more details see https://docs.gradle.org/8.9/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :cinteropSqliteLinuxArm64
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
Downloading dependency https://download.jetbrains.com/kotlin/native/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz to /home/cguida/.konan/dependencies/cache/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/resources/llvm/16.0.0-x86_64-linux/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz to /home/cguida/.konan/dependencies/cache/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/libffi-3.2.1-2-linux-x86-64.tar.gz to /home/cguida/.konan/dependencies/cache/libffi-3.2.1-2-linux-x86-64.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/libffi-3.2.1-2-linux-x86-64.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/qemu-aarch64-static-5.1.0-linux-2.tar.gz to /home/cguida/.konan/dependencies/cache/qemu-aarch64-static-5.1.0-linux-2.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/qemu-aarch64-static-5.1.0-linux-2.tar.gz into /home/cguida/.konan/dependencies

> Task :cinteropSqliteLinuxArm64 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cinteropSqliteLinuxArm64'.
> Could not resolve all files for configuration ':linuxArm64CInterop'.
   > Could not find fr.acinq.lightning:lightning-kmp-core:1.9.2-SNAPSHOT.
     Searched in the following locations:
       - file:/home/cguida/.m2/repository/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - file:/home/cguida/.m2/repository/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://oss.sonatype.org/content/repositories/snapshots/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://oss.sonatype.org/content/repositories/snapshots/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://repo.maven.apache.org/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://dl.google.com/dl/android/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://dl.google.com/dl/android/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
     Required by:
         project :

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2m
2 actionable tasks: 2 executed

@sethforprivacy
Copy link
Contributor

What am I doing wrong?

2025-04-16 11:16:14 cguida@cg-carbon:~/code/phoenixd$ ./gradlew linuxArm64DistZip
Downloading https://services.gradle.org/distributions/gradle-8.9-bin.zip
............10%.............20%.............30%.............40%.............50%.............60%.............70%.............80%.............90%.............100%

Welcome to Gradle 8.9!

Here are the highlights of this release:
 - Enhanced Error and Warning Messages
 - IDE Integration Improvements
 - Daemon JVM Information

For more details see https://docs.gradle.org/8.9/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :cinteropSqliteLinuxArm64
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
Downloading dependency https://download.jetbrains.com/kotlin/native/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz to /home/cguida/.konan/dependencies/cache/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/resources/llvm/16.0.0-x86_64-linux/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz to /home/cguida/.konan/dependencies/cache/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/llvm-16.0.0-x86_64-linux-essentials-80.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/libffi-3.2.1-2-linux-x86-64.tar.gz to /home/cguida/.konan/dependencies/cache/libffi-3.2.1-2-linux-x86-64.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/libffi-3.2.1-2-linux-x86-64.tar.gz into /home/cguida/.konan/dependencies
Downloading dependency https://download.jetbrains.com/kotlin/native/qemu-aarch64-static-5.1.0-linux-2.tar.gz to /home/cguida/.konan/dependencies/cache/qemu-aarch64-static-5.1.0-linux-2.tar.gz
Done.
Extracting dependency: /home/cguida/.konan/dependencies/cache/qemu-aarch64-static-5.1.0-linux-2.tar.gz into /home/cguida/.konan/dependencies

> Task :cinteropSqliteLinuxArm64 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cinteropSqliteLinuxArm64'.
> Could not resolve all files for configuration ':linuxArm64CInterop'.
   > Could not find fr.acinq.lightning:lightning-kmp-core:1.9.2-SNAPSHOT.
     Searched in the following locations:
       - file:/home/cguida/.m2/repository/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - file:/home/cguida/.m2/repository/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://oss.sonatype.org/content/repositories/snapshots/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://oss.sonatype.org/content/repositories/snapshots/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://repo.maven.apache.org/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
       - https://dl.google.com/dl/android/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/maven-metadata.xml
       - https://dl.google.com/dl/android/maven2/fr/acinq/lightning/lightning-kmp-core/1.9.2-SNAPSHOT/lightning-kmp-core-1.9.2-SNAPSHOT.pom
     Required by:
         project :

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2m
2 actionable tasks: 2 executed

Pretty sure they need to push updates to lightning-kmp-core before you can build master. Just wait for a release :)

@chrisguida
Copy link

Gotcha

Jumped the gun hahaha

tlindi pushed a commit to tlindi/phoenixd that referenced this pull request Apr 20, 2025
The binary must be built **on x86** with:
```
./gradlew linuxArm64DistZip
```

Fixes ACINQ#137.

---------

Co-Authored-By: pm47 <[email protected]>
tlindi pushed a commit to tlindi/phoenixd that referenced this pull request Apr 21, 2025
The binary must be built **on x86** with:
```
./gradlew linuxArm64DistZip
```

Fixes ACINQ#137.

---------

Co-Authored-By: pm47 <[email protected]>
tlindi pushed a commit to tlindi/phoenixd that referenced this pull request Apr 21, 2025
The binary must be built **on x86** with:
```
./gradlew linuxArm64DistZip
```

Fixes ACINQ#137.

---------

Co-Authored-By: pm47 <[email protected]>
pm47 added a commit that referenced this pull request May 12, 2025
This a follow-up to #161, specifically:
> The goal of using the JVM on docker was for compatibility with ARM. Once we support native ARM on Linux (#157), we could potentially move back to Alpine with native phoenixd, an even smaller footprint than before.

I didn't go with Alpine because it isn't glibc based and we could run into compat issues. Nevertheless, with Debian slim the image size has been reduced from 230MB to 40MB (-80%).

Cross-platform build:
```shell
docker buildx build --platform linux/amd64,linux/arm64 -t acinq/phoenixd:0.6.0 --push .docker
```

From now on the image will be published on docker hub: https://hub.docker.com/repository/docker/acinq/phoenixd/general.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: support ARM64 Linux

5 participants