Skip to content

Commit

Permalink
Revert "Upgrade to kotlin 2.0.20 (#701)"
Browse files Browse the repository at this point in the history
This reverts commit 0d85f88.
  • Loading branch information
dpad85 committed Sep 26, 2024
1 parent 7383ee2 commit 430abdf
Show file tree
Hide file tree
Showing 52 changed files with 1,196 additions and 613 deletions.
18 changes: 16 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.gradle
build/
.cxx
.kotlin

# this file is local to the dev environment and must not be pushed!
local.properties
Expand All @@ -25,8 +24,23 @@ 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: 26 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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 "2.0.20"
kotlin("plugin.serialization") version "2.0.20"
id("org.jetbrains.dokka") version "1.9.20"
kotlin("multiplatform") version "1.9.23"
kotlin("plugin.serialization") version "1.9.23"
id("org.jetbrains.dokka") version "1.9.10"
`maven-publish`
}

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

val serializationVersion = "1.7.1"
val coroutineVersion = "1.9.0"
val serializationVersion = "1.6.2"
val coroutineVersion = "1.7.3"
val datetimeVersion = "0.6.0"
val ktorVersion = "2.3.12"
val ktorVersion = "2.3.7"
fun ktor(module: String) = "io.ktor:ktor-$module:$ktorVersion"
val kermitLoggerVersion = "2.0.4"
val kermitLoggerVersion = "2.0.2"

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

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

@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")
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"
}
}
}
}

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

mavenPublication {
val publicationToDisable = this
Expand Down Expand Up @@ -321,3 +317,10 @@ 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,18 +2,14 @@ package fr.acinq.lightning.crypto.noise

import fr.acinq.lightning.crypto.ChaCha20Poly1305

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
}
expect object Chacha20Poly1305CipherFunctions : CipherFunctions

/**
* 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(): String = "ChaChaPoly"
override fun name() = "ChaChaPoly"

// as specified in BOLT #8
fun nonce(n: Long): ByteArray = ByteArray(4) + ChaCha20Poly1305.write64(n)
Expand All @@ -25,6 +21,7 @@ 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, ciphertextAndMac: ByteArray): ByteArray
fun decrypt(k: ByteArray, n: Long, ad: ByteArray, ciphertext: ByteArray): ByteArray
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/commonMain/kotlin/fr/acinq/lightning/io/TcpSocket.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.acinq.lightning.io

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

interface TcpSocket {
Expand Down Expand Up @@ -66,8 +65,6 @@ 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 {
override suspend fun connect(host: String, port: Int, tls: TLS, loggerFactory: LoggerFactory): TcpSocket
}
internal expect object PlatformSocketBuilder : TcpSocket.Builder

suspend fun TcpSocket.receiveFully(size: Int): ByteArray = ByteArray(size).also { receiveFully(it) }
24 changes: 16 additions & 8 deletions src/commonTest/resources/nonreg/v2/Closing_0ba41d17/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"trusted_swap_in_provider": "Optional",
"channel_backup_provider": "Optional"
},
"unknown": []
"unknown": [
]
}
},
"remoteParams": {
Expand Down Expand Up @@ -78,7 +79,8 @@
"channel_backup_client": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": []
"unknown": [
]
}
},
"channelFlags": {
Expand All @@ -96,13 +98,18 @@
"paymentPreimage": "470394f1ea93ed652ed8fba12c00dcfe8212c4fd3295f7413f7a927e002ea4eb"
}
],
"signed": [],
"acked": []
"signed": [
],
"acked": [
]
},
"remoteChanges": {
"proposed": [],
"acked": [],
"signed": []
"proposed": [
],
"acked": [
],
"signed": [
]
},
"localNextHtlcId": 1,
"remoteNextHtlcId": 1
Expand Down Expand Up @@ -229,7 +236,8 @@
"nextRemoteCommit": null
}
],
"inactive": [],
"inactive": [
],
"payments": {
"0": "a63c8f54-772a-4912-9b2a-055f7f64ce56"
},
Expand Down
45 changes: 30 additions & 15 deletions src/commonTest/resources/nonreg/v2/Closing_0ed6ff68/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"trusted_swap_in_client": "Optional",
"channel_backup_client": "Optional"
},
"unknown": []
"unknown": [
]
}
},
"remoteParams": {
Expand Down Expand Up @@ -78,7 +79,8 @@
"channel_backup_provider": "Optional",
"trampoline_payment_experimental": "Optional"
},
"unknown": []
"unknown": [
]
}
},
"channelFlags": {
Expand All @@ -88,14 +90,20 @@
},
"changes": {
"localChanges": {
"proposed": [],
"signed": [],
"acked": []
"proposed": [
],
"signed": [
],
"acked": [
]
},
"remoteChanges": {
"proposed": [],
"acked": [],
"signed": []
"proposed": [
],
"acked": [
],
"signed": [
]
},
"localNextHtlcId": 0,
"remoteNextHtlcId": 0
Expand All @@ -114,8 +122,10 @@
"localCommit": {
"index": 0,
"spec": {
"htlcsIn": [],
"htlcsOut": [],
"htlcsIn": [
],
"htlcsOut": [
],
"feerate": 5000,
"toLocal": 200000000,
"toRemote": 800000000
Expand All @@ -132,14 +142,17 @@
},
"tx": "020000000001012f7c825b61cbbf0e685aef20f8923a8cd28943346e59301b629cc89b4e27cdbd000000000000b77080044a0100000000000022002046672803839d10e21d43eafb532bc37cd21bd97dec7f9b50d45380cd1cce69654a01000000000000220020bbd7f17366848d8f624c28438128ce4dc8c72ea21deb0ccf25bee110920da032400d03000000000022002031dbc67ef6930d0825de6c23bd311eb93d40430d543c0555aa0f15b7aaab0cbc781c0c0000000000220020958bb43c9e6d1b985001c2f4dc38d286d7fde78bb04d7ec5a5ae44d8ebf0c40c040047304402201991b61ae8ef7bf6bd03f6f965552294e7941fce3fc91a024094cbd9b3464dd202206068ef64671e59b5825408e58462613a6ad0edfc7aa23853aea36187298c493901483045022100cca233f9a14605a7adab49f959c5b42260a55156282cbc802397fc934d5e537c02203504b82653044526706d76d3ddf0f083ea77a16f6cc13c93add344069a55cb940147522102b6eaf304d966a6df90f3b3df7af7be6b1625854bbc096cb8b3507b2a37c2bf9c210385cfd7d8850e4cb8fcbed57310911218e5d5e1fd34f92ef5d9db14d56418caa452aede99dc20"
},
"htlcTxsAndSigs": []
"htlcTxsAndSigs": [
]
}
},
"remoteCommit": {
"index": 0,
"spec": {
"htlcsIn": [],
"htlcsOut": [],
"htlcsIn": [
],
"htlcsOut": [
],
"feerate": 5000,
"toLocal": 800000000,
"toRemote": 200000000
Expand All @@ -150,8 +163,10 @@
"nextRemoteCommit": null
}
],
"inactive": [],
"payments": {},
"inactive": [
],
"payments": {
},
"remoteNextCommitInfo": {
"left": null,
"right": "0234ea3e3929ca115acc645d07c40eada7a98d86017614c3fa466d7e19760917e4"
Expand Down
Loading

0 comments on commit 430abdf

Please sign in to comment.