Feature/eth syncing (#721)

* Delays starting of codex until eth provider is synced

* bumps nim-ethers to 0.7.2

* bumps nim-ethers to 0.7.3

* Adds increasing delay to waitForSync
This commit is contained in:
Ben Bierens 2024-03-01 08:50:29 +01:00 committed by GitHub
parent 5e7ce52fbe
commit 53fdc88def
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View File

@ -12,7 +12,7 @@ requires "bearssl >= 0.1.4"
requires "chronicles >= 0.7.2"
requires "chronos >= 2.5.2"
requires "confutils"
requires "ethers >= 0.7.1 & < 0.8.0"
requires "ethers >= 0.7.3 & < 0.8.0"
requires "libbacktrace"
requires "libp2p"
requires "metrics"

View File

@ -56,6 +56,14 @@ type
CodexPrivateKey* = libp2p.PrivateKey # alias
EthWallet = ethers.Wallet
proc waitForSync(provider: Provider): Future[void] {.async.} =
var sleepTime = 1
while await provider.isSyncing:
notice "Waiting for Ethereum provider to sync..."
await sleepAsync(sleepTime.seconds)
if sleepTime < 10:
inc sleepTime
proc bootstrapInteractions(
s: CodexServer): Future[void] {.async.} =
## bootstrap interactions and return contracts
@ -79,6 +87,7 @@ proc bootstrapInteractions(
quit QuitFailure
let provider = JsonRpcProvider.new(config.ethProvider)
await waitForSync(provider)
var signer: Signer
if account =? config.ethAccount:
signer = provider.getSigner(account)

2
vendor/nim-ethers vendored

@ -1 +1 @@
Subproject commit fd16d71ea58e8d3e5a7f41e5dfdaa3a9b693a815
Subproject commit 4c7e351fd95af779786705eac0612b6a52b13380