Skip to content
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: add meta_hwm to PrivateCircuitPublicInputs #4341

Merged
merged 14 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 4 additions & 2 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,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
5 changes: 5 additions & 0 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 @@ -330,6 +334,7 @@ impl PrivateContext {
},
args_hash: reader.read(),
return_values: reader.read_array([0; RETURN_VALUES_LENGTH]), // +1
meta_hwm: reader.read() as u32,
read_requests: reader.read_struct_array(SideEffect::deserialize, [SideEffect::empty(); MAX_READ_REQUESTS_PER_CALL]),
nullifier_key_validation_requests: reader.read_struct_array(NullifierKeyValidationRequest::deserialize, [NullifierKeyValidationRequest::empty(); MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL]),
new_commitments: reader.read_struct_array(SideEffect::deserialize, [SideEffect::empty(); MAX_NEW_COMMITMENTS_PER_CALL]),
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
6 changes: 4 additions & 2 deletions yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,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
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `
Fr {
"asBigInt": 7655509707748365385586683354008259293573299722789964529445054772581519738939n,
"asBigInt": 17965057432304162663609649222224826000756674060660466974194339783441351638025n,
"asBuffer": {
"data": [
16,
236,
221,
108,
242,
63,
20,
45,
47,
147,
239,
244,
141,
4,
39,
183,
220,
183,
64,
232,
229,
199,
125,
34,
72,
231,
214,
40,
82,
141,
21,
179,
158,
65,
218,
247,
23,
13,
105,
121,
159,
29,
162,
114,
51,
52,
186,
54,
94,
72,
59,
196,
233,
228,
61,
55,
62,
71,
106,
218,
252,
9,
],
"type": "Buffer",
},
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/structs/call_context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FunctionSelector } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
import { FieldsOf } from '@aztec/foundation/types';

import { Fr, FunctionSelector } from './index.js';

/**
* Call context.
* @see abis/call_context.hpp
Expand Down
Loading
Loading