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 15 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
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
16 changes: 2 additions & 14 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 @@ -306,6 +296,4 @@ proc new*(
config: config,
codexNode: codexNode,
restServer: restServer,
repoStore: repoStore,
maintenance: maintenance,
taskpool: taskpool)
repoStore: repoStore)
40 changes: 27 additions & 13 deletions codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,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 @@ -142,17 +142,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 @@ -413,6 +413,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 @@ -445,13 +448,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 @@ -461,6 +468,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 @@ -494,7 +504,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
2 changes: 1 addition & 1 deletion codex/contracts/clock.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ method start*(clock: OnChainClock) {.async.} =
if clock.started:
return

proc onBlock(_: Block) =
proc onBlock(_: ?!Block) =
# ignore block parameter; hardhat may call this with pending blocks
asyncSpawn clock.update()

Expand Down
98 changes: 71 additions & 27 deletions codex/contracts/market.nim
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,14 @@ method canReserveSlot*(
method subscribeRequests*(market: OnChainMarket,
callback: OnRequest):
Future[MarketSubscription] {.async.} =
proc onEvent(event: StorageRequested) {.upraises:[].} =
callback(event.requestId,
event.ask,
event.expiry)
proc onEvent(event: ?!StorageRequested) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId,
value.ask,
value.expiry)

convertEthersError:
let subscription = await market.contract.subscribe(StorageRequested, onEvent)
Expand All @@ -289,8 +293,12 @@ method subscribeRequests*(market: OnChainMarket,
method subscribeSlotFilled*(market: OnChainMarket,
callback: OnSlotFilled):
Future[MarketSubscription] {.async.} =
proc onEvent(event: SlotFilled) {.upraises:[].} =
callback(event.requestId, event.slotIndex)
proc onEvent(event: ?!SlotFilled) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId, value.slotIndex)

convertEthersError:
let subscription = await market.contract.subscribe(SlotFilled, onEvent)
Expand All @@ -311,8 +319,12 @@ method subscribeSlotFilled*(market: OnChainMarket,
method subscribeSlotFreed*(market: OnChainMarket,
callback: OnSlotFreed):
Future[MarketSubscription] {.async.} =
proc onEvent(event: SlotFreed) {.upraises:[].} =
callback(event.requestId, event.slotIndex)
proc onEvent(event: ?!SlotFreed) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId, value.slotIndex)

convertEthersError:
let subscription = await market.contract.subscribe(SlotFreed, onEvent)
Expand All @@ -322,8 +334,12 @@ method subscribeSlotReservationsFull*(
market: OnChainMarket,
callback: OnSlotReservationsFull): Future[MarketSubscription] {.async.} =

proc onEvent(event: SlotReservationsFull) {.upraises:[].} =
callback(event.requestId, event.slotIndex)
proc onEvent(event: ?!SlotReservationsFull) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId, value.slotIndex)

convertEthersError:
let subscription = await market.contract.subscribe(SlotReservationsFull, onEvent)
Expand All @@ -332,8 +348,12 @@ method subscribeSlotReservationsFull*(
method subscribeFulfillment(market: OnChainMarket,
callback: OnFulfillment):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestFulfilled) {.upraises:[].} =
callback(event.requestId)
proc onEvent(event: ?!RequestFulfilled) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestFulfilled, onEvent)
Expand All @@ -343,9 +363,13 @@ method subscribeFulfillment(market: OnChainMarket,
requestId: RequestId,
callback: OnFulfillment):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestFulfilled) {.upraises:[].} =
if event.requestId == requestId:
callback(event.requestId)
proc onEvent(event: ?!RequestFulfilled) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

if value.requestId == requestId:
callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestFulfilled, onEvent)
Expand All @@ -354,8 +378,12 @@ method subscribeFulfillment(market: OnChainMarket,
method subscribeRequestCancelled*(market: OnChainMarket,
callback: OnRequestCancelled):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestCancelled) {.upraises:[].} =
callback(event.requestId)
proc onEvent(event: ?!RequestCancelled) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestCancelled, onEvent)
Expand All @@ -365,9 +393,13 @@ method subscribeRequestCancelled*(market: OnChainMarket,
requestId: RequestId,
callback: OnRequestCancelled):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestCancelled) {.upraises:[].} =
if event.requestId == requestId:
callback(event.requestId)
proc onEvent(event: ?!RequestCancelled) {.upraises:[].} =
without value =? event:
error "The event object is not defined"
return

if value.requestId == requestId:
callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestCancelled, onEvent)
Expand All @@ -376,8 +408,12 @@ method subscribeRequestCancelled*(market: OnChainMarket,
method subscribeRequestFailed*(market: OnChainMarket,
callback: OnRequestFailed):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestFailed) {.upraises:[]} =
callback(event.requestId)
proc onEvent(event: ?!RequestFailed) {.upraises:[]} =
without value =? event:
error "The event object is not defined"
return

callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestFailed, onEvent)
Expand All @@ -387,9 +423,13 @@ method subscribeRequestFailed*(market: OnChainMarket,
requestId: RequestId,
callback: OnRequestFailed):
Future[MarketSubscription] {.async.} =
proc onEvent(event: RequestFailed) {.upraises:[]} =
if event.requestId == requestId:
callback(event.requestId)
proc onEvent(event: ?!RequestFailed) {.upraises:[]} =
without value =? event:
error "The event object is not defined"
return

if value.requestId == requestId:
callback(value.requestId)

convertEthersError:
let subscription = await market.contract.subscribe(RequestFailed, onEvent)
Expand All @@ -398,8 +438,12 @@ method subscribeRequestFailed*(market: OnChainMarket,
method subscribeProofSubmission*(market: OnChainMarket,
callback: OnProofSubmitted):
Future[MarketSubscription] {.async.} =
proc onEvent(event: ProofSubmitted) {.upraises: [].} =
callback(event.id)
proc onEvent(event: ?!ProofSubmitted) {.upraises: [].} =
without value =? event:
error "The event object is not defined"
return

callback(value.id)

convertEthersError:
let subscription = await market.contract.subscribe(ProofSubmitted, onEvent)
Expand Down
Loading