feat(core/debug): better ButtonAck deadlock detection

M1nd3r/thp-dealloc
matejcik 6 months ago committed by M1nd3r
parent 4e8fb737d8
commit a0267004d5

@ -4,6 +4,7 @@ if not __debug__:
halt("debug mode inactive") halt("debug mode inactive")
if __debug__: if __debug__:
from micropython import const
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import trezorui2 import trezorui2
@ -37,7 +38,9 @@ if __debug__:
REFRESH_INDEX = 0 REFRESH_INDEX = 0
_DEADLOCK_DETECT_SLEEP = loop.sleep(2000) _DEADLOCK_WAIT_TRIES = const(5)
_DEADLOCK_SLEEP_MS = const(2000)
_DEADLOCK_DETECT_SLEEP = loop.sleep(_DEADLOCK_SLEEP_MS)
def screenshot() -> bool: def screenshot() -> bool:
if storage.save_screen: if storage.save_screen:
@ -52,8 +55,14 @@ if __debug__:
def notify_layout_change(layout: Layout | None) -> None: def notify_layout_change(layout: Layout | None) -> None:
layout_change_chan.put(layout, replace=True) layout_change_chan.put(layout, replace=True)
def wait_until_layout_is_running() -> Awaitable[None]: # type: ignore [awaitable-is-generator] def wait_until_layout_is_running(tries: int | None = _DEADLOCK_WAIT_TRIES) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
counter = 0
while ui.CURRENT_LAYOUT is None: while ui.CURRENT_LAYOUT is None:
counter += 1
if tries is not None and counter > tries:
raise wire.FirmwareError(
"layout deadlock detected (did you send a ButtonAck?)"
)
yield yield
async def return_layout_change( async def return_layout_change(

@ -1031,22 +1031,7 @@ class InputFlowSignTxInformationReplacement(InputFlowBase):
self.debug.press_right() self.debug.press_right()
self.debug.press_right() self.debug.press_right()
def input_flow_t3t1(self) -> BRGeneratorType: input_flow_t3t1 = input_flow_tt
yield # confirm txid
self.debug.press_yes()
yield # confirm address
self.debug.press_yes()
# go back to address
self.debug.press_no()
# confirm address
self.debug.press_yes()
yield # confirm amount
self.debug.press_yes()
yield # transaction summary, press info
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.press_yes()
def lock_time_input_flow_tt( def lock_time_input_flow_tt(

Loading…
Cancel
Save