Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class AvmExecutionTests : public ::testing::Test {
PublicCallRequest dummy_request = {
/* msg_sender */ FF::one(),
/* contract_address */ 0xdeadbeef,
/* function_selector */ 3,
/* is_static_call */ true,
/* args_hash */ FF(12),
/* calldata_hash */ FF(12),
};
public_inputs.public_app_logic_call_requests[0] = dummy_request;
};
Expand Down
11 changes: 3 additions & 8 deletions barretenberg/cpp/src/barretenberg/vm/avm/trace/public_inputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,14 @@ struct PublicCallRequest {
* The contract address being called.
*/
FF contract_address{};
/**
* Function selector of the function being called.
*/
uint32_t function_selector = 0;
/**
* Determines whether the call is modifying state.
*/
bool is_static_call = false;
FF args_hash{};
FF calldata_hash{};
inline bool is_empty() const
{
return msg_sender == 0 && contract_address == 0 && function_selector == 0 && !is_static_call && args_hash == 0;
return msg_sender == 0 && contract_address == 0 && !is_static_call && calldata_hash == 0;
}
};

Expand All @@ -170,9 +166,8 @@ inline void read(uint8_t const*& it, PublicCallRequest& public_call_request)
using serialize::read;
read(it, public_call_request.msg_sender);
read(it, public_call_request.contract_address);
read(it, public_call_request.function_selector);
read(it, public_call_request.is_static_call);
read(it, public_call_request.args_hash);
read(it, public_call_request.calldata_hash);
}

