Skip to content

Commit

Permalink
Add yamux support (networking)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Aug 22, 2023
1 parent bb9c51d commit b1ce159
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 229 deletions.
2 changes: 1 addition & 1 deletion acceptance-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
testFixturesImplementation project(':infrastructure:time')
testFixturesImplementation project(':infrastructure:bls-keystore')
testFixturesImplementation 'com.squareup.okhttp3:okhttp'
testFixturesImplementation 'io.libp2p:jvm-libp2p-minimal'
testFixturesImplementation 'io.libp2p:jvm-libp2p'
testFixturesImplementation 'org.apache.commons:commons-lang3'
testFixturesImplementation 'commons-io:commons-io'
testFixturesImplementation 'org.apache.tuweni:tuweni-bytes'
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url "https://artifacts.consensys.net/public/maven/maven/"
content { includeGroupByRegex('tech\\.pegasys($|\\..*)')}
Expand Down
2 changes: 1 addition & 1 deletion data/beaconrestapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {

testImplementation testFixtures(project(':infrastructure:json'))

testCompileOnly 'io.libp2p:jvm-libp2p-minimal'
testCompileOnly 'io.libp2p:jvm-libp2p'

integrationTestImplementation testFixtures(project(':infrastructure:bls'))
integrationTestImplementation testFixtures(project(':ethereum:spec'))
Expand Down
4 changes: 2 additions & 2 deletions gradle/license-report-config/allowed-licenses.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"moduleName": "org.json:json"
},
{
"moduleName": "io.libp2p:jvm-libp2p-minimal"
"moduleName": "io.libp2p:jvm-libp2p"
},
{
"moduleName": "com.squareup.okio:okio"
Expand Down Expand Up @@ -104,7 +104,7 @@
"moduleLicense": "Apache License, Version 2.0"
},
{
"moduleName": "io.libp2p:jvm-libp2p-minimal",
"moduleName": "io.libp2p:jvm-libp2p",
"moduleLicense": "Apache License, Version 2.0",
"moduleLicenseUrl": "https://github.com/libp2p/jvm-libp2p/blob/develop/LICENSE-APACHE"
},
Expand Down
13 changes: 4 additions & 9 deletions gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencyManagement {
entry 'javalin-rendering'
}

dependency 'io.libp2p:jvm-libp2p-minimal:0.10.0-RELEASE'
dependency 'io.libp2p:jvm-libp2p:1.0.0-RELEASE'
dependency 'tech.pegasys:jblst:0.3.10'
dependency 'tech.pegasys:jc-kzg-4844:0.7.2'

Expand All @@ -58,10 +58,8 @@ dependencyManagement {
}

dependencySet(group: 'io.netty', version: '4.1.96.Final') {
entry('netty-all') {
exclude "io.netty:netty-transport-rxtx"
exclude "org.rxtx:rxtx"
}
entry 'netty-handler'
entry 'netty-codec-http'
}

dependencySet(group: 'io.vertx', version: '4.4.4') {
Expand Down Expand Up @@ -136,10 +134,7 @@ dependencyManagement {
dependency 'io.prometheus:simpleclient:0.9.0'

dependencySet(group: 'org.hyperledger.besu.internal', version: '23.4.4') {
entry('metrics-core') {
// We include netty-all so omit the separated jars
exclude 'io.netty:netty-tcnative-boringssl-static'
}
entry('metrics-core')
entry('core')
entry('config')
}
Expand Down
5 changes: 3 additions & 2 deletions networking/eth2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ dependencies {
implementation project(':storage:api')
implementation project(':infrastructure:serviceutils')

implementation 'io.libp2p:jvm-libp2p-minimal'
implementation 'io.libp2p:jvm-libp2p'
implementation 'io.netty:netty-codec-http'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation 'org.xerial.snappy:snappy-java'

Expand Down Expand Up @@ -53,7 +54,7 @@ dependencies {
testFixturesImplementation project(':infrastructure:subscribers')
testFixturesImplementation project(':infrastructure:serviceutils')

testFixturesImplementation 'io.libp2p:jvm-libp2p-minimal'
testFixturesImplementation 'io.libp2p:jvm-libp2p'
testFixturesImplementation 'org.mockito:mockito-core'
testFixturesImplementation 'org.hyperledger.besu:plugin-api'
testFixturesImplementation 'org.hyperledger.besu.internal:metrics-core'
Expand Down
5 changes: 3 additions & 2 deletions networking/p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ dependencies {
implementation project(':storage')
implementation project(':infrastructure:ssz')

implementation 'io.libp2p:jvm-libp2p-minimal'
implementation 'io.libp2p:jvm-libp2p'
implementation 'io.netty:netty-handler'
implementation 'io.projectreactor:reactor-core'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-crypto'
Expand Down Expand Up @@ -45,6 +46,6 @@ dependencies {

testFixturesImplementation 'org.hyperledger.besu:plugin-api'
testFixturesImplementation 'org.hyperledger.besu.internal:metrics-core'
testFixturesImplementation 'io.libp2p:jvm-libp2p-minimal'
testFixturesImplementation 'io.libp2p:jvm-libp2p'
testFixturesImplementation 'org.apache.logging.log4j:log4j-core'
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public static LibP2PNetworkBuilder create() {
protected GossipTopicFilter gossipTopicFilter;

protected Firewall firewall = new Firewall(Duration.ofSeconds(30));
protected MplexFirewall mplexFirewall =
new MplexFirewall(REMOTE_OPEN_STREAMS_RATE_LIMIT, REMOTE_PARALLEL_OPEN_STREAMS_COUNT_LIMIT);
protected MuxFirewall muxFirewall =
new MuxFirewall(REMOTE_OPEN_STREAMS_RATE_LIMIT, REMOTE_PARALLEL_OPEN_STREAMS_COUNT_LIMIT);

protected LibP2PGossipNetwork gossipNetwork;

Expand Down Expand Up @@ -157,6 +157,11 @@ protected Host createHost() {
b.getIdentity().setFactory(() -> privKey);
b.getTransports().add(TcpTransport::new);
b.getSecureChannels().add(NoiseXXSecureChannel::new);

if (config.isYamuxEnabled()) {
// yamux MUST take precedence during negotiation
b.getMuxers().add(StreamMuxerProtocol.getYamux());
}
b.getMuxers().add(StreamMuxerProtocol.getMplex());

b.getNetwork().listen(listenAddr.toString());
Expand All @@ -179,7 +184,7 @@ protected Host createHost() {

b.getConnectionHandlers().add(peerManager);

b.getDebug().getMuxFramesHandler().addHandler(mplexFirewall);
b.getDebug().getMuxFramesHandler().addHandler(muxFirewall);
});
}

Expand Down Expand Up @@ -266,8 +271,8 @@ public LibP2PNetworkBuilder firewall(Firewall firewall) {
return this;
}

public LibP2PNetworkBuilder mplexFirewall(MplexFirewall mplexFirewall) {
this.mplexFirewall = mplexFirewall;
public LibP2PNetworkBuilder muxFirewall(MuxFirewall muxFirewall) {
this.muxFirewall = muxFirewall;
return this;
}
}

This file was deleted.

Loading

0 comments on commit b1ce159

Please sign in to comment.