Skip to content

Commit

Permalink
separating call stack items
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 2, 2024
1 parent 66ac432 commit a85e5cc
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 44 deletions.
9 changes: 1 addition & 8 deletions yarn-project/aztec-nr/authwit/src/entrypoint.nr
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use dep::aztec::abi;
use dep::aztec::context::PrivateContext;
use dep::aztec::protocol_types::{
abis::{
call_stack_item::{
PrivateCallStackItem,
PublicCallStackItem,
},
function_selector::FunctionSelector,
},
abis::function_selector::FunctionSelector,
address::AztecAddress,
constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD,
hash::pedersen_hash,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use dep::protocol_types::{
function_data::FunctionData,
function_selector::FunctionSelector,
nullifier_key_validation_request::NullifierKeyValidationRequest,
private_call_stack_item::PrivateCallStackItem,
private_circuit_public_inputs::PrivateCircuitPublicInputs,
public_call_stack_item::PublicCallStackItem,
public_circuit_public_inputs::PublicCircuitPublicInputs,
call_stack_item::PrivateCallStackItem,
call_stack_item::PublicCallStackItem,
side_effect::{SideEffect, SideEffectLinkedToNoteHash},
},
address::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::types::{
abis::{
call_request::CallRequest,
call_stack_item::PublicCallStackItem,
public_call_stack_item::PublicCallStackItem,
combined_accumulated_data::{CombinedAccumulatedData, CombinedAccumulatedDataBuilder},
kernel_circuit_public_inputs::KernelCircuitPublicInputsBuilder,
new_contract_data::NewContractData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ mod kernel_circuit_public_inputs;
mod previous_kernel_data;

mod call_request;
mod call_stack_item;
mod private_call_stack_item;
mod public_call_stack_item;
mod call_context;

mod public_call_data;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::abis::{
function_data::FunctionData,
private_circuit_public_inputs::PrivateCircuitPublicInputs,
};
use crate::address::AztecAddress;
use crate::constants::GENERATOR_INDEX__CALL_STACK_ITEM;
use crate::traits::Hash;

struct PrivateCallStackItem {
// This is the _actual_ contract address relating to where this function's code resides in the
// contract tree. Regardless of whether this is a call or delegatecall, this
// `contract_address` _does not change_. Amongst other things, it's used as a lookup for
// getting the correct code from the tree. There is a separate `storage_contract_address`
// within a CallStackItem which varies depending on whether this is a call or delegatecall.
contract_address: AztecAddress,
public_inputs: PrivateCircuitPublicInputs,
function_data: FunctionData,
// Not really needed for PrivateCallStackItem.
is_execution_request: bool,
}

impl Hash for PrivateCallStackItem {
fn hash(self) -> Field {
dep::std::hash::pedersen_hash_with_separator([
self.contract_address.to_field(),
self.function_data.hash(),
self.public_inputs.hash(),
], GENERATOR_INDEX__CALL_STACK_ITEM)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::abis::{
call_request::CallRequest,
call_stack_item::PrivateCallStackItem,
private_call_stack_item::PrivateCallStackItem,
membership_witness::{
ContractLeafMembershipWitness,
FunctionLeafMembershipWitness,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
abis::{
call_request::CallRequest,
call_stack_item::PublicCallStackItem,
public_call_stack_item::PublicCallStackItem,
},
address::EthAddress,
mocked::Proof,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
use crate::abis::{
function_data::FunctionData,
private_circuit_public_inputs::PrivateCircuitPublicInputs,
public_circuit_public_inputs::PublicCircuitPublicInputs,
};
use crate::address::AztecAddress;
use crate::constants::{
GENERATOR_INDEX__CALL_STACK_ITEM,
};
use crate::constants::GENERATOR_INDEX__CALL_STACK_ITEM;
use crate::traits::Hash;

struct PrivateCallStackItem {
// This is the _actual_ contract address relating to where this function's code resides in the
// contract tree. Regardless of whether this is a call or delegatecall, this
// `contract_address` _does not change_. Amongst other things, it's used as a lookup for
// getting the correct code from the tree. There is a separate `storage_contract_address`
// within a CallStackItem which varies depending on whether this is a call or delegatecall.
contract_address: AztecAddress,
public_inputs: PrivateCircuitPublicInputs,
function_data: FunctionData,
// Not really needed for PrivateCallStackItem.
is_execution_request: bool,
}

impl Hash for PrivateCallStackItem {
fn hash(self) -> Field {
dep::std::hash::pedersen_hash_with_separator([
self.contract_address.to_field(),
self.function_data.hash(),
self.public_inputs.hash(),
], GENERATOR_INDEX__CALL_STACK_ITEM)
}
}

struct PublicCallStackItem {
contract_address: AztecAddress,
public_inputs: PublicCircuitPublicInputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::abis::function_leaf_preimage::FunctionLeafPreimage;
use crate::contrakt::deployment_data::ContractDeploymentData;
use crate::abis::function_selector::FunctionSelector;
use crate::hash::{compute_l2_to_l1_hash, sha256_to_field};
use crate::abis::call_stack_item::PublicCallStackItem;
use crate::abis::public_call_stack_item::PublicCallStackItem;
use crate::abis::public_circuit_public_inputs::PublicCircuitPublicInputs;
use crate::abis::side_effect::SideEffect;
use crate::contract_class::ContractClassId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
abis::{
call_request::{CallerContext, CallRequest},
call_stack_item::PrivateCallStackItem,
private_call_stack_item::PrivateCallStackItem,
function_data::FunctionData,
membership_witness::{
ContractLeafMembershipWitness,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::{
abis::{
call_context::CallContext,
call_request::{CallerContext, CallRequest},
call_stack_item::PublicCallStackItem,
function_data::FunctionData,
public_call_data::PublicCallData,
public_call_stack_item::PublicCallStackItem,
public_circuit_public_inputs::PublicCircuitPublicInputs,
},
address::{AztecAddress, EthAddress},
Expand Down

0 comments on commit a85e5cc

Please sign in to comment.