From ca30f9f1c9d7a8e954c779f4a46c010b8c471100 Mon Sep 17 00:00:00 2001 From: Conventional Changelog Action Date: Fri, 22 Nov 2024 21:00:03 +0000 Subject: [PATCH 01/10] chore(release): 4.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ce14cc55d..d9d1838ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "lido-oracle" -version = "4.1.0" +version = "4.1.1" description = "Oracle daemon for Lido decentralized staking service. Collects and reports Ethereum 2.0 beacon chain states (the number of visible validators and their summarized balances) to the Lido dApp contract running on Ethereum 1.0 side." authors = [ "Dmitry Chernukhin", From b2377f81a00eb78519177336deaf7b9765126d66 Mon Sep 17 00:00:00 2001 From: F4ever Date: Tue, 11 Feb 2025 20:53:57 +0100 Subject: [PATCH 02/10] fix: `test_calculate_cl_rebase_between_blocks` --- tests/modules/accounting/bunker/conftest.py | 9 +++++---- .../bunker/test_bunker_abnormal_cl_rebase.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/modules/accounting/bunker/conftest.py b/tests/modules/accounting/bunker/conftest.py index 68b01e80e..b7fdcffa2 100644 --- a/tests/modules/accounting/bunker/conftest.py +++ b/tests/modules/accounting/bunker/conftest.py @@ -109,7 +109,8 @@ def _get_eth_distributed_events(from_block: BlockNumber, to_block: BlockNumber): (1, 10): [{'args': {'withdrawalsWithdrawn': 1 * 10**18}}], (1, 20): [{'args': {'withdrawalsWithdrawn': 1 * 10**18}}], (11, 20): [], - (21, 30): [ + (21, 30): [], + (21, 31): [ {'args': {'withdrawalsWithdrawn': 7 * 10**18}}, {'args': {'withdrawalsWithdrawn': 5 * 10**18}}, ], @@ -153,9 +154,9 @@ def _get_validators(state: ReferenceBlockStamp, _=None): simple_validator(5, '0x05', 32 * 10**9), ], 10: [ - simple_validator(0, '0x00', 15 + 32 * 10**9), - simple_validator(1, '0x01', 17 + 32 * 10**9), - simple_validator(2, '0x02', 63 + 32 * 10**9), + simple_validator(0, '0x00', (32 * 10**9) + 15), + simple_validator(1, '0x01', (32 * 10**9) + 17), + simple_validator(2, '0x02', (32 * 10**9) + 63), simple_validator(3, '0x03', (32 * 10**9) + 1), simple_validator(4, '0x04', 32 * 10**9), simple_validator(5, '0x05', (32 * 10**9) + 99), diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index a85c46288..546f7a9f3 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -198,8 +198,13 @@ def test_get_nearest_and_distant_blockstamps( @pytest.mark.parametrize( ("prev_blockstamp", "blockstamp", "expected_rebase"), [ - (simple_ref_blockstamp(0), simple_ref_blockstamp(10), 100), - (simple_ref_blockstamp(10), simple_ref_blockstamp(20), -32000100800), + # the same count of validators, 1 ETH used to finalize requests, new val balance is more than previous + (simple_ref_blockstamp(0), simple_ref_blockstamp(10), 195), + # the same count of validators, 1 ETH used to finalize requests, new val balance is less than previous + (simple_ref_blockstamp(0), simple_ref_blockstamp(20), -(32 * 10**9) - 100700), + # new count of validators, no ETH used to finalize requests, new val balance is more than previous + (simple_ref_blockstamp(30), simple_ref_blockstamp(40), 1157445), + # new validators count is less than previous, should be exception ( simple_ref_blockstamp(20), simple_ref_blockstamp(30), @@ -216,12 +221,11 @@ def test_calculate_cl_rebase_between_blocks( blockstamp, expected_rebase, ): - abnormal_case.lido_validators = abnormal_case.w3.cc.get_validators(blockstamp)[3:6] abnormal_case.lido_keys = [ - simple_key('0x03'), - simple_key('0x04'), - simple_key('0x05'), + simple_key(v.validator.pubkey) for v in abnormal_case.w3.cc.get_validators(simple_ref_blockstamp(0)) ] + abnormal_case.lido_validators = abnormal_case.w3.cc.get_validators(blockstamp) + abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2) if isinstance(expected_rebase, str): with pytest.raises(ValueError, match=expected_rebase): abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, blockstamp) @@ -257,7 +261,7 @@ def test_get_lido_validators_balance_with_vault( [ (simple_ref_blockstamp(0), simple_ref_blockstamp(10), 1 * 10**9), (simple_ref_blockstamp(10), simple_ref_blockstamp(20), 0), - (simple_ref_blockstamp(20), simple_ref_blockstamp(30), "More than one ETHDistributed event found"), + (simple_ref_blockstamp(20), simple_ref_blockstamp(31), "More than one ETHDistributed event found"), ], ) def test_get_withdrawn_from_vault_between( From 85de8265ebc9e1284856f2222d548fb263dcb14f Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Tue, 11 Feb 2025 20:33:08 +0100 Subject: [PATCH 03/10] fix: `_calculate_cl_rebase_between_blocks` rebase calculation --- src/services/bunker_cases/abnormal_cl_rebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/bunker_cases/abnormal_cl_rebase.py b/src/services/bunker_cases/abnormal_cl_rebase.py index ef74a7fca..b75f71bcc 100644 --- a/src/services/bunker_cases/abnormal_cl_rebase.py +++ b/src/services/bunker_cases/abnormal_cl_rebase.py @@ -199,7 +199,7 @@ def _calculate_cl_rebase_between_blocks( withdrawn_from_vault = self._get_withdrawn_from_vault_between_blocks(prev_blockstamp, ref_blockstamp) # Finally, we can calculate corrected CL rebase - cl_rebase = Gwei(raw_cl_rebase + validators_count_diff_in_gwei + withdrawn_from_vault) + cl_rebase = Gwei(raw_cl_rebase - validators_count_diff_in_gwei + withdrawn_from_vault) logger.info( { From d9fc4dec3bcdc57da1962b3acebb14d312f6e527 Mon Sep 17 00:00:00 2001 From: F4ever Date: Tue, 11 Feb 2025 21:10:02 +0100 Subject: [PATCH 04/10] fix: import error --- .../modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index 546f7a9f3..7e26ea2b0 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -1,5 +1,7 @@ import pytest +from unittest.mock import Mock + from src.constants import FAR_FUTURE_EPOCH from src.providers.consensus.types import Validator, ValidatorStatus, ValidatorState from src.services.bunker_cases.abnormal_cl_rebase import AbnormalClRebase From fc059c5962bed53748012ac3afa1ad93037aefc2 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 12 Feb 2025 16:02:55 +0100 Subject: [PATCH 05/10] refactor: `test_calculate_cl_rebase_between_blocks` --- .../bunker/test_bunker_abnormal_cl_rebase.py | 196 +++++++++++++++--- 1 file changed, 170 insertions(+), 26 deletions(-) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index 7e26ea2b0..b8a596120 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -2,12 +2,22 @@ from unittest.mock import Mock +from faker import Faker + from src.constants import FAR_FUTURE_EPOCH from src.providers.consensus.types import Validator, ValidatorStatus, ValidatorState from src.services.bunker_cases.abnormal_cl_rebase import AbnormalClRebase from src.services.bunker_cases.types import BunkerConfig +from src.types import Gwei +from src.web3py.extensions import LidoValidatorsProvider +from src.web3py.types import Web3 +from tests.factory.blockstamp import ReferenceBlockStampFactory +from tests.factory.configs import ChainConfigFactory, BunkerConfigFactory +from tests.factory.no_registry import LidoValidatorFactory from tests.modules.accounting.bunker.conftest import simple_ref_blockstamp, simple_key, simple_blockstamp +faker = Faker() + def simple_validators( from_index: int, @@ -198,41 +208,175 @@ def test_get_nearest_and_distant_blockstamps( @pytest.mark.unit @pytest.mark.parametrize( - ("prev_blockstamp", "blockstamp", "expected_rebase"), + ( + "prev_lido_validators", + "curr_lido_validators", + "prev_withdrawals_vault_balance", # wei + "curr_withdrawals_vault_balance", # wei + "withdrawn_from_vault", # Gwei + "expected_rebase", # Gwei + ), [ - # the same count of validators, 1 ETH used to finalize requests, new val balance is more than previous - (simple_ref_blockstamp(0), simple_ref_blockstamp(10), 195), - # the same count of validators, 1 ETH used to finalize requests, new val balance is less than previous - (simple_ref_blockstamp(0), simple_ref_blockstamp(20), -(32 * 10**9) - 100700), - # new count of validators, no ETH used to finalize requests, new val balance is more than previous - (simple_ref_blockstamp(30), simple_ref_blockstamp(40), 1157445), - # new validators count is less than previous, should be exception ( - simple_ref_blockstamp(20), - simple_ref_blockstamp(30), - "Validators count diff should be positive or 0. Something went wrong with CL API", + # The same count of validators, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # but current validators have more balance (has non-withdrawn rewards). + LidoValidatorFactory.batch(10, balance=(32 * 10**9) + Gwei(100_000)), + # Previous withdrawals vault balance the same as current + 15 * 10**18, + 15 * 10**18, + # and nothing was withdrawn from the vault. + Gwei(0), + # Rebase is equal non-withdrawn rewards from vals above. + Gwei(10 * 100_000), + ), + ( + # The same count of validators, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # and the same balance. + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # Previous withdrawals vault balance the same as current + 15 * 10**18, + 15 * 10**18, + # and rewards was withdrawn from the vault. + Gwei(10 * 100_000), + # Rebase is equal withdrawn rewards. + Gwei(10 * 100_000), + ), + ( + # New vals count is more than previous, + LidoValidatorFactory.batch(9, balance=32 * 10**9), + # and have the same balance. + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # Previous withdrawals vault balance the same as current + 15 * 10**18, + 15 * 10**18, + # and nothing was withdrawn from the vault. + Gwei(0), + # Rebase should be equal to 0 because validators diff has been accounted. + Gwei(0), + ), + ( + # The same count of validators, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # but some validators have less balance (has penalties). + [ + *LidoValidatorFactory.batch(5, balance=(32 * 10**9) - Gwei(100_000)), + *LidoValidatorFactory.batch(5, balance=32 * 10**9), + ], + # Previous withdrawals vault balance the same as current. + 15 * 10**18, + 15 * 10**18, + # rewards was withdrawn from the vault. + Gwei(10 * 100_000), + # Rebase is equal to rewards minus penalties. + Gwei(5 * 100_000), + ), + ( + # The same count of validators, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # but some validators have less balance (has penalties). + [ + *LidoValidatorFactory.batch(5, balance=(32 * 10**9) - Gwei(100_000)), + *LidoValidatorFactory.batch(5, balance=32 * 10**9), + ], + # Current withdrawals vault balance is more than previous because some rewards were withdrawn + 15 * 10**18, + 15 * 10**18 + Web3.to_wei(10 * 100_000, 'gwei'), + # but wasn't withdrawn from the vault. + Gwei(0), + # Rebase is equal to rewards on vault minus penalties + Gwei(5 * 100_000), + ), + ( + # New vals count is more than previous, + LidoValidatorFactory.batch(9, balance=32 * 10**9), + # but some validators have less balance (has penalties). + # and another part has non-withdrawn rewards. + [ + *LidoValidatorFactory.batch(5, balance=(32 * 10**9) - Gwei(100_000)), + *LidoValidatorFactory.batch(5, balance=(32 * 10**9) + Gwei(100_000)), + ], + # Current withdrawals vault balance is more than previous + # because some were got between withdrawal event and ref block, + 15 * 10**18, + 15 * 10**18 + Web3.to_wei(100_000, 'gwei'), + # and some were withdrawn from the vault. + Gwei(10 * 100_000), + # Rebase is equal to rewards withdrawn from vault plus diff between vaults balances + Gwei(10 * 100_000 + 100_000), + ), + ( + # New vals count is more than previous, + LidoValidatorFactory.batch(9, balance=32 * 10**9), + # but some validators have less balance (has penalties). + [ + *LidoValidatorFactory.batch(5, balance=(32 * 10**9) - Gwei(100_000)), + *LidoValidatorFactory.batch(5, balance=32 * 10**9), + ], + # Current withdrawals vault balance is less than previous + 15 * 10**18, + 15 * 10**18 - Web3.to_wei(10 * 100_000, 'gwei'), + # because were withdrawn from the vault. + Gwei(10 * 100_000), + # Rebase is equal to penalties. Validators diff has been accounted + Gwei(-5 * 100_000), + ), + ( + # The same count of validators, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # but current validators have less balance (has penalties). + LidoValidatorFactory.batch(10, balance=(32 * 10**9) - Gwei(100_000)), + # Previous withdrawals vault balance the same as current + 15 * 10**18, + 15 * 10**18, + # nothing was withdrawn from the vault. + Gwei(0), + # Rebase is equal to penalties. + Gwei(-10 * 100_000), + ), + ( + # New vals count is less than previous, + LidoValidatorFactory.batch(10, balance=32 * 10**9), + # and have the same balance + LidoValidatorFactory.batch(9, balance=32 * 10**9), + faker.pyint(), + faker.pyint(), + faker.pyint(), + # It is exception because new vals count can't be less that previous + ValueError("Validators count diff should be positive or 0. Something went wrong with CL API"), ), ], ) def test_calculate_cl_rebase_between_blocks( - abnormal_case, - mock_get_eth_distributed_events, - mock_get_withdrawal_vault_balance, - mock_get_blockstamp, - prev_blockstamp, - blockstamp, + web3, + prev_lido_validators, + curr_lido_validators, + prev_withdrawals_vault_balance, + curr_withdrawals_vault_balance, + withdrawn_from_vault, expected_rebase, ): - abnormal_case.lido_keys = [ - simple_key(v.validator.pubkey) for v in abnormal_case.w3.cc.get_validators(simple_ref_blockstamp(0)) - ] - abnormal_case.lido_validators = abnormal_case.w3.cc.get_validators(blockstamp) - abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2) - if isinstance(expected_rebase, str): - with pytest.raises(ValueError, match=expected_rebase): - abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, blockstamp) + prev_blockstamp = ReferenceBlockStampFactory.build(block_number=8) + ref_blockstamp = ReferenceBlockStampFactory.build(block_number=88) + abnormal_case = AbnormalClRebase(web3, ChainConfigFactory.build(), BunkerConfigFactory.build()) + abnormal_case.lido_keys = Mock() + abnormal_case.w3.cc = Mock() + abnormal_case.w3.lido_contracts = Mock() + abnormal_case.w3.cc.get_validators_no_cache = Mock() + + LidoValidatorsProvider.merge_validators_with_keys = Mock(return_value=prev_lido_validators) + abnormal_case.lido_validators = curr_lido_validators + abnormal_case.w3.lido_contracts.get_withdrawal_balance_no_cache = Mock( + side_effect=[curr_withdrawals_vault_balance, prev_withdrawals_vault_balance] + ) + abnormal_case._get_withdrawn_from_vault_between_blocks = Mock(return_value=withdrawn_from_vault) + + if isinstance(expected_rebase, Exception): + with pytest.raises(ValueError, match=expected_rebase.args[0]): + abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, ref_blockstamp) else: - result = abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, blockstamp) + result = abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, ref_blockstamp) assert result == expected_rebase From c5bc4a95c80d350719077c060b39173443eac557 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 12 Feb 2025 16:55:41 +0100 Subject: [PATCH 06/10] fix: remove faker --- .../bunker/test_bunker_abnormal_cl_rebase.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index b8a596120..fe272f4e0 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -4,7 +4,7 @@ from faker import Faker -from src.constants import FAR_FUTURE_EPOCH +from src.constants import FAR_FUTURE_EPOCH, UINT64_MAX from src.providers.consensus.types import Validator, ValidatorStatus, ValidatorState from src.services.bunker_cases.abnormal_cl_rebase import AbnormalClRebase from src.services.bunker_cases.types import BunkerConfig @@ -16,8 +16,6 @@ from tests.factory.no_registry import LidoValidatorFactory from tests.modules.accounting.bunker.conftest import simple_ref_blockstamp, simple_key, simple_blockstamp -faker = Faker() - def simple_validators( from_index: int, @@ -340,9 +338,9 @@ def test_get_nearest_and_distant_blockstamps( LidoValidatorFactory.batch(10, balance=32 * 10**9), # and have the same balance LidoValidatorFactory.batch(9, balance=32 * 10**9), - faker.pyint(), - faker.pyint(), - faker.pyint(), + UINT64_MAX, + UINT64_MAX, + UINT64_MAX, # It is exception because new vals count can't be less that previous ValueError("Validators count diff should be positive or 0. Something went wrong with CL API"), ), From 1b3caa4540a83383c2a27fefdbce8c0d53cc95ab Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Wed, 12 Feb 2025 17:18:40 +0100 Subject: [PATCH 07/10] fix: use monkeypatch --- .../accounting/bunker/test_bunker_abnormal_cl_rebase.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index fe272f4e0..0a27a8927 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -347,6 +347,7 @@ def test_get_nearest_and_distant_blockstamps( ], ) def test_calculate_cl_rebase_between_blocks( + monkeypatch, web3, prev_lido_validators, curr_lido_validators, @@ -363,7 +364,12 @@ def test_calculate_cl_rebase_between_blocks( abnormal_case.w3.lido_contracts = Mock() abnormal_case.w3.cc.get_validators_no_cache = Mock() - LidoValidatorsProvider.merge_validators_with_keys = Mock(return_value=prev_lido_validators) + with monkeypatch.context(): + monkeypatch.setattr( + LidoValidatorsProvider, + "merge_validators_with_keys", + Mock(return_value=prev_lido_validators), + ) abnormal_case.lido_validators = curr_lido_validators abnormal_case.w3.lido_contracts.get_withdrawal_balance_no_cache = Mock( side_effect=[curr_withdrawals_vault_balance, prev_withdrawals_vault_balance] From 8a087eeb99391b2873a6178eedd31c11ab4179da Mon Sep 17 00:00:00 2001 From: F4ever Date: Wed, 12 Feb 2025 17:28:47 +0100 Subject: [PATCH 08/10] remove unused import --- .../modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index fe272f4e0..680c0f450 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -2,8 +2,6 @@ from unittest.mock import Mock -from faker import Faker - from src.constants import FAR_FUTURE_EPOCH, UINT64_MAX from src.providers.consensus.types import Validator, ValidatorStatus, ValidatorState from src.services.bunker_cases.abnormal_cl_rebase import AbnormalClRebase From b52550df962b08fda8e2fdfd0a6a2e1e3d6be402 Mon Sep 17 00:00:00 2001 From: Conventional Changelog Action Date: Wed, 12 Feb 2025 22:07:18 +0000 Subject: [PATCH 09/10] chore(release): 4.1.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d9d1838ab..f28558cfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "lido-oracle" -version = "4.1.1" +version = "4.1.2" description = "Oracle daemon for Lido decentralized staking service. Collects and reports Ethereum 2.0 beacon chain states (the number of visible validators and their summarized balances) to the Lido dApp contract running on Ethereum 1.0 side." authors = [ "Dmitry Chernukhin", From ce28c2e16830c088bef7aeb880cc3789466a20cd Mon Sep 17 00:00:00 2001 From: F4ever Date: Thu, 13 Feb 2025 10:39:35 +0100 Subject: [PATCH 10/10] fix imports and missing mocks --- .../bunker/test_bunker_abnormal_cl_rebase.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py index 407381785..81735229e 100644 --- a/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py +++ b/tests/modules/accounting/bunker/test_bunker_abnormal_cl_rebase.py @@ -1,19 +1,17 @@ -from unittest.mock import Mock - import pytest from unittest.mock import Mock -from src.constants import FAR_FUTURE_EPOCH, UINT64_MAX -from src.providers.consensus.types import Validator, ValidatorStatus, ValidatorState +from src.constants import FAR_FUTURE_EPOCH, UINT64_MAX, LIDO_DEPOSIT_AMOUNT +from src.providers.consensus.types import Validator, ValidatorState from src.services.bunker_cases.abnormal_cl_rebase import AbnormalClRebase from src.services.bunker_cases.types import BunkerConfig -from src.types import Gwei +from src.types import Gwei, ValidatorIndex, EpochNumber from src.web3py.extensions import LidoValidatorsProvider from src.web3py.types import Web3 from tests.factory.blockstamp import ReferenceBlockStampFactory from tests.factory.configs import ChainConfigFactory, BunkerConfigFactory -from tests.factory.no_registry import LidoValidatorFactory +from tests.factory.no_registry import LidoValidatorFactory, PendingDepositFactory from tests.modules.accounting.bunker.conftest import simple_ref_blockstamp, simple_key, simple_blockstamp @@ -378,6 +376,7 @@ def test_calculate_cl_rebase_between_blocks( side_effect=[curr_withdrawals_vault_balance, prev_withdrawals_vault_balance] ) abnormal_case._get_withdrawn_from_vault_between_blocks = Mock(return_value=withdrawn_from_vault) + abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=3) if isinstance(expected_rebase, Exception): with pytest.raises(ValueError, match=expected_rebase.args[0]):