Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to kotlin 2.0.20 #701

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

49 changes: 23 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest

plugins {
kotlin("multiplatform") version "1.9.23"
kotlin("plugin.serialization") version "1.9.23"
id("org.jetbrains.dokka") version "1.9.10"
kotlin("multiplatform") version "2.0.20"
kotlin("plugin.serialization") version "2.0.20"
id("org.jetbrains.dokka") version "1.9.20"
`maven-publish`
}

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

val serializationVersion = "1.6.2"
val coroutineVersion = "1.7.3"
val serializationVersion = "1.7.2"
pm47 marked this conversation as resolved.
Show resolved Hide resolved
val coroutineVersion = "1.9.0"
val datetimeVersion = "0.6.0"
val ktorVersion = "2.3.7"
val ktorVersion = "2.3.12"
fun ktor(module: String) = "io.ktor:ktor-$module:$ktorVersion"
val kermitLoggerVersion = "2.0.2"
val kermitLoggerVersion = "2.0.4"

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

Expand Down Expand Up @@ -153,15 +156,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 @@ -237,7 +237,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 @@ -318,10 +322,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
5 changes: 4 additions & 1 deletion src/commonMain/kotlin/fr/acinq/lightning/io/TcpSocket.kt
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) }
24 changes: 8 additions & 16 deletions src/commonTest/resources/nonreg/v2/Closing_0ba41d17/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"trusted_swap_in_provider": "Optional",
"channel_backup_provider": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"remoteParams": {
Expand Down Expand Up @@ -78,8 +77,7 @@
"channel_backup_client": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"channelFlags": 0
Expand All @@ -94,18 +92,13 @@
"paymentPreimage": "470394f1ea93ed652ed8fba12c00dcfe8212c4fd3295f7413f7a927e002ea4eb"
}
],
"signed": [
],
"acked": [
]
"signed": [],
"acked": []
},
"remoteChanges": {
"proposed": [
],
"acked": [
],
"signed": [
]
"proposed": [],
"acked": [],
"signed": []
},
"localNextHtlcId": 1,
"remoteNextHtlcId": 1
Expand Down Expand Up @@ -232,8 +225,7 @@
"nextRemoteCommit": null
}
],
"inactive": [
],
"inactive": [],
"payments": {
"0": "a63c8f54-772a-4912-9b2a-055f7f64ce56"
},
Expand Down
45 changes: 15 additions & 30 deletions src/commonTest/resources/nonreg/v2/Closing_0ed6ff68/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"trusted_swap_in_client": "Optional",
"channel_backup_client": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"remoteParams": {
Expand Down Expand Up @@ -78,28 +77,21 @@
"channel_backup_provider": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": [
]
"unknown": []
}
},
"channelFlags": 0
},
"changes": {
"localChanges": {
"proposed": [
],
"signed": [
],
"acked": [
]
"proposed": [],
"signed": [],
"acked": []
},
"remoteChanges": {
"proposed": [
],
"acked": [
],
"signed": [
]
"proposed": [],
"acked": [],
"signed": []
},
"localNextHtlcId": 0,
"remoteNextHtlcId": 0
Expand All @@ -118,10 +110,8 @@
"localCommit": {
"index": 0,
"spec": {
"htlcsIn": [
],
"htlcsOut": [
],
"htlcsIn": [],
"htlcsOut": [],
"feerate": 5000,
"toLocal": 200000000,
"toRemote": 800000000
Expand All @@ -138,17 +128,14 @@
},
"tx": "020000000001012f7c825b61cbbf0e685aef20f8923a8cd28943346e59301b629cc89b4e27cdbd000000000000b77080044a0100000000000022002046672803839d10e21d43eafb532bc37cd21bd97dec7f9b50d45380cd1cce69654a01000000000000220020bbd7f17366848d8f624c28438128ce4dc8c72ea21deb0ccf25bee110920da032400d03000000000022002031dbc67ef6930d0825de6c23bd311eb93d40430d543c0555aa0f15b7aaab0cbc781c0c0000000000220020958bb43c9e6d1b985001c2f4dc38d286d7fde78bb04d7ec5a5ae44d8ebf0c40c040047304402201991b61ae8ef7bf6bd03f6f965552294e7941fce3fc91a024094cbd9b3464dd202206068ef64671e59b5825408e58462613a6ad0edfc7aa23853aea36187298c493901483045022100cca233f9a14605a7adab49f959c5b42260a55156282cbc802397fc934d5e537c02203504b82653044526706d76d3ddf0f083ea77a16f6cc13c93add344069a55cb940147522102b6eaf304d966a6df90f3b3df7af7be6b1625854bbc096cb8b3507b2a37c2bf9c210385cfd7d8850e4cb8fcbed57310911218e5d5e1fd34f92ef5d9db14d56418caa452aede99dc20"
},
"htlcTxsAndSigs": [
]
"htlcTxsAndSigs": []
}
},
"remoteCommit": {
"index": 0,
"spec": {
"htlcsIn": [
],
"htlcsOut": [
],
"htlcsIn": [],
"htlcsOut": [],
"feerate": 5000,
"toLocal": 800000000,
"toRemote": 200000000
Expand All @@ -159,10 +146,8 @@
"nextRemoteCommit": null
}
],
"inactive": [
],
"payments": {
},
"inactive": [],
"payments": {},
"remoteNextCommitInfo": {
"left": null,
"right": "0234ea3e3929ca115acc645d07c40eada7a98d86017614c3fa466d7e19760917e4"
Expand Down
Loading