feat: aztec.nr side of entity store#24139
Conversation
…ntity-store-oracles
nchamo
left a comment
There was a problem hiding this comment.
Great work!
This is going to be super helpful
| { | ||
| let n = <T as Deserialize>::N; | ||
| assert_eq(self.body.len(), n, "entity body length mismatch"); | ||
| let mut fields: [Field; <T as Deserialize>::N] = [0; <T as Deserialize>::N]; |
There was a problem hiding this comment.
Is this needed?
| let mut fields: [Field; <T as Deserialize>::N] = [0; <T as Deserialize>::N]; | |
| let mut fields = [0; <T as Deserialize>::N]; |
| } | ||
|
|
||
| impl RawEntity { | ||
| /// Deserializes the raw body field-array into `T` and wraps it, with its location, as a typed [`Entity`]. |
There was a problem hiding this comment.
By location you mean contract addresS?
|
|
||
| /// The identity a value carries when stored as an entity body. | ||
| /// | ||
| /// Implementors supply the two ids the store needs to address an entity: a per-type `entity_type_id` shared by every |
There was a problem hiding this comment.
I think address has too other meanings already
| /// Implementors supply the two ids the store needs to address an entity: a per-type `entity_type_id` shared by every | |
| /// Implementors supply the two ids the store needs to reference an entity: a per-type `entity_type_id` shared by every |
| } | ||
|
|
||
| /// Returns a populated handle for every active entity of this kind, each carrying its `body` and `facts`. | ||
| pub unconstrained fn read_all(contract_address: AztecAddress, scope: AztecAddress) -> EphemeralArray<Entity<T>> { |
There was a problem hiding this comment.
Nice! I didn't understand how it worked without passing the entity type id, but I understand now 👏
| get_entities::<T>(contract_address, scope, T::entity_type_id()) | ||
| } | ||
|
|
||
| /// Records a retractable fact about this entity, originated at `(block_number, block_hash)`. |
There was a problem hiding this comment.
Small suggestion, completely ignorable
| /// Records a retractable fact about this entity, originated at `(block_number, block_hash)`. | |
| /// Logs a retractable fact about this entity, originated at `(block_number, block_hash)`. |
| * Output mapping for a fact. Serializes to `[factTypeId, payloadSlot]`, where `payloadSlot` is the slot of the | ||
| * fact's payload (its own ephemeral array of fields). Output-only: facts are returned to Noir, never received. | ||
| */ | ||
| export const FACT: TypeMapping<FactOutput> = { |
There was a problem hiding this comment.
I'm working on a STRUCT() type, that would help here
|
|
||
| /** | ||
| * Output mapping for a fact. Serializes to `[factTypeId, payloadSlot]`, where `payloadSlot` is the slot of the | ||
| * fact's payload (its own ephemeral array of fields). Output-only: facts are returned to Noir, never received. |
There was a problem hiding this comment.
Do we need to specify the "output" part? Same question for the actual type name. I don't think we do that for other types, do we?
| /** | ||
| * Input mapping for an optional entity/fact origin block. Reads two ACVM slots `blockNumber` (u32) and `blockHash` | ||
| * (a field) into the store's `OriginBlock` shape. Used inside `OPTION(ORIGIN_BLOCK)`. | ||
| */ |
There was a problem hiding this comment.
Honestly, I would delete this doc. It doesn't add much value
| /** | ||
| * Output mapping for an entity. Serializes to `[bodySlot, factsSlot]`: the body as a slot of fields, and the facts as | ||
| * a slot of `[factTypeId, payloadSlot]` rows. Output-only: entities are returned to Noir, never received. | ||
| */ |
There was a problem hiding this comment.
Same with unnecessary "output" term. I say we can also skip the docs since the type explains where it comes from
| }, | ||
| }; | ||
|
|
||
| /** Returned by `getEntity`/`getEntities`: the entity body plus its facts. */ |
There was a problem hiding this comment.
Is there something else we can say about this? Something that mentions the oracles or the service for example? I feel like "entity" is too generic and I wouldn't know where this is used in a month
Adds oracles to consume EntityStore services from Aztec.nr, as well as some abstractions
Closes F-739