forked from visoftsolutions/noir_rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ocol#3827) Fixes AztecProtocol#3820 **Note**: Temporarily disabled old state hash check in Rollup contract because the values to compute it the old way are no longer populated and I didn't want to touch contracts in this PR.
- Loading branch information
Showing
67 changed files
with
798 additions
and
1,052 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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.