Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Bump dependencies for v0.34 #3096

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,18 @@
branch = master
path = vendor/nph
url = https://github.com/arnetheduck/nph.git
[submodule "vendor/nim-minilru"]
path = vendor/nim-minilru
url = https://github.com/status-im/nim-minilru.git
ignore = untracked
branch = master
[submodule "vendor/nim-quic"]
path = vendor/nim-quic
url = https://github.com/status-im/nim-quic.git
ignore = untracked
branch = master
[submodule "vendor/nim-ngtcp2"]
path = vendor/nim-ngtcp2
url = https://github.com/vacp2p/nim-ngtcp2.git
ignore = untracked
branch = master
3 changes: 1 addition & 2 deletions apps/chat2bridge/chat2bridge.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{.push raises: [].}

import
std/[tables, times, strutils, hashes, sequtils],
std/[tables, times, strutils, hashes, sequtils, json],
chronos,
confutils,
chronicles,
Expand All @@ -11,7 +11,6 @@ import
metrics/chronos_httpserver,
stew/byteutils,
eth/net/nat,
json_rpc/rpcserver,
# Matterbridge client imports
# Waku v2 imports
libp2p/crypto/crypto,
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_enr_builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ suite "nim-eth ENR - Ext: IP address and TCP/UDP ports":
@(record.secp256k1.get()) == expectedPubKey
record.ip == none(array[4, byte])
record.tcp == none(uint16)
record.udp == none(uint16)
record.ip6 == some(enrIpAddr.address_v6)
record.tcp6 == none(uint16)
record.udp6 == some(enrUdpPort.uint16)
record.udp == some(enrUdpPort.uint16)
1 change: 1 addition & 0 deletions tests/waku_discv5/utils.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import
std/options,
stew/results,
stew/shims/net,
chronos,
Expand Down
1 change: 1 addition & 0 deletions tests/waku_enr/utils.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import
std/options,
sequtils,
stew/results,
stew/shims/net,
Expand Down
4 changes: 2 additions & 2 deletions tests/waku_rln_relay/test_rln_group_manager_onchain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ suite "Onchain group manager":
manager.ethRpc.isSome()
manager.wakuRlnContract.isSome()
manager.initialized
manager.rlnContractDeployedBlockNumber > 0
manager.rlnContractDeployedBlockNumber > 0.Quantity
manager.rlnRelayMaxMessageLimit == 100

await manager.stop()

asyncTest "should error on initialization when chainId does not match":
let manager = await setup()
manager.chainId = CHAIN_ID + 1
manager.chainId = utils_onchain.CHAIN_ID + 1

(await manager.init()).isErrOr:
raiseAssert "Expected error when chainId does not match"
Expand Down
17 changes: 9 additions & 8 deletions tests/waku_rln_relay/utils.nim
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import web3, chronos, options, stint
import web3, chronos, options, stint, stew/byteutils

proc deployContract*(
web3: Web3, code: string, gasPrice = 0, contractInput = ""
): Future[ReceiptObject] {.async.} =
# the contract input is the encoded version of contract constructor's input
# use nim-web3/encoding.nim module to find the appropriate encoding procedure for different argument types
# e.g., consider the following contract constructor in solidity
# constructor(uint256 x, uint256 y)
# constructor(uint256 x, uint256 y)
#
# the contractInput can be calculated as follows
# let
# x = 1.u256
# y = 5.u256
# contractInput = encode(x).data & encode(y).data
# contractInput = encode(x).data & encode(y).data
# Note that the order of encoded inputs should match the order of the constructor inputs
let provider = web3.provider
let accounts = await provider.eth_accounts()

var code = code
if code[1] notin {'x', 'X'}:
code = "0x" & code
var tr: EthSend
tr.source = web3.defaultAccount
tr.data = code & contractInput
tr.gas = Quantity(3000000000000).some
var tr: TransactionArgs
tr.`from` = Opt.some(web3.defaultAccount)
let sData = code & contractInput
tr.data = Opt.some(hexToSeqByte(sData))
tr.gas = Opt.some(Quantity(3000000000000))
if gasPrice != 0:
tr.gasPrice = some(gasPrice)
tr.gasPrice = Opt.some(gasPrice.Quantity)

let r = await web3.send(tr)
return await web3.getMinedTransactionReceipt(r)
Expand Down
31 changes: 23 additions & 8 deletions tests/waku_rln_relay/utils_onchain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import
chronicles,
stint,
web3,
web3/conversions,
web3/eth_api_types,
json,
libp2p/crypto/crypto,
eth/keys
Expand All @@ -27,6 +29,18 @@ import

