@@ -526,6 +526,7 @@ impl Interpreter {
526
526
527
527
/// Loads a resource from the data store and return the number of bytes read from the storage.
528
528
fn load_resource < ' b > (
529
+ loader : & Loader ,
529
530
gas_meter : & mut impl GasMeter ,
530
531
data_store : & ' b mut impl DataStore ,
531
532
addr : AccountAddress ,
@@ -547,7 +548,7 @@ impl Interpreter {
547
548
}
548
549
None => None ,
549
550
} ;
550
- gas_meter. charge_load_resource ( opt) ?;
551
+ gas_meter. charge_load_resource ( addr , TypeWithLoader { ty , loader } , opt) ?;
551
552
}
552
553
Ok ( gv)
553
554
}
@@ -572,7 +573,7 @@ impl Interpreter {
572
573
addr : AccountAddress ,
573
574
ty : & Type ,
574
575
) -> PartialVMResult < ( ) > {
575
- let res = Self :: load_resource ( gas_meter, data_store, addr, ty) ?. borrow_global ( ) ;
576
+ let res = Self :: load_resource ( loader , gas_meter, data_store, addr, ty) ?. borrow_global ( ) ;
576
577
gas_meter. charge_borrow_global (
577
578
is_mut,
578
579
is_generic,
@@ -593,7 +594,7 @@ impl Interpreter {
593
594
addr : AccountAddress ,
594
595
ty : & Type ,
595
596
) -> PartialVMResult < ( ) > {
596
- let gv = Self :: load_resource ( gas_meter, data_store, addr, ty) ?;
597
+ let gv = Self :: load_resource ( loader , gas_meter, data_store, addr, ty) ?;
597
598
let exists = gv. exists ( ) ?;
598
599
gas_meter. charge_exists ( is_generic, TypeWithLoader { ty, loader } , exists) ?;
599
600
self . operand_stack . push ( Value :: bool ( exists) ) ?;
@@ -610,21 +611,22 @@ impl Interpreter {
610
611
addr : AccountAddress ,
611
612
ty : & Type ,
612
613
) -> PartialVMResult < ( ) > {
613
- let resource = match Self :: load_resource ( gas_meter, data_store, addr, ty) ?. move_from ( ) {
614
- Ok ( resource) => {
615
- gas_meter. charge_move_from (
616
- is_generic,
617
- TypeWithLoader { ty, loader } ,
618
- Some ( & resource) ,
619
- ) ?;
620
- resource
621
- }
622
- Err ( err) => {
623
- let val: Option < & Value > = None ;
624
- gas_meter. charge_move_from ( is_generic, TypeWithLoader { ty, loader } , val) ?;
625
- return Err ( err) ;
626
- }
627
- } ;
614
+ let resource =
615
+ match Self :: load_resource ( loader, gas_meter, data_store, addr, ty) ?. move_from ( ) {
616
+ Ok ( resource) => {
617
+ gas_meter. charge_move_from (
618
+ is_generic,
619
+ TypeWithLoader { ty, loader } ,
620
+ Some ( & resource) ,
621
+ ) ?;
622
+ resource
623
+ }
624
+ Err ( err) => {
625
+ let val: Option < & Value > = None ;
626
+ gas_meter. charge_move_from ( is_generic, TypeWithLoader { ty, loader } , val) ?;
627
+ return Err ( err) ;
628
+ }
629
+ } ;
628
630
self . operand_stack . push ( resource) ?;
629
631
Ok ( ( ) )
630
632
}
@@ -640,7 +642,7 @@ impl Interpreter {
640
642
ty : & Type ,
641
643
resource : Value ,
642
644
) -> PartialVMResult < ( ) > {
643
- let gv = Self :: load_resource ( gas_meter, data_store, addr, ty) ?;
645
+ let gv = Self :: load_resource ( loader , gas_meter, data_store, addr, ty) ?;
644
646
// NOTE(Gas): To maintain backward compatibility, we need to charge gas after attempting
645
647
// the move_to operation.
646
648
match gv. move_to ( resource) {
0 commit comments