Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
9 changes: 7 additions & 2 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ library Constants {
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 Expand Up @@ -76,12 +79,14 @@ library Constants {
uint256 internal constant HEADER_LENGTH = 18;
uint256 internal constant FUNCTION_DATA_LENGTH = 4;
uint256 internal constant CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 204;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 205;
uint256 internal constant CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
uint256 internal constant CONTRACT_STORAGE_READ_LENGTH = 2;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 201;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;
uint256 internal constant CALL_PRIVATE_FUNCTION_RETURN_SIZE = 210;
uint256 internal constant CALL_PRIVATE_FUNCTION_RETURN_SIZE = 211;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 98;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 189;
uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
uint256 internal constant PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ export class ClientExecutionContext extends ViewDataOracle {
* @param targetContractAddress - The address of the contract to call.
* @param functionSelector - The function selector of the function to call.
* @param argsHash - The packed arguments to pass to the function.
* @param sideffectCounter - The side effect counter at the start of the call.
* @param sideEffectCounter - The side effect counter at the start of the call.
* @returns The execution result.
*/
async callPrivateFunction(
targetContractAddress: AztecAddress,
functionSelector: FunctionSelector,
argsHash: Fr,
sideffectCounter: number,
sideEffectCounter: number,
) {
this.log(
`Calling private function ${this.contractAddress}:${functionSelector} from ${this.callContext.storageContractAddress}`,
Expand All @@ -327,7 +327,7 @@ export class ClientExecutionContext extends ViewDataOracle {
const derivedCallContext = await this.deriveCallContext(
targetContractAddress,
targetArtifact,
sideffectCounter,
sideEffectCounter,
false,
false,
);
Expand Down
46 changes: 25 additions & 21 deletions yarn-project/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct PrivateContext {
inputs: PrivateContextInputs,
side_effect_counter: u32,

meta_hwm: u32,

args_hash : Field,
return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,

Expand Down Expand Up @@ -101,6 +103,7 @@ impl PrivateContext {
PrivateContext {
inputs: inputs,
side_effect_counter: inputs.call_context.start_side_effect_counter,
meta_hwm: 0,

args_hash: args_hash,
return_values: BoundedVec::new(0),
Expand Down Expand Up @@ -172,6 +175,7 @@ impl PrivateContext {
call_context: self.inputs.call_context,
args_hash: self.args_hash,
return_values: self.return_values.storage,
meta_hwm: self.meta_hwm,
read_requests: self.read_requests.storage,
nullifier_key_validation_requests: self.nullifier_key_validation_requests.storage,
new_commitments: self.new_commitments.storage,
Expand Down Expand Up @@ -239,7 +243,7 @@ impl PrivateContext {
}

// docs:start:context_message_portal
pub fn message_portal(&mut self, content: Field)
pub fn message_portal(&mut self, content: Field)
// docs:end:context_message_portal
{
self.new_l2_to_l1_msgs.push(content);
Expand All @@ -254,7 +258,7 @@ impl PrivateContext {
msg_key: Field,
content: Field,
secret: Field
)
)
// docs:end:context_consume_l1_to_l2_message
{
let nullifier = process_l1_to_l2_message(self.historical_header.state.l1_to_l2_message_tree.root, self.this_address(), self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret);
Expand All @@ -278,8 +282,8 @@ impl PrivateContext {

pub fn call_private_function<ARGS_COUNT>(
&mut self,
contract_address: AztecAddress,
function_selector: FunctionSelector,
contract_address: AztecAddress,
function_selector: FunctionSelector,
args: [Field; ARGS_COUNT]
) -> [Field; RETURN_VALUES_LENGTH] {
let args_hash = hash_args(args);
Expand All @@ -289,8 +293,8 @@ impl PrivateContext {

pub fn call_private_function_no_args(
&mut self,
contract_address: AztecAddress,
function_selector: FunctionSelector,
contract_address: AztecAddress,
function_selector: FunctionSelector,
) -> [Field; RETURN_VALUES_LENGTH] {
self.call_private_function_with_packed_args(contract_address, function_selector, 0)
}
Expand All @@ -303,7 +307,7 @@ impl PrivateContext {
) -> [Field; RETURN_VALUES_LENGTH] {
let fields = call_private_function_internal(
contract_address,
function_selector,
function_selector,
args_hash,
self.side_effect_counter,
);
Expand All @@ -320,7 +324,7 @@ impl PrivateContext {

assert_eq(item.public_inputs.call_context.start_side_effect_counter, self.side_effect_counter);
self.side_effect_counter = item.public_inputs.end_side_effect_counter + 1;

assert(contract_address.eq(item.contract_address));
assert(function_selector.eq(item.function_data.selector));

Expand All @@ -345,8 +349,8 @@ impl PrivateContext {

pub fn call_public_function<ARGS_COUNT>(
&mut self,
contract_address: AztecAddress,
function_selector: FunctionSelector,
contract_address: AztecAddress,
function_selector: FunctionSelector,
args: [Field; ARGS_COUNT]
) {
let args_hash = hash_args(args);
Expand All @@ -356,7 +360,7 @@ impl PrivateContext {

pub fn call_public_function_no_args(
&mut self,
contract_address: AztecAddress,
contract_address: AztecAddress,
function_selector: FunctionSelector,
) {
self.call_public_function_with_packed_args(contract_address, function_selector, 0)
Expand All @@ -369,8 +373,8 @@ impl PrivateContext {
args_hash: Field
) {
let fields = enqueue_public_function_call_internal(
contract_address,
function_selector,
contract_address,
function_selector,
args_hash,
self.side_effect_counter
);
Expand Down Expand Up @@ -407,7 +411,7 @@ impl PrivateContext {
assert_eq(item.public_inputs.call_context.start_side_effect_counter, self.side_effect_counter);
// We increment the sideffect counter by one, to account for the call itself being a side effect.
self.side_effect_counter = self.side_effect_counter + 1;

assert(args_hash == item.public_inputs.args_hash);

// Assert that the call context of the enqueued call generated by the oracle matches our request.
Expand Down Expand Up @@ -469,7 +473,7 @@ impl PublicContext {

new_l2_to_l1_msgs: BoundedVec::new(0),


unencrypted_logs_hash: BoundedVec::new(0),
unencrypted_logs_preimages_length: 0,

Expand Down Expand Up @@ -586,27 +590,27 @@ impl PublicContext {

pub fn call_public_function<ARGS_COUNT>(
_self: Self,
contract_address: AztecAddress,
contract_address: AztecAddress,
function_selector: FunctionSelector,
args: [Field; ARGS_COUNT],
) -> [Field; RETURN_VALUES_LENGTH] {
let args_hash = hash_args(args);
assert(args_hash == arguments::pack_arguments(args));
call_public_function_internal(
contract_address,
function_selector,
contract_address,
function_selector,
args_hash,
)
}

pub fn call_public_function_no_args(
_self: Self,
contract_address: AztecAddress,
contract_address: AztecAddress,
function_selector: FunctionSelector,
) -> [Field; RETURN_VALUES_LENGTH] {
call_public_function_internal(
contract_address,
function_selector,
contract_address,
function_selector,
0,
)
}
Expand Down
64 changes: 32 additions & 32 deletions yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,41 @@ exports[`abis Computes an empty sideeffect hash 1`] = `"0x27b1d0839a5b23baf12a8

exports[`abis compute private call stack item hash 1`] = `
Fr {
"asBigInt": 20809484660315254497535468009354600907499263083154533860853878665971818104219n,
"asBigInt": 1058108273519211057958983017403656079426177248613466485863012056136969809881n,
"asBuffer": {
"data": [
46,
1,
192,
60,
242,
95,
113,
243,
178,
218,
79,
199,
55,
206,
59,
194,
234,
24,
158,
215,
200,
157,
95,
167,
67,
42,
204,
172,
237,
2,
86,
222,
57,
41,
140,
244,
156,
248,
127,
77,
151,
136,
165,
186,
107,
37,
5,
155,
17,
119,
4,
83,
102,
195,
226,
180,
18,
253,
220,
202,
174,
239,
217,
],
"type": "Buffer",
},
Expand Down
9 changes: 7 additions & 2 deletions yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const MAX_READ_REQUESTS_PER_TX = 128;
export const MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX = 4;
export const NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1;
export const NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1;
export const MAX_NEW_COMMITMENTS_PER_TX_META = 8;
export const MAX_NEW_NULLIFIERS_PER_TX_META = 8;
export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX_META = 2;
export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
export const VK_TREE_HEIGHT = 3;
export const FUNCTION_TREE_HEIGHT = 5;
Expand Down Expand Up @@ -62,12 +65,14 @@ export const STATE_REFERENCE_LENGTH = 10;
export const HEADER_LENGTH = 18;
export const FUNCTION_DATA_LENGTH = 4;
export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 204;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 205;
export const CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
export const CONTRACT_STORAGE_READ_LENGTH = 2;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 201;
export const GET_NOTES_ORACLE_RETURN_LENGTH = 674;
export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 210;
export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 211;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 98;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 189;
export const COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
export const PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

exports[`PrivateCallStackItem computes hash 1`] = `
Fr {
"asBigInt": 18753511695134949302571620808052147141303876532454748772518515365970855750244n,
"asBigInt": 9863016068749090736597089217395332987261861243138085912865970371247004412709n,
"asBuffer": {
"data": [
41,
118,
28,
137,
21,
206,
68,
13,
118,
183,
92,
239,
238,
170,
83,
16,
215,
198,
142,
84,
234,
235,
13,
55,
245,
66,
184,
218,
252,
190,
14,
252,
58,
237,
34,
161,
161,
6,
106,
100,
109,
208,
170,
255,
213,
239,
82,
127,
177,
202,
57,
71,
80,
176,
101,
103,
69,
251,
253,
215,
107,
37,
],
"type": "Buffer",
},
Expand Down
Loading