const CHAIN_ID* = 1337

template skip0xPrefix(hexStr: string): int =
## Returns the index of the first meaningful char in `hexStr` by skipping
## "0x" prefix
if hexStr.len > 1 and hexStr[0] == '0' and hexStr[1] in {'x', 'X'}: 2 else: 0

func strip0xPrefix(s: string): string =
let prefixLen = skip0xPrefix(s)
if prefixLen != 0:
s[prefixLen .. ^1]
else:
s

proc generateCredentials*(rlnInstance: ptr RLN): IdentityCredential =
let credRes = membershipKeyGen(rlnInstance)
return credRes.get()
Expand Down Expand Up @@ -85,12 +99,13 @@ proc uploadRLNContract*(ethClientAddress: string): Future[Address] {.async.} =
debug "Address of the deployed rlnv2 contract: ", wakuRlnContractAddress

# need to send concat: impl & init_bytes
let contractInput = encode(wakuRlnContractAddress).data & Erc1967ProxyContractInput
let contractInput =
byteutils.toHex(encode(wakuRlnContractAddress)) & Erc1967ProxyContractInput
debug "contractInput", contractInput
let proxyReceipt =
await web3.deployContract(Erc1967Proxy, contractInput = contractInput)

debug "proxy receipt", proxyReceipt
debug "proxy receipt", contractAddress = proxyReceipt.contractAddress.get()
let proxyAddress = proxyReceipt.contractAddress.get()

let newBalance = await web3.provider.eth_getBalance(web3.defaultAccount, "latest")
Expand All @@ -106,17 +121,17 @@ proc createEthAccount*(
): Future[(keys.PrivateKey, Address)] {.async.} =
let web3 = await newWeb3(EthClient)
let accounts = await web3.provider.eth_accounts()
let gasPrice = int(await web3.provider.eth_gasPrice())
let gasPrice = Quantity(await web3.provider.eth_gasPrice())
web3.defaultAccount = accounts[0]

let pk = keys.PrivateKey.random(rng[])
let acc = Address(toCanonicalAddress(pk.toPublicKey()))

var tx: EthSend
tx.source = accounts[0]
tx.value = some(ethToWei(ethAmount))
tx.to = some(acc)
tx.gasPrice = some(gasPrice)
var tx: TransactionArgs
tx.`from` = Opt.some(accounts[0])
tx.value = Opt.some(ethToWei(ethAmount))
tx.to = Opt.some(acc)
tx.gasPrice = Opt.some(gasPrice)

