From 590315bdc12a02e31fab06a4ecad4fff584b9d5b Mon Sep 17 00:00:00 2001 From: grdddj Date: Thu, 4 May 2023 14:25:43 +0200 Subject: [PATCH] feat(all): change debugging messages in protobuf --- common/protob/messages-debug.proto | 15 ++++++++++++--- common/protob/messages.proto | 1 + core/src/trezor/enums/MessageType.py | 1 + core/src/trezor/enums/__init__.py | 1 + core/src/trezor/messages.py | 14 ++++++++++---- legacy/firmware/protob/Makefile | 2 +- legacy/firmware/protob/messages-debug.options | 2 +- python/src/trezorlib/messages.py | 17 +++++++++++------ 8 files changed, 38 insertions(+), 15 deletions(-) diff --git a/common/protob/messages-debug.proto b/common/protob/messages-debug.proto index 554baf2f69..2ea26233c1 100644 --- a/common/protob/messages-debug.proto +++ b/common/protob/messages-debug.proto @@ -46,11 +46,11 @@ message DebugLinkDecision { } /** - * Response: Device text layout + * Response: Device text layout as a list of tokens as returned by Rust * @end */ message DebugLinkLayout { - repeated string lines = 1; + repeated string tokens = 1; } /** @@ -100,7 +100,7 @@ message DebugLinkState { optional uint32 recovery_word_pos = 10; // index of mnemonic word the device is expecting during RecoveryDevice workflow optional uint32 reset_word_pos = 11; // index of mnemonic word the device is expecting during ResetDevice workflow optional management.BackupType mnemonic_type = 12; // current mnemonic type (BIP-39/SLIP-39) - repeated string layout_lines = 13; // current layout text + repeated string tokens = 13; // current layout represented as a list of string tokens } /** @@ -184,3 +184,12 @@ message DebugLinkWatchLayout { optional bool watch = 1; // if true, start watching layout. // if false, stop. } + + +/** + * Request: Remove all the previous debug event state + * @start + * @next Success + */ +message DebugLinkResetDebugEvents { +} diff --git a/common/protob/messages.proto b/common/protob/messages.proto index c0ea0ff753..0c3e7f6b78 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -181,6 +181,7 @@ enum MessageType { MessageType_DebugLinkRecordScreen = 9003 [(bitcoin_only) = true, (wire_debug_in) = true]; MessageType_DebugLinkEraseSdCard = 9005 [(bitcoin_only) = true, (wire_debug_in) = true]; MessageType_DebugLinkWatchLayout = 9006 [(bitcoin_only) = true, (wire_debug_in) = true]; + MessageType_DebugLinkResetDebugEvents = 9007 [(bitcoin_only) = true, (wire_debug_in) = true]; // Ethereum MessageType_EthereumGetPublicKey = 450 [(wire_in) = true]; diff --git a/core/src/trezor/enums/MessageType.py b/core/src/trezor/enums/MessageType.py index c245a903b2..ebd1e68479 100644 --- a/core/src/trezor/enums/MessageType.py +++ b/core/src/trezor/enums/MessageType.py @@ -89,6 +89,7 @@ DebugLinkReseedRandom = 9002 DebugLinkRecordScreen = 9003 DebugLinkEraseSdCard = 9005 DebugLinkWatchLayout = 9006 +DebugLinkResetDebugEvents = 9007 if not utils.BITCOIN_ONLY: SetU2FCounter = 63 GetNextU2FCounter = 80 diff --git a/core/src/trezor/enums/__init__.py b/core/src/trezor/enums/__init__.py index eead516c86..c83b8b88c9 100644 --- a/core/src/trezor/enums/__init__.py +++ b/core/src/trezor/enums/__init__.py @@ -112,6 +112,7 @@ if TYPE_CHECKING: DebugLinkRecordScreen = 9003 DebugLinkEraseSdCard = 9005 DebugLinkWatchLayout = 9006 + DebugLinkResetDebugEvents = 9007 EthereumGetPublicKey = 450 EthereumPublicKey = 451 EthereumGetAddress = 56 diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index c37a6e0233..1d70c614c3 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -2638,12 +2638,12 @@ if TYPE_CHECKING: return isinstance(msg, cls) class DebugLinkLayout(protobuf.MessageType): - lines: "list[str]" + tokens: "list[str]" def __init__( self, *, - lines: "list[str] | None" = None, + tokens: "list[str] | None" = None, ) -> None: pass @@ -2712,12 +2712,12 @@ if TYPE_CHECKING: recovery_word_pos: "int | None" reset_word_pos: "int | None" mnemonic_type: "BackupType | None" - layout_lines: "list[str]" + tokens: "list[str]" def __init__( self, *, - layout_lines: "list[str] | None" = None, + tokens: "list[str] | None" = None, layout: "bytes | None" = None, pin: "str | None" = None, matrix: "str | None" = None, @@ -2851,6 +2851,12 @@ if TYPE_CHECKING: def is_type_of(cls, msg: Any) -> TypeGuard["DebugLinkWatchLayout"]: return isinstance(msg, cls) + class DebugLinkResetDebugEvents(protobuf.MessageType): + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["DebugLinkResetDebugEvents"]: + return isinstance(msg, cls) + class EosGetPublicKey(protobuf.MessageType): address_n: "list[int]" show_display: "bool | None" diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index 8b1f36139c..3f6ec0d6c9 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -4,7 +4,7 @@ endif SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \ - DebugLinkLayout GetNonce \ + DebugLinkLayout DebugLinkResetDebugEvents GetNonce \ TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \ EthereumSignTypedData EthereumTypedDataStructRequest EthereumTypedDataStructAck \ EthereumTypedDataValueRequest EthereumTypedDataValueAck diff --git a/legacy/firmware/protob/messages-debug.options b/legacy/firmware/protob/messages-debug.options index 399c201fd8..b36b617261 100644 --- a/legacy/firmware/protob/messages-debug.options +++ b/legacy/firmware/protob/messages-debug.options @@ -9,7 +9,7 @@ DebugLinkState.mnemonic_secret max_size:240 DebugLinkState.reset_word max_size:12 DebugLinkState.reset_entropy max_size:128 DebugLinkState.recovery_fake_word max_size:12 -DebugLinkState.layout_lines type:FT_IGNORE +DebugLinkState.tokens type:FT_IGNORE DebugLinkLog.bucket max_size:33 DebugLinkLog.text max_size:256 diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index c0e47c271e..e3194d38f8 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -120,6 +120,7 @@ class MessageType(IntEnum): DebugLinkRecordScreen = 9003 DebugLinkEraseSdCard = 9005 DebugLinkWatchLayout = 9006 + DebugLinkResetDebugEvents = 9007 EthereumGetPublicKey = 450 EthereumPublicKey = 451 EthereumGetAddress = 56 @@ -3744,15 +3745,15 @@ class DebugLinkDecision(protobuf.MessageType): class DebugLinkLayout(protobuf.MessageType): MESSAGE_WIRE_TYPE = 9001 FIELDS = { - 1: protobuf.Field("lines", "string", repeated=True, required=False, default=None), + 1: protobuf.Field("tokens", "string", repeated=True, required=False, default=None), } def __init__( self, *, - lines: Optional[Sequence["str"]] = None, + tokens: Optional[Sequence["str"]] = None, ) -> None: - self.lines: Sequence["str"] = lines if lines is not None else [] + self.tokens: Sequence["str"] = tokens if tokens is not None else [] class DebugLinkReseedRandom(protobuf.MessageType): @@ -3821,13 +3822,13 @@ class DebugLinkState(protobuf.MessageType): 10: protobuf.Field("recovery_word_pos", "uint32", repeated=False, required=False, default=None), 11: protobuf.Field("reset_word_pos", "uint32", repeated=False, required=False, default=None), 12: protobuf.Field("mnemonic_type", "BackupType", repeated=False, required=False, default=None), - 13: protobuf.Field("layout_lines", "string", repeated=True, required=False, default=None), + 13: protobuf.Field("tokens", "string", repeated=True, required=False, default=None), } def __init__( self, *, - layout_lines: Optional[Sequence["str"]] = None, + tokens: Optional[Sequence["str"]] = None, layout: Optional["bytes"] = None, pin: Optional["str"] = None, matrix: Optional["str"] = None, @@ -3841,7 +3842,7 @@ class DebugLinkState(protobuf.MessageType): reset_word_pos: Optional["int"] = None, mnemonic_type: Optional["BackupType"] = None, ) -> None: - self.layout_lines: Sequence["str"] = layout_lines if layout_lines is not None else [] + self.tokens: Sequence["str"] = tokens if tokens is not None else [] self.layout = layout self.pin = pin self.matrix = matrix @@ -3973,6 +3974,10 @@ class DebugLinkWatchLayout(protobuf.MessageType): self.watch = watch +class DebugLinkResetDebugEvents(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 9007 + + class EosGetPublicKey(protobuf.MessageType): MESSAGE_WIRE_TYPE = 600 FIELDS = {