-
Notifications
You must be signed in to change notification settings - Fork 146
Add receive server for validator service #580
Conversation
To ensure the tests are blocked until the handlers finish
Tests failed in https://circleci.com/gh/mhchia/trinity/1857. It seems to be related to the change from |
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.
The only problem is with the block.root
/block.signed_root
. Will take another pass on the tests tomorrow.
while len(blocks_to_be_imported) != 0: | ||
block = blocks_to_be_imported.pop() | ||
# try to import the block | ||
if not self._is_block_root_in_db(block.previous_block_root): |
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.
We can also check if block.previous_block_root in self._is_block_root_in_orphan_block_pool
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.
Sorry, I don't quite understand. Could you elaborate more on the advantage to check if block.previous_block_root in self._is_block_root_in_orphan_block_pool
over if not self._is_block_root_in_db(block.previous_block_root)
?
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 meant we can first check if it's parent is in the orphan peer pool then next check if it's parent is in the db. This helps by not having to lookup the db in case where it's parent is already in the pool.
But after a second thought this doesn't really help much(or even worse this adds another lookup into orphan pool) since case like this is probably rare.
And change `BeaconBlock` to `SerenityBeaconBlock`, to align with the TestChain.
- To avoid repeated block generating patterns - Fix typing in the test - Rename `map_requested_id_block_root` to `map_request_id_block_root`
Updated the PR according to the review feedback. |
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.
Looks great!
What was wrong?
Our validator service has no corresponding handler for the command
NewBeaconBlock
.How was it fixed?
Based on
BCCReceiveServer
, the work of @NIC619 from #465.BCCReceiveServer
to define the handler forNewBeaconBlock
.BCCReceiveServer._try_import_or_handle_orphan
to check and maintain orphan blocks inBCCReceiveServer.orphan_block_pool
. Currently, it is a in-memory set. We can further optimize it for purposes through changingorphan_block_pool._pool
.BCCReceiveServer._request_block_by_root
used byBCCReceiveServer._try_import_or_handle_orphan
to request the parents of the orphans from peers.BeaconBlocks
to handle the response of our sent requests.Cute Animal Picture