# Send ethAmount to acc
discard await web3.send(tx)
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-chronicles
2 changes: 1 addition & 1 deletion vendor/nim-eth
Submodule nim-eth updated 135 files
2 changes: 1 addition & 1 deletion vendor/nim-http-utils
2 changes: 1 addition & 1 deletion vendor/nim-json-rpc
Submodule nim-json-rpc updated 47 files
+32 −8 .github/workflows/ci.yml
+84 −66 README.md
+9 −0 config.nims
+24 −15 json_rpc.nimble
+233 −158 json_rpc/client.nim
+115 −56 json_rpc/clients/httpclient.nim
+87 −20 json_rpc/clients/socketclient.nim
+16 −116 json_rpc/clients/websocketclient.nim
+155 −0 json_rpc/clients/websocketclientimpl.nim
+29 −2 json_rpc/errors.nim
+23 −283 json_rpc/jsonmarshal.nim
+163 −0 json_rpc/private/client_handler_wrapper.nim
+321 −0 json_rpc/private/jrpc_sys.nim
+319 −0 json_rpc/private/server_handler_wrapper.nim
+70 −0 json_rpc/private/shared_wrapper.nim
+199 −119 json_rpc/router.nim
+9 −0 json_rpc/rpcclient.nim
+22 −7 json_rpc/rpcproxy.nim
+0 −3 json_rpc/rpcsecureserver.nim
+9 −0 json_rpc/rpcserver.nim
+61 −8 json_rpc/server.nim
+81 −35 json_rpc/servers/httpserver.nim
+41 −22 json_rpc/servers/socketserver.nim
+60 −24 json_rpc/servers/websocketserver.nim
+9 −0 nim.cfg
+16 −1 tests/all.nim
+0 −12 tests/helpers.nim
+0 −9 tests/private/ethcallsigs.nim
+44 −27 tests/private/ethhexstrings.nim
+24 −6 tests/private/ethprocs.nim
+0 −0 tests/private/ethtypes.nim
+11 −0 tests/private/file_callsigs.nim
+19 −0 tests/private/helpers.nim
+44 −0 tests/private/stintjson.nim
+0 −32 tests/stintjson.nim
+145 −0 tests/test_batch_call.nim
+154 −0 tests/test_callsigs.nim
+302 −0 tests/test_client_hook.nim
+255 −0 tests/test_jrpc_sys.nim
+146 −0 tests/test_router_rpc.nim
+42 −14 tests/testethcalls.nim
+24 −13 tests/testhook.nim
+44 −16 tests/testhttp.nim
+27 −17 tests/testhttps.nim
+19 −11 tests/testproxy.nim
+106 −35 tests/testrpcmacro.nim
+40 −13 tests/testserverclient.nim
2 changes: 1 addition & 1 deletion vendor/nim-libp2p
Submodule nim-libp2p updated 58 files
+1 −0 .github/workflows/ci.yml
+1 −0 .github/workflows/coverage.yml
+1 −1 .github/workflows/daily_amd64.yml
+14 −1 .github/workflows/daily_common.yml
+1 −1 .github/workflows/daily_devel.yml
+1 −1 .github/workflows/daily_i386.yml
+15 −0 .github/workflows/daily_sat.yml
+1 −0 .github/workflows/interop.yml
+3 −1 .github/workflows/linters.yml
+3 −1 .pinned
+3 −0 config.nims
+5 −0 funding.json
+1 −0 libp2p.nim
+7 −6 libp2p.nimble
+10 −7 libp2p/connmanager.nim
+10 −8 libp2p/crypto/crypto.nim
+7 −5 libp2p/dialer.nim
+1 −1 libp2p/discovery/rendezvousinterface.nim
+3 −3 libp2p/errors.nim
+18 −12 libp2p/multiaddress.nim
+1 −1 libp2p/multistream.nim
+3 −3 libp2p/muxers/mplex/lpchannel.nim
+5 −5 libp2p/muxers/mplex/mplex.nim
+8 −8 libp2p/muxers/yamux/yamux.nim
+1 −1 libp2p/nameresolving/dnsresolver.nim
+4 −4 libp2p/protocols/connectivity/autonat/server.nim
+4 −4 libp2p/protocols/connectivity/autonat/service.nim
+3 −3 libp2p/protocols/connectivity/dcutr/client.nim
+3 −3 libp2p/protocols/connectivity/dcutr/server.nim
+6 −6 libp2p/protocols/connectivity/relay/client.nim
+8 −7 libp2p/protocols/connectivity/relay/relay.nim
+1 −1 libp2p/protocols/connectivity/relay/utils.nim
+2 −2 libp2p/protocols/identify.nim
+1 −1 libp2p/protocols/perf/server.nim
+1 −1 libp2p/protocols/ping.nim
+3 −3 libp2p/protocols/pubsub/floodsub.nim
+6 −6 libp2p/protocols/pubsub/gossipsub.nim
+1 −1 libp2p/protocols/pubsub/gossipsub/scoring.nim
+4 −4 libp2p/protocols/pubsub/pubsub.nim
+8 −8 libp2p/protocols/pubsub/pubsubpeer.nim
+2 −2 libp2p/protocols/pubsub/rpc/protobuf.nim
+4 −4 libp2p/protocols/rendezvous.nim
+1 −1 libp2p/protocols/secure/secure.nim
+1 −1 libp2p/stream/lpstream.nim
+4 −4 libp2p/switch.nim
+224 −0 libp2p/transports/quictransport.nim
+16 −5 libp2p/transports/tcptransport.nim
+12 −12 libp2p/transports/wstransport.nim
+2 −1 libp2p/utility.nim
+2 −2 libp2p/wire.nim
+0 −4 tests/config.nims
+1 −1 tests/hole-punching-interop/hole_punching.nim
+1 −1 tests/pubsub/testgossipinternal.nim
+2 −2 tests/pubsub/testgossipsub.nim
+17 −7 tests/testmultiaddress.nim
+24 −0 tests/testquic.nim
+37 −0 tests/testswitch.nim
+11 −15 tests/testutility.nim
2 changes: 1 addition & 1 deletion vendor/nim-metrics
1 change: 1 addition & 0 deletions vendor/nim-minilru
Submodule nim-minilru added at 2682cf
1 change: 1 addition & 0 deletions vendor/nim-ngtcp2
Submodule nim-ngtcp2 added at 6834f4
2 changes: 1 addition & 1 deletion vendor/nim-presto
1 change: 1 addition & 0 deletions vendor/nim-quic
Submodule nim-quic added at ddcb31
2 changes: 1 addition & 1 deletion vendor/nim-secp256k1
2 changes: 1 addition & 1 deletion vendor/nim-taskpools
2 changes: 1 addition & 1 deletion vendor/nim-testutils
2 changes: 1 addition & 1 deletion vendor/nim-unicodedb
Submodule nim-unicodedb updated 60 files
+1 −1 .github/workflows/ci.yml
+1 −0 .gitignore
+5 −0 CHANGELOG.md
+4 −4 README.md
+16 −4 gen/UCD/Blocks.txt
+34 −4 gen/UCD/CaseFolding.txt
+898 −111 gen/UCD/DerivedCoreProperties.txt
+6,303 −16 gen/UCD/DerivedNormalizationProps.txt
+2,652 −2,585 gen/UCD/EastAsianWidth.txt
+188 −27 gen/UCD/PropList.txt
+128 −31 gen/UCD/Scripts.txt
+11 −11 gen/UCD/SpecialCasing.txt
+5,201 −9 gen/UCD/UnicodeData.txt
+72 −24 gen/UCD/auxiliary/WordBreakProperty.txt
+31 −11 gen/UCD/emoji/emoji-data.txt
+100 −37 gen/UCD/extracted/DerivedBidiClass.txt
+23 −6 gen/UCD/extracted/DerivedNumericType.txt
+2 −2 gen/blocks.nim
+5 −5 gen/casing.nim
+13 −11 gen/compositions.nim
+6 −6 gen/min_perfect_hash.nim
+3 −1 gen/names.nim
+5 −5 gen/properties.nim
+35 −0 gen/scripts.nim
+4 −8 gen/test_data.nim
+2 −2 gen/two_stage_table.nim
+6 −6 gen/types.nim
+1 −1 gen/unicode_data.nim
+2 −2 gen/utils.nim
+6 −6 gen/widths.nim
+4 −4 gen/widths_legacy.nim
+6 −6 src/unicodedb.nim
+22 −0 src/unicodedb/blocks_data.nim
+6 −6 src/unicodedb/casing.nim
+1,007 −931 src/unicodedb/casing_data.nim
+4 −2 src/unicodedb/collation.nim
+13 −10 src/unicodedb/compositions.nim
+971 −949 src/unicodedb/compositions_data.nim
+646 −530 src/unicodedb/decompositions_data.nim
+8 −5 src/unicodedb/names.nim
+36,880 −35,444 src/unicodedb/names_data.nim
+2 −2 src/unicodedb/properties.nim
+518 −439 src/unicodedb/properties_data.nim
+11 −4 src/unicodedb/scripts.nim
+474 −382 src/unicodedb/scripts_data.nim
+3 −3 src/unicodedb/segmentation.nim
+410 −358 src/unicodedb/segmentation_data.nim
+2 −2 src/unicodedb/types.nim
+563 −503 src/unicodedb/types_data.nim
+4 −4 src/unicodedb/widths.nim
+108 −108 src/unicodedb/widths_data.nim
+77 −44 tests/bidi_test_data.nim
+82 −43 tests/category_test_data.nim
+70 −45 tests/combining_test_data.nim
+62 −0 tests/decompositions_test_data.nim
+0 −1 tests/nim.cfg
+58 −39 tests/tests.nim
+71 −51 tests/types_test_data.nim
+44 −14 tests/word_break_test_data.nim
+2 −1 unicodedb.nimble
2 changes: 1 addition & 1 deletion vendor/nim-unittest2
2 changes: 1 addition & 1 deletion vendor/nim-web3
2 changes: 1 addition & 1 deletion vendor/nim-websock
2 changes: 1 addition & 1 deletion vendor/nim-zlib
4 changes: 3 additions & 1 deletion waku.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ requires "nim >= 2.0.8",
"web3",
"presto",
"regex",
"db_connector"
"db_connector",
"minilru",
"quic"

