Skip to content
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

refactor: nuking "new" from names #7273

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions barretenberg/cpp/pil/avm/constants_gen.pil
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js
namespace constants(256);
pol MAX_NEW_NOTE_HASHES_PER_CALL = 16;
pol MAX_NEW_NULLIFIERS_PER_CALL = 16;
pol MAX_NOTE_HASHES_PER_CALL = 16;
pol MAX_NULLIFIERS_PER_CALL = 16;
pol MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 16;
pol MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
pol MAX_L2_TO_L1_MSGS_PER_CALL = 2;
pol MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32;
Comment on lines -3 to 7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to run ./compile_avm.sh to regenerate C++ code after this change. We'll try to improve this tooling.

Copy link
Contributor Author

@benesjan benesjan Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script seems to be broken:

% ./compile_avm.sh
./compile_avm.sh: line 4: ../../bb-pilcom/target/release/bb_pil: No such file or directory
% 

and when I tried fixing that by changing the content to:

#!/bin/bash

# Compile
../../../bb-pilcom/target/release/bb_pil pil/avm/main.pil --name Avm

I got:

% ./compile_avm.sh
thread 'main' panicked at powdr/pil-analyzer/src/pil_analyzer.rs:84:29:
File "pil/avm/main.pil" not found: No such file or directory (os error 2)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to run it from barretenberg/cpp. Also note that it'll change a lot of the files, but they'll be auto-formatted when you commit them so the diff won't as big as it seems.

Copy link
Contributor Author

@benesjan benesjan Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed to run it and after it got formatted it didn't result in any changes b96023a

I think there were no changes in the commit because I globally replaced the constant names even in generated files. So there was nothing for the script to change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benesjan It is normal because pil constants are completely inlined (replaced by literal value) in the cpp generated relations.

