|
1 | 1 | import logging |
2 | 2 | from collections import defaultdict |
3 | | -from datetime import datetime |
4 | 3 | from time import sleep |
5 | | -from typing import cast |
6 | 4 |
|
7 | | -from eth_typing import ChecksumAddress |
8 | 5 | from hexbytes import HexBytes |
9 | 6 | from web3.exceptions import ContractCustomError |
10 | 7 | from web3.types import Wei |
11 | 8 |
|
12 | 9 | from src import variables |
13 | | -from src.constants import SHARE_RATE_PRECISION_E27, CURATED_MODULE_TYPE |
| 10 | +from src.constants import SHARE_RATE_PRECISION_E27 |
14 | 11 | from src.modules.accounting.third_phase.extra_data import ExtraDataService |
15 | 12 | from src.modules.accounting.third_phase.types import ExtraData, FormatList |
16 | 13 | from src.modules.accounting.types import ( |
|
34 | 31 | from src.metrics.prometheus.duration_meter import duration_meter |
35 | 32 | from src.modules.submodules.types import ZERO_HASH |
36 | 33 | from src.providers.execution.contracts.accounting_oracle import AccountingOracleContract |
37 | | -from src.providers.execution.contracts.staking_module import NodeOperatorRegistry |
38 | 34 | from src.services.validator_state import LidoValidatorStateService |
39 | 35 | from src.modules.submodules.consensus import ConsensusModule, InitialEpochIsYetToArriveRevert |
40 | 36 | from src.modules.submodules.oracle_module import BaseModule, ModuleExecuteDelay |
|
44 | 40 | from src.utils.cache import global_lru_cache as lru_cache |
45 | 41 | from src.utils.units import gwei_to_wei |
46 | 42 | from src.variables import ALLOW_REPORTING_IN_BUNKER_MODE |
47 | | -from src.web3py.extensions.tx_bundle import TransactionBundle |
48 | 43 | from src.web3py.types import Web3 |
49 | 44 | from src.web3py.extensions.lido_validators import StakingModule |
50 | 45 |
|
@@ -302,9 +297,8 @@ def simulate_rebase_after_report( |
302 | 297 | ) |
303 | 298 |
|
304 | 299 | def get_shares_to_burn(self, blockstamp: ReferenceBlockStamp) -> int: |
305 | | - # shares_data = self.w3.lido_contracts.burner.get_shares_requested_to_burn(blockstamp.block_hash) |
306 | | - # return shares_data.cover_shares + shares_data.non_cover_shares |
307 | | - return 0 |
| 300 | + shares_data = self.w3.lido_contracts.burner.get_shares_requested_to_burn(blockstamp.block_hash) |
| 301 | + return shares_data.cover_shares + shares_data.non_cover_shares |
308 | 302 |
|
309 | 303 | def _get_slots_elapsed_from_last_report(self, blockstamp: ReferenceBlockStamp): |
310 | 304 | chain_conf = self.get_chain_config(blockstamp) |
@@ -415,51 +409,3 @@ def _combine_report_parts( |
415 | 409 | extra_data_hash=extra_data.data_hash, |
416 | 410 | extra_data_items_count=extra_data.items_count, |
417 | 411 | ) |
418 | | - |
419 | | - |
420 | | - # --- TX bundling --- |
421 | | - @staticmethod |
422 | | - def _use_private_relays(blockstamp: ReferenceBlockStamp) -> bool: |
423 | | - # If BUNDLE_SEND_TIMEOUT seconds have passed since the reference slot was validated, use the classic flow to send the transaction. |
424 | | - return bool(variables.PRIVATE_RELAYS_LIST) and datetime.now().timestamp() <= blockstamp.block_timestamp + variables.BUNDLE_TIMEOUT_SECONDS |
425 | | - |
426 | | - def _get_sm_contract(self, address: ChecksumAddress) -> NodeOperatorRegistry: |
427 | | - return cast( |
428 | | - NodeOperatorRegistry, |
429 | | - self.w3.eth.contract( |
430 | | - address=address, |
431 | | - ContractFactoryClass=NodeOperatorRegistry, |
432 | | - ) |
433 | | - ) |
434 | | - |
435 | | - def _process_report_data(self, blockstamp: ReferenceBlockStamp, report_data: tuple, report_hash: HexBytes): |
436 | | - if not self._use_private_relays(blockstamp): |
437 | | - super()._process_report_data(blockstamp, report_data, report_hash) |
438 | | - return |
439 | | - |
440 | | - if not self._is_main_data_submittable(report_hash): |
441 | | - return |
442 | | - |
443 | | - contract_version = self.report_contract.get_contract_version(blockstamp.block_hash) |
444 | | - |
445 | | - logger.info({'msg': f'Send report data via private relay. Contract version: [{contract_version}]'}) |
446 | | - txs = [self.report_contract.submit_report_data(report_data, contract_version)] |
447 | | - |
448 | | - logger.info({'msg': 'Bundle extra data transactions.'}) |
449 | | - extra_data = self.get_extra_data(blockstamp) |
450 | | - if extra_data.format == FormatList.EXTRA_DATA_FORMAT_LIST_EMPTY.value: |
451 | | - txs.append(self.report_contract.submit_report_extra_data_empty()) |
452 | | - else: |
453 | | - for tx_data in extra_data.extra_data_list: |
454 | | - txs.append(self.report_contract.submit_report_extra_data_list(tx_data)) |
455 | | - |
456 | | - logger.info({'msg': 'Bundle reward distribution transactions.'}) |
457 | | - staking_modules = self.w3.lido_contracts.staking_router.get_staking_modules() |
458 | | - for staking_module in staking_modules: |
459 | | - ism: NodeOperatorRegistry = self._get_sm_contract(staking_module.staking_module_address) |
460 | | - |
461 | | - if ism.get_type() == CURATED_MODULE_TYPE: |
462 | | - txs.append(ism.distribute_reward()) |
463 | | - |
464 | | - logger.info({'msg': f'Prepared bundle. Txs count: {len(txs)}'}) |
465 | | - TransactionBundle.send_tx_bundle(self.w3, txs) |
0 commit comments