### Helper functions
proc buildModule(filePath, params = "", lang = "c"): bool =
Expand Down
54 changes: 21 additions & 33 deletions waku/common/enr/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@ import
eth/p2p/discoveryv5/enr,
libp2p/crypto/crypto as libp2p_crypto

import ./typed_record

## Builder

type EnrBuilder* = object
seqNumber: uint64
privateKey: eth_keys.PrivateKey
ipAddress: Opt[IpAddress]
tcpPort: Opt[Port]
udpPort: Opt[Port]
fields: seq[FieldPair]

proc init*(T: type EnrBuilder, key: eth_keys.PrivateKey, seqNum: uint64 = 1): T =
EnrBuilder(seqNumber: seqNum, privateKey: key, fields: newSeq[FieldPair]())
EnrBuilder(
seqNumber: seqNum,
privateKey: key,
ipAddress: Opt.none(IpAddress),
tcpPort: Opt.none(Port),
udpPort: Opt.none(Port),
fields: newSeq[FieldPair](),
)

proc init*(T: type EnrBuilder, key: libp2p_crypto.PrivateKey, seqNum: uint64 = 1): T =
# TODO: Inconvenient runtime assertion. Move this assertion to compile time
Expand All @@ -41,9 +53,9 @@ proc build*(builder: EnrBuilder): EnrResult[enr.Record] =
enr.Record.init(
seqNum = builder.seqNumber,
pk = builder.privateKey,
ip = none(IpAddress),
tcpPort = none(Port),
udpPort = none(Port),
ip = builder.ipAddress,
tcpPort = builder.tcpPort,
udpPort = builder.udpPort,
extraFields = builder.fields,
)

