Skip to content

Commit

Permalink
feat: filter all nonce and code collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto-AA committed Jul 15, 2024
1 parent 77f8970 commit 5d882b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tests/integration/snapshots/snap_test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
"filtered": {
"block_producers": 786,
"block_window": 62,
"eoa_nonces": 658,
"codes": 0,
"indirect_dependencies_quick": 47,
"indirect_dependencies_recursive": 38,
"nonces": 658,
"recipient_eth_transfer": 61,
"same_sender": 174,
},
Expand Down
15 changes: 8 additions & 7 deletions tod_attack_miner/db/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ def filter_block_window(db: DB, window_size: int | None) -> int:
return db.remove_candidates_without_collision()


def filter_EOA_nonce_collisions(db: DB):
sql = """
DELETE FROM collisions c
USING transactions
WHERE key = sender AND type = 'nonce'
"""
def filter_nonces(db: DB):
with db._con.cursor() as cursor:
cursor.execute(sql)
cursor.execute("DELETE FROM collisions WHERE type = 'nonce'")
return db.remove_candidates_without_collision()


def filter_codes(db: DB):
with db._con.cursor() as cursor:
cursor.execute("DELETE FROM collisions WHERE type = 'code'")
return db.remove_candidates_without_collision()


Expand Down
8 changes: 4 additions & 4 deletions tod_attack_miner/miner/miner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Sequence
from tod_attack_miner.db.db import DB, Candidate
from tod_attack_miner.db.filters import (
filter_EOA_nonce_collisions,
filter_codes,
filter_nonces,
filter_block_window,
filter_indirect_dependencies_recursive,
filter_indirect_dependencies_quick,
Expand Down Expand Up @@ -36,9 +37,8 @@ def filter_candidates(self, window_size: int | None) -> None:
self._filter_stats["filtered"]["block_producers"] = filter_block_producers(
self.db
)
self._filter_stats["filtered"]["eoa_nonces"] = filter_EOA_nonce_collisions(
self.db
)
self._filter_stats["filtered"]["nonces"] = filter_nonces(self.db)
self._filter_stats["filtered"]["codes"] = filter_codes(self.db)
self._filter_stats["filtered"]["indirect_dependencies_quick"] = (
filter_indirect_dependencies_quick(self.db)
)
Expand Down

0 comments on commit 5d882b8

Please sign in to comment.