7
7
from subprocess import CalledProcessError
8
8
from typing import TYPE_CHECKING , Any , ContextManager , NamedTuple
9
9
10
- from kevm_pyk .kevm import KEVM , KEVMSemantics
10
+ from kevm_pyk .kevm import KEVM , KEVMSemantics , _process_jumpdests
11
11
from kevm_pyk .utils import KDefinition__expand_macros , abstract_cell_vars , run_prover
12
12
from pathos .pools import ProcessPool # type: ignore
13
13
from pyk .cterm import CTerm , CTermSymbolic
16
16
from pyk .kcfg import KCFG , KCFGExplore
17
17
from pyk .kore .rpc import KoreClient , TransportType , kore_server
18
18
from pyk .prelude .bytes import bytesToken
19
- from pyk .prelude .collections import list_empty , map_empty , map_of , set_empty
19
+ from pyk .prelude .collections import list_empty , map_empty , map_of , set_empty , set_of
20
20
from pyk .prelude .k import GENERATED_TOP_CELL
21
21
from pyk .prelude .kbool import FALSE , TRUE , notBool
22
22
from pyk .prelude .kint import intToken
@@ -556,9 +556,9 @@ def _method_to_cfg(
556
556
calldata = None
557
557
callvalue = None
558
558
559
- contract_code = KEVM . bin_runtime ( KApply ( f'contract_ { contract .name_with_path } ' ) )
559
+ contract_code = bytes . fromhex ( contract .deployed_bytecode )
560
560
if isinstance (method , Contract .Constructor ):
561
- program = KEVM . init_bytecode ( KApply ( f'contract_ { contract .name_with_path } ' ) )
561
+ program = bytes . fromhex ( contract .bytecode )
562
562
callvalue = method .callvalue_cell
563
563
564
564
elif isinstance (method , Contract .Method ):
@@ -569,7 +569,7 @@ def _method_to_cfg(
569
569
init_cterm = _init_cterm (
570
570
empty_config ,
571
571
program = program ,
572
- contract_code = contract_code ,
572
+ contract_code = bytesToken ( contract_code ) ,
573
573
use_gas = use_gas ,
574
574
deployment_state_entries = deployment_state_entries ,
575
575
calldata = calldata ,
@@ -609,7 +609,7 @@ def _method_to_cfg(
609
609
)
610
610
611
611
for final_node in final_states :
612
- new_init_cterm = _update_cterm_from_node (init_cterm , final_node , contract . name_with_path , config_type )
612
+ new_init_cterm = _update_cterm_from_node (init_cterm , final_node , config_type )
613
613
new_node = cfg .create_node (new_init_cterm )
614
614
if graft_setup_proof :
615
615
cfg .create_edge (final_node .id , new_node .id , depth = 1 )
@@ -626,7 +626,7 @@ def _method_to_cfg(
626
626
627
627
final_cterm = _final_cterm (
628
628
empty_config ,
629
- program = contract_code ,
629
+ program = bytesToken ( contract_code ) ,
630
630
failing = method .is_testfail ,
631
631
config_type = config_type ,
632
632
is_test = method .is_test ,
@@ -637,7 +637,7 @@ def _method_to_cfg(
637
637
return cfg , new_node_ids , init_node_id , target_node .id
638
638
639
639
640
- def _update_cterm_from_node (cterm : CTerm , node : KCFG .Node , contract_name : str , config_type : ConfigType ) -> CTerm :
640
+ def _update_cterm_from_node (cterm : CTerm , node : KCFG .Node , config_type : ConfigType ) -> CTerm :
641
641
new_accounts_cell = node .cterm .cell ('ACCOUNTS_CELL' )
642
642
number_cell = node .cterm .cell ('NUMBER_CELL' )
643
643
timestamp_cell = node .cterm .cell ('TIMESTAMP_CELL' )
@@ -760,7 +760,7 @@ def _init_account(address: int) -> None:
760
760
761
761
def _init_cterm (
762
762
empty_config : KInner ,
763
- program : KInner ,
763
+ program : bytes ,
764
764
contract_code : KInner ,
765
765
use_gas : bool ,
766
766
config_type : ConfigType ,
@@ -777,13 +777,14 @@ def _init_cterm(
777
777
if not trace_options :
778
778
trace_options = TraceOptions ({})
779
779
780
+ jumpdests = set_of (_process_jumpdests (bytecode = program , offset = 0 ))
780
781
init_subst = {
781
782
'MODE_CELL' : KApply ('NORMAL' ),
782
783
'USEGAS_CELL' : TRUE if use_gas else FALSE ,
783
784
'SCHEDULE_CELL' : schedule ,
784
785
'STATUSCODE_CELL' : KVariable ('STATUSCODE' ),
785
- 'PROGRAM_CELL' : program ,
786
- 'JUMPDESTS_CELL' : KEVM . compute_valid_jumpdests ( program ) ,
786
+ 'PROGRAM_CELL' : bytesToken ( program ) ,
787
+ 'JUMPDESTS_CELL' : jumpdests ,
787
788
'ID_CELL' : KVariable (Foundry .symbolic_contract_id (), sort = KSort ('Int' )),
788
789
'ORIGIN_CELL' : KVariable ('ORIGIN_ID' , sort = KSort ('Int' )),
789
790
'CALLER_CELL' : KVariable ('CALLER_ID' , sort = KSort ('Int' )),
0 commit comments