Expand All @@ -52,38 +64,14 @@ proc build*(builder: EnrBuilder): EnrResult[enr.Record] =
proc addAddressAndPorts(
builder: var EnrBuilder, ip: IpAddress, tcpPort, udpPort: Option[Port]
) =
# Based on: https://github.com/status-im/nim-eth/blob/4b22fcd/eth/p2p/discoveryv5/enr.nim#L166
let isV6 = ip.family == IPv6

let ipField =
if isV6:
toFieldPair("ip6", ip.address_v6)
else:
toFieldPair("ip", ip.address_v4)
builder.addFieldPair(ipField)

if tcpPort.isSome():
let
tcpPortFieldKey = if isV6: "tcp6" else: "tcp"
tcpPortFieldValue = tcpPort.get()
builder.addFieldPair(tcpPortFieldKey, tcpPortFieldValue.uint16)

if udpPort.isSome():
let
udpPortFieldKey = if isV6: "udp6" else: "udp"
udpPortFieldValue = udpPort.get()
builder.addFieldPair(udpPortFieldKey, udpPortFieldValue.uint16)
builder.ipAddress = Opt.some(ip)
builder.tcpPort = tcpPort.toOpt()
builder.udpPort = udpPort.toOpt()

proc addPorts(builder: var EnrBuilder, tcp, udp: Option[Port]) =
# Based on: https://github.com/status-im/nim-eth/blob/4b22fcd/eth/p2p/discoveryv5/enr.nim#L166

if tcp.isSome():
let tcpPort = tcp.get()
builder.addFieldPair("tcp", tcpPort.uint16)

if udp.isSome():
let udpPort = udp.get()
builder.addFieldPair("udp", udpPort.uint16)
builder.tcpPort = tcp.toOpt()
builder.udpPort = udp.toOpt()

proc withIpAddressAndPorts*(
builder: var EnrBuilder,
Expand Down
25 changes: 22 additions & 3 deletions waku/common/enr/typed_record.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import std/options, results, eth/keys as eth_keys, libp2p/crypto/crypto as libp2

import eth/p2p/discoveryv5/enr except TypedRecord, toTypedRecord

## Since enr changed to result.Opt[T] from Option[T] for intercompatibility introduce a conversion between
func toOpt*[T](o: Option[T]): Opt[T] =
if o.isSome():
return Opt.some(o.get())
else:
return Opt.none(T)

func toOption*[T](o: Opt[T]): Option[T] =
if o.isSome():
return some(o.get())
else:
return none(T)

## ENR typed record

# Record identity scheme
Expand Down Expand Up @@ -31,7 +44,7 @@ proc init(T: type TypedRecord, record: Record): T =
TypedRecord(raw: record)

proc tryGet*(record: TypedRecord, field: string, T: type): Option[T] =
record.raw.tryGet(field, T)
return record.raw.tryGet(field, T).toOption()

func toTyped*(record: Record): EnrResult[TypedRecord] =
let tr = TypedRecord.init(record)
Expand Down Expand Up @@ -71,10 +84,16 @@ func tcp*(record: TypedRecord): Option[uint16] =
record.tryGet("tcp", uint16)

func tcp6*(record: TypedRecord): Option[uint16] =
record.tryGet("tcp6", uint16)
let port = record.tryGet("tcp6", uint16)
if port.isNone():
return record.tcp()
return port

func udp*(record: TypedRecord): Option[uint16] =
record.tryGet("udp", uint16)

func udp6*(record: TypedRecord): Option[uint16] =
record.tryGet("udp6", uint16)
let port = record.tryGet("udp6", uint16)
if port.isNone():
return record.udp()
return port
Loading
Loading