-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathcontext.nr
619 lines (523 loc) · 23.8 KB
/
context.nr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
use crate::constants_gen::{
EMPTY_NULLIFIED_COMMITMENT,
MAX_NEW_COMMITMENTS_PER_CALL,
MAX_NEW_L2_TO_L1_MSGS_PER_CALL,
MAX_NEW_NULLIFIERS_PER_CALL,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
MAX_PUBLIC_DATA_READS_PER_CALL,
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
MAX_READ_REQUESTS_PER_CALL,
MAX_PENDING_READ_REQUESTS_PER_CALL,
NUM_FIELDS_PER_SHA256,
RETURN_VALUES_LENGTH,
};
use crate::abi;
use crate::abi::{
hash_args,
CallContext,
ContractDeploymentData,
HistoricBlockData,
FunctionData,
PrivateCircuitPublicInputs,
PublicCircuitPublicInputs,
};
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
// use dep::std::collections::vec::Vec;
// l1 to l2 messaging
use crate::messaging::process_l1_to_l2_message;
use crate::private_call_stack_item::PrivateCallStackItem;
use crate::public_call_stack_item::PublicCallStackItem;
use crate::types::{
vec::BoundedVec,
point::Point,
};
use crate::utils::arr_copy_slice;
use crate::oracle::{
arguments,
call_private_function::call_private_function_internal,
public_call::call_public_function_internal,
enqueue_public_function_call::enqueue_public_function_call_internal,
context::get_portal_address,
};
use dep::std::option::Option;
// When finished, one can call .finish() to convert back to the abi
struct PrivateContext {
// docs:start:private-context
inputs: abi::PrivateContextInputs,
args_hash : Field,
return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,
read_requests: BoundedVec<Field, MAX_READ_REQUESTS_PER_CALL>,
pending_read_requests: BoundedVec<Field, MAX_PENDING_READ_REQUESTS_PER_CALL>,
new_commitments: BoundedVec<Field, MAX_NEW_COMMITMENTS_PER_CALL>,
new_nullifiers: BoundedVec<Field, MAX_NEW_NULLIFIERS_PER_CALL>,
nullified_commitments: BoundedVec<Field, MAX_NEW_NULLIFIERS_PER_CALL>,
private_call_stack : BoundedVec<Field, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,
public_call_stack : BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
new_l2_to_l1_msgs : BoundedVec<Field, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
// docs:end:private-context
block_data: HistoricBlockData,
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
// encrypted_logs_preimages: Vec<Field>,
// unencrypted_logs_preimages: Vec<Field>,
}
impl PrivateContext {
pub fn new(inputs: abi::PrivateContextInputs, args_hash: Field) -> PrivateContext {
PrivateContext {
inputs: inputs,
args_hash: args_hash,
return_values: BoundedVec::new(0),
read_requests: BoundedVec::new(0),
pending_read_requests: BoundedVec::new(0),
new_commitments: BoundedVec::new(0),
new_nullifiers: BoundedVec::new(0),
nullified_commitments: BoundedVec::new(0),
block_data: inputs.block_data,
private_call_stack: BoundedVec::new(0),
public_call_stack: BoundedVec::new(0),
new_l2_to_l1_msgs: BoundedVec::new(0),
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
// encrypted_logs_preimages: Vec::new(),
// unencrypted_logs_preimages: Vec::new(),
}
}
pub fn msg_sender(self) -> Field {
self.inputs.call_context.msg_sender
}
pub fn this_address(self) -> Field {
self.inputs.call_context.storage_contract_address
}
pub fn this_portal_address(self) -> Field {
self.inputs.call_context.portal_contract_address
}
pub fn chain_id(self) -> Field {
self.inputs.private_global_variables.chain_id
}
pub fn version(self) -> Field {
self.inputs.private_global_variables.version
}
pub fn selector(self) -> Field {
self.inputs.call_context.function_selector
}
pub fn finish(self) -> abi::PrivateCircuitPublicInputs {
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
let encrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];
let unencrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];
let encrypted_log_preimages_length = 0;
let unencrypted_log_preimages_length = 0;
let priv_circuit_pub_inputs = abi::PrivateCircuitPublicInputs {
call_context: self.inputs.call_context,
args_hash: self.args_hash,
return_values: self.return_values.storage,
read_requests: self.read_requests.storage,
pending_read_requests: self.pending_read_requests.storage,
new_commitments: self.new_commitments.storage,
new_nullifiers: self.new_nullifiers.storage,
nullified_commitments: self.nullified_commitments.storage,
private_call_stack: self.private_call_stack.storage,
public_call_stack: self.public_call_stack.storage,
new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage,
encrypted_logs_hash: encrypted_logs_hash,
unencrypted_logs_hash: unencrypted_logs_hash,
encrypted_log_preimages_length: encrypted_log_preimages_length,
unencrypted_log_preimages_length: unencrypted_log_preimages_length,
block_data: self.block_data,
contract_deployment_data: self.inputs.contract_deployment_data,
chain_id: self.inputs.private_global_variables.chain_id,
version: self.inputs.private_global_variables.version,
};
priv_circuit_pub_inputs
}
pub fn push_read_request(&mut self, read_request: Field) {
self.read_requests.push(read_request);
}
pub fn push_pending_read_request(&mut self, pending_read_request: Field) {
self.pending_read_requests.push(pending_read_request);
}
pub fn push_new_note_hash(&mut self, note_hash: Field) {
self.new_commitments.push(note_hash);
}
// We never push a zero nullified_commitment as zero is used to indicate the end
// of a field array in private kernel. This routine transparently replaces a
// zero value into the special placeholder: EMPTY_NULLIFIED_COMMITMENT.
pub fn push_new_nullifier(&mut self, nullifier: Field, nullified_commitment: Field) {
self.new_nullifiers.push(nullifier);
let mut non_zero_nullified = nullified_commitment;
if (non_zero_nullified == 0) {
non_zero_nullified = EMPTY_NULLIFIED_COMMITMENT;
}
self.nullified_commitments.push(non_zero_nullified);
}
// docs:start:context_message_portal
pub fn message_portal(&mut self, content: Field)
// docs:end:context_message_portal
{
self.new_l2_to_l1_msgs.push(content);
}
// PrivateContextInputs must be temporarily passed in to prevent too many unknowns
// Note this returns self to get around an issue where mutable structs do not maintain mutations unless reassigned
// docs:start:context_consume_l1_to_l2_message
// docs:start:consume_l1_to_l2_message
pub fn consume_l1_to_l2_message(
&mut self,
msg_key: Field,
content: Field,
secret: Field
)
// docs:end:context_consume_l1_to_l2_message
{
let nullifier = process_l1_to_l2_message(self.block_data.l1_to_l2_messages_tree_root, self.this_address(), self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret);
// Push nullifier (and the "commitment" corresponding to this can be "empty")
self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT)
}
// docs:end:consume_l1_to_l2_message
pub fn accumulate_encrypted_logs<N>(&mut self, log: [Field; N]) {
let _void1 = self.inputs;
let _void2 = log;
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
}
pub fn accumulate_unencrypted_logs<T>(&mut self, log: T) {
let _void1 = self.inputs;
let _void2 = log;
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
}
pub fn call_private_function<ARGS_COUNT>(
&mut self,
contract_address: Field,
function_selector: Field,
args: [Field; ARGS_COUNT]
) -> [Field; RETURN_VALUES_LENGTH] {
let args_hash = hash_args(args);
assert(args_hash == arguments::pack_arguments(args));
self.call_private_function_with_packed_args(contract_address, function_selector, args_hash)
}
pub fn call_private_function_no_args(
&mut self,
contract_address: Field,
function_selector: Field,
) -> [Field; RETURN_VALUES_LENGTH] {
self.call_private_function_with_packed_args(contract_address, function_selector, 0)
}
pub fn call_private_function_with_packed_args(
&mut self,
contract_address: Field,
function_selector: Field,
args_hash: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let fields = call_private_function_internal(
contract_address,
function_selector,
args_hash
);
let item = PrivateCallStackItem {
contract_address: fields[0],
function_data: FunctionData {
function_selector: fields[1],
is_internal: fields[2] as bool,
is_private: fields[3] as bool,
is_constructor: fields[4] as bool,
},
public_inputs: PrivateCircuitPublicInputs {
call_context: CallContext {
msg_sender : fields[5],
storage_contract_address : fields[6],
portal_contract_address : fields[7],
function_selector: fields[8], // practically same as fields[1]
is_delegate_call : fields[9] as bool,
is_static_call : fields[10] as bool,
is_contract_deployment: fields[11] as bool,
},
// TODO handle the offsets as a variable incremented during extraction?
args_hash: fields[12],
return_values: arr_copy_slice(fields, [0; RETURN_VALUES_LENGTH], 13),
read_requests: arr_copy_slice(fields, [0; MAX_READ_REQUESTS_PER_CALL], 17),
pending_read_requests: arr_copy_slice(fields, [0; MAX_READ_REQUESTS_PER_CALL], 49),
new_commitments: arr_copy_slice(fields, [0; MAX_NEW_COMMITMENTS_PER_CALL], 81),
new_nullifiers: arr_copy_slice(fields, [0; MAX_NEW_NULLIFIERS_PER_CALL], 97),
nullified_commitments: arr_copy_slice(fields, [0; MAX_NEW_NULLIFIERS_PER_CALL], 113),
private_call_stack: arr_copy_slice(fields, [0; MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL], 129),
public_call_stack: arr_copy_slice(fields, [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL], 133),
new_l2_to_l1_msgs: arr_copy_slice(fields, [0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL], 137),
encrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 139),
unencrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 141),
encrypted_log_preimages_length: fields[143],
unencrypted_log_preimages_length: fields[144],
block_data: HistoricBlockData {
// Must match order in `private_circuit_public_inputs.hpp`
note_hash_tree_root : fields[145],
nullifier_tree_root : fields[146],
contract_tree_root : fields[147],
l1_to_l2_messages_tree_root : fields[148],
blocks_tree_root : fields[149],
public_data_tree_root: fields[150],
global_variables_hash: fields[151],
},
contract_deployment_data: ContractDeploymentData {
deployer_public_key: Point::new(fields[152], fields[153]),
constructor_vk_hash : fields[154],
function_tree_root : fields[155],
contract_address_salt : fields[156],
portal_contract_address : fields[157],
},
chain_id: fields[158],
version: fields[159],
},
is_execution_request: fields[160] as bool,
};
assert(contract_address == item.contract_address);
assert(function_selector == item.function_data.function_selector);
assert(args_hash == item.public_inputs.args_hash);
assert(item.is_execution_request == false);
// Assert that the call context of the enqueued call generated by the oracle matches our request.
// We are issuing a regular call which is not delegate, static, or deployment. We also constrain
// the msg_sender in the nested call to be equal to our address, and the execution context address
// for the nested call to be equal to the address we actually called.
assert(item.public_inputs.call_context.is_delegate_call == false);
assert(item.public_inputs.call_context.is_static_call == false);
assert(item.public_inputs.call_context.is_contract_deployment == false);
assert(item.public_inputs.call_context.msg_sender == self.inputs.call_context.storage_contract_address);
assert(item.public_inputs.call_context.storage_contract_address == contract_address);
self.private_call_stack.push(item.hash());
item.public_inputs.return_values
}
pub fn call_public_function<ARGS_COUNT>(
&mut self,
contract_address: Field,
function_selector: Field,
args: [Field; ARGS_COUNT]
) {
let args_hash = hash_args(args);
assert(args_hash == arguments::pack_arguments(args));
self.call_public_function_with_packed_args(contract_address, function_selector, args_hash)
}
pub fn call_public_function_no_args(
&mut self,
contract_address: Field,
function_selector: Field,
) {
self.call_public_function_with_packed_args(contract_address, function_selector, 0)
}
pub fn call_public_function_with_packed_args(
&mut self,
contract_address: Field,
function_selector: Field,
args_hash: Field
) {
let fields = enqueue_public_function_call_internal(
contract_address,
function_selector,
args_hash
);
let item = PublicCallStackItem {
contract_address: fields[0],
function_data: FunctionData {
function_selector: fields[1],
is_internal: fields[2] as bool,
is_private: fields[3] as bool,
is_constructor: fields[4] as bool,
},
public_inputs: PublicCircuitPublicInputs {
call_context: CallContext {
msg_sender : fields[5],
storage_contract_address : fields[6],
portal_contract_address : fields[7],
function_selector: fields[8], // practically same as fields[1]
is_delegate_call : fields[9] as bool,
is_static_call : fields[10] as bool,
is_contract_deployment: fields[11] as bool,
},
args_hash: fields[12],
return_values: [0; RETURN_VALUES_LENGTH],
contract_storage_update_requests: [ContractStorageUpdateRequest::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL],
contract_storage_read: [ContractStorageRead::empty(); MAX_PUBLIC_DATA_READS_PER_CALL],
public_call_stack: [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],
new_commitments: [0; MAX_NEW_COMMITMENTS_PER_CALL],
new_nullifiers: [0; MAX_NEW_NULLIFIERS_PER_CALL],
new_l2_to_l1_msgs:[0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL],
unencrypted_logs_hash:[0; NUM_FIELDS_PER_SHA256],
unencrypted_log_preimages_length: 0,
block_data: HistoricBlockData::empty(),
prover_address: 0,
},
is_execution_request: true,
};
assert(contract_address == item.contract_address);
assert(function_selector == item.function_data.function_selector);
assert(args_hash == item.public_inputs.args_hash);
// Assert that the call context of the enqueued call generated by the oracle matches our request.
// We are issuing a regular call which is not delegate, static, or deployment. We also constrain
// the msg_sender in the nested call to be equal to our address, and the execution context address
// for the nested call to be equal to the address we actually called.
assert(item.public_inputs.call_context.is_delegate_call == false);
assert(item.public_inputs.call_context.is_static_call == false);
assert(item.public_inputs.call_context.is_contract_deployment == false);
assert(item.public_inputs.call_context.msg_sender == self.inputs.call_context.storage_contract_address);
assert(item.public_inputs.call_context.storage_contract_address == contract_address);
self.public_call_stack.push(item.hash());
}
}
use crate::abi::{
ContractStorageRead,
ContractStorageUpdateRequest
};
struct PublicContext {
inputs: abi::PublicContextInputs,
args_hash : Field,
return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,
contract_storage_update_requests: BoundedVec<ContractStorageUpdateRequest, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL>,
contract_storage_read: BoundedVec<ContractStorageRead, MAX_PUBLIC_DATA_READS_PER_CALL>,
public_call_stack: BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
new_commitments: BoundedVec<Field, MAX_NEW_COMMITMENTS_PER_CALL>,
new_nullifiers: BoundedVec<Field, crate::abi::MAX_NEW_NULLIFIERS_PER_CALL>,
new_l2_to_l1_msgs: BoundedVec<Field, crate::abi::MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,
unencrypted_logs_hash: BoundedVec<Field, NUM_FIELDS_PER_SHA256>,
unencrypted_logs_preimages_length: Field,
block_data: HistoricBlockData,
prover_address: Field,
}
impl PublicContext {
pub fn new(inputs: abi::PublicContextInputs, args_hash: Field) -> PublicContext {
let empty_storage_read = ContractStorageRead::empty();
let empty_storage_update = ContractStorageUpdateRequest::empty();
PublicContext {
inputs: inputs,
args_hash: args_hash,
return_values: BoundedVec::new(0),
contract_storage_update_requests: BoundedVec::new(empty_storage_update),
contract_storage_read: BoundedVec::new(empty_storage_read),
public_call_stack: BoundedVec::new(0),
new_commitments: BoundedVec::new(0),
new_nullifiers: BoundedVec::new(0),
new_l2_to_l1_msgs: BoundedVec::new(0),
unencrypted_logs_hash: BoundedVec::new(0),
unencrypted_logs_preimages_length: 0,
block_data: inputs.block_data,
prover_address: 0,
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
// encrypted_logs_preimages: Vec::new(),
// unencrypted_logs_preimages: Vec::new(),
}
}
pub fn msg_sender(self) -> Field {
self.inputs.call_context.msg_sender
}
pub fn this_address(self) -> Field {
self.inputs.call_context.storage_contract_address
}
pub fn this_portal_address(self) -> Field {
self.inputs.call_context.portal_contract_address
}
pub fn chain_id(self) -> Field {
self.inputs.public_global_variables.chain_id
}
pub fn version(self) -> Field {
self.inputs.public_global_variables.version
}
pub fn selector(self) -> Field {
self.inputs.call_context.function_selector
}
pub fn block_number(self) -> Field {
self.inputs.public_global_variables.block_number
}
pub fn timestamp(self) -> Field {
self.inputs.public_global_variables.timestamp
}
pub fn finish(self) -> abi::PublicCircuitPublicInputs {
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
let unencrypted_logs_hash = [0; NUM_FIELDS_PER_SHA256];
let unencrypted_log_preimages_length = 0;
// Compute the public call stack hashes
let pub_circuit_pub_inputs = abi::PublicCircuitPublicInputs {
call_context: self.inputs.call_context, // Done
args_hash: self.args_hash, // Done
contract_storage_update_requests: self.contract_storage_update_requests.storage,
contract_storage_read: self.contract_storage_read.storage,
return_values: self.return_values.storage,
new_commitments: self.new_commitments.storage,
new_nullifiers: self.new_nullifiers.storage,
public_call_stack: self.public_call_stack.storage,
new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage,
unencrypted_logs_hash: unencrypted_logs_hash,
unencrypted_log_preimages_length: unencrypted_log_preimages_length,
block_data: self.inputs.block_data,
prover_address: self.prover_address,
};
pub_circuit_pub_inputs
}
pub fn push_new_note_hash(&mut self, note_hash: Field) {
self.new_commitments.push(note_hash);
}
pub fn push_new_nullifier(&mut self, nullifier: Field, _nullified_commitment: Field) {
self.new_nullifiers.push(nullifier);
}
pub fn message_portal(&mut self, content: Field) {
self.new_l2_to_l1_msgs.push(content);
}
// PrivateContextInputs must be temporarily passed in to prevent too many unknowns
// Note this returns self to get around an issue where mutable structs do not maintain mutations unless reassigned
pub fn consume_l1_to_l2_message(&mut self, msg_key: Field, content: Field, secret: Field) {
let this = (*self).this_address();
let nullifier = process_l1_to_l2_message(self.block_data.l1_to_l2_messages_tree_root, this, self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret);
// Push nullifier (and the "commitment" corresponding to this can be "empty")
self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT)
}
pub fn accumulate_encrypted_logs<N>(&mut self, log: [Field; N]) {
let _void1 = self;
let _void2 = log;
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
}
pub fn accumulate_unencrypted_logs<T>(&mut self, log: T) {
let _void1 = self;
let _void2 = log;
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
}
pub fn call_public_function<ARGS_COUNT>(
_self: Self,
contract_address: Field,
function_selector: Field,
args: [Field; ARGS_COUNT],
) -> [Field; RETURN_VALUES_LENGTH] {
let args_hash = abi::hash_args(args);
assert(args_hash == arguments::pack_arguments(args));
call_public_function_internal(
contract_address,
function_selector,
args_hash,
)
}
pub fn call_public_function_no_args(
_self: Self,
contract_address: Field,
function_selector: Field,
) -> [Field; RETURN_VALUES_LENGTH] {
call_public_function_internal(
contract_address,
function_selector,
0,
)
}
}
struct Context {
private: Option<&mut PrivateContext>,
public: Option<&mut PublicContext>,
}
impl Context {
pub fn private(context: &mut PrivateContext) -> Context {
Context {
private: Option::some(context),
public: Option::none()
}
}
pub fn public(context: &mut PublicContext) -> Context {
Context {
public: Option::some(context),
private: Option::none()
}
}
pub fn none() -> Context {
Context {
public: Option::none(),
private: Option::none()
}
}
}