-
Notifications
You must be signed in to change notification settings - Fork 607
feat: PartialStateReference and StateReference structs
#3827
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 all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
09755c8
WIP
benesjan d3a3f76
WIP
benesjan 8b7cb66
updated naming
benesjan f1e6259
WIP
benesjan 4dcae2f
WIP
benesjan 0894ce8
WIP
benesjan 826e934
WIP
benesjan 8f4f5ba
WIP
benesjan 6267f07
WIP
benesjan 4c16822
WIP
benesjan 070340e
WIP
benesjan 21cbe16
WIP
benesjan edba919
WIP
benesjan 065c3a3
fixing cycles
benesjan 848952a
Merge branch 'master' into janb/introducing-state-reference
benesjan 39eac0d
Merge branch 'master' into janb/introducing-state-reference
benesjan 39d16be
import fix
benesjan 62d7681
test workaround
benesjan b8e1dd2
Merge branch 'master' into janb/introducing-state-reference
benesjan 5c0ea28
temporarily disabling old state check
benesjan 3f060e3
formatting
benesjan 9444f62
stale comment fix
benesjan b11cc3f
comment
benesjan 426ff44
fix
benesjan eaefe52
Merge branch 'master' into janb/introducing-state-reference
benesjan d5cf965
note processor test fix
benesjan 6415649
stale naming fix
benesjan 98b815c
Update yarn-project/accounts/src/testing/create_account.ts
benesjan 1052827
Merge branch 'master' into janb/introducing-state-reference
benesjan 0081f16
linking issues
benesjan f0b9f2a
merge fix
benesjan 73b4b69
linking block hash issue
benesjan c08e06a
more standard deserialization of sha256 hash
benesjan 5e3ea0e
Merge branch 'master' into janb/introducing-state-reference
benesjan 7dfa3d9
auto-updated noir docs
benesjan 739e933
temporarily disabling the new start state check
benesjan 13977e8
cleanup
benesjan 6bed131
cleaned up mocks
benesjan 56c95b1
disabling old state check test
benesjan 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 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
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
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,36 @@ | ||
| import { Fr } from '@aztec/foundation/fields'; | ||
| import { BufferReader } from '@aztec/foundation/serialize'; | ||
|
|
||
| import { NUM_FIELDS_PER_SHA256 } from '../constants.gen.js'; | ||
| import { serializeToBuffer } from '../utils/serialize.js'; | ||
| import { GlobalVariables } from './global_variables.js'; | ||
| import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; | ||
| import { StateReference } from './state_reference.js'; | ||
|
|
||
| /** A header of an L2 block. */ | ||
| export class Header { | ||
| constructor( | ||
| /** Snapshot of archive before the block is applied. */ | ||
| public lastArchive: AppendOnlyTreeSnapshot, | ||
| /** Hash of the body of an L2 block. */ | ||
| public bodyHash: [Fr, Fr], | ||
| /** State reference. */ | ||
| public state: StateReference, | ||
| /** Global variables of an L2 block. */ | ||
| public globalVariables: GlobalVariables, | ||
| ) {} | ||
|
|
||
| toBuffer() { | ||
| return serializeToBuffer(this.lastArchive, this.bodyHash, this.state, this.globalVariables); | ||
| } | ||
|
|
||
| static fromBuffer(buffer: Buffer | BufferReader): Header { | ||
| const reader = BufferReader.asReader(buffer); | ||
| return new Header( | ||
| reader.readObject(AppendOnlyTreeSnapshot), | ||
| reader.readArray(NUM_FIELDS_PER_SHA256, Fr) as [Fr, Fr], | ||
| reader.readObject(StateReference), | ||
| reader.readObject(GlobalVariables), | ||
| ); | ||
| } | ||
| } |
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
34 changes: 34 additions & 0 deletions
34
yarn-project/circuits.js/src/structs/partial_state_reference.ts
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,34 @@ | ||
| import { BufferReader } from '@aztec/foundation/serialize'; | ||
|
|
||
| import { serializeToBuffer } from '../utils/serialize.js'; | ||
| import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; | ||
|
|
||
| /** | ||
| * Stores snapshots of trees which are commonly needed by base or merge rollup circuits. | ||
| */ | ||
| export class PartialStateReference { | ||
| constructor( | ||
| /** Snapshot of the note hash tree. */ | ||
| public readonly noteHashTree: AppendOnlyTreeSnapshot, | ||
| /** Snapshot of the nullifier tree. */ | ||
| public readonly nullifierTree: AppendOnlyTreeSnapshot, | ||
| /** Snapshot of the contract tree. */ | ||
| public readonly contractTree: AppendOnlyTreeSnapshot, | ||
| /** Snapshot of the public data tree. */ | ||
| public readonly publicDataTree: AppendOnlyTreeSnapshot, | ||
| ) {} | ||
|
|
||
| static fromBuffer(buffer: Buffer | BufferReader): PartialStateReference { | ||
| const reader = BufferReader.asReader(buffer); | ||
| return new PartialStateReference( | ||
| reader.readObject(AppendOnlyTreeSnapshot), | ||
| reader.readObject(AppendOnlyTreeSnapshot), | ||
| reader.readObject(AppendOnlyTreeSnapshot), | ||
| reader.readObject(AppendOnlyTreeSnapshot), | ||
| ); | ||
| } | ||
|
|
||
| toBuffer() { | ||
| return serializeToBuffer(this.noteHashTree, this.nullifierTree, this.contractTree, this.publicDataTree); | ||
| } | ||
| } |
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
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.