Skip to content

Commit 8752ab5

Browse files
authored
Merge pull request #1210 from carver/header-sync-queues
Sync headers in queue instead of batch, add Peer types
2 parents fcf73d0 + 644dcd5 commit 8752ab5

File tree

14 files changed

+820
-95
lines changed

14 files changed

+820
-95
lines changed

eth/chains/base.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ def validate_uncles(self, block: BaseBlock) -> None:
295295

296296
@abstractmethod
297297
def validate_chain(
298-
self, chain: Tuple[BlockHeader, ...], seal_check_random_sample_rate: int = 1) -> None:
298+
self,
299+
parent: BlockHeader,
300+
chain: Tuple[BlockHeader, ...],
301+
seal_check_random_sample_rate: int = 1) -> None:
299302
raise NotImplementedError("Chain classes must implement this method")
300303

301304

@@ -763,8 +766,11 @@ def validate_uncles(self, block: BaseBlock) -> None:
763766
uncle_vm_class.validate_uncle(block, uncle, uncle_parent)
764767

765768
def validate_chain(
766-
self, chain: Tuple[BlockHeader, ...], seal_check_random_sample_rate: int = 1) -> None:
767-
parent = self.chaindb.get_block_header_by_hash(chain[0].parent_hash)
769+
self,
770+
parent: BlockHeader,
771+
chain: Tuple[BlockHeader, ...],
772+
seal_check_random_sample_rate: int = 1) -> None:
773+
768774
all_indices = list(range(len(chain)))
769775
if seal_check_random_sample_rate == 1:
770776
headers_to_check_seal = set(all_indices)
@@ -865,5 +871,8 @@ async def coro_import_block(self,
865871
raise NotImplementedError()
866872

867873
async def coro_validate_chain(
868-
self, chain: Tuple[BlockHeader, ...], seal_check_random_sample_rate: int = 1) -> None:
874+
self,
875+
parent: BlockHeader,
876+
chain: Tuple[BlockHeader, ...],
877+
seal_check_random_sample_rate: int = 1) -> None:
869878
raise NotImplementedError()

p2p/nat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ async def _discover_upnp_devices(self) -> AsyncGenerator[upnpclient.upnp.Device,
160160
except TimeoutError:
161161
self.logger.info("Timeout waiting for UPNP-enabled devices")
162162
return
163+
else:
164+
self.logger.debug("Found %d candidate NAT devices", len(devices))
163165

164166
# If there are no UPNP devices we can exit early
165167
if not devices:

p2p/service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ def run_task(self, awaitable: Awaitable[Any]) -> None:
128128
If it raises OperationCancelled, that is caught and ignored.
129129
"""
130130
async def _run_task_wrapper() -> None:
131-
self.logger.debug("Running task %s", awaitable)
131+
self.logger.trace("Running task %s", awaitable)
132132
try:
133133
await awaitable
134134
except OperationCancelled:
135135
pass
136136
except Exception as e:
137137
self.logger.warning("Task %s finished unexpectedly: %s", awaitable, e)
138-
self.logger.warning("Task failure traceback", exc_info=True)
138+
self.logger.debug("Task failure traceback", exc_info=True)
139139
else:
140-
self.logger.debug("Task %s finished with no errors", awaitable)
140+
self.logger.trace("Task %s finished with no errors", awaitable)
141141
self._tasks.add(asyncio.ensure_future(_run_task_wrapper()))
142142

143143
def run_child_service(self, child_service: 'BaseService') -> None:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
"web3==4.4.1",
4545
],
4646
'test': [
47-
"hypothesis==3.44.26",
47+
"hypothesis==3.69.5",
4848
# pinned to <3.7 until async fixtures work again
4949
# https://github.com/pytest-dev/pytest-asyncio/issues/89
5050
"pytest>=3.6,<3.7",
51-
"pytest-asyncio==0.8.0",
51+
"pytest-asyncio==0.9.0",
5252
"pytest-cov==2.5.1",
5353
"pytest-watch>=4.1.0,<5",
5454
"pytest-xdist==1.18.1",

tests/p2p/test_service.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ async def _run(self):
2626
async def test_daemon_exit_causes_parent_cancellation():
2727
service = ParentService()
2828
asyncio.ensure_future(service.run())
29+
2930
await asyncio.sleep(0.01)
31+
3032
assert service.daemon.is_operational
3133
assert service.daemon.is_running
34+
3235
await service.daemon.cancel()
3336
await asyncio.sleep(0.01)
37+
3438
assert not service.is_operational
3539
assert not service.is_running
36-
await service.events.cleaned_up.wait()
40+
41+
await asyncio.wait_for(service.events.cleaned_up.wait(), timeout=1)

0 commit comments

Comments
 (0)