Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit 7594cd3

Browse files
veoxcburgdorf
authored andcommitted
eth1_monitor: process logs by using web3's Contracts API.
`get_event_data` has moved from web3.utils to web3._utils, an internal sub-module. Shouldn't be using it.
1 parent 53526fd commit 7594cd3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

trinity/components/eth2/eth1_monitor/eth1_data_provider.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from eth_utils import encode_hex, event_abi_to_log_topic
99

1010
from web3 import Web3
11-
from web3.utils.events import get_event_data
1211

1312
from eth2.beacon.constants import GWEI_PER_ETH
1413
from eth2.beacon.tools.builder.validator import make_deposit_tree_and_root
@@ -108,8 +107,10 @@ def get_block(self, arg: Union[Hash32, int, str]) -> Optional[Eth1Block]:
108107
)
109108

110109
def get_logs(self, block_number: BlockNumber) -> Tuple[DepositLog, ...]:
111-
# NOTE: web3 v4 does not support `contract.events.Event.getLogs`.
112-
# After upgrading to v5, we can change to use the function.
110+
# NOTE: this installs/uninstalls an event filter; we could forego
111+
# this if we had a transaction receipt or transaction hash instead;
112+
# however, that only makes sense when monitoring unmined txs: it's
113+
# otherwise easier to process entire blocks of deposits as batches
113114
logs = self.w3.eth.getLogs(
114115
{
115116
"fromBlock": block_number,
@@ -119,9 +120,7 @@ def get_logs(self, block_number: BlockNumber) -> Tuple[DepositLog, ...]:
119120
}
120121
)
121122
parsed_logs = tuple(
122-
DepositLog.from_contract_log_dict(
123-
get_event_data(self._deposit_event_abi, log)
124-
)
123+
self._deposit_contract.events.DepositEvent().processLog(log)['args']
125124
for log in logs
126125
)
127126
return parsed_logs

0 commit comments

Comments
 (0)