Skip to content

Commit

Permalink
Merge pull request #213 from libp2p/0.8.7
Browse files Browse the repository at this point in the history
0.8.7 release
  • Loading branch information
ajsutton committed Jan 14, 2022
2 parents 270b23a + 7cc9142 commit 7d0145e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 47 deletions.
39 changes: 23 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,41 @@ import java.nio.file.Paths
// ./gradlew publish -PcloudsmithUser=<user> -PcloudsmithApiKey=<api-key>

group = "io.libp2p"
version = "0.8.6-RELEASE"
version = "0.8.7-RELEASE"
description = "a minimal implementation of libp2p for the jvm"

plugins {
java
idea
kotlin("jvm") version "1.4.10"
id("org.jmailen.kotlinter") version "3.2.0"
id("com.google.protobuf") version "0.8.13"
kotlin("jvm") version "1.6.10"
id("org.jmailen.kotlinter") version "3.8.0"
id("com.google.protobuf") version "0.8.18"

`maven-publish`
id("org.jetbrains.dokka") version "1.6.10"
id("com.github.ben-manes.versions") version "0.41.0"
}

repositories {
mavenCentral()
maven("https://artifacts.consensys.net/public/maven/maven/")
}

val log4j2Version = "2.17.0"

val log4j2Version = "2.17.1"

dependencies {
api("io.netty:netty-all:4.1.69.Final")
api("com.google.protobuf:protobuf-java:3.19.1")
api("com.google.protobuf:protobuf-java:3.19.2")

implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("tech.pegasys:noise-java:22.1.0")

implementation("com.google.guava:guava:27.1-jre")
implementation("org.bouncycastle:bcprov-jdk15on:1.62")
implementation("org.bouncycastle:bcpkix-jdk15on:1.62")
implementation("commons-codec:commons-codec:1.13")
implementation("com.google.guava:guava:31.0.1-jre")
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("commons-codec:commons-codec:1.15")

implementation("org.apache.logging.log4j:log4j-api:${log4j2Version}")
implementation("org.apache.logging.log4j:log4j-core:${log4j2Version}")
Expand All @@ -53,10 +55,10 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testImplementation("io.mockk:mockk:1.10.0")
testRuntimeOnly("org.mockito:mockito-core:3.3.3")
testImplementation("org.mockito:mockito-junit-jupiter:3.3.3")
testImplementation("org.assertj:assertj-core:3.16.1")
testImplementation("io.mockk:mockk:1.12.2")
testRuntimeOnly("org.mockito:mockito-core:4.2.0")
testImplementation("org.mockito:mockito-junit-jupiter:4.2.0")
testImplementation("org.assertj:assertj-core:3.22.0")

}

Expand All @@ -70,7 +72,7 @@ sourceSets {

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.18.1"
artifact = "com.google.protobuf:protoc:3.19.2"
}

