mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-18 09:27:05 +00:00
add workaround for stack overflow on block add
This commit is contained in:
parent
d5f20846ad
commit
c98a0d28ae
@ -135,6 +135,8 @@ type
|
|||||||
|
|
||||||
heads*: seq[Head]
|
heads*: seq[Head]
|
||||||
|
|
||||||
|
inAdd*: bool
|
||||||
|
|
||||||
MissingBlock* = object
|
MissingBlock* = object
|
||||||
slots*: uint64 # number of slots that are suspected missing
|
slots*: uint64 # number of slots that are suspected missing
|
||||||
tries*: int
|
tries*: int
|
||||||
|
@ -214,10 +214,21 @@ proc addResolvedBlock(
|
|||||||
# unresolved blocks magically become resolved
|
# unresolved blocks magically become resolved
|
||||||
# TODO there are more efficient ways of doing this that don't risk
|
# TODO there are more efficient ways of doing this that don't risk
|
||||||
# running out of stack etc
|
# running out of stack etc
|
||||||
let retries = pool.pending
|
# TODO This code is convoluted because when there are more than ~1.5k
|
||||||
for k, v in retries:
|
# blocks being synced, there's a stack overflow as `add` gets called
|
||||||
discard pool.add(state, k, v)
|
# for the whole chain of blocks. Instead we use this ugly field in `pool`
|
||||||
|
# which could be avoided by refactoring the code
|
||||||
|
if not pool.inAdd:
|
||||||
|
pool.inAdd = true
|
||||||
|
defer: pool.inAdd = false
|
||||||
|
var keepGoing = true
|
||||||
|
while keepGoing:
|
||||||
|
let retries = pool.pending
|
||||||
|
for k, v in retries:
|
||||||
|
discard pool.add(state, k, v)
|
||||||
|
# Keep going for as long as the pending pool is shrinking
|
||||||
|
# TODO inefficient! so what?
|
||||||
|
keepGoing = pool.pending.len < retries.len
|
||||||
blockRef
|
blockRef
|
||||||
|
|
||||||
proc add*(
|
proc add*(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user