-
Notifications
You must be signed in to change notification settings - Fork 284
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
feat: introduce avm circuit public inputs #9759
Changes from 2 commits
41c2c50
8571d9b
6f3eb31
2b0d1a4
52a0ec8
c78003e
f3293eb
80f98e5
776c861
f040079
bb8df29
cb374b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ use dep::types::{ | |
private_call_request::PrivateCallRequest, | ||
private_circuit_public_inputs::PrivateCircuitPublicInputsArrayLengths, | ||
private_kernel::private_call_data::PrivateCallData, | ||
public_call_request::PublicCallRequest, | ||
side_effect::{Ordered, RangeOrdered}, | ||
}, | ||
address::AztecAddress, | ||
|
@@ -23,17 +24,6 @@ use dep::types::{ | |
utils::arrays::find_index_hint, | ||
}; | ||
|
||
fn validate_call_context(target_context: CallContext, this_context: CallContext) { | ||
assert_eq( | ||
target_context.msg_sender, | ||
this_context.contract_address, | ||
"incorrect msg_sender for call request", | ||
); | ||
if !target_context.is_static_call { | ||
assert(this_context.is_static_call == false, "static call cannot make non-static calls"); | ||
} | ||
} | ||
|
||
fn validate_incrementing_counters_within_range<T, let N: u32>( | ||
counter_start: u32, | ||
counter_end: u32, | ||
|
@@ -111,7 +101,6 @@ impl PrivateCallDataValidator { | |
self.validate_call(); | ||
self.validate_private_call_requests(); | ||
self.validate_public_call_requests(); | ||
self.validate_teardown_call_request(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved into |
||
self.validate_counters(); | ||
self.validate_note_logs(accumulated_note_hashes); | ||
} | ||
|
@@ -244,7 +233,18 @@ impl PrivateCallDataValidator { | |
for i in 0..call_requests.len() { | ||
should_check &= i != num_requests; | ||
if should_check { | ||
validate_call_context(call_requests[i].call_context, public_inputs.call_context); | ||
let call_request = call_requests[i]; | ||
assert_eq( | ||
call_request.call_context.msg_sender, | ||
public_inputs.call_context.contract_address, | ||
"incorrect msg_sender for call request", | ||
); | ||
if !call_request.call_context.is_static_call { | ||
assert( | ||
public_inputs.call_context.is_static_call == false, | ||
"static call cannot make non-static calls", | ||
); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -274,22 +274,34 @@ impl PrivateCallDataValidator { | |
|
||
fn validate_public_call_requests(self) { | ||
let public_inputs = self.data.public_inputs; | ||
|
||
let call_requests = public_inputs.public_call_requests; | ||
let num_requests = self.array_lengths.public_call_requests; | ||
let mut should_check = true; | ||
for i in 0..call_requests.len() { | ||
should_check &= i != num_requests; | ||
if should_check { | ||
validate_call_context(call_requests[i].call_context, public_inputs.call_context); | ||
self.validate_public_call_request(call_requests[i].inner); | ||
} | ||
} | ||
|
||
if !public_inputs.public_teardown_call_request.contract_address.is_zero() { | ||
self.validate_public_call_request(public_inputs.public_teardown_call_request); | ||
} | ||
} | ||
|
||
fn validate_teardown_call_request(self) { | ||
let public_inputs = self.data.public_inputs; | ||
let request = public_inputs.public_teardown_call_request; | ||
if request.counter != 0 { | ||
validate_call_context(request.call_context, public_inputs.call_context); | ||
fn validate_public_call_request(self, call_request: PublicCallRequest) { | ||
let this_context = self.data.public_inputs.call_context; | ||
assert_eq( | ||
call_request.msg_sender, | ||
this_context.contract_address, | ||
"incorrect msg_sender for call request", | ||
); | ||
if !call_request.is_static_call { | ||
assert( | ||
this_context.is_static_call == false, | ||
"static call cannot make non-static calls", | ||
); | ||
} | ||
} | ||
|
||
|
@@ -356,20 +368,7 @@ impl PrivateCallDataValidator { | |
public_inputs.public_call_requests, | ||
self.array_lengths.public_call_requests, | ||
); | ||
|
||
let teardown_call_request_count = if public_inputs.public_teardown_call_request.counter == 0 | ||
{ | ||
0 | ||
} else { | ||
1 | ||
}; | ||
validate_incrementing_counters_within_range( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to check it as teardown_call_request does not have a counter anymore. |
||
counter_start, | ||
counter_end, | ||
[public_inputs.public_teardown_call_request], | ||
teardown_call_request_count, | ||
); | ||
} | ||
} | ||
|
||
fn validate_note_logs<let N: u32>(self, accumulated_note_hashes: [ScopedNoteHash; N]) { | ||
let note_logs = self.data.public_inputs.note_encrypted_logs_hashes; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,10 +85,6 @@ impl PrivateKernelCircuitOutputValidator { | |
private_call.historical_header, | ||
"mismatch historical_header", | ||
); | ||
assert( | ||
is_empty(self.output.constants.global_variables), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this check as a new struct |
||
"constants.global_variables must be empty", | ||
); | ||
assert_eq(self.output.constants.vk_tree_root, vk_tree_root, "mismatch vk_tree_root"); | ||
assert_eq( | ||
self.output.constants.protocol_contract_tree_root, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
use dep::types::{ | ||
abis::{ | ||
accumulated_data::combined_accumulated_data::CombinedAccumulatedData, gas::Gas, | ||
gas_settings::GasSettings, | ||
}, | ||
abis::{accumulated_data::combined_accumulated_data::CombinedAccumulatedData, gas::Gas}, | ||
constants::{ | ||
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, | ||
L2_GAS_PER_NULLIFIER, | ||
}, | ||
utils::arrays::array_length, | ||
}; | ||
|
||
pub fn meter_gas_used(data: CombinedAccumulatedData, gas_settings: GasSettings) -> Gas { | ||
pub fn meter_gas_used(data: CombinedAccumulatedData) -> Gas { | ||
let mut metered_da_bytes = 0; | ||
let mut metered_l2_gas = 0; | ||
|
||
|
@@ -34,6 +31,5 @@ pub fn meter_gas_used(data: CombinedAccumulatedData, gas_settings: GasSettings) | |
metered_da_bytes += data.unencrypted_log_preimages_length as u32; | ||
metered_l2_gas += data.unencrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; | ||
|
||
let teardown_gas = gas_settings.teardown_gas_limits; | ||
Gas::new(metered_da_bytes * DA_GAS_PER_BYTE, metered_l2_gas) + Gas::tx_overhead() + teardown_gas | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't include Before this, the users would have to set it to empty in |
||
Gas::new(metered_da_bytes * DA_GAS_PER_BYTE, metered_l2_gas) + Gas::tx_overhead() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
counter
fromPublicCallRequest
and useCounted
to addcounter
to any struct.Will do the same for other side effects in another PR.