Skip to content

Commit aeca7a0

Browse files
fix: address review comments - dsm and locator checks
1 parent b9c0084 commit aeca7a0

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

scripts/vote_edf_hoodi.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from utils.agent import agent_forward
3333
from utils.config import (
34+
AGENT,
3435
LIDO_LOCATOR,
3536
STAKING_ROUTER,
3637
get_deployer_account,
@@ -206,9 +207,17 @@ def _assert_state_before_vote() -> None:
206207
)
207208

208209
# The vote does not change DSM guardians, so verify the new DSM is deployed
209-
# with the expected guardian set before switching the protocol to it
210+
# with the expected guardian set, owner and protocol links before switching
211+
# the protocol to it
212+
old_dsm = interface.DepositSecurityModule(OLD_DEPOSIT_SECURITY_MODULE)
210213
new_dsm = interface.DepositSecurityModule(NEW_DEPOSIT_SECURITY_MODULE)
211214
assert new_dsm.VERSION() == 5, "New DSM version is not 5"
215+
assert str(new_dsm.getOwner()).lower() == AGENT.lower(), "New DSM owner is not the Agent"
216+
assert str(new_dsm.STAKING_ROUTER()).lower() == STAKING_ROUTER.lower(), "New DSM staking router mismatch"
217+
assert str(new_dsm.DEPOSIT_CONTRACT()).lower() == str(old_dsm.DEPOSIT_CONTRACT()).lower(), (
218+
"New DSM deposit contract mismatch"
219+
)
220+
assert not new_dsm.isDepositsPaused(), "New DSM deposits are paused"
212221
assert new_dsm.getGuardianQuorum() == NEW_DSM_GUARDIAN_QUORUM, "New DSM guardian quorum mismatch"
213222
new_dsm_guardians = {str(g).lower() for g in new_dsm.getGuardians()}
214223
assert new_dsm_guardians == {g.lower() for g in NEW_DSM_GUARDIANS}, "New DSM guardian set mismatch"

tests/test_vote_edf_hoodi.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ def _raw_event_values(raw_event: dict) -> dict:
168168
return {item["name"]: item["value"] for item in raw_event["data"]}
169169

170170

171+
def _locator_addresses(locator) -> dict:
172+
"""Snapshot every zero-arg address getter the current locator implementation responds to."""
173+
addresses = {}
174+
for entry in locator.abi:
175+
if entry.get("type") != "function" or entry.get("inputs") or entry.get("stateMutability") != "view":
176+
continue
177+
outputs = entry.get("outputs") or []
178+
if len(outputs) != 1 or outputs[0].get("type") != "address":
179+
continue
180+
try:
181+
addresses[entry["name"]] = str(getattr(locator, entry["name"])())
182+
except Exception:
183+
continue
184+
return addresses
185+
186+
171187
def _group_agent_dg_events_from_receipt(receipt: TransactionReceipt, timelock: str, agent: str) -> list[EventDict]:
172188
"""Group DG proposal events by the Agent's inner call script items (single Agent.forward)."""
173189
events = tx_events_from_receipt(receipt)
@@ -386,6 +402,7 @@ def test_vote(
386402
expected_dg_proposal_id = timelock.getProposalsCount()
387403

388404
details = timelock.getProposalDetails(expected_dg_proposal_id)
405+
locator_addresses_before = None
389406
if details["status"] != PROPOSAL_STATUS["executed"]:
390407
# =======================================================================
391408
# ==================== Before DG enactment checks =======================
@@ -405,6 +422,11 @@ def test_vote(
405422

406423
assert str(locator_proxy.proxy__getImplementation()).lower() != NEW_LIDO_LOCATOR_IMPLEMENTATION.lower()
407424

425+
# Snapshot the full locator address registry - the upgrade must change
426+
# only the depositSecurityModule entry
427+
locator_addresses_before = _locator_addresses(interface.LidoLocator(LIDO_LOCATOR))
428+
assert locator_addresses_before["depositSecurityModule"].lower() == OLD_DEPOSIT_SECURITY_MODULE.lower()
429+
408430
# Old DSM v4 holds the EOA guardian set (7 guardians: 6 mapped + 1 extra Lido dev team)
409431
old_dsm_guardians = {str(g).lower() for g in old_dsm.getGuardians()}
410432
assert old_dsm_guardians == {g.lower() for g in OLD_DSM_GUARDIANS}
@@ -530,6 +552,16 @@ def test_vote(
530552
== NEW_DEPOSIT_SECURITY_MODULE.lower()
531553
)
532554

555+
# Every locator entry except depositSecurityModule must stay unchanged
556+
if locator_addresses_before is not None:
557+
locator = interface.LidoLocator(LIDO_LOCATOR)
558+
for name, before_value in locator_addresses_before.items():
559+
after_value = str(getattr(locator, name)())
560+
if name == "depositSecurityModule":
561+
assert after_value.lower() == NEW_DEPOSIT_SECURITY_MODULE.lower()
562+
else:
563+
assert after_value == before_value, f"Locator entry {name} changed unexpectedly"
564+
533565
assert not staking_router.hasRole(STAKING_MODULE_UNVETTING_ROLE, OLD_DEPOSIT_SECURITY_MODULE)
534566
assert staking_router.hasRole(STAKING_MODULE_UNVETTING_ROLE, NEW_DEPOSIT_SECURITY_MODULE)
535567
assert top_up_gateway.hasRole(TOP_UP_ROLE, DEPOSITOR_BOT_DELEGATION_CONTRACT)

0 commit comments

Comments
 (0)