11use crate :: { context:: ContextReader , Address , B256 , U256 } ;
2- use alloc:: vec;
32use alloy_primitives:: Bytes ;
43
54#[ derive( Default , Clone , Debug , PartialEq ) ]
@@ -14,21 +13,6 @@ pub struct BlockContextV1 {
1413 pub base_fee : U256 ,
1514}
1615
17- impl From < & revm_primitives:: Env > for BlockContextV1 {
18- fn from ( value : & revm_primitives:: Env ) -> Self {
19- Self {
20- chain_id : value. cfg . chain_id ,
21- coinbase : value. block . coinbase ,
22- timestamp : value. block . timestamp . as_limbs ( ) [ 0 ] ,
23- number : value. block . number . as_limbs ( ) [ 0 ] ,
24- difficulty : value. block . difficulty ,
25- prev_randao : value. block . prevrandao . unwrap_or_default ( ) ,
26- gas_limit : value. block . gas_limit . as_limbs ( ) [ 0 ] ,
27- base_fee : value. block . basefee ,
28- }
29- }
30- }
31-
3216#[ derive( Default , Clone , Debug , PartialEq ) ]
3317pub struct ContractContextV1 {
3418 pub address : Address ,
@@ -39,52 +23,6 @@ pub struct ContractContextV1 {
3923 pub gas_limit : u64 ,
4024}
4125
42- pub fn env_from_context < CR : ContextReader > ( cr : CR ) -> revm_primitives:: Env {
43- use revm_primitives:: { AnalysisKind , BlockEnv , CfgEnv , Env , TransactTo , TxEnv } ;
44- Env {
45- cfg : {
46- let mut cfg_env = CfgEnv :: default ( ) ;
47- cfg_env. chain_id = cr. block_chain_id ( ) ;
48- cfg_env. perf_analyse_created_bytecodes = AnalysisKind :: Raw ;
49- cfg_env
50- } ,
51- block : BlockEnv {
52- number : U256 :: from ( cr. block_number ( ) ) ,
53- coinbase : cr. block_coinbase ( ) ,
54- timestamp : U256 :: from ( cr. block_timestamp ( ) ) ,
55- gas_limit : U256 :: from ( cr. block_gas_limit ( ) ) ,
56- basefee : cr. block_base_fee ( ) ,
57- difficulty : cr. block_difficulty ( ) ,
58- prevrandao : Some ( cr. block_prev_randao ( ) ) ,
59- blob_excess_gas_and_price : None ,
60- } ,
61- tx : TxEnv {
62- caller : cr. tx_origin ( ) ,
63- gas_limit : cr. tx_gas_limit ( ) ,
64- gas_price : cr. tx_gas_price ( ) ,
65- // we don't check this field, and we don't know what type of "transact"
66- // we execute right now, so can safely skip the field
67- transact_to : TransactTo :: Call ( Address :: ZERO ) ,
68- value : cr. tx_value ( ) ,
69- // we don't use this field, so there is no need to do redundant copy operation
70- data : Bytes :: default ( ) ,
71- // we do nonce and chain id checks before executing transaction
72- nonce : None ,
73- chain_id : None ,
74- // we check access lists in advance before executing a smart contract, it
75- // doesn't affect gas price or something else, can skip
76- access_list : Default :: default ( ) ,
77- gas_priority_fee : cr. tx_gas_priority_fee ( ) ,
78- // TODO(dmitry123): "we don't support blobs yet, so 2 tests from e2e testing suite fail"
79- blob_hashes : vec ! [ ] , // tx_context.blob_hashes.clone(),
80- max_fee_per_blob_gas : None , // tx_context.max_fee_per_blob_gas,
81- authorization_list : None ,
82- #[ cfg( feature = "optimism" ) ]
83- optimism : Default :: default ( ) ,
84- } ,
85- }
86- }
87-
8826#[ derive( Default , Clone , Debug , PartialEq ) ]
8927pub struct TxContextV1 {
9028 pub gas_limit : u64 ,
@@ -97,22 +35,6 @@ pub struct TxContextV1 {
9735 pub value : U256 ,
9836}
9937
100- impl From < & revm_primitives:: Env > for TxContextV1 {
101- fn from ( value : & revm_primitives:: Env ) -> Self {
102- Self {
103- gas_limit : value. tx . gas_limit ,
104- nonce : value. tx . nonce . unwrap_or_default ( ) ,
105- gas_price : value. tx . gas_price ,
106- gas_priority_fee : value. tx . gas_priority_fee ,
107- origin : value. tx . caller ,
108- // data: value.tx.data.clone(),
109- // blob_hashes: value.tx.blob_hashes.clone(),
110- // max_fee_per_blob_gas: value.tx.max_fee_per_blob_gas,
111- value : value. tx . value ,
112- }
113- }
114- }
115-
11638#[ derive( Default , Clone , Debug , PartialEq ) ]
11739pub struct SharedContextInputV1 {
11840 pub block : BlockContextV1 ,
0 commit comments