What's the best approach for querying private infromation from a contract? There are two main approaches: using getPrivateStorageAt vs calling an unconstrained function.
Calling an unconstrained function seems like the best option, since it allows the contract dev to encapsulate logic to manipulate the notes before returning them. It also gets the storage layout and note deserialization logic from the contract, without having to reimplement all these in the app client code.
However, unconstrained functions are inherently slower than reading storage directly. And get_notes returns a maximum of 10 elements at a time, which makes sense when having to create a proof, but we could extend that limit when working unconstrained, so devs don't need to build pagination in on every getter.
We could make storage definitions declarative, so they can be exported in the ABI, and have a standard way for serialising notes, so given their struct definition we can have the client code automatically deserialize them. This way, just with the ABI, an app could grab any set of notes on any storage slot.
Alternatively, we should make it easier to write getters that handle pagination, and allow constrained functions to be used as getters as well to remove code duplication (see #2665).
Raised by @0xShaito from Wonderland in Discord
What's the best approach for querying private infromation from a contract? There are two main approaches: using
getPrivateStorageAtvs calling an unconstrained function.Calling an unconstrained function seems like the best option, since it allows the contract dev to encapsulate logic to manipulate the notes before returning them. It also gets the storage layout and note deserialization logic from the contract, without having to reimplement all these in the app client code.
However, unconstrained functions are inherently slower than reading storage directly. And
get_notesreturns a maximum of 10 elements at a time, which makes sense when having to create a proof, but we could extend that limit when working unconstrained, so devs don't need to build pagination in on every getter.We could make storage definitions declarative, so they can be exported in the ABI, and have a standard way for serialising notes, so given their struct definition we can have the client code automatically deserialize them. This way, just with the ABI, an app could grab any set of notes on any storage slot.
Alternatively, we should make it easier to write getters that handle pagination, and allow constrained functions to be used as getters as well to remove code duplication (see #2665).
Raised by @0xShaito from Wonderland in Discord