-
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.
chore: rework nonces (#1210) (#1331)
# Description The way nonces work now, there can be inconsistencies in nonce assignment in the simulator vs the private kernel. Furthermore, you cannot know during function execution what the full set of commitments will be for the whole TX as some new commitments may be nullified and squashed. But we still want the ability to determine nonces and therefore uniqueNoteHashes from L1 calldata alone. I am sure I am not explaining all of the issues well enough, but it was determined that the current nonce paradigm will not work and therefore we must rework it. Rework nonces so that siloing by contract address happens first and uniqueness comes later. For now, nonces are injeced by the private ordering circuit (vs suggestion which was base rollup circuit). Pending notes and their reads have no nonces when processed in kernel. The public kernel (and therefore all commitments created in public functions) does not use nonces. Here was Mike's proposal for the rework: ![image](https://github.com/AztecProtocol/aztec-packages/assets/47112877/7b20c886-1e92-452c-a886-c3da5ed64e17) Why not just use leaf index as nonce? ![image](https://github.com/AztecProtocol/aztec-packages/assets/47112877/e6337107-ac93-4a3b-b83c-27213cb5133d) ## Followup tasks * AztecProtocol/aztec-packages#1029 * AztecProtocol/aztec-packages#1194 * AztecProtocol/aztec-packages#1329 * AztecProtocol/aztec-packages#1407 * AztecProtocol/aztec-packages#1408 * AztecProtocol/aztec-packages#1409 * AztecProtocol/aztec-packages#1410 * Future enhancement: The root rollup circuit could insert all messages at the very beginning of the root rollup circuit, so that txs within the rollup can refer to that state root and read L1>L2 messages immediately. * AztecProtocol/aztec-packages#1383 * AztecProtocol/aztec-packages#1386 * We should implement subscription / polling methods for Aztec logs * We should maybe write rpc functions which allow calldata to be subscribed-to, keyed by tx_hash. * If a dapp wants to write a note from a public function, a lot of honus will be on a dapp developer to retain preimage information, query the blockchain, and derive the nonce. We should provide some examples to demonstrate this pattern.
- Loading branch information
1 parent
90384b0
commit 0a28199
Showing
5 changed files
with
61 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
use dep::std::hash::{pedersen, pedersen_with_separator}; | ||
use crate::constants_gen::{GENERATOR_INDEX__UNIQUE_COMMITMENT, GENERATOR_INDEX__OUTER_COMMITMENT}; | ||
use crate::constants_gen::{GENERATOR_INDEX__UNIQUE_COMMITMENT, GENERATOR_INDEX__SILOED_COMMITMENT}; | ||
|
||
fn compute_inner_hash(storage_slot: Field, note_hash: Field) -> Field { | ||
// TODO(#1205) Do we need a generator index here? | ||
pedersen([storage_slot, note_hash])[0] | ||
} | ||
|
||
fn compute_unique_hash(nonce: Field, inner_note_hash: Field) -> Field { | ||
let inputs = [nonce, inner_note_hash]; | ||
pedersen_with_separator(inputs, GENERATOR_INDEX__UNIQUE_COMMITMENT)[0] | ||
fn compute_siloed_hash(contract_address: Field, inner_note_hash: Field) -> Field { | ||
let inputs = [contract_address, inner_note_hash]; | ||
pedersen_with_separator(inputs, GENERATOR_INDEX__SILOED_COMMITMENT)[0] | ||
} | ||
|
||
fn compute_siloed_hash(contract_address: Field, unique_note_hash: Field) -> Field { | ||
let inputs = [contract_address, unique_note_hash]; | ||
pedersen_with_separator(inputs, GENERATOR_INDEX__OUTER_COMMITMENT)[0] | ||
} | ||
fn compute_unique_hash(nonce: Field, siloed_note_hash: Field) -> Field { | ||
let inputs = [nonce, siloed_note_hash]; | ||
pedersen_with_separator(inputs, GENERATOR_INDEX__UNIQUE_COMMITMENT)[0] | ||
} |
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