Conversation
@@ -120,7 +122,7 @@ def get_logs(self, block_number: BlockNumber) -> Tuple[DepositLog, ...]: | |||
} | |||
) | |||
processed_logs = tuple( | |||
self._deposit_contract.events.DepositEvent().processLog(log) for log in logs | |||
self._deposit_contract.events.DepositEvent.processLog(log) for log in logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This raised a "DepositEvent
is not callable" error in mypy. This is a bug in web3's typing I think: ethereum/web3.py#1646
But since processLog
is callable as a classmethod, and that usage makes more sense here anyhow, I just switched it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, oof, there's no clean way out of this. Will just have to type: ignore, because: ethereum/web3.py#1648
e2bb7c0
to
5171988
Compare
The wheel cli was the missing |
web3.py and eth-tester both had stricter old eth-keys dependencies, so they also need an update.
The old eth-account had an eth-keys version that was incompatible.
b570345
to
858452f
Compare
Hey, sorry to bother you with something so minor @hwwhww but since it touches eth2 code I thought I'd at least send a heads-up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One exception handling suggestion, otherwise LGTM 👍
@@ -189,7 +172,9 @@ def get_block(self, arg: Union[Hash32, int, str]) -> Optional[Eth1Block]: | |||
) | |||
# If `arg` is block hash | |||
elif isinstance(arg, bytes): | |||
block_number = int.from_bytes(arg, byteorder="big") | |||
block_hash = Hash32(arg) | |||
# Why are we interpreting the block hash as a block number here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I'm not certain, but this is FakeEth1DataProvider
, the real one is Web3Eth1DataProvider
, so it can be filled with whatever block_number
for testing.
processed_logs = tuple( | ||
self._deposit_contract.events.DepositEvent().processLog(log) for log in logs | ||
processed_logs = self._deposit_contract.events.DepositEvent.getLogs( | ||
fromBlock=block_number, toBlock=block_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to double confirm: address
& topics
arguments can be removed because it has been initialized in __init__
: self._deposit_contract = self.w3.eth.contract(address=deposit_contract_address, abi=deposit_contract_abi)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Exactly
- Require 5.10.0 for IPCProvider(pathlib.Path) type support - Ignore a few event log parsing type warnings, will fix them next, by using a new v5 API to simplify the logic and avoid the warnings.
Has the side benefit of avoiding type issues
No need to raise a `ValueError`, just break and allow the `Eth1BlockNotFound` to be raised below. Co-authored-by: Hsiao-Wei Wang <hwwang156@gmail.com>
What was wrong?
Fixes #1724
How was it fixed?
Upgraded various libraries. web3.py seems to have started exporting types since the last version, so a lot of new type warnings were triggered.
To-Do
Cute Animal Picture