@@ -17,7 +17,12 @@ pub use types::*;
1717
1818pub trait EvmcVm {
1919 fn init ( ) -> Self ;
20- fn execute ( & self , code : & [ u8 ] , context : & ExecutionContext ) -> ExecutionResult ;
20+ fn execute (
21+ & self ,
22+ code : & [ u8 ] ,
23+ message : & ExecutionMessage ,
24+ context : & ExecutionContext ,
25+ ) -> ExecutionResult ;
2126}
2227
2328/// EVMC result structure.
@@ -44,7 +49,6 @@ pub struct ExecutionMessage {
4449/// EVMC context structure. Exposes the EVMC host functions, message data, and transaction context
4550/// to the executing VM.
4651pub struct ExecutionContext < ' a > {
47- message : ExecutionMessage ,
4852 context : & ' a mut ffi:: evmc_context ,
4953 tx_context : ffi:: evmc_tx_context ,
5054}
@@ -159,23 +163,18 @@ impl ExecutionMessage {
159163}
160164
161165impl < ' a > ExecutionContext < ' a > {
162- pub fn new ( _message : & ' a ffi :: evmc_message , _context : & ' a mut ffi:: evmc_context ) -> Self {
166+ pub fn new ( _context : & ' a mut ffi:: evmc_context ) -> Self {
163167 let _tx_context = unsafe {
164168 assert ! ( ( * ( _context. host) ) . get_tx_context. is_some( ) ) ;
165169 ( * ( _context. host ) ) . get_tx_context . unwrap ( ) ( _context as * mut ffi:: evmc_context )
166170 } ;
167171
168172 ExecutionContext {
169- message : _message. into ( ) ,
170173 context : _context,
171174 tx_context : _tx_context,
172175 }
173176 }
174177
175- pub fn get_message ( & self ) -> & ExecutionMessage {
176- & self . message
177- }
178-
179178 pub fn get_tx_context ( & mut self ) -> & ffi:: evmc_tx_context {
180179 & self . tx_context
181180 }
@@ -789,63 +788,31 @@ mod tests {
789788 }
790789 }
791790
792- fn get_dummy_message ( ) -> ffi:: evmc_message {
793- ffi:: evmc_message {
794- kind : ffi:: evmc_call_kind:: EVMC_CALL ,
795- flags : 0 ,
796- depth : 123 ,
797- gas : 105023 ,
798- destination : Address { bytes : [ 0u8 ; 20 ] } ,
799- sender : Address { bytes : [ 0u8 ; 20 ] } ,
800- input_data : std:: ptr:: null ( ) as * const u8 ,
801- input_size : 0 ,
802- value : Uint256 { bytes : [ 0u8 ; 32 ] } ,
803- create2_salt : Uint256 { bytes : [ 0u8 ; 32 ] } ,
804- }
805- }
806-
807791 #[ test]
808792 fn execution_context ( ) {
809- let msg = get_dummy_message ( ) ;
810793 let mut context_raw = get_dummy_context ( ) ;
811794 // Make a copy here so we don't let get_dummy_context() go out of scope when called again
812795 // in get_dummy_tx_context() and cause LLVM
813796 // sanitizers to complain
814797 let mut context_raw_copy = context_raw. clone ( ) ;
815798
816- let mut exe_context = ExecutionContext :: new ( & msg , & mut context_raw) ;
799+ let mut exe_context = ExecutionContext :: new ( & mut context_raw) ;
817800 let a = exe_context. get_tx_context ( ) ;
818801 let b = unsafe { get_dummy_tx_context ( & mut context_raw_copy as * mut ffi:: evmc_context ) } ;
819802
820803 assert_eq ! ( a. block_gas_limit, b. block_gas_limit) ;
821804 assert_eq ! ( a. block_timestamp, b. block_timestamp) ;
822805 assert_eq ! ( a. block_number, b. block_number) ;
823806
824- let c = exe_context. get_message ( ) ;
825- let d = get_dummy_message ( ) ;
826-
827- assert_eq ! ( c. kind, d. kind) ;
828- assert_eq ! ( c. flags, d. flags) ;
829- assert_eq ! ( c. depth, d. depth) ;
830- assert_eq ! ( c. gas, d. gas) ;
831- if d. input_data . is_null ( ) {
832- assert ! ( c. input( ) . is_none( ) ) ;
833- } else {
834- assert ! ( c. input( ) . is_some( ) ) ;
835- assert_eq ! ( c. input( ) . unwrap( ) . len( ) , d. input_size) ;
836- }
837-
838807 dummy_context_dispose ( context_raw) ;
839808 }
840809
841810 #[ test]
842811 fn get_code_size ( ) {
843- let msg = get_dummy_message ( ) ;
844-
845812 // This address is useless. Just a dummy parameter for the interface function.
846813 let test_addr = Address { bytes : [ 0u8 ; 20 ] } ;
847814 let mut context_raw = get_dummy_context ( ) ;
848- let mut exe_context = ExecutionContext :: new ( & msg , & mut context_raw) ;
815+ let mut exe_context = ExecutionContext :: new ( & mut context_raw) ;
849816
850817 let a: usize = 105023 ;
851818 let b = exe_context. get_code_size ( & test_addr) ;
@@ -857,12 +824,10 @@ mod tests {
857824
858825 #[ test]
859826 fn test_call_empty_data ( ) {
860- let msg = get_dummy_message ( ) ;
861-
862827 // This address is useless. Just a dummy parameter for the interface function.
863828 let test_addr = ffi:: evmc_address { bytes : [ 0u8 ; 20 ] } ;
864829 let mut context_raw = get_dummy_context ( ) ;
865- let mut exe_context = ExecutionContext :: new ( & msg , & mut context_raw) ;
830+ let mut exe_context = ExecutionContext :: new ( & mut context_raw) ;
866831
867832 let message = ExecutionMessage :: new (
868833 ffi:: evmc_call_kind:: EVMC_CALL ,
@@ -892,12 +857,10 @@ mod tests {
892857
893858 #[ test]
894859 fn test_call_with_data ( ) {
895- let msg = get_dummy_message ( ) ;
896-
897860 // This address is useless. Just a dummy parameter for the interface function.
898861 let test_addr = ffi:: evmc_address { bytes : [ 0u8 ; 20 ] } ;
899862 let mut context_raw = get_dummy_context ( ) ;
900- let mut exe_context = ExecutionContext :: new ( & msg , & mut context_raw) ;
863+ let mut exe_context = ExecutionContext :: new ( & mut context_raw) ;
901864
902865 let data = vec ! [ 0xc0 , 0xff , 0xfe ] ;
903866
0 commit comments