-
Notifications
You must be signed in to change notification settings - Fork 175
WIP: Write logs to microSD in HSM mode #196
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
Conversation
scgbckbone
commented
Mar 13, 2023
you need to add your new module logging.py to shared/manifest.py (or shared/manifest_mk4). Simulator does not need this as it loads contents directly from shared dir. When building for real thing all modules have to be included in manifest. Your code is failing in flow.py:22 where it attempts to import from hsm.py module. In hsm.py it fails because it cannot find module logging.py as it is not included in manifest.
Sosthene00
commented
Mar 13, 2023
Thanks, very helpful! I'll try again and try to come up with something cleaner
25c0941 to
9679366
Compare
Sosthene00
commented
Mar 15, 2023
Now it works on the real thing. Here's a summary of the changes made so far:
- Now
AuditLoggeris instantiated as soon as we start parsing the psbt file and passed toapprove_transactionas an argument. I originally thought I could keep theAuditLoggerin theapprove_transactionpart and just add another one higher inauth.pyas to make the less change possible to the way things were, but it appeared that having 2 loggers inside each other writing to the same card was not possible on the real cc (no issue with the simulator though). - Instead of having a
psbtdir with as many log files as psbt submitted, there's now alogdir with one file for each hsm policy ('00'*32 being no hsm mode) logging each signing attempt. - I assumed it was possible to log to card while not being in hsm mode, but maybe it shouldn't be possible idk.
- I started working on the previous release on top of some unrelated changes I was experimenting with and that were the reason I wanted more detailed logs, so I still need to rebase it on the latest release.
Please let me know if you think this is going in the right direction.
Hi, I've been experimenting a lot recently with the CC, especially with the HSM mode, and it happened a couple times that the CC "freezes", it just stops responding at some point without any logs or indication of what happened on the screen. I'd let it run for days, so when it happened I would usually figure it out many hours after. At least once it crashed while signing as the screen was reading "Signing..."
I had a look at what it logged on the microSD and I didn't found it to be very helpful for my situation, so I tried to modify it to write more logs that could help me if it crashes again.
I tested my code with the simulator, and it worked, I could register a policy and then it would sign psbts and write logs on the SD card.
But then I tried to flash an actual CC Mk4 with my custom code, and it crashed on startup with the following error
photo_2023年03月13日_11-53-07
I tried my code again with the simulator, and it works there. Here's an actual example of the content of a log file I just made like this:
I open this PR as a WIP because I think there might be demand for that, especially as more people will run the HSM mode, it's totally hacky right now but if you agree I'd gladly put on some more work because I need it. I'd just be happy to have a little help and not brick a couple more CC just to figure it out 😄