From ef5a964b421c7bb87fca3bdef89c8cde828c7188 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 11:44:09 +0700 Subject: [PATCH 1/5] bump submodules --- vendor/nim-chronicles | 2 +- vendor/nim-chronos | 2 +- vendor/nim-confutils | 2 +- vendor/nim-eth | 2 +- vendor/nim-faststreams | 2 +- vendor/nim-json-rpc | 2 +- vendor/nim-json-serialization | 2 +- vendor/nim-secp256k1 | 2 +- vendor/nim-serialization | 2 +- vendor/nim-snappy | 2 +- vendor/nim-stew | 2 +- vendor/nim-testutils | 2 +- vendor/nimbus-build-system | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index fc3f2d375..3d7619b1f 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit fc3f2d3755e035387ebcf20d87a45eb9dcefadbb +Subproject commit 3d7619b1f559c86b2ef026f386d6d872b9331c82 diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 357baa52a..bedd1ded5 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 357baa52a0ea3da699c8229d97230c7f4340da92 +Subproject commit bedd1ded5edc3bfb6877f7025ca4b21f62492ffe diff --git a/vendor/nim-confutils b/vendor/nim-confutils index 6e5d57049..a76faa5ee 160000 --- a/vendor/nim-confutils +++ b/vendor/nim-confutils @@ -1 +1 @@ -Subproject commit 6e5d570490989c753d4645ba9173ef9358d302bb +Subproject commit a76faa5eec2454309753bbe99a68fb3cc25782f1 diff --git a/vendor/nim-eth b/vendor/nim-eth index 53166fd1f..61feae0f2 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 53166fd1ff28693d12044a7143d0508805c7ae8a +Subproject commit 61feae0f21d49f102e1e0252f3559b600ff54a69 diff --git a/vendor/nim-faststreams b/vendor/nim-faststreams index dd63bbfd1..5df69fc69 160000 --- a/vendor/nim-faststreams +++ b/vendor/nim-faststreams @@ -1 +1 @@ -Subproject commit dd63bbfd1cea26e9ca830a3a8fd70e5d3a0d1306 +Subproject commit 5df69fc6961e58205189cd92ae2477769fa8c4c0 diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc index 5c0d09611..244254632 160000 --- a/vendor/nim-json-rpc +++ b/vendor/nim-json-rpc @@ -1 +1 @@ -Subproject commit 5c0d0961114bcaaf3da52d5918bf0b85ef0e4ce9 +Subproject commit 244254632b15c745b6e15537aafd401f360d9928 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization index 2f5e71b25..463a0cf1b 160000 --- a/vendor/nim-json-serialization +++ b/vendor/nim-json-serialization @@ -1 +1 @@ -Subproject commit 2f5e71b25f5fefd71766c0eacfb1d69a8183b188 +Subproject commit 463a0cf1b79f5e586b537c0ce7518e2d1ee85984 diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 index e8fa92a0c..be9896359 160000 --- a/vendor/nim-secp256k1 +++ b/vendor/nim-secp256k1 @@ -1 +1 @@ -Subproject commit e8fa92a0c6217103eecce2a9e6f274c7eedac13b +Subproject commit be989635994377e0e421e4a039230098ba5ccd28 diff --git a/vendor/nim-serialization b/vendor/nim-serialization index 7ff764ca1..a49e001f9 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit 7ff764ca1f921ee709f05219aa740ab6c42872fc +Subproject commit a49e001f9ec27c666e600ae000ece5999262cc44 diff --git a/vendor/nim-snappy b/vendor/nim-snappy index b4cd68e27..676fa656d 160000 --- a/vendor/nim-snappy +++ b/vendor/nim-snappy @@ -1 +1 @@ -Subproject commit b4cd68e27a56dbda2a56d7b90e666b644cfd5be6 +Subproject commit 676fa656d3a6f4e24691f3f48829c979b1b1bcdd diff --git a/vendor/nim-stew b/vendor/nim-stew index d0f5be497..11aeb996a 160000 --- a/vendor/nim-stew +++ b/vendor/nim-stew @@ -1 +1 @@ -Subproject commit d0f5be4971ad34d115b9749d9fb69bdd2aecf525 +Subproject commit 11aeb996ab31b5b537fc0c8631c96cbd7976eeb5 diff --git a/vendor/nim-testutils b/vendor/nim-testutils index b3b7074e3..c449d909a 160000 --- a/vendor/nim-testutils +++ b/vendor/nim-testutils @@ -1 +1 @@ -Subproject commit b3b7074e395bdbc6820860955ebbc2556a9386a0 +Subproject commit c449d909a638fca2c3adf141fb93710d882ed988 diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index 767c8e0fb..ae49e03af 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit 767c8e0fb433da5276c4ac3e61b3360e003536a7 +Subproject commit ae49e03af6f36393eb7e0fc02c1c47df42efd2de From 702977276bcb72480958183b61ca80d526729d5d Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 12:57:44 +0700 Subject: [PATCH 2/5] bump vendor/news --- vendor/news | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/news b/vendor/news index 0c44ff9cd..1caa232d6 160000 --- a/vendor/news +++ b/vendor/news @@ -1 +1 @@ -Subproject commit 0c44ff9cd31e0f644f10d9adfbfc8e0c181ea724 +Subproject commit 1caa232d63f4607f90d5a9eb428fbe772e010d21 From 51f2017b03f3e47b30179019d811cde8c7ffd1e8 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 13:10:09 +0700 Subject: [PATCH 3/5] add bearssl submodule --- .gitmodules | 7 +++++++ vendor/nim-bearssl | 1 + 2 files changed, 8 insertions(+) create mode 160000 vendor/nim-bearssl diff --git a/.gitmodules b/.gitmodules index fec1472f8..643ec06a3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -166,3 +166,10 @@ [submodule "vendor/nim-sqlite3-abi"] path = vendor/nim-sqlite3-abi url = https://github.com/arnetheduck/nim-sqlite3-abi.git + ignore = dirty + branch = master +[submodule "vendor/nim-bearssl"] + path = vendor/nim-bearssl + url = https://github.com/status-im/nim-bearssl + ignore = dirty + branch = master diff --git a/vendor/nim-bearssl b/vendor/nim-bearssl new file mode 160000 index 000000000..68c6d2730 --- /dev/null +++ b/vendor/nim-bearssl @@ -0,0 +1 @@ +Subproject commit 68c6d27304245c948526487b37e10951acf7dbc8 From 12ddfee6756ef3c52559d0a065822f448f41e234 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 17:07:33 +0700 Subject: [PATCH 4/5] 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") From 2ef8179ab0ab7140ecd6bb7096cc4e027657e9d7 Mon Sep 17 00:00:00 2001 From: jangko Date: Wed, 24 Jun 2020 20:32:49 +0700 Subject: [PATCH 5/5] fix libnimbus compilation errors related to eth/keys changes --- wrappers/libnimbus.nim | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/wrappers/libnimbus.nim b/wrappers/libnimbus.nim index ccf088539..ee0d2ce3b 100644 --- a/wrappers/libnimbus.nim +++ b/wrappers/libnimbus.nim @@ -101,12 +101,11 @@ proc nimbus_start(port: uint16, startListening: bool, enableDiscovery: bool, else: let privKey = PrivateKey.fromRaw(makeOpenArray(privateKey, 32)) - kp = privKey and privKey[].toKeyPair() - if kp.isErr: + if privKey.isErr: error "Passed an invalid private key." return false - keypair = kp[] + keypair = privKey[].toKeyPair() node = newEthereumNode(keypair, address, 1, nil, addAllCapabilities = false) node.addCapability Whisper @@ -174,7 +173,7 @@ proc nimbus_new_keypair(id: var Identifier): bool discard proc nimbus_add_keypair(privateKey: ptr byte, id: var Identifier): - bool {.exportc, dynlib, raises: [Defect].} = + bool {.exportc, dynlib, raises: [Defect, Exception].} = ## Caller needs to provide as id a pointer to 32 bytes allocation. doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.") doAssert(not privateKey.isNil, "Private key cannot be nil.") @@ -189,12 +188,11 @@ proc nimbus_add_keypair(privateKey: ptr byte, id: var Identifier): else: let privKey = PrivateKey.fromRaw(makeOpenArray(privateKey, 32)) - kp = privKey and privKey[].toKeyPair() - if kp.isErr: + if privKey.isErr: error "Passed an invalid private key." return false - keypair = kp[] + keypair = privKey[].toKeyPair() result = true id = generateRandomID() @@ -208,7 +206,7 @@ proc nimbus_delete_keypair(id: Identifier): bool result = whisperKeys.asymKeys.take(id.toHex(), unneeded) proc nimbus_get_private_key(id: Identifier, privateKey: var PrivateKey): - bool {.exportc, dynlib, raises: [OSError, IOError, ValueError].} = + bool {.exportc, dynlib, raises: [OSError, IOError, ValueError, Exception].} = doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.") doAssert(not (unsafeAddr privateKey).isNil, "Private key cannot be nil.") @@ -256,7 +254,7 @@ proc nimbus_delete_symkey(id: Identifier): bool result = whisperKeys.symKeys.take(id.toHex(), unneeded) proc nimbus_get_symkey(id: Identifier, symKey: var SymKey): - bool {.exportc, dynlib, raises: [Defect].} = + bool {.exportc, dynlib, raises: [Defect, Exception].} = doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.") doAssert(not (unsafeAddr symKey).isNil, "Symmetric key cannot be nil.")