From b378e1989230937bfb32056d81d813f755386c3d Mon Sep 17 00:00:00 2001 From: jangko Date: Mon, 17 Apr 2023 15:22:51 +0700 Subject: [PATCH] bump submodules and accompanying fixes --- .../data_sources/json_rpc_data_source.nim | 8 +- nimbus/graphql/ethapi.nim | 91 ++++++++++++------- vendor/nim-blscurve | 2 +- vendor/nim-chronicles | 2 +- vendor/nim-chronos | 2 +- vendor/nim-confutils | 2 +- vendor/nim-eth | 2 +- vendor/nim-faststreams | 2 +- vendor/nim-graphql | 2 +- vendor/nim-http-utils | 2 +- vendor/nim-json-serialization | 2 +- vendor/nim-secp256k1 | 2 +- vendor/nim-serialization | 2 +- vendor/nim-ssz-serialization | 2 +- vendor/nim-stew | 2 +- vendor/nim-stint | 2 +- vendor/nim-toml-serialization | 2 +- 17 files changed, 80 insertions(+), 49 deletions(-) diff --git a/nimbus/evm/async/data_sources/json_rpc_data_source.nim b/nimbus/evm/async/data_sources/json_rpc_data_source.nim index 317d06127..e41038a4d 100644 --- a/nimbus/evm/async/data_sources/json_rpc_data_source.nim +++ b/nimbus/evm/async/data_sources/json_rpc_data_source.nim @@ -13,12 +13,14 @@ import eth/p2p, eth/p2p/rlpx, eth/p2p/private/p2p_types, - ../../../sync/protocol, - ../../../sync/protocol/eth66 as proto_eth66, + ../../../sync/protocol, ../../../db/[db_chain, distinct_tries, incomplete_db, storage_types], ../data_sources -from ../../../sync/protocol/eth66 import getNodeData +when defined(legacy_eth66_enabled): + import + ../../../sync/protocol/eth66 as proto_eth66 + from ../../../sync/protocol/eth66 import getNodeData from ../../../rpc/rpc_utils import toHash from web3 import Web3, BlockHash, BlockObject, FixedBytes, Address, ProofResponse, StorageProof, newWeb3, fromJson, fromHex, eth_getBlockByHash, eth_getBlockByNumber, eth_getCode, eth_getProof, blockId, `%` diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index f87eef183..5f5e050e4 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -74,7 +74,7 @@ when (NimMajor, NimMinor, NimPatch) >= (1, 6, 0): {.push hint[XCannotRaiseY]: off.} else: {.push hint[XDeclaredButNotUsed]: off.} - + proc toHash(n: Node): Hash256 = result.data = hexToByteArray[32](n.stringVal) @@ -305,7 +305,7 @@ proc getTxAt(ctx: GraphqlContextRef, header: BlockHeader, index: int): RespResul ok(respNull()) except CatchableError as e: err("can't get transaction by index '$1': $2" % [$index, e.msg]) - except Exception as em: + except RlpError as em: err("can't get transaction by index '$1': $2" % [$index, em.msg]) proc getTxByHash(ctx: GraphqlContextRef, hash: Hash256): RespResult = @@ -319,20 +319,28 @@ proc getTxByHash(ctx: GraphqlContextRef, hash: Hash256): RespResult = err("can't get transaction by hash '$1': $2" % [hash.data.toHex, em.msg]) proc accountNode(ctx: GraphqlContextRef, header: BlockHeader, address: EthAddress): RespResult = - let db = getStateDB(ctx.com, header) - when false: - # EIP 1767 unclear about non existent account - # but hive test case demand something - if not db.accountExists(address): - return ok(respNull()) - let acc = db.getAccount(address) - ok(accountNode(ctx, acc, address, db)) + try: + let db = getStateDB(ctx.com, header) + when false: + # EIP 1767 unclear about non existent account + # but hive test case demand something + if not db.accountExists(address): + return ok(respNull()) + let acc = db.getAccount(address) + ok(accountNode(ctx, acc, address, db)) + except RlpError as ex: + err(ex.msg) proc parseU64(node: Node): uint64 = for c in node.intVal: result = result * 10 + uint64(c.int - '0'.int) -{.pragma: apiPragma, cdecl, gcsafe, raises: [Defect, CatchableError], locks:0.} +when (NimMajor, NimMinor) < (1, 6): + {.pragma: apiRaises, raises: [Defect, CatchableError].} +else: + {.pragma: apiRaises, raises: [].} + +{.pragma: apiPragma, cdecl, gcsafe, apiRaises, locks:0.} {.push hint[XDeclaredButNotUsed]: off.} proc validateHex(x: Node, minLen = 0): NodeResult = @@ -499,15 +507,23 @@ proc accountTxCount(ud: RootRef, params: Args, parent: Node): RespResult {.apiPr proc accountCode(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) let acc = AccountNode(parent) - let code = acc.db.getCode(acc.address) - resp(code) + try: + let code = acc.db.getCode(acc.address) + resp(code) + except RlpError as ex: + err(ex.msg) proc accountStorage(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) let acc = AccountNode(parent) - let slot = parse(params[0].val.stringVal, UInt256, radix = 16) - let (val, _) = acc.db.getStorage(acc.address, slot) - byte32Node(val) + try: + let slot = parse(params[0].val.stringVal, UInt256, radix = 16) + let (val, _) = acc.db.getStorage(acc.address, slot) + byte32Node(val) + except RlpError as ex: + err(ex.msg) + except ValueError as ex: + err(ex.msg) const accountProcs = { # Note: Need to define it as ResolverProc else a proc with noSideEffect is @@ -899,8 +915,11 @@ proc blockTransactions(ud: RootRef, params: Args, parent: Node): RespResult {.ap proc blockTransactionAt(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) let h = HeaderNode(parent) - let index = parseU64(params[0].val) - getTxAt(ctx, h.header, index.int) + try: + let index = parseU64(params[0].val) + getTxAt(ctx, h.header, index.int) + except ValueError as ex: + err(ex.msg) proc blockLogs(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) @@ -910,8 +929,11 @@ proc blockLogs(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma. proc blockAccount(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) let h = HeaderNode(parent) - let address = hexToByteArray[20](params[0].val.stringVal) - ctx.accountNode(h.header, address) + try: + let address = hexToByteArray[20](params[0].val.stringVal) + ctx.accountNode(h.header, address) + except ValueError as ex: + err(ex.msg) const fFrom = 0 @@ -1122,13 +1144,16 @@ proc pickBlockNumber(ctx: GraphqlContextRef, number: Node): BlockNumber = proc queryAccount(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) - let address = hexToByteArray[20](params[0].val.stringVal) - let blockNumber = pickBlockNumber(ctx, params[1].val) - let hres = getBlockByNumber(ctx, blockNumber) - if hres.isErr: - return hres - let h = HeaderNode(hres.get()) - accountNode(ctx, h.header, address) + try: + let address = hexToByteArray[20](params[0].val.stringVal) + let blockNumber = pickBlockNumber(ctx, params[1].val) + let hres = getBlockByNumber(ctx, blockNumber) + if hres.isErr: + return hres + let h = HeaderNode(hres.get()) + accountNode(ctx, h.header, address) + except ValueError as ex: + err(ex.msg) proc queryBlock(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) @@ -1151,7 +1176,8 @@ proc queryBlocks(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragm let toNumber = pickBlockNumber(ctx, to) if fromNumber > toNumber: - return err("from($1) is bigger than to($2)" % [fromNumber.toString, toNumber.toString]) + return err("from(" & fromNumber.toString & + ") is bigger than to(" & toNumber.toString & ")") # TODO: what is the maximum number here? if toNumber - fromNumber > 32.toBlockNumber: @@ -1176,8 +1202,11 @@ proc queryPending(ud: RootRef, params: Args, parent: Node): RespResult {.apiPrag proc queryTransaction(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) - let hash = toHash(params[0].val) - getTxByHash(ctx, hash) + try: + let hash = toHash(params[0].val) + getTxByHash(ctx, hash) + except ValueError as ex: + err(ex.msg) proc queryLogs(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) @@ -1257,7 +1286,7 @@ type names: array[QcNames, Name] proc calcQC(qc: QueryComplexity, field: FieldRef): int {.cdecl, - gcsafe, raises: [Defect, CatchableError].} = + gcsafe, apiRaises.} = let qc = EthQueryComplexity(qc) if field.parentType.sym.name == qc.names[qcType] and field.field.name.name == qc.names[qcFields]: diff --git a/vendor/nim-blscurve b/vendor/nim-blscurve index 5bd4a0859..d3920425c 160000 --- a/vendor/nim-blscurve +++ b/vendor/nim-blscurve @@ -1 +1 @@ -Subproject commit 5bd4a085923d6c3be8ee095d06d1ec8473ebb6aa +Subproject commit d3920425c5c02b0a7766045c064c888cd5b83e72 diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index 14e8537e4..1e6350870 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit 14e8537e4aefda832996a187c4acfef8eadb2aeb +Subproject commit 1e6350870855541b381d77d4659688bc0d2c4227 diff --git a/vendor/nim-chronos b/vendor/nim-chronos index f7835a192..e05d2f8e9 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit f7835a192b45c37e97614d865141f21eea8c156e +Subproject commit e05d2f8e9648e17b9a71bf5e909a79241c067c8b diff --git a/vendor/nim-confutils b/vendor/nim-confutils index 38dfeaaab..6c6ff76cb 160000 --- a/vendor/nim-confutils +++ b/vendor/nim-confutils @@ -1 +1 @@ -Subproject commit 38dfeaaabdc6792d0f4d701621cbe34001978456 +Subproject commit 6c6ff76cb38a3d4fa369a2757769220f2ecf4e64 diff --git a/vendor/nim-eth b/vendor/nim-eth index ffc3ef3a7..ea3c164a0 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit ffc3ef3a7cc622166ce578e9ce0346fc0916bfe3 +Subproject commit ea3c164a0018bd62232f27d1554a91e9bdb93840 diff --git a/vendor/nim-faststreams b/vendor/nim-faststreams index 49e2c52eb..3576a15f1 160000 --- a/vendor/nim-faststreams +++ b/vendor/nim-faststreams @@ -1 +1 @@ -Subproject commit 49e2c52eb5dda46b1c9c10d079abe7bffe6cea89 +Subproject commit 3576a15f131367d8a36ffb5627b84bb59728b339 diff --git a/vendor/nim-graphql b/vendor/nim-graphql index de2f64ff7..07f238bd0 160000 --- a/vendor/nim-graphql +++ b/vendor/nim-graphql @@ -1 +1 @@ -Subproject commit de2f64ff7bb039550f99323a17ac0d79b0f96a00 +Subproject commit 07f238bd05f966a3ca4aa5c16c108fc7ecd07ed0 diff --git a/vendor/nim-http-utils b/vendor/nim-http-utils index e88e231df..aad684d37 160000 --- a/vendor/nim-http-utils +++ b/vendor/nim-http-utils @@ -1 +1 @@ -Subproject commit e88e231dfcef4585fe3b2fbd9b664dbd28a88040 +Subproject commit aad684d3758a74c1b327df93da2e956458410b48 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization index e5b18fb71..f64d55f7f 160000 --- a/vendor/nim-json-serialization +++ b/vendor/nim-json-serialization @@ -1 +1 @@ -Subproject commit e5b18fb710c3d0167ec79f3b892f5a7a1bc6d1a4 +Subproject commit f64d55f7ff480ed13eca9c97c15450a2c4106078 diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 index 4c41c5029..708a739d3 160000 --- a/vendor/nim-secp256k1 +++ b/vendor/nim-secp256k1 @@ -1 +1 @@ -Subproject commit 4c41c5029ffc73b732233f06018cd52f3ed47dce +Subproject commit 708a739d35f3fb595a83dc6e6cb9edb4c3e5361e diff --git a/vendor/nim-serialization b/vendor/nim-serialization index 257e2e02e..bc46b4c1c 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit 257e2e02ebe2efbe86beb05c62a739fc9c3d10e7 +Subproject commit bc46b4c1c1730cc25bf5fb5f3d64bd708a6ad89e diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index 3a6c350f5..3f8946ab2 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit 3a6c350f515829af327a4238ba60a384f7a02520 +Subproject commit 3f8946ab2de304a9130aa80874bc2e4025d62303 diff --git a/vendor/nim-stew b/vendor/nim-stew index c52569abd..67fdc87e2 160000 --- a/vendor/nim-stew +++ b/vendor/nim-stew @@ -1 +1 @@ -Subproject commit c52569abd5a7753c1892bf9fc85c71f0c9b6ac45 +Subproject commit 67fdc87e2521f7e021fd521c41d3228810a183d0 diff --git a/vendor/nim-stint b/vendor/nim-stint index eb1f32c67..94fc521ee 160000 --- a/vendor/nim-stint +++ b/vendor/nim-stint @@ -1 +1 @@ -Subproject commit eb1f32c6752478e18dff9256ea45538ab3312cd3 +Subproject commit 94fc521ee0f1e113d09ceeaa3568d4d7a6c0b67d diff --git a/vendor/nim-toml-serialization b/vendor/nim-toml-serialization index 2c46429b8..bad61aa6d 160000 --- a/vendor/nim-toml-serialization +++ b/vendor/nim-toml-serialization @@ -1 +1 @@ -Subproject commit 2c46429b822347aa2db04e04671988de734d2b78 +Subproject commit bad61aa6db4fd7aa0007c99b07276da55cc097da