Skip to content

Commit de91bc1

Browse files
authored
Remove redundant checks for receipt validation (ethereum#1500)
1 parent d3e1a9d commit de91bc1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

eth/vm/base.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Tuple,
1515
Type,
1616
)
17+
from typing import Set # noqa: F401
1718

1819
import rlp
1920

@@ -756,19 +757,29 @@ def get_transaction_class(cls) -> Type[BaseTransaction]:
756757
#
757758
@classmethod
758759
def validate_receipt(cls, receipt: Receipt) -> None:
760+
already_checked = set() # type: Set[Hash32]
761+
759762
for log_idx, log in enumerate(receipt.logs):
760-
if log.address not in receipt.bloom_filter:
763+
if log.address in already_checked:
764+
continue
765+
elif log.address not in receipt.bloom_filter:
761766
raise ValidationError(
762767
"The address from the log entry at position {0} is not "
763768
"present in the provided bloom filter.".format(log_idx)
764769
)
770+
already_checked.add(log.address)
771+
772+
for log_idx, log in enumerate(receipt.logs):
765773
for topic_idx, topic in enumerate(log.topics):
766-
if uint32.serialize(topic) not in receipt.bloom_filter:
774+
if topic in already_checked:
775+
continue
776+
elif uint32.serialize(topic) not in receipt.bloom_filter:
767777
raise ValidationError(
768778
"The topic at position {0} from the log entry at "
769779
"position {1} is not present in the provided bloom "
770780
"filter.".format(topic_idx, log_idx)
771781
)
782+
already_checked.add(topic)
772783

773784
def validate_block(self, block: BaseBlock) -> None:
774785
"""

0 commit comments

Comments
 (0)