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

Dependencies sweep #376

Merged
merged 7 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ plugins {

id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false

id("com.github.ben-manes.versions").version("0.48.0")
id("com.github.ben-manes.versions").version("0.51.0")
id("idea")
id("io.gitlab.arturbosch.detekt").version("1.22.0")
id("java")
id("maven-publish")
id("org.jetbrains.dokka").version("1.9.20")
id("com.diffplug.spotless").version("6.21.0")
id("com.diffplug.spotless").version("6.25.0")
id("java-test-fixtures")
id("io.spring.dependency-management").version("1.1.3")
id("io.spring.dependency-management").version("1.1.6")

id("org.jetbrains.kotlin.android") version kotlinVersion apply false
id("com.android.application") version "7.4.2" apply false
Expand Down Expand Up @@ -115,7 +115,11 @@ configure(
"ktlint_standard_no-wildcard-imports" to "disabled",
"ktlint_standard_enum-entry-name-case" to "disabled",
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled"
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
"ktlint_standard_value-parameter-comment" to "disabled",
"ktlint_standard_value-argument-comment" to "disabled",
"ktlint_standard_property-naming" to "disabled",
"ktlint_standard_function-naming" to "disabled"
)
)
}
Expand Down
1 change: 1 addition & 0 deletions examples/android-chatter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ android {
packagingOptions {
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
}
kotlinOptions {
jvmTarget = "11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ typealias OnChatMessage = (PeerId, String) -> Unit

class Chat(chatCallback: OnChatMessage) : ChatBinding(ChatProtocol(chatCallback))

const val protocolId: ProtocolId = "/example/chat/0.1.0"
const val PROTOCOL_ID: ProtocolId = "/example/chat/0.1.0"

open class ChatBinding(echo: ChatProtocol) : StrictProtocolBinding<ChatController>(protocolId, echo)
open class ChatBinding(echo: ChatProtocol) : StrictProtocolBinding<ChatController>(PROTOCOL_ID, echo)

open class ChatProtocol(
private val chatCallback: OnChatMessage
Expand Down
2 changes: 1 addition & 1 deletion libp2p/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.google.protobuf").version("0.9.4")
id("me.champeau.jmh").version("0.7.1")
id("me.champeau.jmh").version("0.7.2")
}

// https://docs.gradle.org/current/userguide/java_testing.html#ex-disable-publishing-of-test-fixtures-variants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.util.concurrent.CompletableFuture
/**
* Represents [ProtocolBinding] with exact protocol version which was agreed on
*/
open class NegotiatedProtocol<TController, TBinding : ProtocolBinding<TController>> (
open class NegotiatedProtocol<TController, TBinding : ProtocolBinding<TController>>(
val binding: TBinding,
val protocol: ProtocolId
) {
Expand Down
4 changes: 2 additions & 2 deletions libp2p/src/main/kotlin/io/libp2p/crypto/Libp2pCrypto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import org.bouncycastle.crypto.macs.HMac
import org.bouncycastle.crypto.params.KeyParameter

/**
* ErrRsaKeyTooSmall is returned when trying to generate or parse an RSA key
* ERR_RSA_KEY_TOO_SMALL is returned when trying to generate or parse an RSA key
* that's smaller than 512 bits. Keys need to be larger enough to sign a 256bit
* hash so this is a reasonable absolute minimum.
*/
const val ErrRsaKeyTooSmall = "rsa keys must be >= 512 bits to be useful"
const val ERR_RSA_KEY_TOO_SMALL = "rsa keys must be >= 512 bits to be useful"

const val RSA_ALGORITHM = "RSA"
const val SHA_ALGORITHM = "SHA-256"
Expand Down
4 changes: 2 additions & 2 deletions libp2p/src/main/kotlin/io/libp2p/crypto/keys/Rsa.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import crypto.pb.Crypto
import io.libp2p.core.Libp2pException
import io.libp2p.core.crypto.PrivKey
import io.libp2p.core.crypto.PubKey
import io.libp2p.crypto.ErrRsaKeyTooSmall
import io.libp2p.crypto.ERR_RSA_KEY_TOO_SMALL
import io.libp2p.crypto.KEY_PKCS8
import io.libp2p.crypto.Libp2pCrypto
import io.libp2p.crypto.RSA_ALGORITHM
Expand Down Expand Up @@ -100,7 +100,7 @@ class RsaPublicKey(private val k: JavaPublicKey) : PubKey(Crypto.KeyType.RSA) {
@JvmOverloads
fun generateRsaKeyPair(bits: Int, random: SecureRandom = SecureRandom()): Pair<PrivKey, PubKey> {
if (bits < 2048) {
throw Libp2pException(ErrRsaKeyTooSmall)
throw Libp2pException(ERR_RSA_KEY_TOO_SMALL)
}

val kp: KeyPair = with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import java.net.SocketAddress
*/
abstract class AbstractChildChannel(parent: Channel, id: ChannelId?) : AbstractChannel(parent, id) {
private enum class State {
OPEN, ACTIVE, INACTIVE, CLOSED
OPEN,
ACTIVE,
INACTIVE,
CLOSED
}

private val parentCloseFuture = parent.closeFuture()
Expand Down
4 changes: 3 additions & 1 deletion libp2p/src/main/kotlin/io/libp2p/pubsub/SeenCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class SimpleSeenCache<TValue> : SeenCache<TValue> {
override fun put(msg: PubsubMessage, value: TValue) {
map[msg.messageId] = value
}
override fun remove(messageId: MessageId) { map -= messageId }
override fun remove(messageId: MessageId) {
map -= messageId
}
}

class LRUSeenCache<TValue>(val delegate: SeenCache<TValue>, private val maxSize: Int) : SeenCache<TValue> by delegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ open class ConnectionOverNetty(
ch.attr(CONNECTION).set(this)
}

fun setMuxerSession(ms: StreamMuxer.Session) { muxerSession = ms }
fun setSecureSession(ss: SecureChannel.Session) { secureSession = ss }
fun setMuxerSession(ms: StreamMuxer.Session) {
muxerSession = ms
}
fun setSecureSession(ss: SecureChannel.Session) {
secureSession = ss
}

override fun muxerSession() = muxerSession
override fun secureSession() = secureSession
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class P2pdRunner(val execNames: List<String> = listOf("p2pd", "p2pd.exe"), val e
fun findP2pdExe(): String? =
(predefinedSearchPaths + execSearchPaths)
.flatMap { path -> execNames.map { File(path, it) } }
.firstOrNull() { it.canExecute() }
.firstOrNull { it.canExecute() }
?.absoluteFile?.canonicalPath

fun launcher() = findP2pdExe()?.let { DaemonLauncher(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface StatsFactory {
override fun toString() = "<dummy>"
}

var DEFAULT: StatsFactory = object : StatsFactory {
val DEFAULT: StatsFactory = object : StatsFactory {
override fun createStats(name: String) = DescriptiveStatsImpl()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import io.libp2p.simulate.util.NullTransport
import io.libp2p.transport.implementation.ConnectionOverNetty

class Libp2pConnectionImpl(
val remoteAddr:
Multiaddr,
val remoteAddr: Multiaddr,
isInitiator: Boolean,
localPubkey: PubKey,
remotePubkey: PubKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ fun <TKey, TSrc> Collection<TSrc>.groupByRangesBy(
where TKey : Number, TKey : Comparable<TKey> =
groupByRangesBy(keyExtractor, { it }, *ranges)

fun <T, V> Collection<Pair<T, V>>.groupByRanges(vararg ranges: ClosedRange<T>): Map<ClosedRange<T>, List<V>>
fun <T, V> Collection<Pair<T, V>>.groupByRanges(
vararg ranges: ClosedRange<T>
): Map<ClosedRange<T>, List<V>>
where T : Number, T : Comparable<T> =
groupByRangesBy({ it.first }, { it.second }, *ranges)

fun <T> Collection<T>.countByRanges(vararg ranges: ClosedRange<T>): List<Int>
fun <T> Collection<T>.countByRanges(
vararg ranges: ClosedRange<T>
): List<Int>
where T : Number, T : Comparable<T> {
val v = this
.map { it to it }
Expand All @@ -35,7 +39,9 @@ fun <T> Collection<T>.countByRanges(vararg ranges: ClosedRange<T>): List<Int>
return ranges.map { v[it]?.size ?: 0 }
}

fun <T> Collection<T>.countByRanges(ranges: List<ClosedRange<T>>): List<Int>
fun <T> Collection<T>.countByRanges(
ranges: List<ClosedRange<T>>
): List<Int>
where T : Number, T : Comparable<T> =
countByRanges(*ranges.toTypedArray())

Expand Down
14 changes: 7 additions & 7 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ dependencyManagement {
dependencies {

dependency "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
dependency "com.google.guava:guava:32.1.2-jre"
dependency "com.google.guava:guava:33.3.1-jre"

dependency "org.slf4j:slf4j-api:2.0.9"
dependencySet(group: 'org.apache.logging.log4j', version: '2.20.0') {
dependencySet(group: 'org.apache.logging.log4j', version: '2.24.0') {
entry 'log4j-core'
entry 'log4j-slf4j2-impl'
}

dependencySet(group: 'org.junit.jupiter', version: '5.10.0') {
dependencySet(group: 'org.junit.jupiter', version: '5.11.1') {
entry 'junit-jupiter-api'
entry 'junit-jupiter-engine'
entry 'junit-jupiter-params'
}
dependency "io.mockk:mockk:1.13.3"
dependency "org.assertj:assertj-core:3.24.2"
dependency "org.assertj:assertj-core:3.26.3"

dependencySet(group: "org.openjdk.jmh", version: "1.36") {
dependencySet(group: "org.openjdk.jmh", version: "1.37") {
entry 'jmh-core'
entry 'jmh-generator-annprocess'
}
Expand All @@ -31,7 +31,7 @@ dependencyManagement {
entry 'protobuf-java'
entry 'protoc'
}
dependencySet(group: "io.netty", version: "4.1.108.Final") {
dependencySet(group: "io.netty", version: "4.1.113.Final") {
entry 'netty-common'
entry 'netty-handler'
entry 'netty-transport'
Expand All @@ -41,7 +41,7 @@ dependencyManagement {
}
dependency "com.github.multiformats:java-multibase:v1.1.1"
dependency "tech.pegasys:noise-java:22.1.0"
dependencySet(group: "org.bouncycastle", version: "1.76") {
dependencySet(group: "org.bouncycastle", version: "1.78.1") {
entry 'bcprov-jdk18on'
entry 'bcpkix-jdk18on'
entry 'bctls-jdk18on'
Expand Down
Loading