pol MAX_PUBLIC_DATA_READS_PER_CALL = 32;
pol MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,23 @@ VmPublicInputs Execution::convert_public_inputs(std::vector<FF> const& public_in
ko_side_effect[dest_offset] = public_inputs_vec[pcpi_offset + 2];
}
// For EMITNOTEHASH
for (size_t i = 0; i < MAX_NEW_NOTE_HASHES_PER_CALL; i++) {
for (size_t i = 0; i < MAX_NOTE_HASHES_PER_CALL; i++) {
size_t dest_offset = START_EMIT_NOTE_HASH_WRITE_OFFSET + i;
size_t pcpi_offset = PCPI_NEW_NOTE_HASHES_OFFSET + (i * NOTE_HASH_LENGTH);

ko_values[dest_offset] = public_inputs_vec[pcpi_offset];
ko_side_effect[dest_offset] = public_inputs_vec[pcpi_offset + 1];
}
// For EMITNULLIFIER
for (size_t i = 0; i < MAX_NEW_NULLIFIERS_PER_CALL; i++) {
for (size_t i = 0; i < MAX_NULLIFIERS_PER_CALL; i++) {
size_t dest_offset = START_EMIT_NULLIFIER_WRITE_OFFSET + i;
size_t pcpi_offset = PCPI_NEW_NULLIFIERS_OFFSET + (i * NULLIFIER_LENGTH);

ko_values[dest_offset] = public_inputs_vec[pcpi_offset];
ko_side_effect[dest_offset] = public_inputs_vec[pcpi_offset + 1];
}
// For EMITL2TOL1MSG
for (size_t i = 0; i < MAX_NEW_L2_TO_L1_MSGS_PER_CALL; i++) {
for (size_t i = 0; i < MAX_L2_TO_L1_MSGS_PER_CALL; i++) {
size_t dest_offset = START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET + i;
size_t pcpi_offset = PCPI_NEW_L2_TO_L1_MSGS_OFFSET + (i * L2_TO_L1_MESSAGE_LENGTH);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js
#pragma once

#define MAX_NEW_NOTE_HASHES_PER_CALL 16
#define MAX_NEW_NULLIFIERS_PER_CALL 16
#define MAX_NOTE_HASHES_PER_CALL 16
#define MAX_NULLIFIERS_PER_CALL 16
#define MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL 16
#define MAX_NEW_L2_TO_L1_MSGS_PER_CALL 2
#define MAX_L2_TO_L1_MSGS_PER_CALL 2
#define MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL 32
#define MAX_PUBLIC_DATA_READS_PER_CALL 32
#define MAX_NOTE_HASH_READ_REQUESTS_PER_CALL 16
Expand Down
10 changes: 5 additions & 5 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ inline const std::size_t KERNEL_INPUTS_LENGTH = PUBLIC_CONTEXT_INPUTS_LENGTH;
inline const std::size_t KERNEL_OUTPUTS_LENGTH =
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL + MAX_NULLIFIER_READ_REQUESTS_PER_CALL +
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL +
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_NEW_NOTE_HASHES_PER_CALL +
MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + MAX_UNENCRYPTED_LOGS_PER_CALL;
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_NOTE_HASHES_PER_CALL +
MAX_NULLIFIERS_PER_CALL + MAX_L2_TO_L1_MSGS_PER_CALL + MAX_UNENCRYPTED_LOGS_PER_CALL;

// START INDEXES in the PUBLIC_CIRCUIT_PUBLIC_INPUTS
// These line up with indexes found in
Expand Down Expand Up @@ -63,14 +63,14 @@ inline const uint32_t PCPI_NEW_NOTE_HASHES_OFFSET =
PCPI_PUBLIC_CALLSTACK_OFFSET + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL;

inline const uint32_t PCPI_NEW_NULLIFIERS_OFFSET =
PCPI_NEW_NOTE_HASHES_OFFSET + (MAX_NEW_NOTE_HASHES_PER_CALL * NOTE_HASH_LENGTH);
PCPI_NEW_NOTE_HASHES_OFFSET + (MAX_NOTE_HASHES_PER_CALL * NOTE_HASH_LENGTH);

// TODO(md): Note legnth of nullifier is 3? - it includes the note it is nullifying too
inline const uint32_t PCPI_NEW_L2_TO_L1_MSGS_OFFSET =
PCPI_NEW_NULLIFIERS_OFFSET + (MAX_NEW_NULLIFIERS_PER_CALL * NULLIFIER_LENGTH);
PCPI_NEW_NULLIFIERS_OFFSET + (MAX_NULLIFIERS_PER_CALL * NULLIFIER_LENGTH);

inline const uint32_t PCPI_START_SIDE_EFFECT_COUNTER_OFFSET =
PCPI_NEW_L2_TO_L1_MSGS_OFFSET + (MAX_NEW_L2_TO_L1_MSGS_PER_CALL * L2_TO_L1_MESSAGE_LENGTH);
PCPI_NEW_L2_TO_L1_MSGS_OFFSET + (MAX_L2_TO_L1_MSGS_PER_CALL * L2_TO_L1_MESSAGE_LENGTH);

inline const uint32_t PCPI_NEW_UNENCRYPTED_LOGS_OFFSET = PCPI_START_SIDE_EFFECT_COUNTER_OFFSET + /*1 item gap*/ 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sequenceDiagram
TokenNote->>Utils: note_hash = H(amount, to, randomness)
Utils->>NoteHash: compute_inner_hash(derived_slot, note_hash)
NoteHash->>LifeCycle: inner_note_hash = H(derived_slot, note_hash)
LifeCycle->>Context: push_new_note_hash(inner_note_hash)
LifeCycle->>Context: push_note_hash(inner_note_hash)
end
Context->>Kernel: siloed_note_hash = H(contract_address, inner_note_hash)
```
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/protocol-specs/circuits/private-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ The public inputs of _every_ private function _must_ adhere to the following ABI
| `call_context` | [`CallContext`](#callcontext) | Context of the call corresponding to this function execution. |
| `args_hash` | `field` | Hash of the function arguments. |
| `return_values` | [`field`; [`RETURN_VALUES_LENGTH`](../constants.md#circuit-constants)] | Return values of this function call. |
| `note_hashes` | [[`NoteHash`](#notehash); [`MAX_NEW_NOTE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | New note hashes created in this function call. |
| `nullifiers` | [[`Nullifier`](#nullifier); [`MAX_NEW_NULLIFIERS_PER_CALL`](../constants.md#circuit-constants)] | New nullifiers created in this function call. |
| `l2_to_l1_messages` | [[`L2toL1Message`](#l2tol1message); [`MAX_NEW_L2_TO_L1_MSGS_PER_CALL`](../constants.md#circuit-constants)] | New L2 to L1 messages created in this function call. |
| `note_hashes` | [[`NoteHash`](#notehash); [`MAX_NOTE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | New note hashes created in this function call. |
| `nullifiers` | [[`Nullifier`](#nullifier); [`MAX_NULLIFIERS_PER_CALL`](../constants.md#circuit-constants)] | New nullifiers created in this function call. |
| `l2_to_l1_messages` | [[`L2toL1Message`](#l2tol1message); [`MAX_L2_TO_L1_MSGS_PER_CALL`](../constants.md#circuit-constants)] | New L2 to L1 messages created in this function call. |
| `unencrypted_log_hashes` | [[`UnencryptedLogHash`](#unencryptedloghash); [`MAX_UNENCRYPTED_LOG_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Hashes of the unencrypted logs emitted in this function call. |
| `encrypted_log_hashes` | [[`EncryptedLogHash`](#encryptedloghash); [`MAX_ENCRYPTED_LOG_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Hashes of the encrypted logs emitted in this function call. |
| `encrypted_note_preimage_hashes` | [[`EncryptedNotePreimageHash`](#encryptednotepreimagehash); [`MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Hashes of the encrypted note preimages emitted in this function call. |
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/protocol-specs/circuits/private-kernel-initial.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ Data that holds details about the current private function call.

| Field | Type | Description |
| ----------------------------- | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `note_hash_range_hints` | [`field`, [`MAX_NEW_NOTE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for note hashes. |
| `nullifier_range_hints` | [`field`, [`MAX_NEW_NULLIFIERS_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for nullifiers. |
| `note_hash_range_hints` | [`field`, [`MAX_NOTE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for note hashes. |
| `nullifier_range_hints` | [`field`, [`MAX_NULLIFIERS_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for nullifiers. |
| `unencrypted_log_range_hints` | [`field`, [`MAX_UNENCRYPTED_LOG_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for unencrypted logs. |
| `encrypted_log_range_hints` | [`field`, [`MAX_ENCRYPTED_LOG_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for encrypted logs. |
| `encrypted_note_range_hints` | [`field`, [`MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_CALL`](../constants.md#circuit-constants)] | Indices of the next emitted private call requests for encrypted notes. |
Expand Down Expand Up @@ -768,9 +768,9 @@ Would it be accurate to describe this as `AccumulatedTransientSideEffects`, perh

| Field | Type | Description |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `note_hash_contexts` | [[`NoteHashContext`](#notehashcontext); [`MAX_NEW_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Note hashes with extra data aiding verification. |
| `nullifier_contexts` | [[`NullifierContext`](#nullifiercontext); [`MAX_NEW_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Nullifiers with extra data aiding verification. |
| `l2_to_l1_message_contexts` | [[`L2toL1MessageContext`](#l2tol1messagecontext); [`MAX_NEW_L2_TO_L1_MSGS_PER_TX`](../constants.md#circuit-constants)] | L2-to-l1 messages with extra data aiding verification. |
| `note_hash_contexts` | [[`NoteHashContext`](#notehashcontext); [`MAX_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Note hashes with extra data aiding verification. |
| `nullifier_contexts` | [[`NullifierContext`](#nullifiercontext); [`MAX_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Nullifiers with extra data aiding verification. |
| `l2_to_l1_message_contexts` | [[`L2toL1MessageContext`](#l2tol1messagecontext); [`MAX_L2_TO_L1_MSGS_PER_TX`](../constants.md#circuit-constants)] | L2-to-l1 messages with extra data aiding verification. |
| `unencrypted_log_hash_contexts` | [[`UnencryptedLogHashContext`](#unencryptedloghashcontext); [`MAX_UNENCRYPTED_LOG_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hashes of the unencrypted logs with extra data aiding verification. |
| `encrypted_log_hash_contexts` | [[`EncryptedLogHashContext`](#encryptedloghashcontext); [`MAX_ENCRYPTED_LOG_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hashes of the encrypted logs with extra data aiding verification. |
| `encrypted_note_preimage_hash_contexts` | [[`EncryptedNotePreimageHashContext`](#encryptednotepreimagehash); [`MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hashes of the encrypted note preimages with extra data aiding verification. |
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/protocol-specs/circuits/private-kernel-reset.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ The format aligns with the [`PreviousKernel`](./private-kernel-inner#previousker

| Field | Type | Description |
| ------------------------------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `transient_nullifier_indices` | [`field`; [`MAX_NEW_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Indices of the nullifiers for transient notes. |
| `nullifier_index_hints` | [`field`; [`MAX_NEW_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Indices of the `transient_nullifier_indices` for transient nullifiers. |
| `transient_nullifier_indices` | [`field`; [`MAX_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Indices of the nullifiers for transient notes. |
| `nullifier_index_hints` | [`field`; [`MAX_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Indices of the `transient_nullifier_indices` for transient nullifiers. |
| `encrypted_note_preimage_hash_index_hints` | [`field`; [`MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Indices of the `encrypted_note_preimage_hash_contexts` for transient preimage hashes. |
| `log_note_hash_hints` | [`field`; [`MAX_NEW_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Indices of the `note_hash_contexts` for transient preimage hashes. |
| `log_note_hash_hints` | [`field`; [`MAX_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Indices of the `note_hash_contexts` for transient preimage hashes. |

## `PublicInputs`

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/protocol-specs/circuits/private-kernel-tail.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ Data that aids in the verifications carried out in this circuit:

| Field | Type | Description |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `note_hash_hints` | [[`OrderHint`](#orderhint); [`MAX_NEW_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hints for ordering `note_hash_contexts`. |
| `nullifier_hints` | [[`OrderHint`](#orderhint); [`MAX_NEW_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Hints for ordering `nullifier_contexts`. |
| `note_hash_hints` | [[`OrderHint`](#orderhint); [`MAX_NOTE_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hints for ordering `note_hash_contexts`. |
| `nullifier_hints` | [[`OrderHint`](#orderhint); [`MAX_NULLIFIERS_PER_TX`](../constants.md#circuit-constants)] | Hints for ordering `nullifier_contexts`. |
| `public_call_request_hints` | [`field`; [`MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX`](../constants.md#circuit-constants)] | Indices of ordered `public_call_request_contexts`. |
| `unencrypted_log_hash_hints` | [[`OrderHint`](#orderhint); [`MAX_UNENCRYPTED_LOG_HASHES_PER_TX`](../constants.md#circuit-constants)] | Hints for ordering `unencrypted_log_hash_contexts`. |
| `ordered_unencrypted_log_hashes_revertible` | [`field`; [`MAX_UNENCRYPTED_LOG_HASHES_PER_TX`](../constants.md#circuit-constants)] | Ordered revertible `unencrypted_log_hashes`. |
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/protocol-specs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ The statically-sized nature the kernel & rollup circuits will restrict the quant
| Name | Value | Description |
|---|---|---|
| `RETURN_VALUES_LENGTH` | 4 |
| `MAX_NEW_NOTE_HASHES_PER_CALL` | 128 |
| `MAX_NEW_NULLIFIERS_PER_CALL` | 128 |
| `MAX_NEW_L2_TO_L1_MSGS_PER_CALL` | 4 |
| `MAX_NOTE_HASHES_PER_CALL` | 128 |
| `MAX_NULLIFIERS_PER_CALL` | 128 |
| `MAX_L2_TO_L1_MSGS_PER_CALL` | 4 |
| `MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL` | 128 |
| `MAX_PUBLIC_DATA_READS_PER_CALL` | 128 |
| `MAX_UNENCRYPTED_LOG_HASHES_PER_CALL` | 128 |
Expand All @@ -61,9 +61,9 @@ The statically-sized nature the kernel & rollup circuits will restrict the quant
<!-- prettier-ignore -->
| Name | Value | Description |
|---|---|---|
| `MAX_NEW_NOTE_HASHES_PER_TX` | 128 |
| `MAX_NEW_NULLIFIERS_PER_TX` | 128 |
| `MAX_NEW_L2_TO_L1_MSGS_PER_TX` | 16 |
| `MAX_NOTE_HASHES_PER_TX` | 128 |
| `MAX_NULLIFIERS_PER_TX` | 128 |
| `MAX_L2_TO_L1_MSGS_PER_TX` | 16 |
| `MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX` | 31 |
| `MAX_PUBLIC_DATA_READS_PER_TX` | 16 |
| `MAX_UNENCRYPTED_LOG_HASHES_PER_TX` | 128 |
Expand Down
Loading
Loading