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/update nim version #1052

Merged
merged 47 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b5af96f
Move to version 2.0.6
2-towns Nov 28, 2024
ca2b63c
Update nim-confutils submodule to latest version
2-towns Nov 28, 2024
ef3274b
Update dependencies
2-towns Dec 18, 2024
34f5e00
Update Nim version to 2.0.12
2-towns Dec 18, 2024
7c9b607
Add gcsafe pragma
2-towns Dec 18, 2024
0e00f0c
Add missing import
2-towns Dec 18, 2024
0ecf3f7
Update specific conf for Nim 2.x
2-towns Dec 18, 2024
4935494
Fix method signatures
2-towns Dec 18, 2024
a1c8c94
Revert erasure coding attempt to fix bug
2-towns Dec 18, 2024
599e868
More gcsafe pragma
2-towns Dec 18, 2024
a2f0528
Duplicate code from libp2p because it is not exported anymore
2-towns Dec 18, 2024
a2f09b2
Fix camelcase function names
2-towns Dec 18, 2024
902c6dc
Use alreadySeen because need is not a bool anymore
2-towns Dec 18, 2024
83b4943
newLPStreamReadError does not exist anymore so use another error
2-towns Dec 18, 2024
daadffe
Replace ValidIpAddress by IpAddress
2-towns Dec 18, 2024
d6b1781
Add gcsafe pragma
2-towns Dec 26, 2024
0724d7f
Restore maintenance parameter deleted by mistake when removing esasur…
2-towns Dec 26, 2024
6ad496d
Update method signatures
2-towns Dec 26, 2024
5c80a84
Copy LPStreamReadError code from libp2p which was removed
2-towns Dec 26, 2024
6b64c25
Fix camel case
2-towns Dec 26, 2024
627e6ae
Fix enums in tests
2-towns Dec 26, 2024
51a4054
Fix camel case
2-towns Dec 26, 2024
ab39da8
Extract node components to a variable to make Nim 2 happy
2-towns Dec 26, 2024
3f9f421
Update the tests using ValidIpAddress to IpAddress
2-towns Dec 26, 2024
d2388a3
Fix cast for value which is already an option
2-towns Dec 27, 2024
b9222d0
Merge branch 'master' into chore/update-nim-version
2-towns Dec 30, 2024
d9eca3b
Set nim version to 2.0.x for CI
2-towns Jan 2, 2025
696f66d
Set nim version to 2.0.x for CI
2-towns Jan 2, 2025
56d2186
Move to miniupnp version 2.2.4 to avoid symlink error
2-towns Jan 3, 2025
1ecad68
Set core.symlinks to false for Windows for miniupnp >= 2.2.5 support
2-towns Jan 6, 2025
7bdbd87
Update to Nim 2.0.14
2-towns Jan 7, 2025
dfcdac6
Update CI nim versions to 2.0.14
2-towns Jan 7, 2025
f24d264
Try with GCC 14
2-towns Jan 8, 2025
fdba4e7
Replace apt-fast by apt-get
2-towns Jan 8, 2025
251d286
Update ubuntu runner to latest
2-towns Jan 8, 2025
b5848da
Use Ubuntu 20.04 for coverage
2-towns Jan 9, 2025
801f6b7
Disable CI cache for coverage
2-towns Jan 9, 2025
2c436db
Add coverage property description
2-towns Jan 9, 2025
958df72
Remove commented test
2-towns Jan 9, 2025
08ced59
Check the node value of seen instead of using alreadySeen
2-towns Jan 9, 2025
00e3f0e
Merge branch 'master' into chore/update-nim-version
2-towns Jan 9, 2025
10bc903
Fix the merge. The taskpool work was reverted.
2-towns Jan 9, 2025
66d1c5b
Update nim-ethers submodule
2-towns Jan 9, 2025
943ca8a
Merge branch 'master' into chore/update-nim-version
2-towns Jan 10, 2025
fb14b60
Remove deprecated ValidIpAddress. Fix missing case and imports.
2-towns Jan 10, 2025
5cbb43b
Fix a weird issue where nim-confutils cannot find NatAny
2-towns Jan 10, 2025
0d71b0a
Fix tests and remove useless static keyword
2-towns Jan 10, 2025
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
8 changes: 7 additions & 1 deletion .github/actions/nimbus-build-system/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
default: "amd64"
nim_version:
description: "Nim version"
default: "version-1-6"
default: "v2.0.12"
rust_version:
description: "Rust version"
default: "1.79.0"
Expand Down Expand Up @@ -168,6 +168,12 @@ runs:
shell: ${{ inputs.shell }} {0}
run: echo "NIM_COMMIT=${{ inputs.nim_version }}" >> ${GITHUB_ENV}

