@@ -250,13 +250,17 @@ namespace nil {
250
250
if (opcode == " STOP" ) {
251
251
// 0x00 -- no RW operations
252
252
_call_stack.back ().end = rw_counter - 1 ;
253
+ _call_stack.back ().returndata = {};
253
254
_rw_operations.push_back (
254
255
call_context_rw_operation (
255
256
call_id,
256
257
call_context_field::end,
257
258
rw_counter - 1
258
259
)
259
260
);
261
+ _rw_operations.push_back (call_context_w_operation (call_id, call_context_field::lastcall_returndata_offset, rw_counter++, 0 ));
262
+ _rw_operations.push_back (call_context_w_operation (call_id, call_context_field::lastcall_returndata_length, rw_counter++, 0 ));
263
+ _rw_operations.push_back (call_context_w_operation (call_id, call_context_field::lastcall_id, rw_counter++, rw_counter + 1 ));
260
264
} else if (opcode == " ADD" ) {
261
265
// 0x01
262
266
_rw_operations.push_back (stack_rw_operation (call_id, stack.size ()-1 , rw_counter++, false , stack[stack.size ()-1 ]));
@@ -541,21 +545,39 @@ namespace nil {
541
545
} else if (opcode == " RETURNDATACOPY" ) {
542
546
// 0x3e
543
547
// std::cout << "Test me, please!" << std::endl;
544
- auto dest_offset = stack[stack.size ()-1 ];
545
- auto offset = stack[stack.size ()-2 ];
546
- auto length = stack[stack.size ()-3 ];
548
+ auto dest_offset = std::size_t (stack[stack.size ()-1 ]);
549
+ auto offset = std::size_t (stack[stack.size ()-2 ]);
550
+ auto length = std::size_t (stack[stack.size ()-3 ]);
551
+ auto lastcall_id = std::size_t (_call_stack.back ().lastcall_id );
547
552
_rw_operations.push_back (stack_rw_operation (call_id, stack.size ()-1 , rw_counter++, false , dest_offset));
548
553
_rw_operations.push_back (stack_rw_operation (call_id, stack.size ()-2 , rw_counter++, false , offset));
549
554
_rw_operations.push_back (stack_rw_operation (call_id, stack.size ()-3 , rw_counter++, false , length));
550
555
551
- // TODO: add length read operations from last return data
556
+ _rw_operations.push_back (
557
+ call_context_r_operation (
558
+ call_id, call_context_field::lastcall_id, rw_counter++, lastcall_id
559
+ )
560
+ );
561
+ copy_event cpy = returndatacopy_copy_event (
562
+ lastcall_id, offset, call_id, dest_offset, rw_counter, length
563
+ );
564
+ for ( std::size_t ind = 0 ; ind < length; ind++){
565
+ _rw_operations.push_back (
566
+ returndata_rw_operation (
567
+ lastcall_id, offset+ind, rw_counter++,
568
+ offset+ind < _call_stack.back ().returndata .size ()? _call_stack.back ().returndata [offset+ind] : 0
569
+ )
570
+ );
571
+ cpy.push_byte (offset+ind < _call_stack.back ().returndata .size ()? _call_stack.back ().returndata [offset+ind] : 0 );
572
+ }
552
573
for ( std::size_t ind = 0 ; ind < length; ind++){
553
574
_rw_operations.push_back (
554
575
memory_rw_operation (
555
576
call_id, dest_offset+ind, rw_counter++, true , memory_next[std::size_t (dest_offset+ind)]
556
577
)
557
578
);
558
579
}
580
+ _copy_events.push_back (cpy);
559
581
memory_size_before = memory_next.size ();
560
582
// Where will consistency check be done?
561
583
} else if (opcode == " EXTCODEHASH" ) {
@@ -1433,6 +1455,7 @@ namespace nil {
1433
1455
// fill end of call
1434
1456
std::cout << " Appended" << std::endl;
1435
1457
_call_stack.pop_back ();
1458
+ _call_stack.back ().returndata = {};
1436
1459
if ( _call_stack.size () != 1 ){
1437
1460
_call_stack.back ().was_accessed .insert (returned_call.was_accessed .begin (),returned_call.was_accessed .end ());
1438
1461
_call_stack.back ().was_written .insert (returned_call.was_written .begin (),returned_call.was_written .end ());
@@ -1463,20 +1486,19 @@ namespace nil {
1463
1486
bytecode_hash = end_call_state.bytecode_hash ;
1464
1487
call_context_address = end_call_state.call_context_address ;
1465
1488
memory_size_before = memory_next.size ();
1466
- _rw_operations.push_back (stack_rw_operation (call_id, stack_next.size ()-1 , rw_counter++, true , stack_next[stack_next.size ()-1 ]));
1467
1489
1468
1490
if ( _call_stack.size () > 1 ){
1469
1491
_rw_operations.push_back (call_context_r_operation (
1470
1492
call_id,
1471
1493
call_context_field::lastcall_returndata_length,
1472
1494
rw_counter++,
1473
- 0
1495
+ _call_stack. back (). lastcall_returndatalength
1474
1496
));
1475
1497
_rw_operations.push_back (call_context_r_operation (
1476
1498
call_id,
1477
1499
call_context_field::lastcall_returndata_offset,
1478
1500
rw_counter++,
1479
- 0
1501
+ _call_stack. back (). lastcall_returndataoffset
1480
1502
));
1481
1503
_rw_operations.push_back (call_context_r_operation (
1482
1504
call_id,
@@ -1485,6 +1507,7 @@ namespace nil {
1485
1507
returned_call.call_id
1486
1508
));
1487
1509
}
1510
+ _rw_operations.push_back (stack_rw_operation (call_id, stack_next.size ()-1 , rw_counter++, true , stack_next[stack_next.size ()-1 ]));
1488
1511
}
1489
1512
if ( opcode == " RETURN" ){
1490
1513
std::size_t offset = std::size_t (stack[stack.size ()-1 ]); // Real value
0 commit comments