0xPolygonMiden / miden-client

Client library that facilitates interaction with the Miden rollup
MIT License
29 stars 25 forks source link

Adding `NoteRelevance::Unknown` to note screener #246

Open mFragaBA opened 3 months ago

mFragaBA commented 3 months ago

TLDR: we should add an Unknown variant to NoteRelevance to handle notes for which we can't be sure if they can be consumed or not. That way to interpret the return value of check_relevance is:

on #208 we're introducing the NoteScreener struct. It's capable of receiving a note and returning whether it is relevant to the client or not and if so by which accounts. By relevant to the client we mean that it can be consumed either now or somewhere in the future. Its check_relevance function does that and also handles malformed input, returning an error in certain cases. This is working fine since for known notes that's all there is to it. However, once we introduce the ability to check arbitrary notes with custom scripts we'll need to try and consume the note. That execution might return an error because it's too early or there's another problem.

To keep it short, an error during execution might not mean that it's not consumable but it's not currently consumable (but might be in the future). In those scenarios we'd like to keep those notes around as we don't know for sure whether they can be consumed or not, thus the need of a NoteRelevance::Unknown variant.

Good point! I think then maybe we do need to have something like NoteRelevance::Unknown variant. So, basically, the "for sure invalid" case still stays as an error - but the "maybe invalid" cases becomes NoteRelevance::Unknown variant. And then the caller will need to filter out unknowns or do w/e based on their requirements.

_Originally posted by @bobbinth in https://github.com/0xPolygonMiden/miden-client/pull/208#discussion_r1550333040_