Skip to content

Commit 6d885d2

Browse files
Upgrade to kotlin 2.0.20 (#701)
And other dependencies. We are not using the new `kotlin.Uuid`, as they are still experimental. Co-authored-by: Dominique Padiou <[email protected]>
1 parent 8bff6ab commit 6d885d2

File tree

52 files changed

+622
-1214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+622
-1214
lines changed

.gitignore

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.gradle
22
build/
33
.cxx
4+
.kotlin
45

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

27-
# sbt specific
28-
.cache/
29-
.history/
30-
.lib/
31-
dist/*
32-
target/
33-
lib_managed/
34-
src_managed/
35-
project/boot/
36-
project/plugins/project/
37-
38-
# Scala-IDE specific
39-
.scala_dependencies
40-
.worksheet
41-
4228
.idea
4329
*.iml
4430
target/
4531
project/target
46-
DeleteMe*.scala
32+

build.gradle.kts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
13
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
24
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
35
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
46

57
plugins {
6-
kotlin("multiplatform") version "1.9.23"
7-
kotlin("plugin.serialization") version "1.9.23"
8-
id("org.jetbrains.dokka") version "1.9.10"
8+
kotlin("multiplatform") version "2.0.20"
9+
kotlin("plugin.serialization") version "2.0.20"
10+
id("org.jetbrains.dokka") version "1.9.20"
911
`maven-publish`
1012
}
1113

@@ -30,16 +32,17 @@ kotlin {
3032
val bitcoinKmpVersion = "0.20.0" // when upgrading bitcoin-kmp, keep secpJniJvmVersion in sync!
3133
val secpJniJvmVersion = "0.15.0"
3234

33-
val serializationVersion = "1.6.2"
34-
val coroutineVersion = "1.7.3"
35+
val serializationVersion = "1.7.1"
36+
val coroutineVersion = "1.9.0"
3537
val datetimeVersion = "0.6.0"
36-
val ktorVersion = "2.3.7"
38+
val ktorVersion = "2.3.12"
3739
fun ktor(module: String) = "io.ktor:ktor-$module:$ktorVersion"
38-
val kermitLoggerVersion = "2.0.2"
40+
val kermitLoggerVersion = "2.0.4"
3941

4042
jvm {
41-
compilations.all {
42-
kotlinOptions.jvmTarget = "1.8"
43+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
44+
compilerOptions {
45+
jvmTarget.set(JvmTarget.JVM_1_8) // TODO: update this?
4346
}
4447
}
4548

@@ -153,15 +156,12 @@ kotlin {
153156
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
154157
}
155158

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

@@ -237,7 +237,11 @@ afterEvaluate {
237237
compileTaskProvider.get().enabled = false
238238
tasks[processResourcesTaskName].enabled = false
239239
}
240-
binaries.all { linkTask.enabled = false }
240+
binaries.all {
241+
linkTaskProvider {
242+
enabled = false
243+
}
244+
}
241245

242246
mavenPublication {
243247
val publicationToDisable = this
@@ -318,10 +322,3 @@ tasks
318322
.map {
319323
it.filter.excludeTestsMatching("*MempoolSpace*Test")
320324
}
321-
322-
// Make NS_FORMAT_ARGUMENT(1) a no-op
323-
// This fixes an issue when building PhoenixCrypto using XCode 13
324-
// More on this: https://youtrack.jetbrains.com/issue/KT-48807#focus=Comments-27-5210791.0-0
325-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class.java) {
326-
settings.compilerOpts("-DNS_FORMAT_ARGUMENT(A)=")
327-
}

src/commonMain/kotlin/fr/acinq/lightning/crypto/noise/Chacha20Poly1305CipherFunctions.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ package fr.acinq.lightning.crypto.noise
22

33
import fr.acinq.lightning.crypto.ChaCha20Poly1305
44

5-
expect object Chacha20Poly1305CipherFunctions : CipherFunctions
5+
expect object Chacha20Poly1305CipherFunctions : CipherFunctions {
6+
override fun name(): String
7+
override fun encrypt(k: ByteArray, n: Long, ad: ByteArray, plaintext: ByteArray): ByteArray
8+
override fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertextAndMac: ByteArray): ByteArray
9+
}
610

711
/**
8-
* Default implementation for [[Chacha20Poly1305CipherFunctions]]. Can be used by modules by
12+
* Default implementation for [Chacha20Poly1305CipherFunctions]. Can be used by modules by
913
* defining a type alias.
1014
*/
1115
object Chacha20Poly1305CipherFunctionsDefault : CipherFunctions {
12-
override fun name() = "ChaChaPoly"
16+
override fun name(): String = "ChaChaPoly"
1317

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

2327
// Decrypts ciphertext using a cipher key k of 32 bytes, an 8-byte unsigned integer nonce n, and associated data ad.
24-
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
2528
override fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertextAndMac: ByteArray): ByteArray {
2629
val ciphertext = ciphertextAndMac.dropLast(16).toByteArray()
2730
val mac = ciphertextAndMac.takeLast(16).toByteArray()

src/commonMain/kotlin/fr/acinq/lightning/crypto/noise/Noise.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface CipherFunctions {
2424

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

3030
/**

src/commonMain/kotlin/fr/acinq/lightning/io/TcpSocket.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.acinq.lightning.io
22

3+
import fr.acinq.lightning.io.TcpSocket.TLS
34
import fr.acinq.lightning.logging.LoggerFactory
45

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

68-
internal expect object PlatformSocketBuilder : TcpSocket.Builder
69+
internal expect object PlatformSocketBuilder : TcpSocket.Builder {
70+
override suspend fun connect(host: String, port: Int, tls: TLS, loggerFactory: LoggerFactory): TcpSocket
71+
}
6972

7073
suspend fun TcpSocket.receiveFully(size: Int): ByteArray = ByteArray(size).also { receiveFully(it) }

src/commonTest/resources/nonreg/v2/Closing_0ba41d17/data.json

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
"trusted_swap_in_provider": "Optional",
4444
"channel_backup_provider": "Optional"
4545
},
46-
"unknown": [
47-
]
46+
"unknown": []
4847
}
4948
},
5049
"remoteParams": {
@@ -78,8 +77,7 @@
7877
"channel_backup_client": "Optional",
7978
"trampoline_payment_experimental": "Optional"
8079
},
81-
"unknown": [
82-
]
80+
"unknown": []
8381
}
8482
},
8583
"channelFlags": 0
@@ -94,18 +92,13 @@
9492
"paymentPreimage": "470394f1ea93ed652ed8fba12c00dcfe8212c4fd3295f7413f7a927e002ea4eb"
9593
}
9694
],
97-
"signed": [
98-
],
99-
"acked": [
100-
]
95+
"signed": [],
96+
"acked": []
10197
},
10298
"remoteChanges": {
103-
"proposed": [
104-
],
105-
"acked": [
106-
],
107-
"signed": [
108-
]
99+
"proposed": [],
100+
"acked": [],
101+
"signed": []
109102
},
110103
"localNextHtlcId": 1,
111104
"remoteNextHtlcId": 1
@@ -232,8 +225,7 @@
232225
"nextRemoteCommit": null
233226
}
234227
],
235-
"inactive": [
236-
],
228+
"inactive": [],
237229
"payments": {
238230
"0": "a63c8f54-772a-4912-9b2a-055f7f64ce56"
239231
},

src/commonTest/resources/nonreg/v2/Closing_0ed6ff68/data.json

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
"trusted_swap_in_client": "Optional",
4444
"channel_backup_client": "Optional"
4545
},
46-
"unknown": [
47-
]
46+
"unknown": []
4847
}
4948
},
5049
"remoteParams": {
@@ -78,28 +77,21 @@
7877
"channel_backup_provider": "Optional",
7978
"trampoline_payment_experimental": "Optional"
8079
},
81-
"unknown": [
82-
]
80+
"unknown": []
8381
}
8482
},
8583
"channelFlags": 0
8684
},
8785
"changes": {
8886
"localChanges": {
89-
"proposed": [
90-
],
91-
"signed": [
92-
],
93-
"acked": [
94-
]
87+
"proposed": [],
88+
"signed": [],
89+
"acked": []
9590
},
9691
"remoteChanges": {
97-
"proposed": [
98-
],
99-
"acked": [
100-
],
101-
"signed": [
102-
]
92+
"proposed": [],
93+
"acked": [],
94+
"signed": []
10395
},
10496
"localNextHtlcId": 0,
10597
"remoteNextHtlcId": 0
@@ -118,10 +110,8 @@
118110
"localCommit": {
119111
"index": 0,
120112
"spec": {
121-
"htlcsIn": [
122-
],
123-
"htlcsOut": [
124-
],
113+
"htlcsIn": [],
114+
"htlcsOut": [],
125115
"feerate": 5000,
126116
"toLocal": 200000000,
127117
"toRemote": 800000000
@@ -138,17 +128,14 @@
138128
},
139129
"tx": "020000000001012f7c825b61cbbf0e685aef20f8923a8cd28943346e59301b629cc89b4e27cdbd000000000000b77080044a0100000000000022002046672803839d10e21d43eafb532bc37cd21bd97dec7f9b50d45380cd1cce69654a01000000000000220020bbd7f17366848d8f624c28438128ce4dc8c72ea21deb0ccf25bee110920da032400d03000000000022002031dbc67ef6930d0825de6c23bd311eb93d40430d543c0555aa0f15b7aaab0cbc781c0c0000000000220020958bb43c9e6d1b985001c2f4dc38d286d7fde78bb04d7ec5a5ae44d8ebf0c40c040047304402201991b61ae8ef7bf6bd03f6f965552294e7941fce3fc91a024094cbd9b3464dd202206068ef64671e59b5825408e58462613a6ad0edfc7aa23853aea36187298c493901483045022100cca233f9a14605a7adab49f959c5b42260a55156282cbc802397fc934d5e537c02203504b82653044526706d76d3ddf0f083ea77a16f6cc13c93add344069a55cb940147522102b6eaf304d966a6df90f3b3df7af7be6b1625854bbc096cb8b3507b2a37c2bf9c210385cfd7d8850e4cb8fcbed57310911218e5d5e1fd34f92ef5d9db14d56418caa452aede99dc20"
140130
},
141-
"htlcTxsAndSigs": [
142-
]
131+
"htlcTxsAndSigs": []
143132
}
144133
},
145134
"remoteCommit": {
146135
"index": 0,
147136
"spec": {
148-
"htlcsIn": [
149-
],
150-
"htlcsOut": [
151-
],
137+
"htlcsIn": [],
138+
"htlcsOut": [],
152139
"feerate": 5000,
153140
"toLocal": 800000000,
154141
"toRemote": 200000000
@@ -159,10 +146,8 @@
159146
"nextRemoteCommit": null
160147
}
161148
],
162-
"inactive": [
163-
],
164-
"payments": {
165-
},
149+
"inactive": [],
150+
"payments": {},
166151
"remoteNextCommitInfo": {
167152
"left": null,
168153
"right": "0234ea3e3929ca115acc645d07c40eada7a98d86017614c3fa466d7e19760917e4"

0 commit comments

Comments
 (0)