-
Notifications
You must be signed in to change notification settings - Fork 615
feat(docs): applied structure feedback #9288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
54d396c
moved things around
catmcgee 132f861
moved stuff
catmcgee 6e7951b
concepts overeview
catmcgee 04a17ac
concepts overview
catmcgee 8388f4f
concepts
catmcgee c173c87
broken links
catmcgee 531d357
broken links
catmcgee 38fd304
Merge branch 'master' into docs/concepts=and-flow
catmcgee 2d5b73f
links
catmcgee 3c21dc3
diagrams
catmcgee b1104f1
Merge remote-tracking branch 'origin/master' into docs/concepts=and-flow
catmcgee a4487b4
Merge branch 'master' into docs/concepts=and-flow
catmcgee 0864dac
broken link
catmcgee 3eef47b
broken links
catmcgee 4baaa02
Merge branch 'master' into docs/concepts=and-flow
catmcgee a288fa2
add "protocol" to "circuits", pxe nit
critesjosh 2c70b8f
Apply suggestions from code review
catmcgee 717d8c7
code review comments
catmcgee 70ea969
slight copy change
catmcgee b0df801
Merge branch 'master' into docs/concepts=and-flow
catmcgee 7983707
Apply suggestions from code review
catmcgee 3720b96
clairication in overview
catmcgee 9c225fe
Merge branch 'master' into docs/concepts=and-flow
catmcgee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| title: Public VM | ||
| --- | ||
|
|
||
| Refer to the [protocol specs section](../../../../protocol-specs/public-vm/index.md) for the latest information about the Aztec Public VM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
|
|
||
| # Storage Slots | ||
|
|
||
| ## Public State Slots | ||
|
|
||
| As mentioned in [State Model](../storage/state_model/index.md), Aztec public state behaves similarly to public state on Ethereum from the point of view of the developer. Behind the scenes however, the storage is managed differently. As mentioned, public state has just one large sparse tree in Aztec - so we silo slots of public data by hashing it together with its contract address. | ||
|
|
||
| The mental model is that we have a key-value store, where the siloed slot is the key, and the value is the data stored in that slot. You can think of the `real_storage_slot` identifying its position in the tree, and the `logical_storage_slot` identifying the position in the contract storage. | ||
|
|
||
| ```rust | ||
| real_storage_slot = H(contract_address, logical_storage_slot) | ||
| ``` | ||
|
|
||
| The siloing is performed by the [Kernel circuits](../circuits/index.md). | ||
|
|
||
| For structs and arrays, we are logically using a similar storage slot computation to ethereum, e.g., as a struct with 3 fields would be stored in 3 consecutive slots. However, because the "actual" storage slot is computed as a hash of the contract address and the logical storage slot, the actual storage slot is not consecutive. | ||
|
|
||
| ## Private State Slots - Slots aren't real | ||
|
|
||
| Private storage is a different beast. As you might remember from [Hybrid State Model](../storage/state_model/index.md), private state is stored in encrypted logs and the corresponding private state commitments in append-only tree where each leaf is a commitment. Being append-only, means that leaves are never updated or deleted; instead a nullifier is emitted to signify that some note is no longer valid. A major reason we used this tree, is that lookups at a specific storage slot would leak information in the context of private state. If you could look up a specific address balance just by looking at the storage slot, even if encrypted you would be able to see it changing! That is not good privacy. | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| Following this, the storage slot as we know it doesn't really exist. The leaves of the note hashes tree are just commitments to content (think of it as a hash of its content). | ||
|
|
||
| Nevertheless, the concept of a storage slot is very useful when writing applications, since it allows us to reason about distinct and disjoint pieces of data. For example we can say that the balance of an account is stored in a specific slot and that the balance of another account is stored in another slot with the total supply stored in some third slot. By making sure that these slots are disjoint, we can be sure that the balances are not mixed up and that someone cannot use the total supply as their balance. | ||
|
|
||
| ### But how? | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| If we include the storage slot, as part of the note whose commitment is stored in the note hashes tree, we can _logically link_ all the notes that make up the storage slot. For the case of a balance, we can say that the balance is the sum of all the notes that have the same storage slot - in the same way that your physical \$ balance might be the sum of all the notes in your wallet. | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| Similarly to how we siloed the public storage slots, we can silo our private storage by hashing the logical storage slot together with the note content. | ||
|
|
||
| ```rust | ||
| note_hash = H(logical_storage_slot, note_content_hash); | ||
| ``` | ||
|
|
||
| This siloing (there will be more) is done in the application circuit, since it is not necessary for security of the network (but only the application). | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
| :::info | ||
| The private variable wrappers `PrivateSet` and `PrivateMutable` in Aztec.nr include the `logical_storage_slot` in the commitments they compute, to make it easier for developers to write contracts without having to think about how to correctly handle storage slots. | ||
| ::: | ||
|
|
||
| When reading the values for these notes, the application circuit can then constrain the values to only read notes with a specific logical storage slot. | ||
|
|
||
| To ensure that one contract cannot insert storage that other contracts would believe is theirs, we do a second siloing by hashing the `commitment` with the contract address. | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```rust | ||
| siloed_note_hash = H(contract_address, note_hash); | ||
| ``` | ||
|
|
||
| By doing this address-siloing at the kernel circuit we _force_ the inserted commitments to include and not lie about the `contract_address`. | ||
|
|
||
| :::info | ||
| To ensure that nullifiers don't collide across contracts we also force this contract siloing at the kernel level. | ||
| ::: | ||
|
|
||
| For an example of this see [developer documentation on storage](../../../reference/developer_references/smart_contract_reference/storage/index.md). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.