From b7676e7a0df8529105fc95ba5860d3a1bbc5dadf Mon Sep 17 00:00:00 2001 From: hweawer Date: Mon, 3 Feb 2025 17:02:32 +0100 Subject: [PATCH 1/2] Fetch constants latest block --- src/modules/accounting/accounting.py | 2 +- .../execution/contracts/oracle_report_sanity_checker.py | 1 - src/providers/execution/contracts/withdrawal_queue_nft.py | 1 - src/services/exit_order_iterator.py | 7 ++----- src/services/safe_border.py | 2 +- src/services/withdrawal.py | 2 +- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/modules/accounting/accounting.py b/src/modules/accounting/accounting.py index ba3f43300..056873cb2 100644 --- a/src/modules/accounting/accounting.py +++ b/src/modules/accounting/accounting.py @@ -347,7 +347,7 @@ def _get_generic_extra_data(self, blockstamp: ReferenceBlockStamp) -> GenericExt logger.info({'msg': 'Calculate stuck validators.', 'value': stuck_validators}) exited_validators = self.lido_validator_state_service.get_lido_newly_exited_validators(blockstamp) logger.info({'msg': 'Calculate exited validators.', 'value': exited_validators}) - orl = self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits(blockstamp.block_hash) + orl = self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits() return stuck_validators, exited_validators, orl # fetches validators_count, cl_balance, withdrawal_balance, el_vault_balance, shares_to_burn diff --git a/src/providers/execution/contracts/oracle_report_sanity_checker.py b/src/providers/execution/contracts/oracle_report_sanity_checker.py index 499676ca2..ec53f407e 100644 --- a/src/providers/execution/contracts/oracle_report_sanity_checker.py +++ b/src/providers/execution/contracts/oracle_report_sanity_checker.py @@ -14,7 +14,6 @@ class OracleReportSanityCheckerContract(ContractInterface): abi_path = './assets/OracleReportSanityChecker.json' - @lru_cache(maxsize=1) def get_oracle_report_limits(self, block_identifier: BlockIdentifier = 'latest') -> OracleReportLimits: """ Returns the limits list for the Lido's oracle report sanity checks diff --git a/src/providers/execution/contracts/withdrawal_queue_nft.py b/src/providers/execution/contracts/withdrawal_queue_nft.py index 4671c000f..31e1fba4b 100644 --- a/src/providers/execution/contracts/withdrawal_queue_nft.py +++ b/src/providers/execution/contracts/withdrawal_queue_nft.py @@ -107,7 +107,6 @@ def is_paused(self, block_identifier: BlockIdentifier = 'latest') -> bool: }) return response - @lru_cache(maxsize=1) def max_batches_length(self, block_identifier: BlockIdentifier = 'latest') -> int: """ maximal length of the batch array provided for prefinalization. diff --git a/src/services/exit_order_iterator.py b/src/services/exit_order_iterator.py index d12eeeb55..5d459d6be 100644 --- a/src/services/exit_order_iterator.py +++ b/src/services/exit_order_iterator.py @@ -12,7 +12,6 @@ from src.web3py.extensions.lido_validators import LidoValidator, StakingModule, NodeOperator, NodeOperatorLimitMode from src.web3py.types import Web3 - logger = logging.getLogger(__name__) @@ -149,9 +148,8 @@ def _calculate_lido_stats(self): self.node_operators_stats[gid].soft_exit_to = self.node_operators_stats[gid].node_operator.target_validators_count def _load_blockchain_state(self): - self.max_validators_to_exit = self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits( - self.blockstamp.block_hash, - ).max_validator_exit_requests_per_report + self.max_validators_to_exit = (self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits() + .max_validator_exit_requests_per_report) self.no_penetration_threshold = self.w3.lido_contracts.oracle_daemon_config.node_operator_network_penetration_threshold_bp( block_identifier=self.blockstamp.block_hash, @@ -180,7 +178,6 @@ def _get_delayed_validators(self) -> dict[NodeOperatorGlobalIndex, int]: result = {} for gid, validators_list in lido_validators.items(): - def is_delayed(validator: LidoValidator) -> bool: requested_to_exit = validator.index <= last_requested_to_exit[gid] recently_requested_to_exit = validator.index in recent_requests[gid] diff --git a/src/services/safe_border.py b/src/services/safe_border.py index 00625140c..f5a9ab2f9 100644 --- a/src/services/safe_border.py +++ b/src/services/safe_border.py @@ -57,7 +57,7 @@ def __init__( self._retrieve_constants() def _retrieve_constants(self): - limits_list = self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits(self.blockstamp.block_hash) + limits_list = self.w3.lido_contracts.oracle_report_sanity_checker.get_oracle_report_limits() self.finalization_default_shift = math.ceil( limits_list.request_timestamp_margin / (self.chain_config.slots_per_epoch * self.chain_config.seconds_per_slot) diff --git a/src/services/withdrawal.py b/src/services/withdrawal.py index ada3d5a41..57bbdb011 100644 --- a/src/services/withdrawal.py +++ b/src/services/withdrawal.py @@ -82,7 +82,7 @@ def _calculate_finalization_batches( available_eth: int, until_timestamp: int ) -> list[int]: - max_length = self.w3.lido_contracts.withdrawal_queue_nft.max_batches_length(self.blockstamp.block_hash) + max_length = self.w3.lido_contracts.withdrawal_queue_nft.max_batches_length() state = BatchState( remaining_eth_budget=available_eth, From 8d796c587279effbef88d0f9116e2f44696723de Mon Sep 17 00:00:00 2001 From: hweawer Date: Mon, 3 Feb 2025 21:19:30 +0100 Subject: [PATCH 2/2] Fix tests --- .../test_withdrawal_integration.py/test_happy_path.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fixtures/tests/modules/accounting/test_withdrawal_integration.py/test_happy_path.json b/fixtures/tests/modules/accounting/test_withdrawal_integration.py/test_happy_path.json index 2f8b7f796..cd66099db 100644 --- a/fixtures/tests/modules/accounting/test_withdrawal_integration.py/test_happy_path.json +++ b/fixtures/tests/modules/accounting/test_withdrawal_integration.py/test_happy_path.json @@ -6,7 +6,7 @@ "to": "0x8D49f1b4AF30598679D4D37Be4B094da1b459b82", "data": "0xa3a3fd5d" }, - "0x8ee61584b9d3e010c55f1fa77a803051f5f783385ec75b4e3fc71e199a86184d" + "latest" ], "response": { "jsonrpc": "2.0", @@ -195,7 +195,7 @@ "to": "0x4c1F6cA213abdbc19b27f2562d7b1A645A019bD9", "data": "0x29fd065d" }, - "0x8ee61584b9d3e010c55f1fa77a803051f5f783385ec75b4e3fc71e199a86184d" + "latest" ], "response": { "jsonrpc": "2.0", @@ -218,4 +218,4 @@ "result": "0x0000000000000000000000000000000000000000000000037d3047cdfd698705000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000030af00000000000000000000000000000000000000000000000000000000000030c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002" } } -] \ No newline at end of file +]