Skip to content

Commit

Permalink
upgrade to kotlin 2.1.0
Browse files Browse the repository at this point in the history
And other dependencies. Based on the work made in #701.

We are not using the new `kotlin.Uuid`, as it is still experimental.

Co-authored-by: Dominique Padiou <[email protected]>
  • Loading branch information
pm47 and dpad85 committed Dec 12, 2024
1 parent 7cfdb96 commit 575417f
Show file tree
Hide file tree
Showing 54 changed files with 614 additions and 1,198 deletions.
18 changes: 2 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.gradle
build/
.cxx
.kotlin

# this file is local to the dev environment and must not be pushed!
local.properties
Expand All @@ -24,23 +25,8 @@ gradle-app.setting
*.class
*.log

# sbt specific
.cache/
.history/
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/

# Scala-IDE specific
.scala_dependencies
.worksheet

.idea
*.iml
target/
project/target
DeleteMe*.scala

14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
kotlin = "1.9.23"
kotlinx-coroutines = "1.7.3"
kotlinx-datetime = "0.6.0"
kotlinx-serialization = "1.6.2"
ktor = "2.3.7"
kotlin = "2.1.0"
kotlinx-coroutines = "1.9.0"
kotlinx-datetime = "0.6.1"
kotlinx-serialization = "1.7.3"
ktor = "2.3.13"
bitcoinkmp = "0.21.0" # when upgrading bitcoin-kmp, keep secpjnijvm in sync!
secpjnijvm = "0.16.0"
kermit = "2.0.2"
kermit = "2.0.4"
slf4j = "1.7.36"

# test dependencies
Expand All @@ -18,4 +18,4 @@ test-sqlitejdbc = "3.32.3.3"
[plugins]
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.10" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
35 changes: 16 additions & 19 deletions modules/core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.DefaultCInteropSettings
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
Expand All @@ -14,8 +16,9 @@ val currentOs = org.gradle.internal.os.OperatingSystem.current()

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8) // TODO: update this?
}
}

Expand Down Expand Up @@ -128,15 +131,12 @@ kotlin {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
}

targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
// We use expect/actual for classes (see Chacha20Poly1305CipherFunctions). This feature is in beta and raises a warning.
// See https://youtrack.jetbrains.com/issue/KT-61573
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
}
}
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
allWarningsAsErrors.set(true)
// We use expect/actual for classes (see Chacha20Poly1305CipherFunctions). This feature is in beta and raises a warning.
// See https://youtrack.jetbrains.com/issue/KT-61573
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}

Expand Down Expand Up @@ -212,7 +212,11 @@ afterEvaluate {
compileTaskProvider.get().enabled = false
tasks[processResourcesTaskName].enabled = false
}
binaries.all { linkTask.enabled = false }
binaries.all {
linkTaskProvider {
enabled = false
}
}

mavenPublication {
val publicationToDisable = this
Expand Down Expand Up @@ -292,10 +296,3 @@ tasks
.map {
it.filter.excludeTestsMatching("*MempoolSpace*Test")
}

// Make NS_FORMAT_ARGUMENT(1) a no-op
// This fixes an issue when building PhoenixCrypto using XCode 13
// More on this: https://youtrack.jetbrains.com/issue/KT-48807#focus=Comments-27-5210791.0-0
tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package fr.acinq.lightning.crypto.noise

import fr.acinq.lightning.crypto.ChaCha20Poly1305

expect object Chacha20Poly1305CipherFunctions : CipherFunctions
expect object Chacha20Poly1305CipherFunctions : CipherFunctions {
override fun name(): String
override fun encrypt(k: ByteArray, n: Long, ad: ByteArray, plaintext: ByteArray): ByteArray
override fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertextAndMac: ByteArray): ByteArray
}

/**
* Default implementation for [[Chacha20Poly1305CipherFunctions]]. Can be used by modules by
* Default implementation for [Chacha20Poly1305CipherFunctions]. Can be used by modules by
* defining a type alias.
*/
object Chacha20Poly1305CipherFunctionsDefault : CipherFunctions {
override fun name() = "ChaChaPoly"
override fun name(): String = "ChaChaPoly"

// as specified in BOLT #8
fun nonce(n: Long): ByteArray = ByteArray(4) + ChaCha20Poly1305.write64(n)
Expand All @@ -21,7 +25,6 @@ object Chacha20Poly1305CipherFunctionsDefault : CipherFunctions {
}

// Decrypts ciphertext using a cipher key k of 32 bytes, an 8-byte unsigned integer nonce n, and associated data ad.
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
override fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertextAndMac: ByteArray): ByteArray {
val ciphertext = ciphertextAndMac.dropLast(16).toByteArray()
val mac = ciphertextAndMac.takeLast(16).toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface CipherFunctions {

// Decrypts ciphertext using a cipher key k of 32 bytes, an 8-byte unsigned integer nonce n, and associated data ad.
// Returns the plaintext, unless authentication fails, in which case an error is signaled to the caller.
fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertext: ByteArray): ByteArray
fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertextAndMac: ByteArray): ByteArray
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.acinq.lightning.io

import fr.acinq.lightning.io.TcpSocket.TLS
import fr.acinq.lightning.logging.LoggerFactory

