Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 5, 2024
1 parent 26f1471 commit d3bead9
Show file tree
Hide file tree
Showing 22 changed files with 368 additions and 292 deletions.
8 changes: 4 additions & 4 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ library Constants {
uint256 internal constant GLOBAL_VARIABLES_LENGTH = 6;
uint256 internal constant PARTIAL_STATE_REFERENCE_LENGTH = 8;
uint256 internal constant STATE_REFERENCE_LENGTH = 10;
uint256 internal constant HEADER_LENGTH = 18;
uint256 internal constant HEADER_LENGTH = 20;
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_CALL_STACK_ITEM_LENGTH = 209;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 206;
uint256 internal constant PRIVATE_CALL_STACK_ITEM_LENGTH = 211;
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 PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 203;
uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674;
uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
Expand Down
18 changes: 16 additions & 2 deletions yarn-project/acir-simulator/src/public/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,14 @@ describe('ACIR public execution simulator', () => {
});

const execution: PublicExecution = { contractAddress: parentContractAddress, functionData, args, callContext };
const globalVariables = new GlobalVariables(new Fr(69), new Fr(420), new Fr(1), new Fr(7));
const globalVariables = new GlobalVariables(
new Fr(69),
new Fr(420),
new Fr(1),
new Fr(7),
EthAddress.fromField(new Fr(8)),
AztecAddress.fromField(new Fr(9)),
);

if (isInternal === undefined) {
await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError(/Method not found -/);
Expand Down Expand Up @@ -449,7 +456,14 @@ describe('ACIR public execution simulator', () => {
});

const computeGlobalVariables = () =>
new GlobalVariables(new Fr(preimage.sender.chainId), new Fr(preimage.recipient.version), Fr.ZERO, Fr.ZERO);
new GlobalVariables(
new Fr(preimage.sender.chainId),
new Fr(preimage.recipient.version),
Fr.ZERO,
Fr.ZERO,
EthAddress.ZERO,
AztecAddress.ZERO,
);

const mockOracles = () => {
publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64'));
Expand Down
11 changes: 10 additions & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import {
ARCHIVE_HEIGHT,
CONTRACT_TREE_HEIGHT,
EthAddress,
Fr,
Header,
L1_TO_L2_MSG_TREE_HEIGHT,
Expand Down Expand Up @@ -550,7 +551,15 @@ export class AztecNodeService implements AztecNode {
public async simulatePublicCalls(tx: Tx) {
this.log.info(`Simulating tx ${await tx.getTxHash()}`);
const blockNumber = (await this.blockSource.getBlockNumber()) + 1;
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(new Fr(blockNumber));

// TODO(benesjan): populate these values from config.
const coinbase = EthAddress.ZERO;
const feeRecipient = AztecAddress.ZERO;
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
new Fr(blockNumber),
coinbase,
feeRecipient,
);
const prevHeader = (await this.blockSource.getBlock(-1))?.header;

// Instantiate merkle trees so uncommitted updates by this simulation are local to it.
Expand Down
66 changes: 33 additions & 33 deletions yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`abis Computes a callstack item hash 1`] = `"0x037cb5ba672a7c461e23cf22ae618757ab4f1a912f3fdc93b2b2800cfe57bb91"`;
exports[`abis Computes a callstack item hash 1`] = `"0x17095bbb9e3e104dc520b6eec9338e9b6ce1fdc0f3a66b06d5ca90b15909ad0e"`;

exports[`abis Computes a callstack item request hash 1`] = `"0x2c36008a759d932a3a1986429aa295e2c2d4e62c33197a7d259750d29347bf30"`;
exports[`abis Computes a callstack item request hash 1`] = `"0x28cb4c264eb11e13c77a5e60b251a6b3edfb4cfed786c4f1ec5e1749fede9b78"`;

exports[`abis Computes an empty nullifier hash 1`] = `"0x066e6cdc4a6ba5e4781deda650b0be6c12f975f064fc38df72c1060716759b17"`;

exports[`abis Computes an empty sideeffect hash 1`] = `"0x27b1d0839a5b23baf12a8d195b18ac288fcf401afb2f70b8a4b529ede5fa9fed"`;

exports[`abis compute public call stack item hash 1`] = `
Fr {
"asBigInt": 4942803204430729321299247114280769628204291639882373728884145897482860239103n,
"asBigInt": 6902726350534637945034037933577508446422215007904358955522461123516426791152n,
"asBuffer": {
"data": [
10,
237,
135,
8,
121,
161,
111,
170,
23,
173,
20,
73,
240,
78,
59,
30,
113,
136,
151,
15,
66,
205,
254,
91,
241,
101,
117,
250,
42,
35,
186,
162,
159,
250,
242,
152,
210,
214,
154,
136,
128,
223,
11,
120,
249,
245,
174,
102,
132,
69,
153,
88,
179,
36,
144,
98,
110,
24,
255,
250,
168,
240,
],
"type": "Buffer",
},
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export const CALL_CONTEXT_LENGTH = 8;
export const GLOBAL_VARIABLES_LENGTH = 6;
export const PARTIAL_STATE_REFERENCE_LENGTH = 8;
export const STATE_REFERENCE_LENGTH = 10;
export const HEADER_LENGTH = 18;
export const HEADER_LENGTH = 20;
export const FUNCTION_DATA_LENGTH = 4;
export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 204;
export const PRIVATE_CALL_STACK_ITEM_LENGTH = 209;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 206;
export const PRIVATE_CALL_STACK_ITEM_LENGTH = 211;
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 PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 203;
export const GET_NOTES_ORACLE_RETURN_LENGTH = 674;
export const COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

exports[`Header computes hash 1`] = `
Fr {
"asBigInt": 17991638921121681345555824161757346486368776085978982802127357651656088857262n,
"asBigInt": 17535834694933389587922737272908689289752880632518238306089028120587248314683n,
"asBuffer": {
"data": [
39,
198,
232,
33,
120,
194,
121,
42,
23,
66,
111,
251,
166,
131,
251,
128,
16,
46,
122,
209,
193,
24,
177,
38,
196,
238,
67,
172,
91,
198,
153,
236,
93,
20,
47,
99,
167,
32,
178,
243,
109,
29,
247,
170,
174,
104,
85,
155,
139,
190,
13,
63,
35,
158,
188,
79,
120,
214,
216,
211,
169,
59,
],
"type": "Buffer",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

exports[`PrivateCallStackItem computes empty item hash 1`] = `
Fr {
"asBigInt": 21230813221792739829032218511346459661622392006403997687170807299887246304465n,
"asBigInt": 11439500418935448938812546834954776447064444607864398684460320872436560621982n,
"asBuffer": {
"data": [
25,
74,
135,
29,
37,
166,
46,
240,
54,
249,
105,
229,
221,
27,
22,
205,
116,
188,
205,
128,
113,
43,
99,
253,
225,
42,
162,
230,
75,
8,
243,
160,
150,
65,
149,
200,
179,
79,
100,
209,
215,
206,
201,
62,
133,
18,
199,
148,
18,
180,
37,
240,
5,
122,
38,
213,
39,
140,
152,
152,
241,
158,
],
"type": "Buffer",
},
Expand All @@ -45,41 +45,41 @@ Fr {

exports[`PrivateCallStackItem computes hash 1`] = `
Fr {
"asBigInt": 14723811775539034985226914197401344473208275906441619992416957589322673569693n,
"asBigInt": 17854733235616142992562943781448885630816268824088546745305752514531058544044n,
"asBuffer": {
"data": [
32,
141,
97,
211,
254,
114,
95,
205,
151,
179,
64,
109,
39,
121,
107,
191,
93,
67,
27,
97,
134,
246,
58,
60,
32,
239,
10,
45,
51,
244,
117,
162,
13,
12,
74,
168,
124,
233,
127,
77,
252,
30,
126,
12,
59,
146,
221,
124,
42,
63,
157,
179,
89,
72,
47,
17,
15,
212,
109,
172,
],
"type": "Buffer",
},
Expand Down
Loading

0 comments on commit d3bead9

Please sign in to comment.