- name: MSYS2 (Windows All) - Disable git symbolic links (since miniupnp 2.2.5)
if: inputs.os == 'windows'
shell: ${{ inputs.shell }} {0}
run: |
git config --global core.symlinks false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veaceslavdoina Double check if it is okay for you


- name: Build Nim and Codex dependencies
shell: ${{ inputs.shell }} {0}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
cache_nonce: 0 # Allows for easily busting actions/cache caches
nim_version: pinned
nim_version: v2.0.12

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
# If NIM_COMMIT is set to "nimbusbuild", this will use the
# version pinned by nimbus-build-system.
PINNED_NIM_VERSION := 38640664088251bbc88917b4bacfd86ec53014b8 # 1.6.21

#PINNED_NIM_VERSION := 38640664088251bbc88917b4bacfd86ec53014b8 # 1.6.21
PINNED_NIM_VERSION := v2.0.12
ifeq ($(NIM_COMMIT),)
NIM_COMMIT := $(PINNED_NIM_VERSION)
else ifeq ($(NIM_COMMIT),pinned)
Expand Down
6 changes: 3 additions & 3 deletions codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ when isMainModule:
let config = CodexConf.load(
version = codexFullVersion,
envVarsPrefix = "codex",
secondarySources = proc (config: CodexConf, sources: auto) =
secondarySources = proc (config: CodexConf, sources: auto) {.gcsafe, raises: [ConfigurationError].} =
if configFile =? config.configFile:
sources.addConfigFile(Toml, configFile)
)
config.setupLogging()
config.setupMetrics()

if config.nat == ValidIpAddress.init(IPv4_any()):
if config.nat == IPv4_any():
error "`--nat` cannot be set to the any (`0.0.0.0`) address"
quit QuitFailure

if config.nat == ValidIpAddress.init("127.0.0.1"):
if config.nat == static parseIpAddress("127.0.0.1"):
warn "`--nat` is set to loopback, your node wont properly announce over the DHT"

if not(checkAndCreateDataDir((config.dataDir).string)):
Expand Down
2 changes: 1 addition & 1 deletion codex/clock.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type
SecondsSince1970* = int64
Timeout* = object of CatchableError

method now*(clock: Clock): SecondsSince1970 {.base, upraises: [].} =
method now*(clock: Clock): SecondsSince1970 {.base, gcsafe, upraises: [].} =
raiseAssert "not implemented"

method waitUntil*(clock: Clock, time: SecondsSince1970) {.base, async.} =
Expand Down
15 changes: 2 additions & 13 deletions codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import std/sequtils
import std/strutils
import std/os
import std/tables
import std/cpuinfo

import pkg/chronos
import pkg/presto
Expand All @@ -24,7 +23,6 @@ import pkg/stew/shims/net as stewnet
import pkg/datastore
import pkg/ethers except Rng
import pkg/stew/io2
import pkg/taskpools

import ./node
import ./conf
Expand Down Expand Up @@ -55,7 +53,6 @@ type
codexNode: CodexNodeRef
repoStore: RepoStore
maintenance: BlockMaintainer
taskpool: Taskpool

