@@ -983,47 +983,46 @@ impl<'a, E: Ext, M: ?Sized + Memory<E::T>> Runtime<'a, E, M> {
983
983
if let Some ( value) = outcome {
984
984
self . adjust_gas ( charged, costs ( value. len ( ) as u32 ) ) ;
985
985
986
- // For fixed-size operations use write_fixed_sandbox_output
987
- if out_len_ptr == SENTINEL {
988
- let mut fixed_output = [ 0u8 ; 32 ] ;
989
- let len = core:: cmp:: min ( value. len ( ) , 32 ) ;
990
- fixed_output[ ..len] . copy_from_slice ( & value[ ..len] ) ;
986
+ match read_mode {
987
+ StorageReadMode :: ZeroIfMissing => {
988
+ let mut fixed_output = [ 0u8 ; 32 ] ;
989
+ let len = core:: cmp:: min ( value. len ( ) , 32 ) ;
990
+ fixed_output[ ..len] . copy_from_slice ( & value[ ..len] ) ;
991
991
992
- self . write_fixed_sandbox_output (
993
- memory,
994
- out_ptr,
995
- & fixed_output,
996
- false ,
997
- already_charged,
998
- ) ?;
999
- } else {
1000
- self . write_sandbox_output (
1001
- memory,
1002
- out_ptr,
1003
- out_len_ptr,
1004
- & value,
1005
- false ,
1006
- already_charged,
1007
- ) ?;
992
+ self . write_fixed_sandbox_output (
993
+ memory,
994
+ out_ptr,
995
+ & fixed_output,
996
+ false ,
997
+ already_charged,
998
+ ) ?;
999
+ Ok ( ReturnErrorCode :: Success )
1000
+ } ,
1001
+ StorageReadMode :: ErrorIfMissing => {
1002
+ // preserve original behavior
1003
+ self . write_sandbox_output (
1004
+ memory,
1005
+ out_ptr,
1006
+ out_len_ptr,
1007
+ & value,
1008
+ false ,
1009
+ already_charged,
1010
+ ) ?;
1011
+ Ok ( ReturnErrorCode :: Success )
1012
+ } ,
1008
1013
}
1009
-
1010
- Ok ( ReturnErrorCode :: Success )
1011
1014
} else {
1012
1015
self . adjust_gas ( charged, costs ( 0 ) ) ;
1013
1016
1014
1017
match read_mode {
1015
1018
StorageReadMode :: ZeroIfMissing => {
1016
- if out_len_ptr == SENTINEL {
1017
- self . write_fixed_sandbox_output (
1018
- memory,
1019
- out_ptr,
1020
- & [ 0u8 ; 32 ] ,
1021
- false ,
1022
- already_charged,
1023
- ) ?;
1024
- } else {
1025
- memory. write ( out_len_ptr, & 0u32 . encode ( ) ) ?;
1026
- }
1019
+ self . write_fixed_sandbox_output (
1020
+ memory,
1021
+ out_ptr,
1022
+ & [ 0u8 ; 32 ] ,
1023
+ false ,
1024
+ already_charged,
1025
+ ) ?;
1027
1026
Ok ( ReturnErrorCode :: Success )
1028
1027
} ,
1029
1028
StorageReadMode :: ErrorIfMissing => Ok ( ReturnErrorCode :: KeyNotFound ) ,
0 commit comments