tasks.get("clean").doFirst({ delete(generatedFilesBaseDir) })
Expand All @@ -82,6 +84,11 @@ protobuf {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/libp2p/pubsub/gossip/GossipScore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ class GossipScore(
when {
validationResult.isPresent && validationResult.get() == ValidationResult.Invalid ->
topicScores.invalidMessages++
!validationResult.isPresent
|| durationAfterValidation < topicParams[topic].meshMessageDeliveryWindow ->
!validationResult.isPresent ||
durationAfterValidation < topicParams[topic].meshMessageDeliveryWindow ->
topicScores.meshMessageDeliveries++
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ abstract class NettyTransport(

override fun dial(addr: Multiaddr, connHandler: ConnectionHandler):
CompletableFuture<Connection> {
if (closed) throw Libp2pException("Transport is closed")
if (closed) throw Libp2pException("Transport is closed")

val remotePeerId = addr.getStringComponent(Protocol.P2P)?.let { PeerId.fromBase58(it) }
val connectionBuilder = makeConnectionBuilder(connHandler, true, remotePeerId)
val channelHandler = clientTransportBuilder(connectionBuilder, addr) ?: connectionBuilder
val remotePeerId = addr.getStringComponent(Protocol.P2P)?.let { PeerId.fromBase58(it) }
val connectionBuilder = makeConnectionBuilder(connHandler, true, remotePeerId)
val channelHandler = clientTransportBuilder(connectionBuilder, addr) ?: connectionBuilder

val chanFuture = client.clone()
.handler(channelHandler)
.connect(fromMultiaddr(addr))
.also { registerChannel(it.channel()) }
val chanFuture = client.clone()
.handler(channelHandler)
.connect(fromMultiaddr(addr))
.also { registerChannel(it.channel()) }

return chanFuture.toCompletableFuture()
.thenCompose { connectionBuilder.connectionEstablished }
} // dial
return chanFuture.toCompletableFuture()
.thenCompose { connectionBuilder.connectionEstablished }
} // dial

protected abstract fun clientTransportBuilder(
connectionBuilder: ConnectionBuilder,
Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/io/libp2p/core/HostTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Test
import java.util.Random
import java.util.concurrent.TimeUnit
import java.util.function.Consumer

class HostTest {

Expand Down Expand Up @@ -221,7 +222,7 @@ class HostTest {
}

fun assertDoesntContainSequence(data: ByteArray, seq: ByteArray) {
assertThat(listOf(data)).noneSatisfy { candidate -> assertThat(candidate).containsSequence(*seq) }
assertThat(listOf(data)).noneSatisfy(Consumer { candidate -> assertThat(candidate).containsSequence(*seq) })
}

fun mergeBufs(bufs: Collection<ByteBuf>): ByteArray =
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/io/libp2p/pubsub/gossip/Eth2GossipParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ private val subnetTopicParams =
(0..63).map { "$AttestTopicPrefix$it$AttestTopicSuffix" to Eth2DefaultAttestTopicParams }.toMap()
val Eth2DefaultTopicsParams = GossipTopicsScoreParams(
topicParamsMap =
mapOf(
BlocksTopic to Eth2DefaultBlockTopicParams,
AggrAttestTopic to Eth2DefaultAggrAttestTopicParams
) + subnetTopicParams
mapOf(
BlocksTopic to Eth2DefaultBlockTopicParams,
AggrAttestTopic to Eth2DefaultAggrAttestTopicParams
) + subnetTopicParams
)

val Eth2DefaultPeerScoreParams = GossipPeerScoreParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class NoiseHandshakeTest {
localKeyPair.getPrivateKey(prk, 0)
localKeyPair.getPublicKey(puk, 0)

assert(prk.max()?.compareTo(0) != 0)
assert(puk.max()?.compareTo(0) != 0)
assert(prk.maxOrNull()?.compareTo(0) != 0)
assert(puk.maxOrNull()?.compareTo(0) != 0)
assert(aliceHS.hasLocalKeyPair())
}

Expand Down Expand Up @@ -121,7 +121,7 @@ class NoiseHandshakeTest {
// use it for encoding and decoding peer identities from the wire
// this identity is intended to be sent as a Noise transport payload
val (privKey, pubKey) = generateKeyPair(KEY_TYPE.ECDSA)
assert(pubKey.bytes().max()?.compareTo(0) != 0)
assert(pubKey.bytes().maxOrNull()?.compareTo(0) != 0)

// sign the identity using the identity's private key
val signed = privKey.sign(pubKey.bytes())
Expand All @@ -139,7 +139,7 @@ class NoiseHandshakeTest {
val msgLength = aliceHS.writeMessage(msgBuffer, 0, bs.toByteArray(), 0, bs.toByteArray().size)

assert(msgLength > 0)
assert(msgBuffer.max()?.compareTo(0) != 0)
assert(msgBuffer.maxOrNull()?.compareTo(0) != 0)
}

@Test
Expand Down
18 changes: 9 additions & 9 deletions src/test/kotlin/io/libp2p/transport/NullConnectionUpgrader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class NullConnectionUpgrader :

override fun establishSecureChannel(connection: Connection):
CompletableFuture<SecureChannel.Session> {
val nonsenseSession = SecureChannel.Session(
PeerId.random(),
PeerId.random(),
generateKeyPair(KEY_TYPE.RSA).second
)
return CompletableFuture.completedFuture(nonsenseSession)
} // establishSecureChannel
val nonsenseSession = SecureChannel.Session(
PeerId.random(),
PeerId.random(),
generateKeyPair(KEY_TYPE.RSA).second
)
return CompletableFuture.completedFuture(nonsenseSession)
} // establishSecureChannel

override fun establishMuxer(connection: Connection):
CompletableFuture<StreamMuxer.Session> {
return CompletableFuture.completedFuture(DoNothingMuxerSession())
} // establishMuxer
return CompletableFuture.completedFuture(DoNothingMuxerSession())
} // establishMuxer

private class DoNothingMuxerSession : StreamMuxer.Session {
override fun <T> createStream(protocols: List<ProtocolBinding<T>>): StreamPromise<T> {
Expand Down

0 comments on commit 7d0145e

Please sign in to comment.