From 12ddfee6756ef3c52559d0a065822f448f41e234 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 17:07:33 +0700 Subject: [PATCH] fix compilation error related to lib-secp256k1 changes --- nimbus/config.nim | 1 + nimbus/nimbus.nim | 5 +---- nimbus/rpc/p2p.nim | 2 +- nimbus/rpc/whisper.nim | 2 +- tests/test_helpers.nim | 10 ++++------ 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/nimbus/config.nim b/nimbus/config.nim index 65f9dd291..0d3299dd4 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -847,6 +847,7 @@ proc initConfiguration(): NimbusConfiguration = result.net.ident = NimbusIdent result.net.nat = NatAny result.net.protocols = defaultProtocols + result.net.nodekey = PrivateKey.random().tryGet() const dataDir = getDefaultDataDir() diff --git a/nimbus/nimbus.nim b/nimbus/nimbus.nim index 550def1b4..b37c65520 100644 --- a/nimbus/nimbus.nim +++ b/nimbus/nimbus.nim @@ -58,10 +58,7 @@ proc start(nimbus: NimbusNode) = setupCommonRpc(nimbus.rpcServer) ## Creating P2P Server - if not conf.net.nodekey.verify(): - conf.net.nodekey = PrivateKey.random().tryGet() - - let keypair = conf.net.nodekey.toKeyPair().tryGet() + let keypair = conf.net.nodekey.toKeyPair() var address: Address address.ip = parseIpAddress("0.0.0.0") diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index 90aa610c0..d1ffcdcf6 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -226,7 +226,7 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) = template sign(privateKey: PrivateKey, message: string): string = # TODO: Is message length encoded as bytes or characters? let msgData = "\x19Ethereum Signed Message:\n" & $message.len & message - $sign(privateKey, msgData.toBytes()).tryGet() + $sign(privateKey, msgData.toBytes()) rpcsrv.rpc("eth_sign") do(data: EthAddressStr, message: HexDataStr) -> HexDataStr: ## The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))). diff --git a/nimbus/rpc/whisper.nim b/nimbus/rpc/whisper.nim index c200c2bc7..c0ea03f35 100644 --- a/nimbus/rpc/whisper.nim +++ b/nimbus/rpc/whisper.nim @@ -81,7 +81,7 @@ proc setupWhisperRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) = ## Returns key identifier on success and an error on failure. result = generateRandomID().Identifier - keys.asymKeys.add(result.string, key.toKeyPair().tryGet()) + keys.asymKeys.add(result.string, key.toKeyPair()) rpcsrv.rpc("shh_deleteKeyPair") do(id: Identifier) -> bool: ## Deletes the specifies key if it exists. diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index 05d38677b..4a05e9872 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -199,7 +199,7 @@ proc getFixtureTransaction*(j: JsonNode, dataIndex, gasIndex, valueIndex: int): var secretKey = j["secretKey"].getStr removePrefix(secretKey, "0x") let privateKey = PrivateKey.fromHex(secretKey).tryGet() - let sig = sign(privateKey, result.rlpEncode).tryGet() + let sig = sign(privateKey, result.rlpEncode) let raw = sig.toRaw() result.R = fromBytesBE(Uint256, raw[0..31]) @@ -210,11 +210,9 @@ proc hashLogEntries*(logs: seq[Log]): string = toLowerAscii("0x" & $keccakHash(rlp.encode(logs))) proc setupEthNode*(capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode = - var - conf = getConfiguration() - if not conf.net.nodekey.verify(): - conf.net.nodekey = PrivateKey.random().tryGet() - let keypair = conf.net.nodekey.toKeyPair().tryGet() + var conf = getConfiguration() + conf.net.nodekey = PrivateKey.random().tryGet() + let keypair = conf.net.nodekey.toKeyPair() var srvAddress: Address srvAddress.ip = parseIpAddress("0.0.0.0")