Skip to content

Commit

Permalink
fix: do not break on 0x0 code
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto-AA committed Jul 23, 2024
1 parent ad812a0 commit 0355a02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion tod_attack_miner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()))
2 changes: 2 additions & 0 deletions tod_attack_miner/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions tod_attack_miner/fetcher/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0355a02

Please sign in to comment.