New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some sync crash fixups #1321
Some sync crash fixups #1321
Conversation
trinity/sync/full/chain.py
Outdated
# Tried a bunch of things that failed to make mypy happy: | ||
# - cast(DuplicateTasks[BlockHeader], exc) -- refuses to cast | ||
# - except DuplicateTasks[BlockHeader]: -- doesn't catch the exception | ||
# - OrderedTaskPreparation.DuplicateTasks to inherit TTask -- mypy refuses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a line up above the try
:
exc: DuplicateTask[BlockHeader]
try:
...
except DuplicateTasks as exc:
...
I think that's how you tell mypy
ahead of time what type something is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternate idea:
duplicates = cast(Tuple[BlockHeader, ...], exc.duplicates)
self.header_queue.complete(batch_id, duplicates)
Less elegant/type-safe...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-defining the exception type still complained... going with the duplicates
cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rabbit hole'd this a while ago. There's a solution that works for simple types but not this one but which has a runtime cost.
if isinstance(v, SomeType):
do_SomeType_specific_thing(v)
mypy
correctly understands that within the if
context v
must be SomeType
. However, there's no way to do the equivalent of if isinstance(v, Tuple[SomeType, ...])
that I could find. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No review requested yet, but I did a full pass on this and it looks 👍
Yeah, marked WIP because I had no idea what the p2p.discovery failure is. I spent some time digging into it. I can't reproduce locally. I am having a hard time even guessing what might have happened:
So far, I think maybe both alice and bob binded to the same UDP port, and alice responded to her own request for nodes with an empty list. Still not sure why that happened in 0.02s when the timeout is 0.9s. (the wait for response is supposed to hang until it gets the desired number of nodes, no matter the intermediate responses) |
Error message was: "Cannot re-register task id * for completion"
Otherwise, on a peer switchover, it's possible to redownload chunks of headers, and then have to skip the next chunk, which really borks things.
f562759
to
39026da
Compare
What was wrong?
Two crashes during sync, both during peer switchover:
How was it fixed?
DuplicateTasks
exception that is caught, so the relevant headers can be skipped.Plus some logging improvements.
There's another typing tangent that I wasted a lot of time on. Grumble. Any suggestions for making it work? (where the
type: ignore
is)Cute Animal Picture