From c7ec0938638e1946f62a542b838620759d3d8546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Tue, 16 Jul 2024 16:32:24 +0200 Subject: [PATCH] feat(core): make "experimental features" storage field public to get rid of the cached field [no changelog] --- core/src/storage/cache.py | 12 +++++------- core/src/storage/device.py | 15 ++------------- tests/ui_tests/fixtures.json | 6 +++--- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/core/src/storage/cache.py b/core/src/storage/cache.py index 7cfc71424b..2228b3532b 100644 --- a/core/src/storage/cache.py +++ b/core/src/storage/cache.py @@ -29,12 +29,11 @@ if not utils.BITCOIN_ONLY: # Keys that are valid across sessions APP_COMMON_SEED_WITHOUT_PASSPHRASE = const(0 | _SESSIONLESS_FLAG) APP_COMMON_SAFETY_CHECKS_TEMPORARY = const(1 | _SESSIONLESS_FLAG) -STORAGE_DEVICE_EXPERIMENTAL_FEATURES = const(2 | _SESSIONLESS_FLAG) -APP_COMMON_REQUEST_PIN_LAST_UNLOCK = const(3 | _SESSIONLESS_FLAG) -APP_COMMON_BUSY_DEADLINE_MS = const(4 | _SESSIONLESS_FLAG) -APP_MISC_COSI_NONCE = const(5 | _SESSIONLESS_FLAG) -APP_MISC_COSI_COMMITMENT = const(6 | _SESSIONLESS_FLAG) -APP_RECOVERY_REPEATED_BACKUP_UNLOCKED = const(7 | _SESSIONLESS_FLAG) +APP_COMMON_REQUEST_PIN_LAST_UNLOCK = const(2 | _SESSIONLESS_FLAG) +APP_COMMON_BUSY_DEADLINE_MS = const(3 | _SESSIONLESS_FLAG) +APP_MISC_COSI_NONCE = const(4 | _SESSIONLESS_FLAG) +APP_MISC_COSI_COMMITMENT = const(5 | _SESSIONLESS_FLAG) +APP_RECOVERY_REPEATED_BACKUP_UNLOCKED = const(6 | _SESSIONLESS_FLAG) # === Homescreen storage === # This does not logically belong to the "cache" functionality, but the cache module is @@ -140,7 +139,6 @@ class SessionlessCache(DataCache): self.fields = ( 64, # APP_COMMON_SEED_WITHOUT_PASSPHRASE 1, # APP_COMMON_SAFETY_CHECKS_TEMPORARY - 1, # STORAGE_DEVICE_EXPERIMENTAL_FEATURES 8, # APP_COMMON_REQUEST_PIN_LAST_UNLOCK 8, # APP_COMMON_BUSY_DEADLINE_MS 32, # APP_MISC_COSI_NONCE diff --git a/core/src/storage/device.py b/core/src/storage/device.py index 1b84f1bfdc..fad4e136b1 100644 --- a/core/src/storage/device.py +++ b/core/src/storage/device.py @@ -1,7 +1,6 @@ from micropython import const from typing import TYPE_CHECKING -import storage.cache as storage_cache from storage import common from trezor import utils @@ -329,22 +328,12 @@ def set_safety_check_level(level: StorageSafetyCheckLevel) -> None: common.set_uint8(_NAMESPACE, _SAFETY_CHECK_LEVEL, level) -@storage_cache.stored(storage_cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES) -def _get_experimental_features() -> bytes: - if common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES): - return b"\x01" - else: - return b"" - - def get_experimental_features() -> bool: - return bool(_get_experimental_features()) + return common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES, True) def set_experimental_features(enabled: bool) -> None: - cached_bytes = b"\x01" if enabled else b"" - storage_cache.set(storage_cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES, cached_bytes) - common.set_true_or_delete(_NAMESPACE, _EXPERIMENTAL_FEATURES, enabled) + common.set_true_or_delete(_NAMESPACE, _EXPERIMENTAL_FEATURES, enabled, True) def set_hide_passphrase_from_host(hide: bool) -> None: diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index ece25d4e83..2c1472d921 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -4955,7 +4955,7 @@ "T2B1_en_test_msg_applysettings.py::test_apply_settings_passphrase": "a82a4ab4ca8d905ae55f12474230a72d3a2c6b495af64e659ec6093342b93e29", "T2B1_en_test_msg_applysettings.py::test_apply_settings_passphrase_on_device": "e595040cd60ac0e5a31a768dcbdb517c5a8ca28e02707ccc35be95a0e516ac95", "T2B1_en_test_msg_applysettings.py::test_apply_settings_rotation": "360ab2993d6610006f922c54c79ddbc0a5a4d8cadc5333c634db5bce4df6a4ba", -"T2B1_en_test_msg_applysettings.py::test_experimental_features": "36947f290173554568d788c0242a42871fb651587ce653b2f8367bfc818c09a9", +"T2B1_en_test_msg_applysettings.py::test_experimental_features": "cb18c97c7dcf8d6f839d207efe7c13a2448b1463e3b325d7be3c865630f93c58", "T2B1_en_test_msg_applysettings.py::test_label_too_long": "8c801bd0142e5c1ad4aad50b34c7debb1b8f17a2e0a87eb7f95531b9fd15e095", "T2B1_en_test_msg_applysettings.py::test_safety_checks": "a34a867f1d58b2a29c5d1724378f269ce699b380fd2206cc8cc4c06bcb76565d", "T2B1_en_test_msg_backup_device.py::test_backup_bip39": "2c19ff45c8c02dadc065f360af23af8d357dedc066711cdc30c846cfc07a7d4d", @@ -12280,7 +12280,7 @@ "T2T1_en_test_msg_applysettings.py::test_apply_settings_passphrase": "c2b3471ea4f29da8b3ce71a8f1d822a6b320a484e0ca75386ad3e32116a8d8ff", "T2T1_en_test_msg_applysettings.py::test_apply_settings_passphrase_on_device": "4356ecb3e22e2c04e396b1bff23f72382ae2796f0d93a0e778a25c3ba28857a4", "T2T1_en_test_msg_applysettings.py::test_apply_settings_rotation": "28bb0fb9d5296039f379a0c6e9bc38f37358928dd3938cc322d523874c628240", -"T2T1_en_test_msg_applysettings.py::test_experimental_features": "38bfcb19f17cd020b3cd38a0a09c1698da86dacc62a43f59b926a50b1fadd041", +"T2T1_en_test_msg_applysettings.py::test_experimental_features": "40eaa5f22e43a86a13f132d617831929f691bcfe2a13bb29ce8ce946f1bcb6d5", "T2T1_en_test_msg_applysettings.py::test_label_too_long": "80a6e289138a604cf351a29511cf6f85e2243591317894703152787e1351a1a3", "T2T1_en_test_msg_applysettings.py::test_safety_checks": "b129e0ba2e3c7ac836b3bb4b0bc8ded1c922eba054b42b434d10499fc780ea2b", "T2T1_en_test_msg_backup_device.py::test_backup_bip39": "7c8c3efab17cad82000aff453bc426b7665621edbff1bdb1c631827d23b4988b", @@ -19493,7 +19493,7 @@ "T3T1_en_test_msg_applysettings.py::test_apply_settings_passphrase": "e89ddabe256ca5f8feb558f20e0d4b978ea83f0bf5b60c0abdadcb677becd928", "T3T1_en_test_msg_applysettings.py::test_apply_settings_passphrase_on_device": "75a8135cc46a082b667abb29e54c7549186b1c4469a912b02ba67ff3841b58f2", "T3T1_en_test_msg_applysettings.py::test_apply_settings_rotation": "d07c2cc218fc9da94f861c2bcc8066c318333535c236bb76600e03ffdf9bbc1e", -"T3T1_en_test_msg_applysettings.py::test_experimental_features": "df77985e171a884259a5684f654c5d14c6bc008bd068f5d07cb52f0b056ed252", +"T3T1_en_test_msg_applysettings.py::test_experimental_features": "3ccd6c5126d5329905391fdf8e270a3ecfeafb4e87d42ad3d184275e542f6cd2", "T3T1_en_test_msg_applysettings.py::test_label_too_long": "5133fce02dd881612fb121f919b85166d9edf574147fc18d5ab9812f01a17e3a", "T3T1_en_test_msg_applysettings.py::test_safety_checks": "9ac2948f5dc0d41632d5717811add555ed1f5bd5b9670a1296427a23569b8ebb", "T3T1_en_test_msg_backup_device.py::test_backup_bip39": "f5d8efb15dfe2b4542ac65f405fd98ea86359573ed95ac8f7c8dfa9fa7c19dd6",