-
Notifications
You must be signed in to change notification settings - Fork 104
Description
When we receive a new public note, we insert a record into the note_scripts table. I believe currently this just overwrites the previous record with the same note root. This should work fine most of the time, but there is an edge case which a malicious user could exploit.
The reason for this edge case is that MAST does not enforce which part of the underlying code must be made available. Specifically, we could have two script details, both with the same MAST root, but one is a "more complete" version of the other. How to handle this in generality is still an open question but we don't need to solve the general case here.
What we need to do is:
- If we
scriptwe are trying to insert is the same script as the one we have in the DB. - If they are the same, we don't need to do anything extra.
- If they are not the same, we need to pick a "more complete" version, and replace the old version with it.
The last step could be tricky - as we may need to merge the two scripts. This logic should probably live in miden-vm.