Skip to content

Commit

Permalink
Update jvm-libp2p to 0.8.8 (#4904)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored Jan 25, 2022
1 parent ba55402 commit 6648486
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ For information on changes in released versions of Teku, see the [releases page]
### Bug Fixes
* Rest api endpoints accepting validator IDs will no longer reject valid bytes48 hex strings that are not on the g2 curve.
* Upgraded discovery to fix `ConcurrentModificationException`.
* Fixed 503 response from REST APIs when creating an attestation or block based on finalized data.
* Fixed 503 response from REST APIs when creating an attestation or block based on finalized data.
* Improved peer validation during libp2p handshake.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract class Node {
protected static final int REST_API_PORT = 9051;
protected static final int METRICS_PORT = 8008;
protected static final String CONFIG_FILE_PATH = "/config.yaml";
protected static final String PRIVATE_KEY_FILE_PATH = "/private-key.txt";
protected static final String WORKING_DIRECTORY = "/opt/teku/";
protected static final String DATA_PATH = WORKING_DIRECTORY + "data/";
protected static final int P2P_PORT = 9000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package tech.pegasys.teku.test.acceptance.dsl;

import static java.util.Arrays.asList;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
Expand All @@ -27,8 +27,10 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -566,6 +568,7 @@ public Config() {
configMap.put("p2p-port", P2P_PORT);
configMap.put("p2p-advertised-port", P2P_PORT);
configMap.put("p2p-interface", "0.0.0.0");
configMap.put("p2p-private-key-file", PRIVATE_KEY_FILE_PATH);
configMap.put("Xinterop-genesis-time", 0);
configMap.put("Xinterop-owned-validator-start-index", 0);
configMap.put("Xstartup-target-peer-count", 0);
Expand Down Expand Up @@ -657,7 +660,7 @@ public Config withRealNetwork() {

public Config withPeers(final TekuNode... nodes) {
final String peers =
asList(nodes).stream().map(TekuNode::getMultiAddr).collect(Collectors.joining(", "));
Arrays.stream(nodes).map(TekuNode::getMultiAddr).collect(Collectors.joining(", "));
LOG.debug("Set peers: {}", peers);
configMap.put("p2p-static-peers", peers);
return this;
Expand All @@ -678,6 +681,12 @@ public Map<File, String> write() throws Exception {
configFile.deleteOnExit();
writeTo(configFile);
configFiles.put(configFile, CONFIG_FILE_PATH);

final File privateKeyFile = File.createTempFile("private-key", ".txt");
privateKeyFile.deleteOnExit();
Files.writeString(
privateKeyFile.toPath(), Bytes.wrap(privateKey.bytes()).toHexString(), UTF_8);
configFiles.put(privateKeyFile, PRIVATE_KEY_FILE_PATH);
return configFiles;
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencyManagement {
dependency 'io.protostuff:protostuff-core:1.6.2'
dependency 'io.protostuff:protostuff-runtime:1.6.2'

dependency 'io.libp2p:jvm-libp2p-minimal:0.8.7-RELEASE'
dependency 'io.libp2p:jvm-libp2p-minimal:0.8.8-RELEASE'
dependency 'tech.pegasys:jblst:0.3.6-4'

dependency 'org.hdrhistogram:HdrHistogram:2.1.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public LibP2PPrivateKeyLoader(
this.privateKeyFile = privateKeyFile;
}

public static PrivKey loadPrivateKey(
KeyValueStore<String, Bytes> keyValueStore, final Optional<String> privateKeyFile) {
return new LibP2PPrivateKeyLoader(keyValueStore, privateKeyFile).get();
}

@Override
public PrivKey get() {
final Bytes privKeyBytes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Multiaddr fromInetSocketAddress(
}

private static Multiaddr addPeerId(final Multiaddr addr, final NodeId nodeId) {
return new Multiaddr(addr, Multiaddr.fromString("/p2p/" + nodeId.toBase58()));
return addr.withP2P(PeerId.fromBase58(nodeId.toBase58()));
}

private static LibP2PNodeId getNodeId(final DiscoveryPeer peer) {
Expand Down

0 comments on commit 6648486

Please sign in to comment.