chronos: bump (#5684)

This PR causes a few new warnings to appear - these are harmless but
will need addressing separately as they span several libraries.

* new asyncraises syntax
* asyncraises support in several modules
* `sink` usage reduces spurious copying
* `?` compatiblity for `async` + `results`
* remove `-d:chronosStrictException` (obsolete)
This commit is contained in:
Jacek Sieka 2024-01-05 10:08:38 +01:00 committed by GitHub
parent 7a89404404
commit 3f525acb87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 29 deletions

View File

@ -215,7 +215,7 @@ jobs:
if: ${{ !cancelled() }} && github.event_name == 'pull_request' if: ${{ !cancelled() }} && github.event_name == 'pull_request'
run: | run: |
excluded_files="config.yaml" excluded_files="config.yaml"
excluded_extensions="ans|json|json\\.template|md|png|service|ssz|txt" excluded_extensions="ans|cfg|json|json\\.template|md|png|service|ssz|txt"
current_year=$(date +"%Y") current_year=$(date +"%Y")
outdated_files=() outdated_files=()

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2023 Status Research & Development GmbH # Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -841,19 +841,23 @@ template gossipMaxSize(T: untyped): uint32 =
static: doAssert maxSize <= GOSSIP_MAX_SIZE static: doAssert maxSize <= GOSSIP_MAX_SIZE
maxSize.uint32 maxSize.uint32
proc readChunkPayload*(conn: Connection, peer: Peer, proc readVarint2(conn: Connection): Future[NetRes[uint64]] {.async.} =
MsgType: type): Future[NetRes[MsgType]] {.async.} = try:
let sm = now(chronos.Moment) ok await conn.readVarint()
let size =
try: await conn.readVarint()
except LPStreamEOFError: #, LPStreamIncompleteError, InvalidVarintError except LPStreamEOFError: #, LPStreamIncompleteError, InvalidVarintError
# TODO compiler error - haha, uncaught exception # TODO compiler error - haha, uncaught exception
# Error: unhandled exception: closureiters.nim(322, 17) `c[i].kind == nkType` [AssertionError] # Error: unhandled exception: closureiters.nim(322, 17) `c[i].kind == nkType` [AssertionError]
return neterr UnexpectedEOF neterr UnexpectedEOF
except LPStreamIncompleteError: except LPStreamIncompleteError:
return neterr UnexpectedEOF neterr UnexpectedEOF
except InvalidVarintError: except InvalidVarintError:
return neterr InvalidSizePrefix neterr InvalidSizePrefix
proc readChunkPayload*(conn: Connection, peer: Peer,
MsgType: type): Future[NetRes[MsgType]] {.async.} =
let
sm = now(chronos.Moment)
size = ? await readVarint2(conn)
const maxSize = chunkMaxSize[MsgType]() const maxSize = chunkMaxSize[MsgType]()
if size > maxSize: if size > maxSize:
@ -862,16 +866,17 @@ proc readChunkPayload*(conn: Connection, peer: Peer,
return neterr ZeroSizePrefix return neterr ZeroSizePrefix
# The `size.int` conversion is safe because `size` is bounded to `MAX_CHUNK_SIZE` # The `size.int` conversion is safe because `size` is bounded to `MAX_CHUNK_SIZE`
let data = await conn.uncompressFramedStream(size.int) let
if data.isOk: dataRes = await conn.uncompressFramedStream(size.int)
data = dataRes.valueOr:
debug "Snappy decompression/read failed", msg = $dataRes.error, conn
return neterr InvalidSnappyBytes
# `10` is the maximum size of variable integer on wire, so error could # `10` is the maximum size of variable integer on wire, so error could
# not be significant. # not be significant.
peer.updateNetThroughput(now(chronos.Moment) - sm, peer.updateNetThroughput(now(chronos.Moment) - sm,
uint64(10 + size)) uint64(10 + size))
return ok SSZ.decode(data.get(), MsgType) ok SSZ.decode(data, MsgType)
else:
debug "Snappy decompression/read failed", msg = $data.error, conn
return neterr InvalidSnappyBytes
proc readResponseChunk( proc readResponseChunk(
conn: Connection, peer: Peer, MsgType: typedesc): conn: Connection, peer: Peer, MsgType: typedesc):

View File

@ -8,7 +8,6 @@
# Use only `secp256k1` public key cryptography as an identity in LibP2P. # Use only `secp256k1` public key cryptography as an identity in LibP2P.
-d:"libp2p_pki_schemes=secp256k1" -d:"libp2p_pki_schemes=secp256k1"
-d:chronosStrictException
--styleCheck:usages --styleCheck:usages
--styleCheck:hint --styleCheck:hint
--hint[ConvFromXtoItselfNotNeeded]:off --hint[ConvFromXtoItselfNotNeeded]:off

View File

@ -9,7 +9,6 @@
-d:"libp2p_pki_schemes=secp256k1" -d:"libp2p_pki_schemes=secp256k1"
-d:chronosStrictException
--styleCheck:usages --styleCheck:usages
--styleCheck:hint --styleCheck:hint
--hint[ConvFromXtoItselfNotNeeded]:off --hint[ConvFromXtoItselfNotNeeded]:off

View File

@ -1,3 +1,10 @@
# beacon_chain
# Copyright (c) 2020-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
strutils, strformat, parseutils strutils, strformat, parseutils

View File

@ -9,7 +9,6 @@
-d:"libp2p_pki_schemes=secp256k1" -d:"libp2p_pki_schemes=secp256k1"
-d:chronosStrictException
--styleCheck:usages --styleCheck:usages
--styleCheck:hint --styleCheck:hint
--hint[ConvFromXtoItselfNotNeeded]:off --hint[ConvFromXtoItselfNotNeeded]:off

View File

@ -8,7 +8,7 @@
# Use only `secp256k1` public key cryptography as an identity in LibP2P. # Use only `secp256k1` public key cryptography as an identity in LibP2P.
-d:"libp2p_pki_schemes=secp256k1" -d:"libp2p_pki_schemes=secp256k1"
-d:"chronicles_runtime_filtering=on" -d:"chronicles_runtime_filtering=on"
-d:chronosStrictException
--styleCheck:usages --styleCheck:usages
--styleCheck:hint --styleCheck:hint
--hint[ConvFromXtoItselfNotNeeded]:off --hint[ConvFromXtoItselfNotNeeded]:off

2
vendor/nim-chronos vendored

@ -1 +1 @@
Subproject commit be2edab3ac101da03a70cbf52bc3f3d972b35d91 Subproject commit 41f77d261ead2508acdd3bd3f88a5cbbcefff05f

2
vendor/nim-results vendored

@ -1 +1 @@
Subproject commit f3c666a272c69d70cb41e7245e7f6844797303ad Subproject commit 113d433f48894ee8e7da3e340c8fe19ad7b9db4d