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

Commit 2fed529

Browse files
veoxcburgdorf
authored andcommitted
eth1_monitor: fix endianness when storing in DB.
With the `web3.py` v4->v5 change, the `log.amount` was now passed as `bytes`, so there's a chance there's something wrong with the ABI. (When `web3` v4 was being used, this type conversion was not needed.) Plain conversion to `int` results is test errors: wrong amount, and subsequently wrong data (local DB deposit data corrupted). This is because the data obtained from the log / event object, as emitted by the contract, is of different endianness. To fix this and arising typing issues, instead use a "dead code" function from `DepositLog` and a double-pass to first obtain/process the logs (raw data), and then populate objects (with typing).
1 parent 7594cd3 commit 2fed529

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

trinity/components/eth2/eth1_monitor/eth1_data_provider.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ def get_logs(self, block_number: BlockNumber) -> Tuple[DepositLog, ...]:
119119
"topics": [self._deposit_event_topic],
120120
}
121121
)
122-
parsed_logs = tuple(
123-
self._deposit_contract.events.DepositEvent().processLog(log)['args']
122+
processed_logs = tuple(
123+
self._deposit_contract.events.DepositEvent().processLog(log)
124124
for log in logs
125125
)
126+
parsed_logs = tuple(
127+
DepositLog.from_contract_log_dict(log)
128+
for log in processed_logs
129+
)
126130
return parsed_logs
127131

128132
def get_deposit_count(self, block_number: BlockNumber) -> bytes:

trinity/components/eth2/eth1_monitor/eth1_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def _process_logs(
326326
self, logs: Sequence[DepositLog], block_number: BlockNumber
327327
) -> None:
328328
"""
329-
Simply store the deposit data from the log, and increase the corresponding block's
329+
Store deposit data from the log in database, and increase the corresponding block's
330330
`deposit_count`.
331331
"""
332332
seq_deposit_data = tuple(

0 commit comments

Comments
 (0)