-
Notifications
You must be signed in to change notification settings - Fork 608
feat(public->private): create commitments in public contexts (in noir) #810
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
14 commits
Select commit
Hold shift + click to select a range
e3c69bc
temp
Maddiaa0 1242ff1
feat: create commitments and l1 messages in a public call
Maddiaa0 28915ce
feat: consume public message in private context
Maddiaa0 7dc2ca3
chore: formatting:fix
Maddiaa0 230bf19
refactor: implement with read requests
Maddiaa0 902fc72
feat: e2e consume public commitment test
Maddiaa0 cccbf0a
chore(ci): add to circle ci
Maddiaa0 b0741d3
chore: fmt
Maddiaa0 366a761
fix: tidy up noir syntax
Maddiaa0 a5fca67
Merge branch 'master' into md/com-pub
Maddiaa0 331526d
fix: lint
Maddiaa0 73a119a
fix: update noir review comments
Maddiaa0 bc9b611
fix: update nits
Maddiaa0 6c2310b
chore(fmt)
Maddiaa0 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 |
|---|---|---|
|
|
@@ -3,7 +3,18 @@ import { padArrayEnd } from '@aztec/foundation/collection'; | |
| import { createDebugLogger } from '@aztec/foundation/log'; | ||
| import { TxExecutionRequest } from '@aztec/types'; | ||
| import { select_return_flattened as selectPublicWitnessFlattened } from '@noir-lang/noir_util_wasm'; | ||
| import { acvm, frToAztecAddress, frToSelector, fromACVMField, toACVMField, toACVMWitness } from '../acvm/index.js'; | ||
| import { | ||
| ACVMField, | ||
| ZERO_ACVM_FIELD, | ||
| acvm, | ||
| frToAztecAddress, | ||
| frToSelector, | ||
| fromACVMField, | ||
| toACVMField, | ||
| toACVMWitness, | ||
| toAcvmCommitmentLoadOracleInputs, | ||
| toAcvmL1ToL2MessageLoadOracleInputs, | ||
| } from '../acvm/index.js'; | ||
| import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js'; | ||
| import { PublicExecution, PublicExecutionResult } from './execution.js'; | ||
| import { ContractStorageActionsCollector } from './state_actions.js'; | ||
|
|
@@ -42,6 +53,8 @@ export class PublicExecutor { | |
|
|
||
| const initialWitness = getInitialWitness(execution.args, execution.callContext, this.treeRoots); | ||
| const storageActions = new ContractStorageActionsCollector(this.stateDb, execution.contractAddress); | ||
| const newCommitments: Fr[] = []; | ||
| const newL2ToL1Messages: Fr[] = []; | ||
| const nestedExecutions: PublicExecutionResult[] = []; | ||
|
|
||
| const notAvailable = () => Promise.reject(`Built-in not available for public execution simulation`); | ||
|
|
@@ -57,7 +70,18 @@ export class PublicExecutor { | |
| emitEncryptedLog: notAvailable, | ||
| viewNotesPage: notAvailable, | ||
| debugLog: notAvailable, | ||
| getL1ToL2Message: notAvailable, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 | ||
|
|
||
| getL1ToL2Message: async ([msgKey]: ACVMField[]) => { | ||
| const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey)); | ||
| return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.treeRoots.l1ToL2MessagesTreeRoot); | ||
| }, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 | ||
| getCommitment: async ([commitment]: ACVMField[]) => { | ||
| const commitmentInputs = await this.commitmentsDb.getCommitmentOracle( | ||
| execution.contractAddress, | ||
| fromACVMField(commitment), | ||
| ); | ||
| return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.treeRoots.privateDataTreeRoot); | ||
| }, | ||
| storageRead: async ([slot]) => { | ||
| const storageSlot = fromACVMField(slot); | ||
| const value = await storageActions.read(storageSlot); | ||
|
|
@@ -72,6 +96,16 @@ export class PublicExecutor { | |
| this.log(`Oracle storage write: slot=${storageSlot.toShortString()} value=${value.toString()}`); | ||
| return [toACVMField(newValue)]; | ||
| }, | ||
| createCommitment: async ([commitment]) => { | ||
| this.log('Creating commitment: ' + commitment.toString()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to print these long numbers?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just keeping with the style of the other oracle calls where they log what they do |
||
| newCommitments.push(fromACVMField(commitment)); | ||
| return await Promise.resolve([ZERO_ACVM_FIELD]); | ||
| }, | ||
| createL2ToL1Message: async ([message]) => { | ||
| this.log('Creating L2 to L1 message: ' + message.toString()); | ||
| newL2ToL1Messages.push(fromACVMField(message)); | ||
| return await Promise.resolve([ZERO_ACVM_FIELD]); | ||
| }, | ||
| callPublicFunction: async ([address, functionSelector, ...args]) => { | ||
| this.log(`Public function call: addr=${address} selector=${functionSelector} args=${args.join(',')}`); | ||
| const childExecutionResult = await this.callPublicFunction( | ||
|
|
@@ -92,6 +126,8 @@ export class PublicExecutor { | |
|
|
||
| return { | ||
| execution, | ||
| newCommitments, | ||
| newL2ToL1Messages, | ||
| contractStorageReads, | ||
| contractStorageUpdateRequests, | ||
| returnValues, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somewhere in the code, can you add a comment on why it is called "silo"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the siloCommitment function natspec