Add backoff for the deposit logs requests as well; More debug logs
This commit is contained in:
parent
7225a6d6ed
commit
92655f936a
|
@ -676,6 +676,7 @@ proc syncBlockRange(m: Eth1Monitor,
|
||||||
depositLogs: JsonNode = nil
|
depositLogs: JsonNode = nil
|
||||||
blocksPerRequest = 5000'u64 # This is roughly a day of Eth1 blocks
|
blocksPerRequest = 5000'u64 # This is roughly a day of Eth1 blocks
|
||||||
maxBlockNumberRequested: Eth1BlockNumber
|
maxBlockNumberRequested: Eth1BlockNumber
|
||||||
|
backoff = 100
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
maxBlockNumberRequested = min(toBlock, currentBlock + blocksPerRequest - 1)
|
maxBlockNumberRequested = min(toBlock, currentBlock + blocksPerRequest - 1)
|
||||||
|
@ -688,12 +689,13 @@ proc syncBlockRange(m: Eth1Monitor,
|
||||||
|
|
||||||
debug "Obtaining deposit log events",
|
debug "Obtaining deposit log events",
|
||||||
fromBlock = currentBlock,
|
fromBlock = currentBlock,
|
||||||
toBlock = maxBlockNumberRequested
|
toBlock = maxBlockNumberRequested,
|
||||||
|
backoff
|
||||||
|
|
||||||
debug.logTime "Deposit logs obtained":
|
debug.logTime "Deposit logs obtained":
|
||||||
# Reduce all request rate until we have a more general solution
|
# Reduce all request rate until we have a more general solution
|
||||||
# for dealing with Infura's rate limits
|
# for dealing with Infura's rate limits
|
||||||
await sleepAsync(milliseconds(100))
|
await sleepAsync(milliseconds(backoff))
|
||||||
|
|
||||||
let jsonLogsFut = m.dataProvider.ns.getJsonLogs(
|
let jsonLogsFut = m.dataProvider.ns.getJsonLogs(
|
||||||
DepositEvent,
|
DepositEvent,
|
||||||
|
@ -706,6 +708,8 @@ proc syncBlockRange(m: Eth1Monitor,
|
||||||
retryOrRaise newException(DataProviderTimeout,
|
retryOrRaise newException(DataProviderTimeout,
|
||||||
"Request time out while obtaining json logs")
|
"Request time out while obtaining json logs")
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
|
debug "Request for deposit logs failed", err = err.msg
|
||||||
|
backoff = (backoff * 3) div 2
|
||||||
retryOrRaise err
|
retryOrRaise err
|
||||||
|
|
||||||
currentBlock = maxBlockNumberRequested + 1
|
currentBlock = maxBlockNumberRequested + 1
|
||||||
|
@ -725,6 +729,7 @@ proc syncBlockRange(m: Eth1Monitor,
|
||||||
if blk.number > fullSyncFromBlock:
|
if blk.number > fullSyncFromBlock:
|
||||||
let lastBlock = m.eth1Chain.blocks.peekLast
|
let lastBlock = m.eth1Chain.blocks.peekLast
|
||||||
for n in max(lastBlock.number + 1, fullSyncFromBlock) ..< blk.number:
|
for n in max(lastBlock.number + 1, fullSyncFromBlock) ..< blk.number:
|
||||||
|
debug "Obtaining block without deposits", blockNum = n
|
||||||
let blockWithoutDeposits = awaitWithRetries(
|
let blockWithoutDeposits = awaitWithRetries(
|
||||||
m.dataProvider.getBlockByNumber(n))
|
m.dataProvider.getBlockByNumber(n))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue