Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from lidofinance/bugfix/update-when-no-unused-…
Browse files Browse the repository at this point in the history
…keys

Bugfix/update when no unused keys
  • Loading branch information
Raman Siamionau authored Nov 9, 2021
2 parents 9b9f277 + e153b30 commit 3b25a4d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[comment]: <> (## [Unreleased]&#40;https://github.com/lidofinance/lido-python-sdk&#41; - 2021-09-15)


## [2.4.1](https://github.com/lidofinance/lido-python-sdk) - 2021-11-09
### Added
- Fixed empty call_args when operators have zero unused keys while updating keys (`lido.update_keys`) ([#0054](https://github.com/lidofinance/lido-python-sdk/pull/54))

## [2.4.0](https://github.com/lidofinance/lido-python-sdk) - 2021-10-01
### Added
- Add ability to update keys in optimal way (`lido.update_keys`) ([#0050](https://github.com/lidofinance/lido-python-sdk/pull/50))
Expand Down
3 changes: 3 additions & 0 deletions lido_sdk/methods/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def get_keys_by_indexes(
@param call_args: List of operator_index and keys_index
@return: List of dicts (OperatorKey)
"""
if not call_args:
return []

keys = NodeOpsContract.getSigningKey_multicall(w3, call_args)

for key, (operator_index, key_index) in zip(keys, call_args):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lido-sdk"
version = "2.4.0"
version = "2.4.1"
description = "This library consolidates various functions to efficiently load network data for Lido, validate node operator keys and find key duplicates."
authors = ["Lido <[email protected]>"]
license = "MIT License"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
EMAIL = "[email protected]"
AUTHOR = "Lido"
REQUIRES_PYTHON = ">=3.7,<4"
VERSION = "2.4.0"
VERSION = "2.4.1"

# Detecting target platform
PLATFORMS = {"windows", "linux", "darwin", "cygwin", "android"}
Expand Down
37 changes: 37 additions & 0 deletions tests/test_lido.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,40 @@ def test_keys_update(self):
)
)
self.assertTrue(key["used"])

def test_keys_update_when_unused_keys_removed(self):
self.mocker.patch(
"lido_sdk.contract.load_contract.NodeOpsContract.getNodeOperatorsCount",
return_value={"": 2},
)
self.mocker.patch(
"lido_sdk.contract.load_contract.NodeOpsContract.getNodeOperator_multicall",
return_value=OPERATORS_DATA,
)
self.mocker.patch(
"lido_sdk.contract.load_contract.NodeOpsContract.getSigningKey_multicall",
return_value=OPERATORS_KEYS,
)

self.lido.get_operators_indexes()
self.lido.get_operators_data()
self.lido.get_operators_keys()

operators = copy.deepcopy(OPERATORS_DATA)
# All unused keys were removed (operator 0)
# All unused keys were removed (operator 1)
operators[0]["totalSigningKeys"] = 1
operators[0]["usedSigningKeys"] = 1
operators[1]["totalSigningKeys"] = 2
operators[1]["usedSigningKeys"] = 2

self.mocker.patch(
"lido_sdk.contract.load_contract.NodeOpsContract.getNodeOperator_multicall",
return_value=operators,
)

self.lido.update_keys()

# All unused keys were removed (operator 0)
# All unused keys were removed (operator 1)
self.assertEqual(len(self.lido.keys), 3)

0 comments on commit 3b25a4d

Please sign in to comment.