Skip to content

Commit

Permalink
Merge pull request #303 from libp2p/v1.0.0
Browse files Browse the repository at this point in the history
Integrate V1.0.0 changes into develop
  • Loading branch information
Nashatyrev authored Aug 21, 2023
2 parents 0ba9a90 + 4e73088 commit 1a5f08d
Show file tree
Hide file tree
Showing 121 changed files with 2,684 additions and 995 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Execute Gradle build
run: ./gradlew -s build dokkaJar
119 changes: 63 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,69 @@
![Build Status](https://github.com/libp2p/jvm-libp2p/actions/workflows/build.yml/badge.svg?branch=master)
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)

> a libp2p implementation for the JVM, written in Kotlin 🔥
**⚠️ This is heavy work in progress! ⚠️**

## Roadmap

The endeavour to build jvm-libp2p is split in two phases:

* **minimal phase (v0.x):** aims to provide the bare minimum stack that will
allow JVM-based Ethereum 2.0 clients to interoperate with other clients that
rely on fully-fledged libp2p stacks written in other languages.
* To achieve this, we have to be wire-compliant, but don't need to fulfill
the complete catalogue of libp2p abstractions.
* This effort will act as a starting point to evolve this project into a
fully-fledged libp2p stack for JVM environments, including Android
runtimes.
* We are shooting for Aug/early Sept 2019.
* Only Java-friendly façade.

* **maturity phase (v1.x):** upgrades the minimal version to a flexible and
versatile stack adhering to the key design principles of modularity and
pluggability that define the libp2p project. It adds features present in
mature implementations like go-libp2p, rust-libp2p, js-libp2p.
* will offer: pluggable peerstore, connection manager, QUIC transport,
circuit relay, AutoNAT, AutoRelay, NAT traversal, etc.
* Android-friendly.
* Kotlin coroutine-based façade, possibly a Reactive Streams façade too.
* work will begin after the minimal phase concludes.

## minimal phase (v0.x): Definition of Done

We have identified the following components on the path to attaining a minimal
implementation:

