Skip to content

Commit

Permalink
Merge branch 'main' into second_version_greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcere committed Jan 16, 2025
2 parents a2dd061 + bd1ab12 commit a2b311b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/parser/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
split_block = {'calldatacopy', 'create', 'codecopy', 'call', 'log4', 'gas', 'delegatecall', 'extcodecopy', 'create2',
'assignimmutable', 'returndatacopy', 'log2', 'log1', 'log3', 'log0', 'datacopy', 'staticcall'}
'assignimmutable', 'returndatacopy', 'log2', 'log1', 'log3', 'log0', 'datacopy', 'staticcall','tstore','tload'}

terminal_ops = {"functionReturn", "functionReturn", "return", "revert"}

Expand Down
7 changes: 6 additions & 1 deletion src/parser/opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"JUMPDEST": [0x5b, 0, 0],
"SLOADEXT": [0x5c, 2, 1],
"SSTOREEXT": [0x5d, 3, 0],
"TLOAD": [0x5c, 1, 1],
"TSTORE": [0x5d, 2, 0],
"SLOADBYTESEXT": [0x5c, 4, 0],
"SSTOREBYTESEXT": [0x5d, 4, 0],
"LOG0": [0xa0, 2, 0],
Expand Down Expand Up @@ -295,7 +297,10 @@ def get_ins_cost(opcode, params=None, already=False, store_changed_original_valu
return (GCOST["Gcoldsload"] if not already else 0) + (GCOST["Gwarmaccess"] if store_changed_original_value else GCOST["Gsreset"])
elif opcode == "KECCAK256":
return GCOST["Gsha3"]

elif opcode == "TLOAD":
return 100
elif opcode == "TSTORE":
return 100
elif opcode == "SELFDESTRUCT":
return GCOST["Gsuicide"]
return 0
Expand Down
7 changes: 4 additions & 3 deletions src/solution_generation/reconstruct_bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ def recursive_runtime_asm_from_cfg(cfg: CFG, asm_dicts: Dict[str, List[ASM_bytec
sub_object = cfg.get_subobject()
if sub_object is not None:
json_asm_subobjects = recursive_init_asm_from_cfg(sub_object, asm_dicts, tags_dict)
current_object_json[".data"] = {"0": json_asm_subobjects}

current_object_json[".data"] = {}
current_object_json[".data"]["0"] = json_asm_subobjects["0"]

return current_object_json


Expand All @@ -335,7 +336,7 @@ def recursive_init_asm_from_cfg(cfg: CFG, asm_dicts: Dict[str, List[ASM_bytecode

asm = traverse_cfg(obj, asm_dicts, tags)
current_object_json = {".code": asm}

sub_object = cfg.get_subobject()
assert sub_object is not None, "Init code must be followed by the runtime code"
json_asm_subobjects = recursive_runtime_asm_from_cfg(sub_object, asm_dicts, tags_dict, obj_name)
Expand Down

0 comments on commit a2b311b

Please sign in to comment.