CodexPrivateKey* = libp2p.PrivateKey # alias
EthWallet = ethers.Wallet
Expand Down Expand Up @@ -190,10 +187,6 @@ proc start*(s: CodexServer) {.async.} =
proc stop*(s: CodexServer) {.async.} =
notice "Stopping codex node"


s.taskpool.syncAll()
s.taskpool.shutdown()

await allFuturesThrowing(
s.restServer.stop(),
s.codexNode.switch.stop(),
Expand Down Expand Up @@ -283,15 +276,12 @@ proc new*(
else:
none Prover

taskpool = Taskpool.new(num_threads = countProcessors())

codexNode = CodexNodeRef.new(
switch = switch,
networkStore = store,
engine = engine,
prover = prover,
discovery = discovery,
taskpool = taskpool)
prover = prover)

restServer = RestServerRef.new(
codexNode.initRestApi(config, repoStore, config.apiCorsAllowedOrigin),
Expand All @@ -307,5 +297,4 @@ proc new*(
codexNode: codexNode,
restServer: restServer,
repoStore: repoStore,
maintenance: maintenance,
taskpool: taskpool)
maintenance: maintenance)
40 changes: 27 additions & 13 deletions codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ type

metricsAddress* {.
desc: "Listening address of the metrics server"
defaultValue: ValidIpAddress.init("127.0.0.1")
defaultValue: defaultAddress(config)
defaultValueDesc: "127.0.0.1"
name: "metrics-address" }: ValidIpAddress
name: "metrics-address" }: IpAddress

metricsPort* {.
desc: "Listening HTTP port of the metrics server"
Expand All @@ -141,17 +141,17 @@ type
# TODO: change this once we integrate nat support
nat* {.
desc: "IP Addresses to announce behind a NAT"
defaultValue: ValidIpAddress.init("127.0.0.1")
defaultValue: defaultAddress(config)
defaultValueDesc: "127.0.0.1"
abbr: "a"
name: "nat" }: ValidIpAddress
name: "nat" }: IpAddress

discoveryIp* {.
desc: "Discovery listen address"
defaultValue: ValidIpAddress.init(IPv4_any())
defaultValue: IPv4_any()
defaultValueDesc: "0.0.0.0"
abbr: "e"
name: "disc-ip" }: ValidIpAddress
name: "disc-ip" }: IpAddress

discoveryPort* {.
desc: "Discovery (UDP) port"
Expand Down Expand Up @@ -412,6 +412,9 @@ type
logutils.formatIt(LogFormat.textLines, EthAddress): it.short0xHexLog
logutils.formatIt(LogFormat.json, EthAddress): %it

func defaultAddress*(conf: CodexConf): IpAddress =
result = static parseIpAddress("127.0.0.1")

func persistence*(self: CodexConf): bool =
self.cmd == StartUpCmd.persistence

Expand Down Expand Up @@ -444,13 +447,17 @@ const

proc parseCmdArg*(T: typedesc[MultiAddress],
input: string): MultiAddress
{.upraises: [ValueError, LPError].} =
{.upraises: [ValueError] .} =
var ma: MultiAddress
let res = MultiAddress.init(input)
if res.isOk:
ma = res.get()
else:
warn "Invalid MultiAddress", input=input, error = res.error()
try:
let res = MultiAddress.init(input)
if res.isOk:
ma = res.get()
else:
warn "Invalid MultiAddress", input=input, error = res.error()
quit QuitFailure
except LPError as exc:
warn "Invalid MultiAddress uri", uri = input, error = exc.msg
quit QuitFailure
ma

Expand All @@ -460,6 +467,9 @@ proc parseCmdArg*(T: type SignedPeerRecord, uri: string): T =
if not res.fromURI(uri):
warn "Invalid SignedPeerRecord uri", uri = uri
quit QuitFailure
except LPError as exc:
warn "Invalid SignedPeerRecord uri", uri = uri, error = exc.msg
quit QuitFailure
except CatchableError as exc:
warn "Invalid SignedPeerRecord uri", uri = uri, error = exc.msg
quit QuitFailure
Expand Down Expand Up @@ -493,7 +503,11 @@ proc readValue*(r: var TomlReader, val: var SignedPeerRecord) =
error "invalid SignedPeerRecord configuration value", error = err.msg
quit QuitFailure

val = SignedPeerRecord.parseCmdArg(uri)
try:
val = SignedPeerRecord.parseCmdArg(uri)
except LPError as err:
warn "Invalid SignedPeerRecord uri", uri = uri, error = err.msg
quit QuitFailure

proc readValue*(r: var TomlReader, val: var MultiAddress) =
without input =? r.readValue(string).catch, err:
Expand Down
9 changes: 5 additions & 4 deletions codex/discovery.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pkg/stew/shims/net
import pkg/contractabi/address as ca
import pkg/codexdht/discv5/[routing_table, protocol as discv5]
from pkg/nimcrypto import keccak256

import ./rng
import ./errors
Expand Down Expand Up @@ -124,7 +125,7 @@

method removeProvider*(
d: Discovery,
peerId: PeerId): Future[void] {.base.} =
peerId: PeerId): Future[void] {.base, gcsafe.} =

