Skip to content

chore(core): exclude all_modules.py bytecode from frozen_mpy.c #4836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

romanz
Copy link
Contributor

@romanz romanz commented Mar 27, 2025

Also, bump MicroPython dependency following trezor/micropython#15 and trezor/micropython#16.

@romanz romanz self-assigned this Mar 27, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs review in Firmware Mar 27, 2025
@romanz romanz added core Trezor Core firmware. Runs on Trezor Model T and T2B1. micropython Python interpreter and runtime that runs Trezor firmware labels Mar 27, 2025
@romanz romanz moved this from 🔎 Needs review to 🏃‍♀️ In progress in Firmware Mar 27, 2025
Copy link

github-actions bot commented Mar 27, 2025

core UI changes device test click test persistence test
T2T1 Model T test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3B1 Safe 3 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3T1 Safe 5 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
All main(screens)

See `all_modules.py.mako` for more details.

[no changelog]
@romanz romanz force-pushed the romanz/exclude-all-modules branch from 2848d71 to 63a17ea Compare March 27, 2025 08:24
@romanz
Copy link
Contributor Author

romanz commented Mar 27, 2025

Comparing core/build/unix/frozen_mpy.c before and after the PR:

--- /tmp/f1.c   2025-03-27 09:19:20.841171236 +0200
+++ /tmp/f2.c   2025-03-27 10:34:24.118286276 +0200
@@ -325730,14 +321576,14 @@
 /*
 byte sizes:
 qstr content: 5533 unique, 110213 bytes
-bc content: 277527
-const str content: 25973
+bc content: 269598
+const str content: 25941
 const int content: 422
-const obj content: 14356
+const obj content: 14340
 const table qstr content: 0 entries, 0 bytes
-const table ptr content: 1756 entries, 7024 bytes
-raw code content: 3007 * 4 = 48112
-mp_frozen_mpy_names_content: 11173
-mp_frozen_mpy_content_size: 1516
-total: 496316
+const table ptr content: 1755 entries, 7020 bytes
+raw code content: 3006 * 4 = 48096
+mp_frozen_mpy_names_content: 11158
+mp_frozen_mpy_content_size: 1512
+total: 488300
 */

frozen.zip

@matejcik
Copy link
Contributor

Comparing core/build/unix/frozen_mpy.c before and after the PR:

the important part is, are the qstrings still collected?

@romanz
Copy link
Contributor Author

romanz commented Mar 27, 2025

Yes, there is no diff in the qstr section - only the bytecode of all_modules.py is missing.

extern const qstr_pool_t mp_qstr_const_pool;
const qstr_pool_t mp_qstr_frozen_const_pool = {
    &mp_qstr_const_pool, // previous pool
    MP_QSTRnumber_of, // previous pool size
    10, // allocated entries
    5533, // used entries
    (qstr_hash_t *)mp_qstr_frozen_const_hashes,
    (qstr_len_t *)mp_qstr_frozen_const_lengths,
    {
        "all_modules.py",
        "trezor.utils",
        "utils",
        "trezor",
        "all_modules",
        "boot",
        "session",
        "usb",
        "storage",
        "cache",
        "storage.cache",
        "cache_codec",
        "storage.cache_codec",
        "cache_common",
        "storage.cache_common",
        "storage.common",
        "debug",
        "storage.debug",
        "device",
        "storage.device",
        "fido2",
        "storage.fido2",
        "storage.recovery",
        "recovery_shares",
        "storage.recovery_shares",
        "resident_credentials",
        "storage.resident_credentials",
        ...

@romanz romanz moved this from 🏃‍♀️ In progress to 🔎 Needs review in Firmware Mar 27, 2025
@romanz romanz marked this pull request as ready for review March 27, 2025 09:06
@romanz romanz requested a review from prusnak as a code owner March 27, 2025 09:06
@romanz romanz requested review from matejcik and removed request for prusnak March 27, 2025 09:06
@romanz romanz merged commit 63a17ea into main Mar 27, 2025
96 checks passed
@romanz romanz deleted the romanz/exclude-all-modules branch March 27, 2025 10:04
@github-project-automation github-project-automation bot moved this from 🔎 Needs review to 🤝 Needs QA in Firmware Mar 27, 2025
@bosomt bosomt moved this from 🤝 Needs QA to ✅ Approved in Firmware Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Trezor Core firmware. Runs on Trezor Model T and T2B1. micropython Python interpreter and runtime that runs Trezor firmware
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants