chore: bump Nim to 2.2.4 (#1242)

* chore: bump Nim to 2.2.4

* fix: resolve symbol ambiguity and drop auto type

* fix: use reference to task instead of pointer or the compiler will deallocate `task` before the encoding/decoding is done

* fix: convention that maxCollateralPerByte equals totalRemainingCollateral when freeSize is 0 to avoid DivByZeroDefect

* fix: bump compiler version in CI pipeline as well
This commit is contained in:
Giuliano Mega 2025-05-29 20:37:38 -03:00 committed by GitHub
parent 28a83db69e
commit d59c5b023c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 16 additions and 16 deletions

View File

@ -9,7 +9,7 @@ on:
env:
cache_nonce: 0 # Allows for easily busting actions/cache caches
nim_version: v2.0.14
nim_version: v2.2.4
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}

View File

@ -15,8 +15,7 @@
#
# 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 := v2.0.14
PINNED_NIM_VERSION := v2.2.4
ifeq ($(NIM_COMMIT),)
NIM_COMMIT := $(PINNED_NIM_VERSION)

View File

@ -28,7 +28,7 @@ import pkg/stew/io2
import ./node
import ./conf
import ./rng
import ./rng as random
import ./rest/api
import ./stores
import ./slots
@ -199,7 +199,7 @@ proc new*(
.new()
.withPrivateKey(privateKey)
.withAddresses(config.listenAddrs)
.withRng(Rng.instance())
.withRng(random.Rng.instance())
.withNoise()
.withMplex(5.minutes, 5.minutes)
.withMaxConnections(config.maxPeers)

View File

@ -338,11 +338,9 @@ proc asyncEncode*(
signal: threadPtr,
)
let t = addr task
doAssert self.taskPool.numThreads > 1,
"Must have at least one separate thread or signal will never be fired"
self.taskPool.spawn leopardEncodeTask(self.taskPool, t)
self.taskPool.spawn leopardEncodeTask(self.taskPool, addr task)
let threadFut = threadPtr.wait()
if joinErr =? catch(await threadFut.join()).errorOption:
@ -353,7 +351,7 @@ proc asyncEncode*(
else:
return failure(joinErr)
if not t.success.load():
if not task.success.load():
return failure("Leopard encoding failed")
success()
@ -532,11 +530,9 @@ proc asyncDecode*(
signal: threadPtr,
)
# Hold the task pointer until the signal is received
let t = addr task
doAssert self.taskPool.numThreads > 1,
"Must have at least one separate thread or signal will never be fired"
self.taskPool.spawn leopardDecodeTask(self.taskPool, t)
self.taskPool.spawn leopardDecodeTask(self.taskPool, addr task)
let threadFut = threadPtr.wait()
if joinErr =? catch(await threadFut.join()).errorOption:
@ -547,7 +543,7 @@ proc asyncDecode*(
else:
return failure(joinErr)
if not t.success.load():
if not task.success.load():
return failure("Leopard encoding failed")
success()

View File

@ -231,6 +231,11 @@ func key*(availability: Availability): ?!Key =
return availability.id.key
func maxCollateralPerByte*(availability: Availability): UInt256 =
# If freeSize happens to be zero, we convention that the maxCollateralPerByte
# should be equal to totalRemainingCollateral.
if availability.freeSize == 0.uint64:
return availability.totalRemainingCollateral
return availability.totalRemainingCollateral div availability.freeSize.stuint(256)
func key*(reservation: Reservation): ?!Key =

View File

@ -293,8 +293,8 @@ asyncchecksuite "RepoStore":
test "Should retrieve block expiration information":
proc unpack(
beIter: auto
): Future[seq[BlockExpiration]] {.async: (raises: [CancelledError]).} =
beIter: Future[?!SafeAsyncIter[BlockExpiration]]
): Future[seq[BlockExpiration]] {.async: (raises: [CatchableError]).} =
var expirations = newSeq[BlockExpiration](0)
without iter =? (await beIter), err:
return expirations

@ -1 +1 @@
Subproject commit 4c6ff070c116450bb2c285691724ac9e6202cb28
Subproject commit 0be0663e1af76e869837226a4ef3e586fcc737d3