From 6be7d64e8c81d3d8365867d1c2fba621e8d19d38 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 18 May 2020 10:11:21 +0200 Subject: [PATCH] bump libp2p (#1031) --- beacon_chain/eth2_network.nim | 22 ++++++++++++---------- beacon_chain/inspector.nim | 10 +++++----- vendor/nim-libp2p | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index 32d7f7240..38256e282 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -910,17 +910,19 @@ template tcpEndPoint(address, port): auto = MultiAddress.init(address, Protocol.IPPROTO_TCP, port) proc getPersistentNetKeys*(conf: BeaconNodeConf): KeyPair = - let privKeyPath = conf.dataDir / networkKeyFilename - var privKey: PrivateKey - if not fileExists(privKeyPath): - createDir conf.dataDir.string - privKey = PrivateKey.random(Secp256k1) - writeFile(privKeyPath, privKey.getBytes()) - else: - let keyBytes = readFile(privKeyPath) - privKey = PrivateKey.init(keyBytes.toOpenArrayByte(0, keyBytes.high)) + let + privKeyPath = conf.dataDir / networkKeyFilename + privKey = + if not fileExists(privKeyPath): + createDir conf.dataDir.string + let key = PrivateKey.random(Secp256k1).tryGet() + writeFile(privKeyPath, key.getBytes().tryGet()) + key + else: + let keyBytes = readFile(privKeyPath) + PrivateKey.init(keyBytes.toOpenArrayByte(0, keyBytes.high)).tryGet() - KeyPair(seckey: privKey, pubkey: privKey.getKey()) + KeyPair(seckey: privKey, pubkey: privKey.getKey().tryGet()) proc createEth2Node*(conf: BeaconNodeConf, enrForkId: ENRForkID): Future[Eth2Node] {.async, gcsafe.} = var diff --git a/beacon_chain/inspector.nim b/beacon_chain/inspector.nim index b8c5a3984..65a155608 100644 --- a/beacon_chain/inspector.nim +++ b/beacon_chain/inspector.nim @@ -316,10 +316,10 @@ proc init*(p: typedesc[PeerInfo], if trecOpt.isSome(): trec = trecOpt.get() if trec.secp256k1.isSome(): - var skpubkey: SkPublicKey - if skpubkey.init(trec.secp256k1.get()): + let skpubkey = SkPublicKey.fromRaw(trec.secp256k1.get()) + if skpubkey.isOk(): let peerid = PeerID.init(PublicKey(scheme: Secp256k1, - skkey: skpubkey)) + skkey: skpubkey[])) var mas = newSeq[MultiAddress]() if trec.ip.isSome() and trec.tcp.isSome(): let ma = MultiAddress.init(multiCodec("ip4"), trec.ip.get()) & @@ -411,7 +411,7 @@ proc bootstrapDiscovery(conf: InspectorConf, privkey: lcrypto.PrivateKey, bootnodes: seq[enr.Record], enrFields: Option[ENRFieldPair]): DiscoveryProtocol = - var pk = ethkeys.PrivateKey.fromRaw(privkey.getBytes()).tryGet() + var pk = ethkeys.PrivateKey(privkey.skkey) var db = DiscoveryDB.init(newMemoryDB()) let udpPort = Port(conf.discoveryPort) let tcpPort = Port(conf.ethPort) @@ -684,7 +684,7 @@ proc run(conf: InspectorConf) {.async.} = bootstrap_fork_digest = forkDigest.get() forkDigest = argForkDigest - let seckey = lcrypto.PrivateKey.random(PKScheme.Secp256k1) + let seckey = lcrypto.PrivateKey.random(PKScheme.Secp256k1).tryGet() # let pubkey = seckey.getKey() let hostAddress = tryGetMultiAddress(conf.bindAddress) diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 5abbcfb5e..7dcb807f6 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 5abbcfb5eb85826b1a141f7035bc17fc6e8a949a +Subproject commit 7dcb807f647a9f979820de5d450f17492f2e0ed5