Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Feb 16, 2024
1 parent e6d65a7 commit 3837151
Show file tree
Hide file tree
Showing 84 changed files with 4,377 additions and 3,982 deletions.
4 changes: 2 additions & 2 deletions l1-contracts/slither_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ src/core/messagebridge/Inbox.sol#L148-L153
Impact: Informational
Confidence: Medium
- [ ] ID-41
Variable [Constants.L1_TO_L2_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L96) is too similar to [Constants.L2_TO_L1_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L97)
Variable [Constants.L1_TO_L2_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L103) is too similar to [Constants.L2_TO_L1_MESSAGE_LENGTH](src/core/libraries/ConstantsGen.sol#L104)

src/core/libraries/ConstantsGen.sol#L96
src/core/libraries/ConstantsGen.sol#L103


- [ ] ID-42
Expand Down
15 changes: 11 additions & 4 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,27 @@ library Constants {
uint256 internal constant MAX_READ_REQUESTS_PER_CALL = 32;
uint256 internal constant MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL = 1;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_TX = 64;
uint256 internal constant MAX_NON_REVERTIBLE_COMMITMENTS_PER_TX = 8;
uint256 internal constant MAX_REVERTIBLE_COMMITMENTS_PER_TX = 56;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_TX = 64;
uint256 internal constant MAX_NON_REVERTIBLE_NULLIFIERS_PER_TX = 8;
uint256 internal constant MAX_REVERTIBLE_NULLIFIERS_PER_TX = 56;
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_NON_REVERTIBLE_PUBLIC_CALL_STACK_LENGTH_PER_TX = 3;
uint256 internal constant MAX_REVERTIBLE_PUBLIC_CALL_STACK_LENGTH_PER_TX = 5;
uint256 internal constant MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 16;
uint256 internal constant MAX_NON_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 1;
uint256 internal constant MAX_REVERTIBLE_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 15;
uint256 internal constant MAX_PUBLIC_DATA_READS_PER_TX = 16;
uint256 internal constant MAX_NON_REVERTIBLE_PUBLIC_DATA_READS_PER_TX = 1;
uint256 internal constant MAX_REVERTIBLE_PUBLIC_DATA_READS_PER_TX = 15;
uint256 internal constant MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
uint256 internal constant MAX_NEW_CONTRACTS_PER_TX = 1;
uint256 internal constant MAX_READ_REQUESTS_PER_TX = 128;
uint256 internal constant MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX = 4;
uint256 internal constant NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
uint256 internal constant NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1;
uint256 internal constant MAX_NEW_COMMITMENTS_PER_TX_META = 8;
uint256 internal constant MAX_NEW_NULLIFIERS_PER_TX_META = 8;
uint256 internal constant MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX_META = 2;
uint256 internal constant NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
uint256 internal constant VK_TREE_HEIGHT = 3;
uint256 internal constant FUNCTION_TREE_HEIGHT = 5;
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/account.nr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl AccountActions {
let fee_hash = fee_payload.hash();
assert(valid_fn(private_context, fee_hash));
fee_payload.execute_calls(private_context);
private_context.capture_max_non_revertible_side_effect_counter();
private_context.capture_min_revertible_side_effect_counter();

let app_hash = app_payload.hash();
assert(valid_fn(private_context, app_hash));
Expand Down
29 changes: 19 additions & 10 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::{
oracle::{
arguments, call_private_function::call_private_function_internal,
enqueue_public_function_call::enqueue_public_function_call_internal, context::get_portal_address,
header::get_header_at, nullifier_key::{get_nullifier_key_pair, NullifierKeyPair}
header::get_header_at, nullifier_key::{get_nullifier_key_pair, NullifierKeyPair},
debug_log::debug_log
}
};
use dep::protocol_types::{
Expand Down Expand Up @@ -40,7 +41,7 @@ struct PrivateContext {
inputs: PrivateContextInputs,
side_effect_counter: u32,

max_non_revertible_side_effect_counter: u32,
min_revertible_side_effect_counter: u32,

args_hash : Field,
return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,
Expand Down Expand Up @@ -68,10 +69,16 @@ struct PrivateContext {

impl PrivateContext {
pub fn new(inputs: PrivateContextInputs, args_hash: Field) -> PrivateContext {
let side_effect_counter = inputs.call_context.start_side_effect_counter;
let mut min_revertible_side_effect_counter = 0;
// Note. The side effect counter is 2 when this is the initial call
if (side_effect_counter == 2) {
min_revertible_side_effect_counter = side_effect_counter;
}
PrivateContext {
inputs,
side_effect_counter: inputs.call_context.start_side_effect_counter,
max_non_revertible_side_effect_counter: 0,
side_effect_counter,
min_revertible_side_effect_counter,
args_hash,
return_values: BoundedVec::new(0),
read_requests: BoundedVec::new(SideEffect::empty()),
Expand Down Expand Up @@ -136,7 +143,12 @@ impl PrivateContext {
call_context: self.inputs.call_context,
args_hash: self.args_hash,
return_values: self.return_values.storage,
max_non_revertible_side_effect_counter: self.max_non_revertible_side_effect_counter,
// TODO(fees): start this from 0 and test the following:
// - in the private circuit init that it gets set correctly
// - in the private circuit inner that it remains 0
// I've had to initialize the counter here so that it would work for contract deployments
// the above checks should be doable after we figure out fee payments for contract deployments
min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,
read_requests: self.read_requests.storage,
nullifier_key_validation_requests: self.nullifier_key_validation_requests.storage,
new_commitments: self.new_commitments.storage,
Expand All @@ -157,11 +169,8 @@ impl PrivateContext {
priv_circuit_pub_inputs
}

pub fn capture_max_non_revertible_side_effect_counter(&mut self) {
assert(
self.max_non_revertible_side_effect_counter == 0, "Already captured the non-revertible side effect counter"
);
self.max_non_revertible_side_effect_counter = self.side_effect_counter;
pub fn capture_min_revertible_side_effect_counter(&mut self) {
self.min_revertible_side_effect_counter = self.side_effect_counter;
}

pub fn push_read_request(&mut self, read_request: Field) {
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/noir-protocol-circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"build": "yarn clean && yarn noir:build",
"clean": "rm -rf ./dest src/target",
"noir:build": "cd src && ../../../noir/target/release/nargo compile --silence-warnings",
"test": "cd src && ../../../noir/target/release/nargo test"
"test": "cd src && ../../../noir/target/release/nargo test --silence-warnings"
},
"files": [
"dest",
"src"
]
}
}
2 changes: 2 additions & 0 deletions noir-projects/noir-protocol-circuits/src/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ members = [
"crates/public-kernel-setup-simulated",
"crates/public-kernel-app-logic",
"crates/public-kernel-app-logic-simulated",
"crates/public-kernel-teardown",
"crates/public-kernel-teardown-simulated",
"crates/rollup-lib",
"crates/rollup-merge",
"crates/rollup-base",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn initialize_end_values(
public_inputs: &mut PrivateKernelCircuitPublicInputsBuilder
) {
public_inputs.constants = previous_kernel.public_inputs.constants;
public_inputs.min_revertible_side_effect_counter = previous_kernel.public_inputs.min_revertible_side_effect_counter;

// Ensure the arrays are the same as previously, before we start pushing more data onto them in other
// functions within this circuit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl PrivateKernelInitCircuitPrivateInputs {
historical_header: self.private_call.call_stack_item.public_inputs.historical_header,
tx_context: self.tx_request.tx_context,
};
public_inputs.max_non_revertible_side_effect_counter = self.private_call.call_stack_item.public_inputs.max_non_revertible_side_effect_counter;
public_inputs.min_revertible_side_effect_counter = self.private_call.call_stack_item.public_inputs.min_revertible_side_effect_counter;
}

// Confirm that the TxRequest (user's intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod tests {

impl PrivateKernelInnerInputsBuilder {
pub fn new() -> Self {
let previous_kernel = PreviousKernelDataBuilder::new();
let previous_kernel = PreviousKernelDataBuilder::new(false);
let private_call = PrivateCallDataBuilder::new(false);

PrivateKernelInnerInputsBuilder { previous_kernel, private_call }
Expand Down
Loading

0 comments on commit 3837151

Please sign in to comment.