Skip to content

Commit

Permalink
Merge branch 'unstable' into chore/add-rendezvous-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavlin authored Jun 7, 2023
2 parents b4448d1 + c76d1e1 commit 583b89d
Show file tree
Hide file tree
Showing 112 changed files with 255 additions and 566 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cpu: amd64
#- os: windows
#cpu: i386
branch: [version-1-2, version-1-6]
branch: [version-1-6]
include:
- target:
os: linux
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/multi_nim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cpu: amd64
#- os: windows
#cpu: i386
branch: [version-1-2, version-1-6, devel]
branch: [version-1-6, version-2-0, devel]
include:
- target:
os: linux
Expand All @@ -48,7 +48,7 @@ jobs:

name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
continue-on-error: ${{ matrix.branch == 'devel' }}
continue-on-error: ${{ matrix.branch == 'devel' || matrix.branch == 'version-2-0' }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The versioning follows [semver](https://semver.org/), with some additions:
- Some of libp2p procedures are marked as `.public.`, they will remain compatible during each `MAJOR` version
- The rest of the procedures are considered internal, and can change at any `MINOR` version (but remain compatible for each new `PATCH`)

We aim to be compatible at all time with at least 2 Nim `MINOR` versions, currently `1.2 & 1.6`
We aim to be compatible at all time with at least 2 Nim `MINOR` versions, currently `1.6 & 2.0`

## Development
Clone and Install dependencies:
Expand Down
7 changes: 2 additions & 5 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ switch("warning", "ObservableStores:off")
switch("warning", "LockLevel:off")
--define:chronosStrictException
--styleCheck:usages
if (NimMajor, NimMinor) < (1, 6):
--styleCheck:hint
else:
switch("warningAsError", "UseBase:on")
--styleCheck:error
switch("warningAsError", "UseBase:on")
--styleCheck:error

# Avoid some rare stack corruption while using exceptions with a SEH-enabled
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
Expand Down
19 changes: 8 additions & 11 deletions libp2p.nimble
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mode = ScriptMode.Verbose

packageName = "libp2p"
version = "1.0.0"
version = "1.1.0"
author = "Status Research & Development GmbH"
description = "LibP2P implementation"
license = "MIT"
skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"]

requires "nim >= 1.2.0",
requires "nim >= 1.6.0",
"nimcrypto >= 0.4.1",
"dnsclient >= 0.3.0 & < 0.4.0",
"bearssl >= 0.1.4",
Expand Down Expand Up @@ -104,15 +104,12 @@ task examples_build, "Build the samples":
buildSample("circuitrelay", true)
buildSample("tutorial_1_connect", true)
buildSample("tutorial_2_customproto", true)
if (NimMajor, NimMinor) > (1, 2):
# These tutorials relies on post 1.4 exception tracking
buildSample("tutorial_3_protobuf", true)
buildSample("tutorial_4_gossipsub", true)
buildSample("tutorial_5_discovery", true)
# Nico doesn't work in 1.2
exec "nimble install -y nimpng@#HEAD" # this is to fix broken build on 1.7.3, remove it when nimpng version 0.3.2 or later is released
exec "nimble install -y nico"
buildSample("tutorial_6_game", false, "--styleCheck:off")
buildSample("tutorial_3_protobuf", true)
buildSample("tutorial_4_gossipsub", true)
buildSample("tutorial_5_discovery", true)
exec "nimble install -y nimpng@#HEAD" # this is to fix broken build on 1.7.3, remove it when nimpng version 0.3.2 or later is released
exec "nimble install -y nico"
buildSample("tutorial_6_game", false, "--styleCheck:off")

# pin system
# while nimble lockfile
Expand Down
11 changes: 4 additions & 7 deletions libp2p/builders.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ runnableExamples:
# etc
.build()

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import
options, tables, chronos, chronicles, sequtils,
Expand All @@ -36,7 +33,7 @@ export
switch, peerid, peerinfo, connection, multiaddress, crypto, errors

type
TransportProvider* {.public.} = proc(upgr: Upgrade): Transport {.gcsafe, raises: [Defect].}
TransportProvider* {.public.} = proc(upgr: Upgrade): Transport {.gcsafe, raises: [].}

SecureProtocol* {.pure.} = enum
Noise,
Expand Down Expand Up @@ -205,7 +202,7 @@ proc withServices*(b: SwitchBuilder, services: seq[Service]): SwitchBuilder =
b

proc build*(b: SwitchBuilder): Switch
{.raises: [Defect, LPError], public.} =
{.raises: [LPError], public.} =

if b.rng == nil: # newRng could fail
raise newException(Defect, "Cannot initialize RNG")
Expand Down Expand Up @@ -296,7 +293,7 @@ proc newStandardSwitch*(
nameResolver: NameResolver = nil,
sendSignedPeerRecord = false,
peerStoreCapacity = 1000): Switch
{.raises: [Defect, LPError], public.} =
{.raises: [LPError], public.} =
## Helper for common switch configurations.
{.push warning[Deprecated]:off.}
if SecureProtocol.Secio in secureManagers:
Expand Down
5 changes: 1 addition & 4 deletions libp2p/cid.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

## This module implementes CID (Content IDentifier).

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import tables, hashes
import multibase, multicodec, multihash, vbuffer, varint
Expand Down
13 changes: 5 additions & 8 deletions libp2p/connmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
# This file may not be copied, modified, or distributed except according to
# those terms.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import std/[options, tables, sequtils, sets]
import pkg/[chronos, chronicles, metrics]
Expand Down Expand Up @@ -51,7 +48,7 @@ type

ConnEventHandler* =
proc(peerId: PeerId, event: ConnEvent): Future[void]
{.gcsafe, raises: [Defect].}
{.gcsafe, raises: [].}

PeerEventKind* {.pure.} = enum
Left,
Expand All @@ -65,7 +62,7 @@ type
discard

PeerEventHandler* =
proc(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe, raises: [Defect].}
proc(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe, raises: [].}

ConnManager* = ref object of RootObj
maxConnsPerPeer: int
Expand Down Expand Up @@ -285,7 +282,7 @@ proc selectMuxer*(c: ConnManager, peerId: PeerId): Muxer =

proc storeMuxer*(c: ConnManager,
muxer: Muxer)
{.raises: [Defect, CatchableError].} =
{.raises: [CatchableError].} =
## store the connection and muxer
##

Expand Down Expand Up @@ -338,7 +335,7 @@ proc getIncomingSlot*(c: ConnManager): Future[ConnectionSlot] {.async.} =
await c.inSema.acquire()
return ConnectionSlot(connManager: c, direction: In)

proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [Defect, TooManyConnectionsError].} =
proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [TooManyConnectionsError].} =
if forceDial:
c.outSema.forceAcquire()
elif not c.outSema.tryAcquire():
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/chacha20poly1305.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