struct PrivateToAvmAccumulatedDataArrayLengths {
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define TOTAL_FEES_LENGTH 1
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 908
#define AVM_ACCUMULATED_DATA_LENGTH 400
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1091
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1026
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
#define MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS 21
#define AVM_PROOF_LENGTH_IN_FIELDS 4154
Expand Down
Binary file not shown.
16 changes: 8 additions & 8 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ library Constants {
uint256 internal constant MAX_FIELD_VALUE =
21888242871839275222246405745257275088548364400416034343698204186575808495616;
uint256 internal constant ARGS_LENGTH = 16;
uint256 internal constant MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS = 16000;
uint256 internal constant MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS = 16000;
uint256 internal constant MAX_NOTE_HASHES_PER_CALL = 16;
uint256 internal constant MAX_NULLIFIERS_PER_CALL = 16;
uint256 internal constant MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 5;
Expand Down Expand Up @@ -184,8 +184,8 @@ library Constants {
uint256 internal constant PUBLIC_DATA_WRITE_LENGTH = 2;
uint256 internal constant PUBLIC_CALL_STACK_ITEM_COMPRESSED_LENGTH = 12;
uint256 internal constant PRIVATE_CALL_REQUEST_LENGTH = 8;
uint256 internal constant PUBLIC_CALL_REQUEST_LENGTH = 5;
uint256 internal constant COUNTED_PUBLIC_CALL_REQUEST_LENGTH = 6;
uint256 internal constant PUBLIC_CALL_REQUEST_LENGTH = 4;
uint256 internal constant COUNTED_PUBLIC_CALL_REQUEST_LENGTH = 5;
uint256 internal constant PUBLIC_INNER_CALL_REQUEST_LENGTH = 13;
uint256 internal constant ROLLUP_VALIDATION_REQUESTS_LENGTH = 2;
uint256 internal constant STATE_REFERENCE_LENGTH = 8;
Expand All @@ -196,7 +196,7 @@ library Constants {
uint256 internal constant TOTAL_MANA_USED_LENGTH = 1;
uint256 internal constant BLOCK_HEADER_LENGTH = 25;
uint256 internal constant BLOCK_HEADER_LENGTH_BYTES = 648;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 741;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 724;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 908;
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 40;
uint256 internal constant FEE_RECIPIENT_LENGTH = 2;
Expand All @@ -208,12 +208,12 @@ library Constants {
uint256 internal constant PRIVATE_TO_ROLLUP_ACCUMULATED_DATA_LENGTH = 740;
uint256 internal constant TX_CONSTANT_DATA_LENGTH = 37;
uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 46;
uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1412;
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2230;
uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 900;
uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1380;
uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2197;
uint256 internal constant PRIVATE_TO_PUBLIC_ACCUMULATED_DATA_LENGTH = 868;
uint256 internal constant PRIVATE_TO_AVM_ACCUMULATED_DATA_LENGTH = 160;
uint256 internal constant NUM_PRIVATE_TO_AVM_ACCUMULATED_DATA_ARRAYS = 3;
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1847;
uint256 internal constant PRIVATE_TO_PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1782;
uint256 internal constant PRIVATE_TO_ROLLUP_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 782;
uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 13;
uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 52;
Expand Down
3 changes: 1 addition & 2 deletions noir-projects/aztec-nr/authwit/src/entrypoint/app.nr
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ impl AppPayload {
for call in self.function_calls {
if !call.target_address.is_zero() {
if call.is_public {
context.call_public_function_with_args_hash(
context.call_public_function_with_calldata_hash(
call.target_address,
call.function_selector,
call.args_hash,
call.is_static,
);
Expand Down
3 changes: 1 addition & 2 deletions noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ impl FeePayload {
for call in self.function_calls {
if !call.target_address.is_zero() {
if call.is_public {
context.call_public_function_with_args_hash(
context.call_public_function_with_calldata_hash(
call.target_address,
call.function_selector,
call.args_hash,
call.is_static,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ global FUNCTION_CALL_SIZE_IN_BYTES: u32 = 98;

#[derive(Serialize)]
pub struct FunctionCall {
pub args_hash: Field,
pub args_hash: Field, /* args_hash is calldata_hash if is_public is true */
pub function_selector: FunctionSelector,
pub target_address: AztecAddress,
pub is_public: bool,
Expand Down
88 changes: 45 additions & 43 deletions noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use dep::protocol_types::{
abis::function_selector::FunctionSelector, address::AztecAddress, traits::Deserialize,
abis::function_selector::FunctionSelector,
address::AztecAddress,
traits::{Deserialize, ToField},
};

use crate::context::{gas::GasOpts, private_context::PrivateContext, public_context::PublicContext};

use crate::hash::hash_args;
use crate::hash::{hash_args, hash_calldata};
use crate::oracle::execution_cache;

pub trait CallInterface<let N: u32> {
Expand Down Expand Up @@ -51,7 +53,7 @@ impl<let N: u32, T> PrivateCallInterface<N, T> {
where
T: Deserialize<M>,
{
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
let returns_hash = context.call_private_function_with_args_hash(
self.target_contract,
self.selector,
Expand All @@ -66,7 +68,7 @@ impl<let N: u32, T> PrivateCallInterface<N, T> {
where
T: Deserialize<M>,
{
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
let returns_hash = context.call_private_function_with_args_hash(
self.target_contract,
self.selector,
Expand Down Expand Up @@ -124,7 +126,7 @@ impl<let N: u32> PrivateVoidCallInterface<N> {
}

pub fn call(self, context: &mut PrivateContext) {
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
context
.call_private_function_with_args_hash(
self.target_contract,
Expand All @@ -136,7 +138,7 @@ impl<let N: u32> PrivateVoidCallInterface<N> {
}

pub fn view(self, context: &mut PrivateContext) {
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
context
.call_private_function_with_args_hash(
self.target_contract,
Expand Down Expand Up @@ -205,7 +207,7 @@ impl<let N: u32, T> PrivateStaticCallInterface<N, T> {
where
T: Deserialize<M>,
{
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
let returns = context.call_private_function_with_args_hash(
self.target_contract,
self.selector,
Expand Down Expand Up @@ -262,7 +264,7 @@ impl<let N: u32> PrivateStaticVoidCallInterface<N> {
}

pub fn view(self, context: &mut PrivateContext) {
execution_cache::store(self.args);
execution_cache::store(self.args, self.args_hash);
context
.call_private_function_with_args_hash(
self.target_contract,
Expand Down Expand Up @@ -359,24 +361,24 @@ impl<let N: u32, T> PublicCallInterface<N, T> {
}

pub fn enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
false,
)
}

pub fn enqueue_view(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
true,
)
Expand Down Expand Up @@ -462,36 +464,36 @@ impl<let N: u32> PublicVoidCallInterface<N> {
}

pub fn enqueue(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
false,
)
}

pub fn enqueue_view(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
true,
)
}

pub fn set_as_teardown(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.set_public_teardown_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.set_public_teardown_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
false,
)
}
Expand Down Expand Up @@ -568,12 +570,12 @@ impl<let N: u32, T> PublicStaticCallInterface<N, T> {
}

pub fn enqueue_view(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
true,
)
Expand Down Expand Up @@ -648,12 +650,12 @@ impl<let N: u32> PublicStaticVoidCallInterface<N> {
}

pub fn enqueue_view(self, context: &mut PrivateContext) {
let args_hash = hash_args(self.args);
execution_cache::store(self.args);
context.call_public_function_with_args_hash(
let calldata = self.args.push_front(self.selector.to_field());
let calldata_hash = hash_calldata(calldata);
execution_cache::store(calldata, calldata_hash);
context.call_public_function_with_calldata_hash(
self.target_contract,
self.selector,
args_hash,
calldata_hash,
/*static=*/
true,
)
Expand Down
Loading