Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lean_spec/node/validator/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _sign_block(

# Sign the block root with the proposal key.
block_root = hash_tree_root(block)
_, proposer_signature = self._sign_with_key(
proposer_signature = self._sign_with_key(
validator_entry,
block.slot,
block_root,
Expand Down Expand Up @@ -521,7 +521,7 @@ def _sign_attestation(
raise ValueError(f"No secret key for validator {validator_index}")

# Sign the attestation data root with the attestation key.
_, signature = self._sign_with_key(
signature = self._sign_with_key(
validator_entry,
attestation_data.slot,
hash_tree_root(attestation_data),
Expand All @@ -540,7 +540,7 @@ def _sign_with_key(
slot: Slot,
message: Bytes32,
key_field: Literal["attestation_secret_key", "proposal_secret_key"],
) -> tuple[ValidatorEntry, Signature]:
) -> Signature:
"""
Prepare an XMSS key for the given slot, sign, and update the registry.

Expand All @@ -557,7 +557,7 @@ def _sign_with_key(
key_field: Which secret key field to use and advance.

Returns:
Tuple of (updated entry, signature).
The signature over the message.
"""
scheme = TARGET_SIGNATURE_SCHEME
secret_key = getattr(validator_entry, key_field)
Expand All @@ -577,7 +577,7 @@ def _sign_with_key(
},
)
self.registry.add(updated_entry)
return updated_entry, signature
return signature

def _is_synced_for_duties(
self,
Expand Down
7 changes: 3 additions & 4 deletions tests/node/validator/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ def test_proposal_key_updated_attestation_key_unchanged(
assert stored.proposal_secret_key is advanced_proposal
assert stored.attestation_secret_key is attestation_key

def test_returns_updated_entry_and_signature(
def test_returns_signature(
self, sync_service: SyncService, key_manager: XmssKeyManager
) -> None:
"""Return value is (updated ValidatorEntry, Signature) — both fields correct."""
"""Return value is the signature produced by the scheme."""
service, _, validator_entry, attestation_key, _ = self._setup(sync_service, key_manager)
advanced = MagicMock(name="adv")
mock_signature = MagicMock(name="ret_sig")
Expand All @@ -396,12 +396,11 @@ def test_returns_updated_entry_and_signature(
scheme.advance_preparation.return_value = advanced
scheme.sign.return_value = mock_signature

returned_entry, returned_signature = service._sign_with_key(
returned_signature = service._sign_with_key(
validator_entry, Slot(2), MagicMock(), "attestation_secret_key"
)

assert returned_signature is mock_signature
assert returned_entry.attestation_secret_key is advanced


class TestValidatorServiceBasic:
Expand Down
Loading