- [X] multistream-select 1.0
- [X] multiformats: [multiaddr](https://github.com/multiformats/multiaddr)
- [X] crypto (RSA, ed25519, secp256k1)
- [X] [secio](https://github.com/libp2p/specs/pull/106)
- [X] [connection bootstrapping](https://github.com/libp2p/specs/pull/168)
- [X] mplex as a multiplexer
- [X] stream multiplexing
- [X] TCP transport (dialing and listening)
- [X] Identify protocol
- [X] Ping protocol
- [X] [peer ID](https://github.com/libp2p/specs/pull/100)
- [X] noise security protocol
- [X] MDNS
- [X] Gossip 1.1 pubsub

We are explicitly leaving out the peerstore, DHT, pubsub, connection manager,
etc. and other subsystems or concepts that are internal to implementations and
do not impact the ability to hold communications with other libp2p processes.
[Libp2p](https://libp2p.io/) implementation for the JVM, written in Kotlin 🔥

## Components

List of components in the Libp2p spec and their JVM implementation status

| | Component | Status |
|--------------------------|-------------------------------------------------------------------------------------------------|:----------------:|
| **Transport** | tcp | :green_apple: |
| | [quic](https://github.com/libp2p/specs/tree/master/quic) | :tomato: |
| | websocket | :lemon: |
| | [webtransport](https://github.com/libp2p/specs/tree/master/webtransport) | |
| | [webrtc-browser-to-server](https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md) | |
| | [webrtc-private-to-private](https://github.com/libp2p/specs/blob/master/webrtc/webrtc.md) | |
| **Secure Communication** | [noise](https://github.com/libp2p/specs/blob/master/noise/) | :green_apple: |
| | [tls](https://github.com/libp2p/specs/blob/master/tls/tls.md) | :lemon: |
| | [plaintext](https://github.com/libp2p/specs/blob/master/plaintext/README.md) | :lemon: |
| | [secio](https://github.com/libp2p/specs/blob/master/secio/README.md) **(deprecated)** | :green_apple: |
| **Protocol Select** | [multistream](https://github.com/multiformats/multistream-select) | :green_apple: |
| **Stream Multiplexing** | [yamux](https://github.com/libp2p/specs/blob/master/yamux/README.md) | :lemon: |
| | [mplex](https://github.com/libp2p/specs/blob/master/mplex/README.md) | :green_apple: |
| **NAT Traversal** | [circuit-relay-v2](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md) | |
| | [autonat](https://github.com/libp2p/specs/tree/master/autonat) | |
| | [hole-punching](https://github.com/libp2p/specs/blob/master/connections/hole-punching.md) | |
| **Discovery** | [bootstrap](https://github.com/libp2p/specs/blob/master/kad-dht/README.md#bootstrap-process) | |
| | random-walk | |
| | [mdns-discovery](https://github.com/libp2p/specs/blob/master/discovery/mdns.md) | :lemon: |
| | [rendezvous](https://github.com/libp2p/specs/blob/master/rendezvous/README.md) | |
| **Peer Routing** | [kad-dht](https://github.com/libp2p/specs/blob/master/kad-dht/README.md) | |
| **Publish/Subscribe** | floodsub | :lemon: |
| | [gossipsub](https://github.com/libp2p/specs/tree/master/pubsub/gossipsub) | :green_apple: |
| **Storage** | record | |
| **Other protocols** | [ping](https://github.com/libp2p/specs/blob/master/ping/ping.md) | :green_apple: |
| | [identify](https://github.com/libp2p/specs/blob/master/identify/README.md) | :green_apple: |

Legend:
- :green_apple: - tested in production
- :lemon: - prototype or beta, not tested in production
- :tomato: - in progress

## Gossip simulator

Deterministic Gossip simulator which may simulate networks as large as 10000 of peers

Please check the Simulator [README](tools/simulator/README.md) for more details

## Android support

The library is basically being developed with Android compatibility in mind.
However we are not aware of anyone using it in production.

The `examples/android-chatter` module contains working sample Android application. This module is ignored by the Gradle
build when no Android SDK is installed.
To include the Android module define a valid SDK location with an `ANDROID_HOME` environment variable
or by setting the `sdk.dir` path in your project's local properties file local.properties.

Importing the project into Android Studio should work out of the box.

## Adding as a dependency to your project

Hosting of artefacts is graciously provided by [Cloudsmith](https://cloudsmith.com).

[![Latest version of 'jvm-libp2p-minimal' @ Cloudsmith](https://api-prd.cloudsmith.io/v1/badges/version/libp2p/jvm-libp2p/maven/jvm-libp2p-minimal/latest/a=noarch;xg=io.libp2p/?render=true&show_latest=true)](https://cloudsmith.io/~libp2p/repos/jvm-libp2p/packages/detail/maven/jvm-libp2p-minimal/latest/a=noarch;xg=io.libp2p/)
[![Latest version of 'jvm-libp2p' @ Cloudsmith](https://api-prd.cloudsmith.io/v1/badges/version/libp2p/jvm-libp2p/maven/jvm-libp2p/latest/a=noarch;xg=io.libp2p/?render=true&show_latest=true)](https://cloudsmith.io/~libp2p/repos/jvm-libp2p/packages/detail/maven/jvm-libp2p/latest/a=noarch;xg=io.libp2p/)

As an alternative, artefacts are also available on [JitPack](https://jitpack.io/).

Expand All @@ -87,7 +86,7 @@ Add the library to the `implementation` part of your Gradle file.
```groovy
dependencies {
// ...
implementation 'io.libp2p:jvm-libp2p-minimal:X.Y.Z-RELEASE'
implementation 'io.libp2p:jvm-libp2p:X.Y.Z-RELEASE'
}
```
### Using Maven
Expand All @@ -113,7 +112,7 @@ And then add jvm-libp2p as a dependency:
``` xml
<dependency>
<groupId>io.libp2p</groupId>
<artifactId>jvm-libp2p-minimal</artifactId>
<artifactId>jvm-libp2p</artifactId>
<version>X.Y.Z-RELEASE</version>
<type>pom</type>
</dependency>
Expand All @@ -138,7 +137,15 @@ To build the library from the `jvm-libp2p` folder, run:
./gradlew build
```

After the build is complete you may find the library `.jar` file here: `jvm-libp2p/build/libs/jvm-libp2p-minimal-0.x.y-RELEASE.jar`
After the build is complete you may find the library `.jar` file here: `jvm-libp2p/build/libs/jvm-libp2p-X.Y.Z-RELEASE.jar`

## Notable users

- [Teku](https://github.com/Consensys/teku) - Ethereum Consensus Layer client
- [Nabu](https://github.com/peergos/nabu) - minimal Java implementation of IPFS
- [Peergos](https://github.com/peergos/peergos) - peer-to-peer encrypted global filesystem

(Please open a pull request if you want your project to be added here)

## License

Expand Down
34 changes: 22 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import java.net.URL
// To publish the release artifact to CloudSmith repo run the following :
// ./gradlew publish -PcloudsmithUser=<user> -PcloudsmithApiKey=<api-key>

description = "a minimal implementation of libp2p for the jvm"
description = "an implementation of libp2p for the jvm"

plugins {
kotlin("jvm").version("1.6.21")
val kotlinVersion = "1.6.21"

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

id("com.github.ben-manes.versions").version("0.44.0")
id("idea")
Expand All @@ -19,44 +21,52 @@ plugins {
id("org.jmailen.kotlinter").version("3.10.0")
id("java-test-fixtures")
id("io.spring.dependency-management").version("1.1.0")

id("org.jetbrains.kotlin.android") version kotlinVersion apply false
id("com.android.application") version "7.4.2" apply false
}

allprojects {
fun Project.getBooleanPropertyOrFalse(propName: String) =
(this.properties[propName] as? String)?.toBoolean() ?: false

configure(
allprojects
.filterNot {
it.getBooleanPropertyOrFalse("libp2p.gradle.custom")
}
) {
group = "io.libp2p"
version = "develop"

apply(plugin = "kotlin")
apply(plugin = "idea")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "java")

apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jmailen.kotlinter")
apply(plugin = "java-test-fixtures")
apply(plugin = "io.spring.dependency-management")
apply(from = "$rootDir/versions.gradle")

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

dependencies {

implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")

implementation("com.google.guava:guava")
implementation("org.apache.logging.log4j:log4j-api")
implementation("org.slf4j:slf4j-api")
implementation("com.github.multiformats:java-multibase:v1.1.1")

testFixturesImplementation("org.apache.logging.log4j:log4j-api")
testFixturesImplementation("com.google.guava:guava")
testFixturesImplementation("org.slf4j:slf4j-api")

testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("io.mockk:mockk")
testImplementation("org.assertj:assertj-core")
testImplementation("org.apache.logging.log4j:log4j-core")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl")
}

java {
Expand Down
58 changes: 23 additions & 35 deletions examples/android-chatter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

repositories {
google()
}

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: "io.spring.dependency-management"
apply from: "$rootDir/versions.gradle"

android {
compileSdkVersion 28
namespace = "io.libp2p.example.chat"
compileSdkVersion 30
defaultConfig {
applicationId "io.libp2p.example.chatter"
minSdkVersion 28
targetSdkVersion 28
applicationId "io.libp2p.example.chat"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -38,20 +22,24 @@ android {
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
}
kotlinOptions {
jvmTarget = "11"
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.11
targetCompatibility = 1.11
}
lint {
abortOnError = false
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':chatter')
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.11.2'
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("com.google.android.material:material:1.2.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation project(':examples:chatter')
}
1 change: 1 addition & 0 deletions examples/android-chatter/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libp2p.gradle.custom = true
3 changes: 1 addition & 2 deletions examples/android-chatter/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.libp2p.example.chat">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import java.util.concurrent.CompletableFuture.runAsync


class MainActivity : AppCompatActivity() {
private lateinit var chatScroller: ScrollView
private lateinit var chatWindow: TextView
Expand Down
2 changes: 1 addition & 1 deletion examples/cli-chatter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
dependencies {
implementation project(':examples:chatter')

runtimeOnly("org.apache.logging.log4j:log4j-core")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl")
}

application {
Expand Down
2 changes: 1 addition & 1 deletion examples/pinger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
dependencies {
implementation project(':libp2p')

runtimeOnly("org.apache.logging.log4j:log4j-core")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl")
}

application {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kotlin.code.style=official

org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx1G
android.useAndroidX=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu May 11 18:05:55 GST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 1a5f08d

Please sign in to comment.