interface TcpSocket {
Expand Down Expand Up @@ -65,6 +66,8 @@ suspend fun TcpSocket.send(bytes: ByteArray, flush: Boolean = true) = send(bytes
suspend fun TcpSocket.receiveFully(buffer: ByteArray) = receiveFully(buffer, 0, buffer.size)
suspend fun TcpSocket.receiveAvailable(buffer: ByteArray) = receiveAvailable(buffer, 0, buffer.size)

internal expect object PlatformSocketBuilder : TcpSocket.Builder
internal expect object PlatformSocketBuilder : TcpSocket.Builder {
override suspend fun connect(host: String, port: Int, tls: TLS, loggerFactory: LoggerFactory): TcpSocket
}

suspend fun TcpSocket.receiveFully(size: Int): ByteArray = ByteArray(size).also { receiveFully(it) }
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ class ElectrumMiniWalletTest : LightningTestSuite() {
client.stop()
}

@Ignore
@Test
//@Test
fun `perf test generator`() = runSuspendTest(timeout = 45.seconds) {
val client = connectToMainnetServer()
val wallet = ElectrumMiniWallet(Block.LivenetGenesisBlock.hash, client, this, logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
"trusted_swap_in_provider": "Optional",
"channel_backup_provider": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"remoteParams": {
Expand Down Expand Up @@ -79,8 +78,7 @@
"channel_backup_client": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"channelFlags": {
Expand All @@ -98,18 +96,13 @@
"paymentPreimage": "470394f1ea93ed652ed8fba12c00dcfe8212c4fd3295f7413f7a927e002ea4eb"
}
],
"signed": [
],
"acked": [
]
"signed": [],
"acked": []
},
"remoteChanges": {
"proposed": [
],
"acked": [
],
"signed": [
]
"proposed": [],
"acked": [],
"signed": []
},
"localNextHtlcId": 1,
"remoteNextHtlcId": 1
Expand Down Expand Up @@ -236,8 +229,7 @@
"nextRemoteCommit": null
}
],
"inactive": [
],
"inactive": [],
"payments": {
"0": "a63c8f54-772a-4912-9b2a-055f7f64ce56"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
"trusted_swap_in_client": "Optional",
"channel_backup_client": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"remoteParams": {
Expand Down Expand Up @@ -79,8 +78,7 @@
"channel_backup_provider": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"channelFlags": {
Expand All @@ -90,20 +88,14 @@
},
"changes": {
"localChanges": {
"proposed": [
],
"signed": [
],
"acked": [
]
"proposed": [],
"signed": [],
"acked": []
},
"remoteChanges": {
"proposed": [
],
"acked": [
],
"signed": [
]
"proposed": [],
"acked": [],
"signed": []
},
"localNextHtlcId": 0,
"remoteNextHtlcId": 0
Expand All @@ -122,10 +114,8 @@
"localCommit": {
"index": 0,
"spec": {
"htlcsIn": [
],
"htlcsOut": [
],
"htlcsIn": [],
"htlcsOut": [],
"feerate": 5000,
"toLocal": 200000000,
"toRemote": 800000000
Expand All @@ -142,17 +132,14 @@
},
"tx": "020000000001012f7c825b61cbbf0e685aef20f8923a8cd28943346e59301b629cc89b4e27cdbd000000000000b77080044a0100000000000022002046672803839d10e21d43eafb532bc37cd21bd97dec7f9b50d45380cd1cce69654a01000000000000220020bbd7f17366848d8f624c28438128ce4dc8c72ea21deb0ccf25bee110920da032400d03000000000022002031dbc67ef6930d0825de6c23bd311eb93d40430d543c0555aa0f15b7aaab0cbc781c0c0000000000220020958bb43c9e6d1b985001c2f4dc38d286d7fde78bb04d7ec5a5ae44d8ebf0c40c040047304402201991b61ae8ef7bf6bd03f6f965552294e7941fce3fc91a024094cbd9b3464dd202206068ef64671e59b5825408e58462613a6ad0edfc7aa23853aea36187298c493901483045022100cca233f9a14605a7adab49f959c5b42260a55156282cbc802397fc934d5e537c02203504b82653044526706d76d3ddf0f083ea77a16f6cc13c93add344069a55cb940147522102b6eaf304d966a6df90f3b3df7af7be6b1625854bbc096cb8b3507b2a37c2bf9c210385cfd7d8850e4cb8fcbed57310911218e5d5e1fd34f92ef5d9db14d56418caa452aede99dc20"
},
"htlcTxsAndSigs": [
]
"htlcTxsAndSigs": []
}
},
"remoteCommit": {
"index": 0,
"spec": {
"htlcsIn": [
],
"htlcsOut": [
],
"htlcsIn": [],
"htlcsOut": [],
"feerate": 5000,
"toLocal": 800000000,
"toRemote": 200000000
Expand All @@ -163,10 +150,8 @@
"nextRemoteCommit": null
}
],
"inactive": [
],
"payments": {
},
"inactive": [],
"payments": {},
"remoteNextCommitInfo": {
"left": null,
"right": "0234ea3e3929ca115acc645d07c40eada7a98d86017614c3fa466d7e19760917e4"
Expand Down
Loading

0 comments on commit 575417f

Please sign in to comment.