diff --git a/tod_attack_miner/cli.py b/tod_attack_miner/cli.py index b9da4b7..81fb4cf 100644 --- a/tod_attack_miner/cli.py +++ b/tod_attack_miner/cli.py @@ -7,6 +7,10 @@ import psycopg from tod_attack_miner.db.db import DB +from tod_attack_miner.db.filters import ( + get_filters_duplicate_limits, + get_filters_except_duplicate_limits, +) from tod_attack_miner.miner.miner import Miner from tod_attack_miner.rpc.rpc import RPC @@ -48,6 +52,9 @@ def main(): miner.fetch(int(args.from_block), int(args.to_block)) miner.compute_skelcodes() miner.find_collisions() - miner.filter_candidates(args.window_size) + miner.filter_candidates( + get_filters_except_duplicate_limits(25) + + get_filters_duplicate_limits(10) + ) print(f"Found {miner.count_candidates()} candidates") print(json.dumps(miner.get_stats())) diff --git a/tod_attack_miner/db/db.py b/tod_attack_miner/db/db.py index d8b7621..f8cb744 100644 --- a/tod_attack_miner/db/db.py +++ b/tod_attack_miner/db/db.py @@ -470,5 +470,7 @@ def hash_code(code: str) -> str: def code_skeleton_hash(code: str) -> str: code_without_prefix = code[2:] + if code_without_prefix == "0": + code_without_prefix = "" skelcode = skeletize(bytes.fromhex(code_without_prefix)).hex() return hash_code(skelcode) diff --git a/tod_attack_miner/fetcher/fetcher.py b/tod_attack_miner/fetcher/fetcher.py index 4726f30..0c46f62 100644 --- a/tod_attack_miner/fetcher/fetcher.py +++ b/tod_attack_miner/fetcher/fetcher.py @@ -32,11 +32,11 @@ def fetch_block_range(rpc: RPC, db: DB, block_range: BlockRange): ) ): bar.set_postfix_str(f"block {block_number}") - rpc.fetch_block_with_transactions(block_number) + block = rpc.fetch_block_with_transactions(block_number) prestates = rpc.fetch_prestates(block_number) state_diffs = rpc.fetch_state_diffs(block_number) - db.insert_block(rpc.fetch_block_with_transactions(block_number)) + db.insert_block(block) for i, prestate in enumerate(prestates): db.insert_prestate(block_number, i, prestate) for i, state_diff in enumerate(state_diffs):