Skip to content

Commit

Permalink
chore(constants): bump number of private reads and writes (#2062)
Browse files Browse the repository at this point in the history
Increases the constants to support wider set of applications.
Specifically:

MAX_NEW_COMMITMENTS_PER_CALL = 4 $\longrightarrow$ 16
MAX_NEW_NULLIFIERS_PER_CALL = 4 $\longrightarrow$ 16
MAX_READ_REQUESTS_PER_CALL = 4 $\longrightarrow$ 32

Therefore, we have:

MAX_NEW_COMMITMENTS_PER_TX = 16 $\longrightarrow$ 64
MAX_NEW_NULLIFIERS_PER_TX = 16 $\longrightarrow$ 64
MAX_READ_REQUESTS_PER_TX = 16 $\longrightarrow$ 128

---------

Co-authored-by: Suyash Bagad <suyashnbagad1997@gmail.com>
Co-authored-by: ludamad <adam.domurad@gmail.com>
  • Loading branch information
3 people authored Sep 8, 2023
1 parent 4f5c4fe commit ab6c6b1
Show file tree
Hide file tree
Showing 16 changed files with 916 additions and 209 deletions.
6 changes: 3 additions & 3 deletions circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ constexpr size_t RETURN_VALUES_LENGTH = 4;

// docs:start:constants
// "PER CALL" CONSTANTS
constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4;
constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4;
constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 16;
constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 16;
constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4;
constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 16;
constexpr size_t MAX_PUBLIC_DATA_READS_PER_CALL = 16;
constexpr size_t MAX_READ_REQUESTS_PER_CALL = 4;
constexpr size_t MAX_READ_REQUESTS_PER_CALL = 32;


// "PER TRANSACTION" CONSTANTS
Expand Down
36 changes: 18 additions & 18 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ library Constants {

uint256 internal constant ARGS_LENGTH = 16;
uint256 internal constant RETURN_VALUES_LENGTH = 4;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_CALL = 4;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_CALL = 4;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_CALL = 16;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_CALL = 16;
uint256 internal constant MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
uint256 internal constant MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4;
uint256 internal constant MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
uint256 internal constant MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 16;
uint256 internal constant MAX_PUBLIC_DATA_READS_PER_CALL = 16;
uint256 internal constant MAX_READ_REQUESTS_PER_CALL = 4;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_TX = 16;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_TX = 16;
uint256 internal constant MAX_READ_REQUESTS_PER_CALL = 32;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_TX = 64;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_TX = 64;
uint256 internal constant MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8;
uint256 internal constant MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8;
uint256 internal constant MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
uint256 internal constant MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 16;
uint256 internal constant MAX_PUBLIC_DATA_READS_PER_TX = 16;
uint256 internal constant MAX_NEW_CONTRACTS_PER_TX = 1;
uint256 internal constant MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
uint256 internal constant MAX_READ_REQUESTS_PER_TX = 16;
uint256 internal constant MAX_READ_REQUESTS_PER_TX = 128;
uint256 internal constant NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
uint256 internal constant NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1;
uint256 internal constant NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
Expand All @@ -48,11 +48,11 @@ library Constants {
uint256 internal constant ROLLUP_VK_TREE_HEIGHT = 8;
uint256 internal constant CONTRACT_SUBTREE_HEIGHT = 1;
uint256 internal constant CONTRACT_SUBTREE_SIBLING_PATH_LENGTH = 15;
uint256 internal constant PRIVATE_DATA_SUBTREE_HEIGHT = 5;
uint256 internal constant PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH = 27;
uint256 internal constant NULLIFIER_SUBTREE_HEIGHT = 5;
uint256 internal constant PRIVATE_DATA_SUBTREE_HEIGHT = 7;
uint256 internal constant PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH = 25;
uint256 internal constant NULLIFIER_SUBTREE_HEIGHT = 7;
uint256 internal constant HISTORIC_BLOCKS_TREE_HEIGHT = 16;
uint256 internal constant NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 11;
uint256 internal constant NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 9;
uint256 internal constant L1_TO_L2_MSG_SUBTREE_HEIGHT = 4;
uint256 internal constant L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12;
uint256 internal constant FUNCTION_SELECTOR_NUM_BYTES = 4;
Expand All @@ -68,17 +68,17 @@ library Constants {
uint256 internal constant HISTORIC_BLOCK_DATA_LENGTH = 7;
uint256 internal constant FUNCTION_DATA_LENGTH = 4;
uint256 internal constant CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 58;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 122;
uint256 internal constant CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
uint256 internal constant CONTRACT_STORAGE_READ_LENGTH = 2;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 117;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 86;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 141;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;
uint256 internal constant EMPTY_NULLIFIED_COMMITMENT = 1000000;
uint256 internal constant CALL_PRIVATE_FUNCTION_RETURN_SIZE = 64;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 63;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 48;
uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 1024;
uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 1024;
uint256 internal constant CALL_PRIVATE_FUNCTION_RETURN_SIZE = 128;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 87;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 112;
uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 4096;
uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 4096;
uint256 internal constant PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 2048;
uint256 internal constant CONTRACTS_NUM_BYTES_PER_BASE_ROLLUP = 64;
uint256 internal constant CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP = 128;
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/abis/ecdsa_account_contract.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/abis/schnorr_account_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions yarn-project/circuits.js/src/cbind/circuits.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ export function fromPublicDataRead(o: PublicDataRead): MsgpackPublicDataRead {

interface MsgpackCombinedAccumulatedData {
aggregation_object: MsgpackNativeAggregationState;
read_requests: Tuple<Buffer, 16>;
new_commitments: Tuple<Buffer, 16>;
new_nullifiers: Tuple<Buffer, 16>;
nullified_commitments: Tuple<Buffer, 16>;
read_requests: Tuple<Buffer, 128>;
new_commitments: Tuple<Buffer, 64>;
new_nullifiers: Tuple<Buffer, 64>;
nullified_commitments: Tuple<Buffer, 64>;
private_call_stack: Tuple<Buffer, 8>;
public_call_stack: Tuple<Buffer, 8>;
new_l2_to_l1_msgs: Tuple<Buffer, 2>;
Expand Down Expand Up @@ -1158,10 +1158,10 @@ interface MsgpackPrivateCircuitPublicInputs {
call_context: MsgpackCallContext;
args_hash: Buffer;
return_values: Tuple<Buffer, 4>;
read_requests: Tuple<Buffer, 4>;
new_commitments: Tuple<Buffer, 4>;
new_nullifiers: Tuple<Buffer, 4>;
nullified_commitments: Tuple<Buffer, 4>;
read_requests: Tuple<Buffer, 32>;
new_commitments: Tuple<Buffer, 16>;
new_nullifiers: Tuple<Buffer, 16>;
nullified_commitments: Tuple<Buffer, 16>;
private_call_stack: Tuple<Buffer, 4>;
public_call_stack: Tuple<Buffer, 4>;
new_l2_to_l1_msgs: Tuple<Buffer, 2>;
Expand Down Expand Up @@ -1496,7 +1496,7 @@ interface MsgpackPrivateCallData {
vk: MsgpackVerificationKeyData;
function_leaf_membership_witness: MsgpackMembershipWitness4;
contract_leaf_membership_witness: MsgpackMembershipWitness16;
read_request_membership_witnesses: Tuple<MsgpackReadRequestMembershipWitness, 4>;
read_request_membership_witnesses: Tuple<MsgpackReadRequestMembershipWitness, 32>;
portal_contract_address: Buffer;
acir_hash: Buffer;
}
Expand Down Expand Up @@ -1675,8 +1675,8 @@ export function fromPrivateKernelInputsInner(o: PrivateKernelInputsInner): Msgpa

interface MsgpackPrivateKernelInputsOrdering {
previous_kernel: MsgpackPreviousKernelData;
read_commitment_hints: Tuple<Buffer, 16>;
nullifier_commitment_hints: Tuple<Buffer, 16>;
read_commitment_hints: Tuple<Buffer, 128>;
nullifier_commitment_hints: Tuple<Buffer, 64>;
}

export function toPrivateKernelInputsOrdering(o: MsgpackPrivateKernelInputsOrdering): PrivateKernelInputsOrdering {
Expand Down Expand Up @@ -1715,9 +1715,9 @@ export function fromPrivateKernelInputsOrdering(o: PrivateKernelInputsOrdering):

interface MsgpackFinalAccumulatedData {
aggregation_object: MsgpackNativeAggregationState;
new_commitments: Tuple<Buffer, 16>;
new_nullifiers: Tuple<Buffer, 16>;
nullified_commitments: Tuple<Buffer, 16>;
new_commitments: Tuple<Buffer, 64>;
new_nullifiers: Tuple<Buffer, 64>;
nullified_commitments: Tuple<Buffer, 64>;
private_call_stack: Tuple<Buffer, 8>;
public_call_stack: Tuple<Buffer, 8>;
new_l2_to_l1_msgs: Tuple<Buffer, 2>;
Expand Down Expand Up @@ -1964,8 +1964,8 @@ interface MsgpackPublicCircuitPublicInputs {
contract_storage_update_requests: Tuple<MsgpackContractStorageUpdateRequest, 16>;
contract_storage_reads: Tuple<MsgpackContractStorageRead, 16>;
public_call_stack: Tuple<Buffer, 4>;
new_commitments: Tuple<Buffer, 4>;
new_nullifiers: Tuple<Buffer, 4>;
new_commitments: Tuple<Buffer, 16>;
new_nullifiers: Tuple<Buffer, 16>;
new_l2_to_l1_msgs: Tuple<Buffer, 2>;
unencrypted_logs_hash: Tuple<Buffer, 2>;
unencrypted_log_preimages_length: Buffer;
Expand Down
36 changes: 18 additions & 18 deletions yarn-project/circuits.js/src/cbind/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants
export const ARGS_LENGTH = 16;
export const RETURN_VALUES_LENGTH = 4;
export const MAX_NEW_COMMITMENTS_PER_CALL = 4;
export const MAX_NEW_NULLIFIERS_PER_CALL = 4;
export const MAX_NEW_COMMITMENTS_PER_CALL = 16;
export const MAX_NEW_NULLIFIERS_PER_CALL = 16;
export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4;
export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 16;
export const MAX_PUBLIC_DATA_READS_PER_CALL = 16;
export const MAX_READ_REQUESTS_PER_CALL = 4;
export const MAX_NEW_COMMITMENTS_PER_TX = 16;
export const MAX_NEW_NULLIFIERS_PER_TX = 16;
export const MAX_READ_REQUESTS_PER_CALL = 32;
export const MAX_NEW_COMMITMENTS_PER_TX = 64;
export const MAX_NEW_NULLIFIERS_PER_TX = 64;
export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8;
export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8;
export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 16;
export const MAX_PUBLIC_DATA_READS_PER_TX = 16;
export const MAX_NEW_CONTRACTS_PER_TX = 1;
export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
export const MAX_READ_REQUESTS_PER_TX = 16;
export const MAX_READ_REQUESTS_PER_TX = 128;
export const NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
export const NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1;
export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
Expand All @@ -34,11 +34,11 @@ export const L1_TO_L2_MSG_TREE_HEIGHT = 16;
export const ROLLUP_VK_TREE_HEIGHT = 8;
export const CONTRACT_SUBTREE_HEIGHT = 1;
export const CONTRACT_SUBTREE_SIBLING_PATH_LENGTH = 15;
export const PRIVATE_DATA_SUBTREE_HEIGHT = 5;
export const PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH = 27;
export const NULLIFIER_SUBTREE_HEIGHT = 5;
export const PRIVATE_DATA_SUBTREE_HEIGHT = 7;
export const PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH = 25;
export const NULLIFIER_SUBTREE_HEIGHT = 7;
export const HISTORIC_BLOCKS_TREE_HEIGHT = 16;
export const NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 11;
export const NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 9;
export const L1_TO_L2_MSG_SUBTREE_HEIGHT = 4;
export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12;
export const FUNCTION_SELECTOR_NUM_BYTES = 4;
Expand All @@ -54,17 +54,17 @@ export const CALL_CONTEXT_LENGTH = 6;
export const HISTORIC_BLOCK_DATA_LENGTH = 7;
export const FUNCTION_DATA_LENGTH = 4;
export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 58;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 122;
export const CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
export const CONTRACT_STORAGE_READ_LENGTH = 2;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 117;
export const GET_NOTES_ORACLE_RETURN_LENGTH = 86;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 141;
export const GET_NOTES_ORACLE_RETURN_LENGTH = 674;
export const EMPTY_NULLIFIED_COMMITMENT = 1000000;
export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 64;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 63;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 48;
export const COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 1024;
export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 1024;
export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 128;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 87;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 112;
export const COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 4096;
export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 4096;
export const PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 2048;
export const CONTRACTS_NUM_BYTES_PER_BASE_ROLLUP = 64;
export const CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP = 128;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ is_contract_deployment: 1
args_hash: 0x100
return_values: [ 0x200 0x201 0x202 0x203 ]
read_requests: [ 0x300 0x301 0x302 0x303 ]
new_commitments: [ 0x400 0x401 0x402 0x403 ]
new_nullifiers: [ 0x500 0x501 0x502 0x503 ]
nullified_commitments: [ 0x510 0x511 0x512 0x513 ]
read_requests: [ 0x300 0x301 0x302 0x303 0x304 0x305 0x306 0x307 0x308 0x309 0x30a 0x30b 0x30c 0x30d 0x30e 0x30f 0x310 0x311 0x312 0x313 0x314 0x315 0x316 0x317 0x318 0x319 0x31a 0x31b 0x31c 0x31d 0x31e 0x31f ]
new_commitments: [ 0x400 0x401 0x402 0x403 0x404 0x405 0x406 0x407 0x408 0x409 0x40a 0x40b 0x40c 0x40d 0x40e 0x40f ]
new_nullifiers: [ 0x500 0x501 0x502 0x503 0x504 0x505 0x506 0x507 0x508 0x509 0x50a 0x50b 0x50c 0x50d 0x50e 0x50f ]
nullified_commitments: [ 0x510 0x511 0x512 0x513 0x514 0x515 0x516 0x517 0x518 0x519 0x51a 0x51b 0x51c 0x51d 0x51e 0x51f ]
private_call_stack: [ 0x600 0x601 0x602 0x603 ]
public_call_stack: [ 0x700 0x701 0x702 0x703 ]
new_l2_to_l1_msgs: [ 0x800 0x801 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ current_value: 0x1
current_value: 0x1
]
public_call_stack: [ 0x600 0x601 0x0 0x0 ]
new_commitments: [ 0x700 0x701 0x0 0x0 ]
new_nullifiers: [ 0x800 0x801 0x0 0x0 ]
new_commitments: [ 0x700 0x701 0x702 0x703 0x704 0x705 0x706 0x707 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ]
new_nullifiers: [ 0x800 0x801 0x802 0x803 0x804 0x805 0x806 0x807 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ]
new_l2_to_l1_msgs: [ 0x900 0x0 ]
unencrypted_logs_hash: [ 0x901 0x0 ]
unencrypted_log_preimages_length: 0x902
Expand Down
Loading

0 comments on commit ab6c6b1

Please sign in to comment.