# RFC @ https://tools.ietf.org/html/rfc7539

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/blockx
from stew/assign2 import assign
Expand Down
15 changes: 6 additions & 9 deletions libp2p/crypto/crypto.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
# those terms.

## This module implements Public Key and Private Key interface for libp2p.
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

from strutils import split, strip, cmpIgnoreCase

Expand Down Expand Up @@ -1003,27 +1000,27 @@ proc decodeExchange*(message: seq[byte],
## Serialization/Deserialization helpers

proc write*(vb: var VBuffer, pubkey: PublicKey) {.
inline, raises: [Defect, ResultError[CryptoError]].} =
inline, raises: [ResultError[CryptoError]].} =
## Write PublicKey value ``pubkey`` to buffer ``vb``.
vb.writeSeq(pubkey.getBytes().tryGet())

proc write*(vb: var VBuffer, seckey: PrivateKey) {.
inline, raises: [Defect, ResultError[CryptoError]].} =
inline, raises: [ResultError[CryptoError]].} =
## Write PrivateKey value ``seckey`` to buffer ``vb``.
vb.writeSeq(seckey.getBytes().tryGet())

proc write*(vb: var VBuffer, sig: PrivateKey) {.
inline, raises: [Defect, ResultError[CryptoError]].} =
inline, raises: [ResultError[CryptoError]].} =
## Write Signature value ``sig`` to buffer ``vb``.
vb.writeSeq(sig.getBytes().tryGet())

proc write*[T: PublicKey|PrivateKey](pb: var ProtoBuffer, field: int,
key: T) {.
inline, raises: [Defect, ResultError[CryptoError]].} =
inline, raises: [ResultError[CryptoError]].} =
write(pb, field, key.getBytes().tryGet())

proc write*(pb: var ProtoBuffer, field: int, sig: Signature) {.
inline, raises: [Defect].} =
inline, raises: [].} =
write(pb, field, sig.getBytes())

proc getField*[T: PublicKey|PrivateKey](pb: ProtoBuffer, field: int,
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/curve25519.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

# RFC @ https://tools.ietf.org/html/rfc7748

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/[ec, rand]
import stew/results
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/ecnist.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
## BearSSL library <https://bearssl.org/>
## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/[ec, rand, hash]
# We use `ncrutils` for constant-time hexadecimal encoding/decoding procedures.
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/ed25519/ed25519.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
## This code is a port of the public domain, "ref10" implementation of ed25519
## from SUPERCOP.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/rand
import constants
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/hkdf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

# https://tools.ietf.org/html/rfc5869

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import nimcrypto
import bearssl/[kdf, hash]
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/minasn1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

## This module implements minimal ASN.1 encoding/decoding primitives.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import stew/[endians2, results, ctops]
export results
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/rsa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
## BearSSL library <https://bearssl.org/>
## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/[rsa, rand, hash]
import minasn1
Expand Down
5 changes: 1 addition & 4 deletions libp2p/crypto/secp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
# This file may not be copied, modified, or distributed except according to
# those terms.

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push raises: [].}

import bearssl/rand
import
Expand Down
Loading

0 comments on commit 583b89d

Please sign in to comment.