Skip to content

Commit

Permalink
feat: increasing MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, removing h…
Browse files Browse the repository at this point in the history
…ack (#6739)
  • Loading branch information
benesjan authored May 30, 2024
1 parent 9b0572d commit d5550c6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const size_t MAX_NEW_NOTE_HASHES_PER_CALL = 16;
const size_t MAX_NEW_NULLIFIERS_PER_CALL = 16;
const size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
const size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 16;
const size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32;
const size_t MAX_PUBLIC_DATA_READS_PER_CALL = 16;
const size_t MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32;
const size_t MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32;
Expand Down
3 changes: 1 addition & 2 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library Constants {
uint256 internal constant MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
uint256 internal constant MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 16;
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_UPDATE_REQUESTS_PER_CALL = 32;
uint256 internal constant MAX_PUBLIC_DATA_READS_PER_CALL = 16;
uint256 internal constant MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32;
uint256 internal constant MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32;
Expand Down Expand Up @@ -143,7 +143,6 @@ library Constants {
uint256 internal constant PRIVATE_CALL_REQUEST_LENGTH = 3 + CALLER_CONTEXT_LENGTH;
uint256 internal constant SCOPED_PRIVATE_CALL_REQUEST_LENGTH =
PRIVATE_CALL_REQUEST_LENGTH + AZTEC_ADDRESS_LENGTH;
uint256 internal constant SIDE_EFFECT_LENGTH = 2;
uint256 internal constant ROLLUP_VALIDATION_REQUESTS_LENGTH = MAX_BLOCK_NUMBER_LENGTH;
uint256 internal constant STATE_REFERENCE_LENGTH =
APPEND_ONLY_TREE_SNAPSHOT_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,18 @@ contract KeyRegistry {
let npk_m_y_registry = storage.npk_m_y_registry.at(address);
let ivpk_m_x_registry = storage.ivpk_m_x_registry.at(address);
let ivpk_m_y_registry = storage.ivpk_m_y_registry.at(address);

npk_m_x_registry.schedule_value_change(keys.npk_m.x);
npk_m_y_registry.schedule_value_change(keys.npk_m.y);
ivpk_m_x_registry.schedule_value_change(keys.ivpk_m.x);
ivpk_m_y_registry.schedule_value_change(keys.ivpk_m.y);

// Note: This is a hack to get around MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL limit
KeyRegistry::at(context.this_address())._register_remaining(address, keys.ovpk_m, keys.tpk_m).call(&mut context);
}

#[aztec(public)]
#[aztec(internal)]
fn _register_remaining(address: AztecAddress, ovpk_m: GrumpkinPoint, tpk_m: GrumpkinPoint) {
// We don't need to do any checks here because they were already performed in register(...) and this function is
// internal
let ovpk_m_x_registry = storage.ovpk_m_x_registry.at(address);
let ovpk_m_y_registry = storage.ovpk_m_y_registry.at(address);
let tpk_m_x_registry = storage.tpk_m_x_registry.at(address);
let tpk_m_y_registry = storage.tpk_m_y_registry.at(address);

ovpk_m_x_registry.schedule_value_change(ovpk_m.x);
ovpk_m_y_registry.schedule_value_change(ovpk_m.y);
tpk_m_x_registry.schedule_value_change(tpk_m.x);
tpk_m_y_registry.schedule_value_change(tpk_m.y);
npk_m_x_registry.schedule_value_change(keys.npk_m.x);
npk_m_y_registry.schedule_value_change(keys.npk_m.y);
ivpk_m_x_registry.schedule_value_change(keys.ivpk_m.x);
ivpk_m_y_registry.schedule_value_change(keys.ivpk_m.y);
ovpk_m_x_registry.schedule_value_change(keys.ovpk_m.x);
ovpk_m_y_registry.schedule_value_change(keys.ovpk_m.y);
tpk_m_x_registry.schedule_value_change(keys.tpk_m.x);
tpk_m_y_registry.schedule_value_change(keys.tpk_m.y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
let call_stack_item = PublicCallStackItem { contract_address, public_inputs, is_execution_request: true, function_data };

// Value from public_call_stack_item.test.ts "Computes a callstack item request hash" test
let test_data_call_stack_item_request_hash = 0x09b460df8be10a6bd56588c93b478243fdf5cc92db59d9b1670ce2a044fab6d6;
let test_data_call_stack_item_request_hash = 0x2e8e08091cc52f5177715b2cf03e0a14741fb89862232acade59eb107b64d71b;
assert_eq(call_stack_item.hash(), test_data_call_stack_item_request_hash);
}

Expand All @@ -87,7 +87,7 @@ mod tests {
let call_stack_item = PublicCallStackItem { contract_address, public_inputs, is_execution_request: false, function_data };

// Value from public_call_stack_item.test.ts "Computes a callstack item hash" test
let test_data_call_stack_item_hash = 0x0931a8de516f3f49dff48fbdea57f01b706dc67cbd1fd8bde97d26c4a53afd0a;
let test_data_call_stack_item_hash = 0x10ed3d5ca5eb90d5c1b5ea35b3b71016b34618352d1acf7083878aa106d33577;
assert_eq(call_stack_item.hash(), test_data_call_stack_item_hash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,6 @@ fn empty_hash() {
let hash = inputs.hash();

// Value from public_circuit_public_inputs.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x05061edabeae1057b6f6216afc118e46ea0b77044d4c57ed12e5712dab01b8d4;
let test_data_empty_hash = 0x067b9bd773ae49145e07b395da4f156fb35972e77bd4c40ed980ea8c9b90dd64;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ global MAX_NEW_NULLIFIERS_PER_CALL: u64 = 16;
global MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL: u64 = 4;
global MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL: u64 = 16;
global MAX_NEW_L2_TO_L1_MSGS_PER_CALL: u64 = 2;
global MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL: u64 = 16;
global MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL: u64 = 32;
global MAX_PUBLIC_DATA_READS_PER_CALL: u64 = 16;
global MAX_NOTE_HASH_READ_REQUESTS_PER_CALL: u64 = 32;
global MAX_NULLIFIER_READ_REQUESTS_PER_CALL: u64 = 32;
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 = 16;
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_UPDATE_REQUESTS_PER_CALL = 32;
export const MAX_PUBLIC_DATA_READS_PER_CALL = 16;
export const MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32;
export const MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32;
Expand Down Expand Up @@ -122,7 +122,6 @@ export const SCOPED_NULLIFIER_LENGTH = NULLIFIER_LENGTH + 1;
export const CALLER_CONTEXT_LENGTH = 2 * AZTEC_ADDRESS_LENGTH + 1;
export const PRIVATE_CALL_REQUEST_LENGTH = 3 + CALLER_CONTEXT_LENGTH;
export const SCOPED_PRIVATE_CALL_REQUEST_LENGTH = PRIVATE_CALL_REQUEST_LENGTH + AZTEC_ADDRESS_LENGTH;
export const SIDE_EFFECT_LENGTH = 2;
export const ROLLUP_VALIDATION_REQUESTS_LENGTH = MAX_BLOCK_NUMBER_LENGTH;
export const STATE_REFERENCE_LENGTH = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH;
export const TX_CONTEXT_LENGTH = 2 + GAS_SETTINGS_LENGTH;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PublicCallStackItem Computes a callstack item hash 1`] = `"0x0931a8de516f3f49dff48fbdea57f01b706dc67cbd1fd8bde97d26c4a53afd0a"`;
exports[`PublicCallStackItem Computes a callstack item hash 1`] = `"0x10ed3d5ca5eb90d5c1b5ea35b3b71016b34618352d1acf7083878aa106d33577"`;

exports[`PublicCallStackItem Computes a callstack item request hash 1`] = `"0x09b460df8be10a6bd56588c93b478243fdf5cc92db59d9b1670ce2a044fab6d6"`;
exports[`PublicCallStackItem Computes a callstack item request hash 1`] = `"0x2e8e08091cc52f5177715b2cf03e0a14741fb89862232acade59eb107b64d71b"`;

exports[`PublicCallStackItem computes empty item hash 1`] = `Fr<0x2baaf9d674eb8f64e18bca2f87a665fdbd43d8696c7a62d689d88bd0296175a4>`;
exports[`PublicCallStackItem computes empty item hash 1`] = `Fr<0x181b8f691a79ebb94c77d188df1bc677a7d4edb989ad158b84d99d99529755a9>`;

exports[`PublicCallStackItem computes hash 1`] = `Fr<0x17703e5a5555de5e97d3e6c991b489f4818e71931fd8ee958a00e2c18b806072>`;
exports[`PublicCallStackItem computes hash 1`] = `Fr<0x0702f117ff468b7dff3b8dcf0b56c1fcc0b3272c85c6d33e631e0ae93d0c5ccf>`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x05061edabeae1057b6f6216afc118e46ea0b77044d4c57ed12e5712dab01b8d4>`;
exports[`PublicCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x067b9bd773ae49145e07b395da4f156fb35972e77bd4c40ed980ea8c9b90dd64>`;

exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x14d9838268c0549fdbc4231fc36432f7ec6687157287117bf15b2fb5a39c9026>`;
exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x1f365550bc7d23274b5f320452ab3df01e9fdc6e6cf0854f7ecce5e4a5df094c>`;

0 comments on commit d5550c6

Please sign in to comment.