Skip to content

Commit

Permalink
chore: Update serialisation (#6378)
Browse files Browse the repository at this point in the history
This PR adds lots of serialisation methods and tests to
`noir-protocol-circuits`.

---------

Co-authored-by: Aztec Bot <[email protected]>
  • Loading branch information
PhilWindle and AztecBot committed May 15, 2024
1 parent a95b12d commit 6985424
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const size_t MAX_ARGS_LENGTH = ARGS_HASH_CHUNK_COUNT * ARGS_HASH_CHUNK_LENGTH;
const size_t INITIAL_L2_BLOCK_NUM = 1;
const size_t BLOB_SIZE_IN_BYTES = 31 * 4096;
const size_t NESTED_CALL_L2_GAS_BUFFER = 20000;
const size_t MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 16200;
const size_t MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 32000;
const size_t MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000;
const size_t MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 3000;
const size_t REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 19;
Expand All @@ -87,23 +87,26 @@ const size_t FUNCTION_LEAF_PREIMAGE_LENGTH = 5;
const size_t GLOBAL_VARIABLES_LENGTH = 6 + GAS_FEES_LENGTH;
const size_t APPEND_ONLY_TREE_SNAPSHOT_LENGTH = 2;
const size_t L1_TO_L2_MESSAGE_LENGTH = 6;
const size_t L2_TO_L1_MESSAGE_LENGTH = 2;
const size_t L2_TO_L1_MESSAGE_LENGTH = 3;
const size_t SCOPED_L2_TO_L1_MESSAGE_LENGTH = L2_TO_L1_MESSAGE_LENGTH + 1;
const size_t MAX_BLOCK_NUMBER_LENGTH = 2;
const size_t NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH = 3;
const size_t NULLIFIER_KEY_VALIDATION_REQUEST_CONTEXT_LENGTH = 4;
const size_t SCOPED_NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH = NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH + 1;
const size_t PARTIAL_STATE_REFERENCE_LENGTH = 6;
const size_t READ_REQUEST_LENGTH = 2;
const size_t NOTE_HASH_LENGTH = 2;
const size_t NOTE_HASH_CONTEXT_LENGTH = 3;
const size_t SCOPED_NOTE_HASH_LENGTH = NOTE_HASH_LENGTH + 2;
const size_t NULLIFIER_LENGTH = 3;
const size_t SCOPED_NULLIFIER_LENGTH = NULLIFIER_LENGTH + 1;
const size_t SIDE_EFFECT_LENGTH = 2;
const size_t ROLLUP_VALIDATION_REQUESTS_LENGTH = MAX_BLOCK_NUMBER_LENGTH;
const size_t STATE_REFERENCE_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH;
const size_t TX_CONTEXT_LENGTH = 2 + GAS_SETTINGS_LENGTH;
const size_t TX_REQUEST_LENGTH = 2 + TX_CONTEXT_LENGTH + FUNCTION_DATA_LENGTH;
const size_t HEADER_LENGTH =
APPEND_ONLY_TREE_SNAPSHOT_LENGTH + CONTENT_COMMITMENT_LENGTH + STATE_REFERENCE_LENGTH + GLOBAL_VARIABLES_LENGTH;
const size_t PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH =
CALL_CONTEXT_LENGTH + 3 + MAX_BLOCK_NUMBER_LENGTH + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) +
CALL_CONTEXT_LENGTH + 4 + MAX_BLOCK_NUMBER_LENGTH + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) +
(READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) +
(NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH * MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL) +
(NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL) +
Expand All @@ -124,6 +127,40 @@ const size_t PRIVATE_CALL_STACK_ITEM_LENGTH =
AZTEC_ADDRESS_LENGTH + FUNCTION_DATA_LENGTH + PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH;
const size_t PUBLIC_CONTEXT_INPUTS_LENGTH =
CALL_CONTEXT_LENGTH + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + GAS_LENGTH + 2;
const size_t SCOPED_READ_REQUEST_LEN = READ_REQUEST_LENGTH + 1;
const size_t PUBLIC_DATA_READ_LENGTH = 2;
const size_t VALIDATION_REQUESTS_LENGTH =
ROLLUP_VALIDATION_REQUESTS_LENGTH + (SCOPED_READ_REQUEST_LEN * MAX_NOTE_HASH_READ_REQUESTS_PER_TX) +
(SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_READ_REQUESTS_PER_TX) +
(SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX) +
(SCOPED_NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH * MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX) +
(PUBLIC_DATA_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_TX);
const size_t PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 2;
const size_t COMBINED_ACCUMULATED_DATA_LENGTH =
MAX_NEW_NOTE_HASHES_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + MAX_NEW_L2_TO_L1_MSGS_PER_TX + 4 +
(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * PUBLIC_DATA_UPDATE_REQUEST_LENGTH) + GAS_LENGTH;
const size_t COMBINED_CONSTANT_DATA_LENGTH = HEADER_LENGTH + TX_CONTEXT_LENGTH + GLOBAL_VARIABLES_LENGTH;
const size_t CALLER_CONTEXT_LENGTH = 2 * AZTEC_ADDRESS_LENGTH;
const size_t CALL_REQUEST_LENGTH = 1 + AZTEC_ADDRESS_LENGTH + CALLER_CONTEXT_LENGTH + 2;
const size_t PRIVATE_ACCUMULATED_DATA_LENGTH =
(SCOPED_NOTE_HASH_LENGTH * MAX_NEW_NOTE_HASHES_PER_TX) + (SCOPED_NULLIFIER_LENGTH * MAX_NEW_NULLIFIERS_PER_TX) +
(MAX_NEW_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (SIDE_EFFECT_LENGTH * MAX_ENCRYPTED_LOGS_PER_TX) +
(SIDE_EFFECT_LENGTH * MAX_UNENCRYPTED_LOGS_PER_TX) + 2 +
(CALL_REQUEST_LENGTH * MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX) +
(CALL_REQUEST_LENGTH * MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX);
const size_t PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH =
1 + VALIDATION_REQUESTS_LENGTH + PRIVATE_ACCUMULATED_DATA_LENGTH + COMBINED_CONSTANT_DATA_LENGTH +
CALL_REQUEST_LENGTH + AZTEC_ADDRESS_LENGTH;
const size_t PUBLIC_ACCUMULATED_DATA_LENGTH =
(MAX_NEW_NOTE_HASHES_PER_TX * NOTE_HASH_LENGTH) + (MAX_NEW_NULLIFIERS_PER_TX * NULLIFIER_LENGTH) +
(MAX_NEW_L2_TO_L1_MSGS_PER_TX * 1) + (MAX_ENCRYPTED_LOGS_PER_TX * SIDE_EFFECT_LENGTH) +
(MAX_UNENCRYPTED_LOGS_PER_TX * SIDE_EFFECT_LENGTH) + 2 +
(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * PUBLIC_DATA_UPDATE_REQUEST_LENGTH) +
(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX * CALL_REQUEST_LENGTH) + GAS_LENGTH;
const size_t PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH =
VALIDATION_REQUESTS_LENGTH + PUBLIC_ACCUMULATED_DATA_LENGTH + PUBLIC_ACCUMULATED_DATA_LENGTH +
COMBINED_CONSTANT_DATA_LENGTH + 1 + (MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX * CALL_REQUEST_LENGTH) +
AZTEC_ADDRESS_LENGTH;
const size_t ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_LENGTH = 2 + FUNCTION_DATA_LENGTH + CALL_CONTEXT_LENGTH;
const size_t GET_NOTES_ORACLE_RETURN_LENGTH = 674;
const size_t NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 2048;
Expand Down

0 comments on commit 6985424

Please sign in to comment.