fix(libs): ethers async cancellation propagation

Previously, ethers was not propagating async cancellations correctly, causing the CancelledError exceptions to be wrapped and propagated as CatchableErrors to Codex. This was causing the sales asyncstatemachine to see these cancellations as errors and handle them incorrectly, without allowing any cancellations to propagate.
This commit is contained in:
Eric 2025-02-13 10:00:42 +11:00
parent c65148822e
commit e9a90478fd
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -14,7 +14,7 @@ proc raiseProviderError(message: string) {.raises: [ProviderError].} =
proc blockNumberAndTimestamp*(
provider: Provider, blockTag: BlockTag
): Future[(UInt256, UInt256)] {.async: (raises: [ProviderError]).} =
): Future[(UInt256, UInt256)] {.async: (raises: [ProviderError, CancelledError]).} =
without latestBlock =? await provider.getBlock(blockTag):
raiseProviderError("Could not get latest block")
@ -25,7 +25,7 @@ proc blockNumberAndTimestamp*(
proc binarySearchFindClosestBlock(
provider: Provider, epochTime: int, low: UInt256, high: UInt256
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
let (_, lowTimestamp) = await provider.blockNumberAndTimestamp(BlockTag.init(low))
let (_, highTimestamp) = await provider.blockNumberAndTimestamp(BlockTag.init(high))
if abs(lowTimestamp.truncate(int) - epochTime) <
@ -39,7 +39,7 @@ proc binarySearchBlockNumberForEpoch(
epochTime: UInt256,
latestBlockNumber: UInt256,
earliestBlockNumber: UInt256,
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
var low = earliestBlockNumber
var high = latestBlockNumber
@ -65,7 +65,7 @@ proc binarySearchBlockNumberForEpoch(
proc blockNumberForEpoch*(
provider: Provider, epochTime: SecondsSince1970
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
let epochTimeUInt256 = epochTime.u256
let (latestBlockNumber, latestBlockTimestamp) =
await provider.blockNumberAndTimestamp(BlockTag.latest)
@ -118,6 +118,6 @@ proc blockNumberForEpoch*(
proc pastBlockTag*(
provider: Provider, blocksAgo: int
): Future[BlockTag] {.async: (raises: [ProviderError]).} =
): Future[BlockTag] {.async: (raises: [ProviderError, CancelledError]).} =
let head = await provider.getBlockNumber()
return BlockTag.init(head - blocksAgo.abs.u256)

2
vendor/nim-ethers vendored

@ -1 +1 @@
Subproject commit 1cfccb9695fa47860bf7ef3d75da9019096a3933
Subproject commit e3503b0ac6069923627b32c205680e23fe8a2d3c