From the user's standpoint the process should be relatively simple:
- To add a note script to this "registry" they'd need to execute one transaction that created a public note with the script they care about (this needs to be done once per script and could be done by the app developer).
Continuing the excellent thread by @partylikeits1983 on Slack:
I think this could lead to a particularly obscure DevEx if not abstracted well. Specifically, if Note A directed at a ntx account were to create a previously-unseen note, the transaction that creates Note A would succeed from the users' point of view. However, it would later fail at the ntx transaction builder, with the details (logs) only available to us on the node, making it near impossible to debug for the users/developers.
A good abstraction on the client that handles the scenario of ntx transactions creating public notes would look like:
- Client detects that a note created by the user is for a ntx account (presumably by the
NoteTag prefix?)
- Client dry-runs this transaction, and sees that it would create a public output note.*
- Client queries the node to see if this note's script is available in the registry.
If it is available, proceed as normal.
If it is not available, the client effectively needs to do something equivalent to a POST /add_note_script_to_registry request to the node. However, due to spam concerns, this needs gatekeeping and is likely best achieved at the protocol level. Namely, as mentioned above, the client would have to "execute one transaction that created a public note with the script they care about".
One optimization here: I don't think this needs to be a separate transaction: we can extend the transaction script to output the desired note (TransactionRequestBuilder::own_output_notes) and just create one transaction.
I'm not a huge fan of creating an output note just for the purpose of registering its script. For one, it's an anti-pattern for using notes in Miden. Then there might be unforeseen security implications we might need to think about: can such an "empty" note be exploited?
While there are mechanisms that let users add note scripts to the node's registry (e.g. API-key - based), atm I can't convince myself of a better solution than what was originally suggested^, but I wanted to at least mention that there might be alternatives in case others have better ideas for populating the note script registry outside the protocol.
*How the client dry-runs a transaction where the network account consumes the note is not implemented AFAIK. It's still unclear to me how this would be done, but likely along the lines of running the ntx transaction builder locally.
Originally posted by @mmagician in #1748
Originally posted by @mmagician in #1748