Skip to content

Commit

Permalink
Disable Peer Exchange in PRUNE message (Consensys#7894)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Jan 23, 2024
1 parent cd76a2b commit d43ba28
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencyManagement {
dependency 'io.javalin:javalin:5.6.3'
dependency 'io.javalin:javalin-rendering:5.6.2'

dependency 'io.libp2p:jvm-libp2p:1.0.1-RELEASE'
dependency 'io.libp2p:jvm-libp2p:1.1.0-RELEASE'
dependency 'tech.pegasys:jblst:0.3.11'
dependency 'tech.pegasys:jc-kzg-4844:0.8.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.libp2p.etc.util.netty.mux.MuxId;
import io.libp2p.mux.mplex.MplexFlag;
import io.libp2p.mux.mplex.MplexFrame;
import io.libp2p.mux.yamux.YamuxFlags;
import io.libp2p.mux.yamux.YamuxFlag;
import io.libp2p.mux.yamux.YamuxFrame;
import io.libp2p.mux.yamux.YamuxType;
import io.netty.channel.ChannelDuplexHandler;
Expand Down Expand Up @@ -166,7 +166,7 @@ public boolean indicatesStreamResetting() {
if (msg instanceof YamuxFrame yamuxFrame) {
return new MuxFrame() {

private final int yamuxFlags = yamuxFrame.getFlags();
private final Set<YamuxFlag> yamuxFlags = yamuxFrame.getFlags();

@Override
public MuxId getId() {
Expand All @@ -179,17 +179,17 @@ public boolean indicatesStreamOpening() {
yamuxFrame.getType() == YamuxType.DATA
|| yamuxFrame.getType() == YamuxType.WINDOW_UPDATE;
return isDataOrWindowUpdate
&& (yamuxFlags == YamuxFlags.SYN || yamuxFlags == YamuxFlags.ACK);
&& (yamuxFlags.contains(YamuxFlag.SYN) || yamuxFlags.contains(YamuxFlag.ACK));
}

@Override
public boolean indicatesStreamClosing() {
return yamuxFlags == YamuxFlags.FIN;
return yamuxFlags.contains(YamuxFlag.FIN);
}

@Override
public boolean indicatesStreamResetting() {
return yamuxFlags == YamuxFlags.RST;
return yamuxFlags.contains(YamuxFlag.RST);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private static void addGossipParamsMaxValues(final GossipParamsBuilder builder)
.maxSubscriptions(MAX_SUBSCRIPTIONS_PER_MESSAGE)
.maxGraftMessages(200)
.maxPruneMessages(200)
.maxPeersPerPruneMessage(1000)
.maxPeersSentInPruneMsg(0)
.maxPeersAcceptedInPruneMsg(Integer.MAX_VALUE)
.maxIHaveLength(5000)
.maxIWantMessageIds(5000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.libp2p.mux.mplex.MplexFlag;
import io.libp2p.mux.mplex.MplexFrame;
import io.libp2p.mux.mplex.MplexId;
import io.libp2p.mux.yamux.YamuxFlags;
import io.libp2p.mux.yamux.YamuxFlag;
import io.libp2p.mux.yamux.YamuxFrame;
import io.libp2p.mux.yamux.YamuxId;
import io.libp2p.mux.yamux.YamuxType;
Expand All @@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -242,7 +243,7 @@ private Object createNewStreamFrame(final MuxType muxType, final long id) {
return switch (muxType) {
case MPLEX -> new MplexFrame(createMplexId(id), MplexFlag.NewStream, Unpooled.EMPTY_BUFFER);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, YamuxFlags.ACK, 0, Unpooled.EMPTY_BUFFER);
createYamuxId(id), YamuxType.DATA, Set.of(YamuxFlag.ACK), 0, Unpooled.EMPTY_BUFFER);
};
}

Expand All @@ -251,7 +252,7 @@ private Object createCloseInitiatorFrame(final MuxType muxType, final long id) {
case MPLEX -> new MplexFrame(
createMplexId(id), MplexFlag.CloseInitiator, Unpooled.EMPTY_BUFFER);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, YamuxFlags.FIN, 0, Unpooled.EMPTY_BUFFER);
createYamuxId(id), YamuxType.DATA, Set.of(YamuxFlag.FIN), 0, Unpooled.EMPTY_BUFFER);
};
}

Expand All @@ -260,7 +261,7 @@ private Object createCloseReceiverFrame(final MuxType muxType, final long id) {
case MPLEX -> new MplexFrame(
createMplexId(id), MplexFlag.CloseReceiver, Unpooled.EMPTY_BUFFER);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, YamuxFlags.FIN, 0, Unpooled.EMPTY_BUFFER);
createYamuxId(id), YamuxType.DATA, Set.of(YamuxFlag.FIN), 0, Unpooled.EMPTY_BUFFER);
};
}

Expand All @@ -269,7 +270,11 @@ private Object createDataFrame(final MuxType muxType, final long id) {
return switch (muxType) {
case MPLEX -> new MplexFrame(createMplexId(id), MplexFlag.MessageReceiver, slicedByteBuf);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, 0, slicedByteBuf.readableBytes(), slicedByteBuf);
createYamuxId(id),
YamuxType.DATA,
Set.of(),
slicedByteBuf.readableBytes(),
slicedByteBuf);
};
}

Expand All @@ -278,7 +283,7 @@ private Object createResetInitiatorFrame(final MuxType muxType, final long id) {
case MPLEX -> new MplexFrame(
createMplexId(id), MplexFlag.ResetInitiator, Unpooled.EMPTY_BUFFER);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, YamuxFlags.RST, 0, Unpooled.EMPTY_BUFFER);
createYamuxId(id), YamuxType.DATA, Set.of(YamuxFlag.RST), 0, Unpooled.EMPTY_BUFFER);
};
}

Expand All @@ -287,7 +292,7 @@ private Object createResetReceiverFrame(final MuxType muxType, final long id) {
case MPLEX -> new MplexFrame(
createMplexId(id), MplexFlag.ResetReceiver, Unpooled.EMPTY_BUFFER);
case YAMUX -> new YamuxFrame(
createYamuxId(id), YamuxType.DATA, YamuxFlags.RST, 0, Unpooled.EMPTY_BUFFER);
createYamuxId(id), YamuxType.DATA, Set.of(YamuxFlag.RST), 0, Unpooled.EMPTY_BUFFER);
};
}

Expand Down

0 comments on commit d43ba28

Please sign in to comment.