@@ -926,35 +926,35 @@ impl<'a> VM<'a> {
926
926
tx_report : & ExecutionReport ,
927
927
retdata : RetData ,
928
928
) -> Result < ( ) , VMError > {
929
+ let previous_call_frame = self . call_frames . pop ( ) . ok_or ( VMError :: Internal ( InternalError :: CouldNotPopCallframe ) ) ?;
929
930
// Return gas left from subcontext
930
- let gas_left_from_new_call_frame = self
931
- . current_call_frame ( ) ?
931
+ let gas_left_from_new_call_frame = previous_call_frame
932
932
. gas_limit
933
933
. checked_sub ( tx_report. gas_used )
934
934
. ok_or ( InternalError :: GasOverflow ) ?;
935
935
{
936
- let next_call_frame = self . next_call_frame_mut ( ) ?;
937
- next_call_frame . gas_used = next_call_frame
936
+ let current_call_frame = self . current_call_frame_mut ( ) ?;
937
+ current_call_frame . gas_used = current_call_frame
938
938
. gas_used
939
939
. checked_sub ( gas_left_from_new_call_frame)
940
940
. ok_or ( InternalError :: GasOverflow ) ?;
941
941
942
- next_call_frame . logs . extend ( tx_report. logs . clone ( ) ) ;
942
+ current_call_frame . logs . extend ( tx_report. logs . clone ( ) ) ;
943
943
memory:: try_store_range (
944
- & mut next_call_frame . memory ,
944
+ & mut current_call_frame . memory ,
945
945
retdata. ret_offset ,
946
946
retdata. ret_size ,
947
947
& tx_report. output ,
948
948
) ?;
949
- next_call_frame . sub_return_data = tx_report. output . clone ( ) ;
949
+ current_call_frame . sub_return_data = tx_report. output . clone ( ) ;
950
950
}
951
951
952
952
// What to do, depending on TxResult
953
953
match tx_report. result {
954
954
TxResult :: Success => {
955
- self . next_call_frame_mut ( ) ?. stack . push ( SUCCESS_FOR_CALL ) ?;
956
- for ( address, account_opt) in self . current_call_frame ( ) ? . cache_backup . clone ( ) {
957
- self . next_call_frame_mut ( ) ?
955
+ self . current_call_frame_mut ( ) ?. stack . push ( SUCCESS_FOR_CALL ) ?;
956
+ for ( address, account_opt) in previous_call_frame . cache_backup . clone ( ) {
957
+ self . current_call_frame_mut ( ) ?
958
958
. cache_backup
959
959
. entry ( address)
960
960
. or_insert ( account_opt) ;
@@ -968,11 +968,12 @@ impl<'a> VM<'a> {
968
968
self . increase_account_balance ( retdata. msg_sender , retdata. value ) ?;
969
969
}
970
970
// Push 0 to stack
971
- self . next_call_frame_mut ( ) ?. stack . push ( REVERT_FOR_CALL ) ?;
971
+ self . current_call_frame_mut ( ) ?. stack . push ( REVERT_FOR_CALL ) ?;
972
972
}
973
973
}
974
974
Ok ( ( ) )
975
975
}
976
+
976
977
pub fn handle_return_create (
977
978
& mut self ,
978
979
tx_report : & ExecutionReport ,
@@ -982,25 +983,25 @@ impl<'a> VM<'a> {
982
983
. max_message_call_gas
983
984
. checked_sub ( tx_report. gas_used )
984
985
. ok_or ( InternalError :: GasOverflow ) ?;
985
-
986
+ let previous_call_frame = self . call_frames . pop ( ) . ok_or ( VMError :: Internal ( InternalError :: CouldNotPopCallframe ) ) ? ;
986
987
{
987
- let next_call_frame = self . next_call_frame_mut ( ) ?;
988
+ let current_call_frame = self . current_call_frame_mut ( ) ?;
988
989
// Return reserved gas
989
- next_call_frame . gas_used = next_call_frame
990
+ current_call_frame . gas_used = current_call_frame
990
991
. gas_used
991
992
. checked_sub ( unused_gas)
992
993
. ok_or ( InternalError :: GasOverflow ) ?;
993
994
994
- next_call_frame . logs . extend ( tx_report. logs . clone ( ) ) ;
995
+ current_call_frame . logs . extend ( tx_report. logs . clone ( ) ) ;
995
996
}
996
997
997
998
match tx_report. result . clone ( ) {
998
999
TxResult :: Success => {
999
- self . next_call_frame_mut ( ) ?
1000
+ self . current_call_frame_mut ( ) ?
1000
1001
. stack
1001
1002
. push ( address_to_word ( retdata. to ) ) ?;
1002
- for ( address, account_opt) in self . current_call_frame ( ) ? . cache_backup . clone ( ) {
1003
- self . next_call_frame_mut ( ) ?
1003
+ for ( address, account_opt) in previous_call_frame . cache_backup . clone ( ) {
1004
+ self . current_call_frame_mut ( ) ?
1004
1005
. cache_backup
1005
1006
. entry ( address)
1006
1007
. or_insert ( account_opt) ;
@@ -1014,12 +1015,12 @@ impl<'a> VM<'a> {
1014
1015
cache:: remove_account ( & mut self . db . cache , & retdata. to ) ;
1015
1016
self . accrued_substate . created_accounts . remove ( & retdata. to ) ;
1016
1017
1017
- let next_call_frame = self . next_call_frame_mut ( ) ?;
1018
+ let current_call_frame = self . current_call_frame_mut ( ) ?;
1018
1019
// If revert we have to copy the return_data
1019
1020
if err == VMError :: RevertOpcode {
1020
- next_call_frame . sub_return_data = tx_report. output . clone ( ) ;
1021
+ current_call_frame . sub_return_data = tx_report. output . clone ( ) ;
1021
1022
}
1022
- next_call_frame . stack . push ( CREATE_DEPLOYMENT_FAIL ) ?;
1023
+ current_call_frame . stack . push ( CREATE_DEPLOYMENT_FAIL ) ?;
1023
1024
}
1024
1025
}
1025
1026
Ok ( ( ) )
0 commit comments