1313""" 
1414
1515from  dataclasses  import  dataclass 
16- from  typing  import  Any ,  List , Optional , Tuple 
16+ from  typing  import  List , Optional , Tuple 
1717
1818from  ethereum_rlp  import  rlp 
1919from  ethereum_types .bytes  import  Bytes 
@@ -179,9 +179,7 @@ def get_last_256_block_hashes(chain: BlockChain) -> List[Hash32]:
179179    return  recent_block_hashes 
180180
181181
182- def  state_transition (
183-     chain : BlockChain , block : Block , oracle : Optional [Any ] =  None 
184- ) ->  None :
182+ def  state_transition (chain : BlockChain , block : Block ) ->  None :
185183    """ 
186184    Attempts to apply a block to an existing block chain. 
187185
@@ -212,13 +210,9 @@ def state_transition(
212210    if  block .ommers  !=  ():
213211        raise  InvalidBlock 
214212
215-     # Oracle must be provided 
216-     if  oracle  is  None :
217-         raise  ValueError ("Oracle parameter is required for state_transition" )
218- 
219213    block_env  =  vm .BlockEnvironment (
220214        chain_id = chain .chain_id ,
221-         oracle = oracle ,
215+         state = chain . state ,
222216        block_gas_limit = block .header .gas_limit ,
223217        block_hashes = get_last_256_block_hashes (chain ),
224218        coinbase = block .header .coinbase ,
@@ -235,7 +229,7 @@ def state_transition(
235229        transactions = block .transactions ,
236230        withdrawals = block .withdrawals ,
237231    )
238-     block_state_root  =  block_env .oracle .state_root ()
232+     block_state_root  =  block_env .get_oracle () .state_root ()
239233    transactions_root  =  root (block_output .transactions_trie )
240234    receipt_root  =  root (block_output .receipts_trie )
241235    block_logs_bloom  =  logs_bloom (block_output .block_logs )
@@ -459,7 +453,7 @@ def check_transaction(
459453        raise  BlobGasLimitExceededError ("blob gas limit exceeded" )
460454
461455    sender_address  =  recover_sender (block_env .chain_id , tx )
462-     sender_account  =  block_env .oracle .get_account (sender_address )
456+     sender_account  =  block_env .get_oracle () .get_account (sender_address )
463457
464458    if  isinstance (
465459        tx , (FeeMarketTransaction , BlobTransaction , SetCodeTransaction )
@@ -664,7 +658,9 @@ def process_checked_system_transaction(
664658    system_tx_output : `MessageCallOutput` 
665659        Output of processing the system transaction. 
666660    """ 
667-     system_contract_code  =  block_env .oracle .get_account (target_address ).code 
661+     system_contract_code  =  (
662+         block_env .get_oracle ().get_account (target_address ).code 
663+     )
668664
669665    if  len (system_contract_code ) ==  0 :
670666        raise  InvalidBlock (
@@ -711,7 +707,9 @@ def process_unchecked_system_transaction(
711707    system_tx_output : `MessageCallOutput` 
712708        Output of processing the system transaction. 
713709    """ 
714-     system_contract_code  =  block_env .oracle .get_account (target_address ).code 
710+     system_contract_code  =  (
711+         block_env .get_oracle ().get_account (target_address ).code 
712+     )
715713    return  process_system_transaction (
716714        block_env ,
717715        target_address ,
@@ -868,7 +866,7 @@ def process_transaction(
868866        tx = tx ,
869867    )
870868
871-     sender_account  =  block_env .oracle .get_account (sender )
869+     sender_account  =  block_env .get_oracle () .get_account (sender )
872870
873871    if  isinstance (tx , BlobTransaction ):
874872        blob_gas_fee  =  calculate_data_fee (block_env .excess_blob_gas , tx )
@@ -878,12 +876,12 @@ def process_transaction(
878876    effective_gas_fee  =  tx .gas  *  effective_gas_price 
879877
880878    gas  =  tx .gas  -  intrinsic_gas 
881-     block_env .oracle .increment_nonce (sender )
879+     block_env .get_oracle () .increment_nonce (sender )
882880
883881    sender_balance_after_gas_fee  =  (
884882        Uint (sender_account .balance ) -  effective_gas_fee  -  blob_gas_fee 
885883    )
886-     block_env .oracle .set_account_balance (
884+     block_env .get_oracle () .set_account_balance (
887885        sender , U256 (sender_balance_after_gas_fee )
888886    )
889887
@@ -947,29 +945,33 @@ def process_transaction(
947945    transaction_fee  =  tx_gas_used_after_refund  *  priority_fee_per_gas 
948946
949947    # refund gas 
950-     current_sender_balance  =  block_env .oracle .get_account (sender ).balance 
948+     current_sender_balance  =  block_env .get_oracle () .get_account (sender ).balance 
951949    sender_balance_after_refund  =  current_sender_balance  +  U256 (
952950        gas_refund_amount 
953951    )
954-     block_env .oracle .set_account_balance (sender , sender_balance_after_refund )
952+     block_env .get_oracle ().set_account_balance (
953+         sender , sender_balance_after_refund 
954+     )
955955
956956    # transfer miner fees 
957-     current_coinbase_balance  =  block_env . oracle . get_account (
958-         block_env .coinbase 
959-     ). balance 
957+     current_coinbase_balance  =  (
958+         block_env .get_oracle (). get_account ( block_env . coinbase ). balance 
959+     )
960960    coinbase_balance_after_mining_fee  =  current_coinbase_balance  +  U256 (
961961        transaction_fee 
962962    )
963963    if  coinbase_balance_after_mining_fee  !=  0 :
964-         block_env .oracle .set_account_balance (
964+         block_env .get_oracle () .set_account_balance (
965965            block_env .coinbase ,
966966            coinbase_balance_after_mining_fee ,
967967        )
968-     elif  block_env .oracle .account_exists_and_is_empty (block_env .coinbase ):
969-         block_env .oracle .destroy_account (block_env .coinbase )
968+     elif  block_env .get_oracle ().account_exists_and_is_empty (
969+         block_env .coinbase 
970+     ):
971+         block_env .get_oracle ().destroy_account (block_env .coinbase )
970972
971973    for  address  in  tx_output .accounts_to_delete :
972-         block_env .oracle .destroy_account (address )
974+         block_env .get_oracle () .destroy_account (address )
973975
974976    block_output .block_gas_used  +=  tx_gas_used_after_refund 
975977    block_output .blob_gas_used  +=  tx_blob_gas_used 
@@ -1009,10 +1011,12 @@ def increase_recipient_balance(recipient: Account) -> None:
10091011            rlp .encode (wd ),
10101012        )
10111013
1012-         block_env .oracle .modify_state (wd .address , increase_recipient_balance )
1014+         block_env .get_oracle ().modify_state (
1015+             wd .address , increase_recipient_balance 
1016+         )
10131017
1014-         if  block_env .oracle .account_exists_and_is_empty (wd .address ):
1015-             block_env .oracle .destroy_account (wd .address )
1018+         if  block_env .get_oracle () .account_exists_and_is_empty (wd .address ):
1019+             block_env .get_oracle () .destroy_account (wd .address )
10161020
10171021
10181022def  check_gas_limit (gas_limit : Uint , parent_gas_limit : Uint ) ->  bool :
0 commit comments