Check warning on line 128 in codex/discovery.nim

View check run for this annotation

Codecov / codecov/patch

codex/discovery.nim#L128

Added line #L128 was not covered by tests
## Remove provider from providers table
##

Expand All @@ -146,7 +147,7 @@
d.protocol.updateRecord(d.providerRecord)
.expect("Should update SPR")

proc updateDhtRecord*(d: Discovery, ip: ValidIpAddress, port: Port) =
proc updateDhtRecord*(d: Discovery, ip: IpAddress, port: Port) =
## Update providers record
##

Expand All @@ -172,7 +173,7 @@
proc new*(
T: type Discovery,
key: PrivateKey,
bindIp = ValidIpAddress.init(IPv4_any()),
bindIp = IPv4_any(),
bindPort = 0.Port,
announceAddrs: openArray[MultiAddress],
bootstrapNodes: openArray[SignedPeerRecord] = [],
Expand Down Expand Up @@ -202,7 +203,7 @@

self.protocol = newProtocol(
key,
bindIp = bindIp.toNormalIp,
bindIp = bindIp,

Check warning on line 206 in codex/discovery.nim

View check run for this annotation

Codecov / codecov/patch

codex/discovery.nim#L206

Added line #L206 was not covered by tests
bindPort = bindPort,
record = self.providerRecord.get,
bootstrapRecords = bootstrapNodes,
Expand Down
6 changes: 3 additions & 3 deletions codex/erasure/backend.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
EncoderBackend* = ref object of ErasureBackend
DecoderBackend* = ref object of ErasureBackend

method release*(self: ErasureBackend) {.base.} =
method release*(self: ErasureBackend) {.base, gcsafe.} =
## release the backend
##
raiseAssert("not implemented!")
Expand All @@ -31,7 +31,7 @@
self: EncoderBackend,
buffers,
parity: var openArray[seq[byte]]
): Result[void, cstring] {.base.} =
): Result[void, cstring] {.base, gcsafe.} =

Check warning on line 34 in codex/erasure/backend.nim

View check run for this annotation

Codecov / codecov/patch

codex/erasure/backend.nim#L34

Added line #L34 was not covered by tests
## encode buffers using a backend
##
raiseAssert("not implemented!")
Expand All @@ -41,7 +41,7 @@
buffers,
parity,
recovered: var openArray[seq[byte]]
): Result[void, cstring] {.base.} =
): Result[void, cstring] {.base, gcsafe.} =

Check warning on line 44 in codex/erasure/backend.nim

View check run for this annotation

Codecov / codecov/patch

codex/erasure/backend.nim#L44

Added line #L44 was not covered by tests
## decode buffers using a backend
##
raiseAssert("not implemented!")
Loading
Loading