0xMiden / 0xMiden/node

Make note script insertion procedure more robust

未關閉
#1,188 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
blocked store
主要語言
Rust
星號
104
分支
138
平均合併
1 天 13 小時
30 天內合併 PR
56

描述

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:

1. If we `script` we are trying to insert is the same script as the one we have in the DB.
2. If they are the same, we don't need to do anything extra.
3. 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`.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。