diff --git a/.github/workflows/build-and-verify-alignment.yml b/.github/workflows/build-and-verify-alignment.yml new file mode 100644 index 0000000..6dd6d42 --- /dev/null +++ b/.github/workflows/build-and-verify-alignment.yml @@ -0,0 +1,119 @@ +name: Build and Verify 16KB Page Size Alignment + +on: + push: + branches: [ master, main, develop ] + pull_request: + branches: [ master, main, develop ] + +jobs: + build-and-verify: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Install Android NDK + run: | + echo "Installing Android NDK 29.0.14206865..." + $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;29.0.14206865" + echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/29.0.14206865" >> $GITHUB_ENV + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Install SWIG + run: | + sudo apt-get update + sudo apt-get install -y swig + + - name: generate the header file + run: | + cd dash-sdk-bindings + cargo build + cd .. + + - name: Generate SWIG bindings + run: ./gradlew generateSWIG + + - name: Generate Protobuf + run: ./gradlew generateProto + + - name: Build CMake + run: ./gradlew cmakeClean cmakeConfigure cmakeBuild + + - name: Build with Gradle + run: ./gradlew build + + - name: Verify 16KB Page Size Alignment + run: ./scripts/verify-16kb-alignment.sh + + - name: Verify AAR Contents + run: | + echo "🔍 Verifying AAR files contain native libraries..." + + # Find AAR files + aar_files=$(find . -name "*.aar" -path "*/build/outputs/aar/*" -type f) + + if [ -z "$aar_files" ]; then + echo "❌ No AAR files found" + exit 1 + fi + + echo "Found AAR files:" + for aar in $aar_files; do + echo "đŸ“Ļ $(basename $aar)" + + # Check if AAR contains native libraries + native_libs=$(unzip -l "$aar" | grep -E "jni/.*\.so$" | wc -l) + + if [ $native_libs -gt 0 ]; then + echo " ✅ Contains $native_libs native libraries" + echo " 📋 Native library details:" + unzip -l "$aar" | grep -E "jni/.*\.so$" | awk '{print " " $4}' + else + echo " â„šī¸ No native libraries (library may be pure Java/Kotlin)" + fi + echo + done + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: build-outputs + path: | + **/build/outputs/aar/*.aar + **/build/intermediates/cxx/*/obj/*/*.so + retention-days: 7 + + - name: Upload lint reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: lint-reports + path: | + **/build/reports/lint-results-*.html + retention-days: 7 \ No newline at end of file diff --git a/.gitignore b/.gitignore index c2b85cc..fa35442 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ build/ *.spvchain *.wallet -.DS_Store \ No newline at end of file +.DS_Store +local.properties \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1aa2625..e7f8be4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { - ext.version = '2.0.1' - ext.kotlin_version = '1.8.22' + ext.version = '2.0.2-SNAPSHOT' + ext.kotlin_version = '2.1.20' ext.dashj_version = '21.1.7' repositories { google() // Required for Android library and application projects @@ -10,7 +10,7 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.tools.build:gradle:8.1.4' // Use the latest version + classpath 'com.android.tools.build:gradle:8.5.1' classpath "com.google.protobuf:protobuf-gradle-plugin:0.9.4" classpath 'org.jreleaser:jreleaser-gradle-plugin:1.17.0' } diff --git a/dash-sdk-android/build.gradle b/dash-sdk-android/build.gradle index fc987d6..7c0faa7 100644 --- a/dash-sdk-android/build.gradle +++ b/dash-sdk-android/build.gradle @@ -11,7 +11,7 @@ android { defaultConfig { minSdk 24 - targetSdk 32 + targetSdk 35 versionCode 1 versionName project.rootProject.ext.version @@ -26,15 +26,15 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { pickFirst '**/*.so' } - ndkVersion = "23.1.7779620" + ndkVersion = "29.0.14206865" externalNativeBuild { cmake { path 'src/main/cpp/CMakeLists.txt' diff --git a/dash-sdk-android/src/main/cpp/CMakeLists.txt b/dash-sdk-android/src/main/cpp/CMakeLists.txt index 790d79d..4f37b6b 100644 --- a/dash-sdk-android/src/main/cpp/CMakeLists.txt +++ b/dash-sdk-android/src/main/cpp/CMakeLists.txt @@ -42,11 +42,14 @@ file( "${RUST_SOURCE_DIR}/src/*.rs" "${RUST_SOURCE_DIR}/Cargo.toml" ) +# Set RUSTFLAGS for 16KB page alignment +set(RUSTFLAGS_16KB "-C link-arg=-Wl,-z,max-page-size=16384") + # Command to build the Rust Bindings Library add_custom_command( OUTPUT ${RUST_LIB_OUTPUT_PATH} COMMAND ${CMAKE_COMMAND} -E touch ${RUST_SOURCE_DIR}/Cargo.toml - COMMAND cargo +nightly ndk -t ${RUST_TARGET_TRIPLE} -p ${ANDROID_API_LEVEL} build --release -Zbuild-std + COMMAND ${CMAKE_COMMAND} -E env RUSTFLAGS=${RUSTFLAGS_16KB} cargo +nightly ndk -t ${RUST_TARGET_TRIPLE} -p ${ANDROID_API_LEVEL} build --release -Zbuild-std WORKING_DIRECTORY ${RUST_SOURCE_DIR} COMMENT "Building Rust library with cargo ndk" DEPENDS ${RUST_PROJECT_FILES} diff --git a/dash-sdk-android/src/main/rust/Cargo.lock b/dash-sdk-android/src/main/rust/Cargo.lock index 98794ba..14199a9 100644 --- a/dash-sdk-android/src/main/rust/Cargo.lock +++ b/dash-sdk-android/src/main/rust/Cargo.lock @@ -868,7 +868,7 @@ dependencies = [ [[package]] name = "dash-sdk-bindings" -version = "2.0.0" +version = "2.0.2" dependencies = [ "cbindgen 0.26.0", "dash-sdk", @@ -2899,7 +2899,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "platform-mobile" -version = "2.0.0" +version = "2.0.2" dependencies = [ "async-trait", "base64 0.13.1", diff --git a/dash-sdk-android/src/main/rust/Cargo.toml b/dash-sdk-android/src/main/rust/Cargo.toml index f081fe1..8f2c3ec 100644 --- a/dash-sdk-android/src/main/rust/Cargo.toml +++ b/dash-sdk-android/src/main/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dash-sdk-bindings" -version = "2.0.0" +version = "2.0.2" edition = "2021" [dependencies] diff --git a/dash-sdk-bindings/Cargo.lock b/dash-sdk-bindings/Cargo.lock index 0d3323d..7e7af66 100644 --- a/dash-sdk-bindings/Cargo.lock +++ b/dash-sdk-bindings/Cargo.lock @@ -868,7 +868,7 @@ dependencies = [ [[package]] name = "dash-sdk-bindings" -version = "2.0.0" +version = "2.0.2" dependencies = [ "cbindgen 0.26.0", "dash-sdk", @@ -2882,7 +2882,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platform-mobile" -version = "2.0.0" +version = "2.0.2" dependencies = [ "async-trait", "base64 0.13.1", diff --git a/dash-sdk-bindings/Cargo.toml b/dash-sdk-bindings/Cargo.toml index cedb061..9993461 100644 --- a/dash-sdk-bindings/Cargo.toml +++ b/dash-sdk-bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dash-sdk-bindings" -version = "2.0.0" +version = "2.0.2" edition = "2021" [dependencies] diff --git a/dash-sdk-java/src/main/cpp/java_map_string_value.cpp b/dash-sdk-java/src/main/cpp/java_map_string_value.cpp index e8e589b..cf50e23 100644 --- a/dash-sdk-java/src/main/cpp/java_map_string_value.cpp +++ b/dash-sdk-java/src/main/cpp/java_map_string_value.cpp @@ -2,6 +2,7 @@ // Created by Eric Britten on 3/24/24. // #include +#include #include "conversions.h" // TODO: This function needs to handle all of the variants diff --git a/dash-sdk-java/src/main/swig/identity.i b/dash-sdk-java/src/main/swig/identity.i index 55deae3..9c50f74 100644 --- a/dash-sdk-java/src/main/swig/identity.i +++ b/dash-sdk-java/src/main/swig/identity.i @@ -34,7 +34,7 @@ } struct dpp_identity_identity_public_key_v0_IdentityPublicKeyV0 * getPublicKeyById(uint32_t id) { - for (int i = 0; i < $self->public_keys->count; ++i) { + for (uintptr_t i = 0; i < $self->public_keys->count; ++i) { if ($self->public_keys->keys[i]->_0 == id) return $self->public_keys->values[i]->v0._0; } diff --git a/dash-sdk-java/src/main/swig/myexception.i b/dash-sdk-java/src/main/swig/myexception.i index 9567992..64a3942 100644 --- a/dash-sdk-java/src/main/swig/myexception.i +++ b/dash-sdk-java/src/main/swig/myexception.i @@ -4,15 +4,15 @@ %exception { try { $action - } catch(std::string x) { + } catch(std::string& x) { SWIG_exception(SWIG_JavaUnknownError, x.c_str()); - } catch(std::runtime_error x) { - SWIG_exception(SWIG_RuntimeError, x.what()); - } catch(std::invalid_argument x) { + } catch(std::runtime_error& x) { + SWIG_exception(SWIG_RuntimeError, x.what()); + } catch(std::invalid_argument& x) { SWIG_exception(SWIG_TypeError, x.what()); - } catch(std::exception x) { - SWIG_exception(SWIG_UnknownError, x.what()); - } catch(...) { + } catch(std::exception& x) { + SWIG_exception(SWIG_UnknownError, x.what()); + } catch(...) { SWIG_exception(SWIG_UnknownError,"Unknown exception"); } } diff --git a/dashj-platform-android-simple/build.gradle b/dashj-platform-android-simple/build.gradle index 49979e0..7a401b2 100644 --- a/dashj-platform-android-simple/build.gradle +++ b/dashj-platform-android-simple/build.gradle @@ -6,11 +6,11 @@ plugins { android { namespace "org.dashj.platform" - compileSdk 32 + compileSdk 34 defaultConfig { minSdk 24 - targetSdk 32 + targetSdk 35 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -23,15 +23,15 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { pickFirst '**/*.so' } - ndkVersion "25.2.9519653" + ndkVersion "29.0.14206865" } task buildRustRelease() { diff --git a/dpp/build.gradle b/dpp/build.gradle index ba525fe..11d858e 100644 --- a/dpp/build.gradle +++ b/dpp/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java' id 'org.jetbrains.kotlin.jvm' id 'com.google.protobuf' - id('io.gitlab.arturbosch.detekt').version("1.19.0") + id('io.gitlab.arturbosch.detekt').version("1.23.7") id 'maven-publish' id 'signing' id 'org.jreleaser' diff --git a/dpp/src/main/java/org/dashj/platform/dashpay/BlockchainIdentity.kt b/dpp/src/main/java/org/dashj/platform/dashpay/BlockchainIdentity.kt index bdaff6e..62f8daa 100644 --- a/dpp/src/main/java/org/dashj/platform/dashpay/BlockchainIdentity.kt +++ b/dpp/src/main/java/org/dashj/platform/dashpay/BlockchainIdentity.kt @@ -1668,7 +1668,7 @@ class BlockchainIdentity { ) { val query = DocumentQuery.Builder() .where("normalizedParentDomainName", "==", Names.DEFAULT_PARENT_DOMAIN) - .where(listOf("normalizedLabel", "in", usernames.map { it.toLowerCase() })) + .where(listOf("normalizedLabel", "in", usernames.map { it.lowercase() })) .orderBy("normalizedParentDomainName") .orderBy("normalizedLabel") .build() @@ -1677,7 +1677,7 @@ class BlockchainIdentity { if (nameDocuments.isNotEmpty()) { val usernamesLeft = ArrayList(usernames) for (username in usernames) { - val normalizedName = username.toLowerCase() + val normalizedName = username.lowercase() for (nameDocument in nameDocuments) { if (nameDocument.data["normalizedLabel"] == normalizedName) { val usernameStatus = usernameStatuses[username]!! @@ -1733,13 +1733,13 @@ class BlockchainIdentity { ): Pair> { val query = DocumentQuery.Builder() .where("normalizedParentDomainName", "==", Names.DEFAULT_PARENT_DOMAIN) - .where(listOf("normalizedLabel", "in", usernames.map { "${it.toLowerCase()}" })).build() + .where(listOf("normalizedLabel", "in", usernames.map { "${it.lowercase()}" })).build() val nameDocuments = platform.documents.get(Names.DPNS_DOMAIN_DOCUMENT, query) if (nameDocuments.isNotEmpty()) { val usernamesLeft = ArrayList(usernames) for (username in usernames) { - val normalizedName = username.toLowerCase() + val normalizedName = username.lowercase() for (nameDocument in nameDocuments) { if (nameDocument.data["normalizedLabel"] == normalizedName) { val usernameStatus = usernameStatuses[username]!! diff --git a/dpp/src/main/java/org/dashj/platform/dpp/document/DocumentTransition.kt b/dpp/src/main/java/org/dashj/platform/dpp/document/DocumentTransition.kt index f5c9b6b..d62bf30 100644 --- a/dpp/src/main/java/org/dashj/platform/dpp/document/DocumentTransition.kt +++ b/dpp/src/main/java/org/dashj/platform/dpp/document/DocumentTransition.kt @@ -24,11 +24,11 @@ abstract class DocumentTransition(rawStateTransition: MutableMap, } fun getByName(name: String): Action { - return values.filter { it.name.toLowerCase() == name }[0] + return values.filter { it.name.lowercase() == name }[0] } fun getValidNames(): List { - return values.map { it.name.toLowerCase() } + return values.map { it.name.lowercase() } } } } diff --git a/local.properties b/local.properties deleted file mode 100644 index e2e630c..0000000 --- a/local.properties +++ /dev/null @@ -1,9 +0,0 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Sun Oct 02 22:07:07 PDT 2022 -sdk.dir=/Users/hashengineering/Library/Android/sdk -#ndk.dir=/Users/hashengineering/Library/Android/sdk/ndk/23.1.7779620 \ No newline at end of file diff --git a/platform-mobile/Cargo.lock b/platform-mobile/Cargo.lock index 18e0684..9df197f 100644 --- a/platform-mobile/Cargo.lock +++ b/platform-mobile/Cargo.lock @@ -2782,7 +2782,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "platform-mobile" -version = "2.0.0" +version = "2.0.2" dependencies = [ "async-trait", "base64 0.13.1", diff --git a/platform-mobile/Cargo.toml b/platform-mobile/Cargo.toml index 51d29c2..e9c5810 100644 --- a/platform-mobile/Cargo.toml +++ b/platform-mobile/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "platform-mobile" -version = "2.0.0" +version = "2.0.2" edition = "2021" [dependencies] diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..a2ba965 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +cd dash-sdk-bindings +cargo clean +cargo build +cd .. + +./gradlew generateSWIG + +./gradlew generateProto + +./gradlew cmakeClean cmakeConfigure cmakeBuild \ No newline at end of file diff --git a/scripts/verify-16kb-alignment.sh b/scripts/verify-16kb-alignment.sh new file mode 100755 index 0000000..5560c0f --- /dev/null +++ b/scripts/verify-16kb-alignment.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +# 16KB Page Size Alignment Verification Script +# This script verifies that native libraries are properly aligned for 16KB page size compatibility + +set -e + +echo "🔍 Checking 16KB page size alignment of 64-bit native libraries..." + +# Function to check alignment of a shared library +check_alignment() { + local lib_path="$1" + local lib_name=$(basename "$lib_path") + + echo "Checking $lib_name..." + + # Use llvm-readelf from NDK to check alignment + local ndk_path="${ANDROID_NDK_ROOT:-$ANDROID_HOME/ndk/29.0.14206865}" + local readelf="$ndk_path/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf" + + # For macOS, use the darwin prebuilt tools + if [[ "$OSTYPE" == "darwin"* ]]; then + readelf="$ndk_path/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-readelf" + fi + + if [ ! -f "$readelf" ]; then + echo "❌ Error: llvm-readelf not found at $readelf" + echo "💡 Make sure ANDROID_NDK_ROOT is set or NDK is installed at $ANDROID_HOME/ndk/29.0.14206865" + return 1 + fi + + # Check LOAD segments alignment + local alignments=$($readelf -l "$lib_path" | grep "LOAD" | awk '{print $NF}') + + local all_aligned=true + for alignment in $alignments; do + # Convert hex to decimal + local decimal_alignment=$((alignment)) + local kb_alignment=$((decimal_alignment / 1024)) + + echo " Segment alignment: $alignment ($decimal_alignment bytes = ${kb_alignment}KB)" + + if [ $decimal_alignment -ne 16384 ]; then + echo " ❌ Not 16KB aligned (expected 0x4000 = 16384 bytes)" + all_aligned=false + else + echo " ✅ 16KB aligned" + fi + done + + if [ "$all_aligned" = true ]; then + echo "✅ $lib_name is properly 16KB aligned" + return 0 + else + echo "❌ $lib_name has incorrect alignment" + return 1 + fi +} + +# Parse command line arguments +SEARCH_PATH="." +VERBOSE=false +MAX_FILES=20 + +while [[ $# -gt 0 ]]; do + case $1 in + -p|--path) + SEARCH_PATH="$2" + shift 2 + ;; + -v|--verbose) + VERBOSE=true + shift + ;; + -m|--max-files) + MAX_FILES="$2" + shift 2 + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -p, --path PATH Search path for native libraries (default: current directory)" + echo " -v, --verbose Enable verbose output" + echo " -m, --max-files NUM Maximum number of files to check (default: 20)" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use -h or --help for usage information" + exit 1 + ;; + esac +done + +# Find all .so files in build outputs (64-bit architectures only) +echo "Finding 64-bit native libraries in build outputs..." +if [ "$VERBOSE" = true ]; then + echo "Search path: $SEARCH_PATH" + echo "Max files: $MAX_FILES" +fi + +so_files=$(find "$SEARCH_PATH" -path "*/build/intermediates/cxx/*/obj/*/*.so" -type f | grep -E "(Release|RelWithDebInfo)" | grep -E "(arm64-v8a|x86_64)" | head -$MAX_FILES) + +if [ -z "$so_files" ]; then + echo "❌ No native libraries found in build outputs" + echo "💡 Make sure you've built the project first with: ./gradlew build" + exit 1 +fi + +echo "Found native libraries:" +echo "$so_files" +echo + +# Check alignment for each library +all_libs_aligned=true +for so_file in $so_files; do + if ! check_alignment "$so_file"; then + all_libs_aligned=false + fi + echo +done + +# Summary +echo "📊 Alignment Verification Summary:" +if [ "$all_libs_aligned" = true ]; then + echo "🎉 All native libraries are properly 16KB aligned!" + echo "✅ This build is compatible with 16KB page size devices" +else + echo "❌ Some libraries are not properly aligned" + echo "💡 Ensure you're using Android Gradle Plugin 8.5.1+ and target SDK 35+" + exit 1 +fi \ No newline at end of file