Skip to content

Commit ed10c59

Browse files
tcoratgerclaude
andauthored
refactor(testing): rename signer_ids to signer_indices (leanEthereum#902)
A validator is referenced by its index, never an id — the field even described "these validator indices" in its own docstring. Rename the field and every reference on the aggregated-attestation spec to use the index vocabulary. The field has no explicit pydantic alias and appears in no emitted fixture, so the camelCase serialization simply changes from signerIds to signerIndices with no wire-compat concern (audit finding DOC-01). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c0a044c commit ed10c59

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

packages/testing/src/consensus_testing/test_fixtures/state_transition.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def validate_signatures_are_out_of_scope(self) -> "StateTransitionTest":
103103
"""Reject signature-flavored attestation fields at construction."""
104104
for block_spec in self.blocks:
105105
for attestation_spec in block_spec.attestations or []:
106-
if not attestation_spec.valid_signature or attestation_spec.signer_ids is not None:
106+
if (
107+
not attestation_spec.valid_signature
108+
or attestation_spec.signer_indices is not None
109+
):
107110
raise ValueError(
108111
"state transition assumes signatures were verified upstream; "
109112
"author invalid-signature scenarios through the fork choice "

packages/testing/src/consensus_testing/test_types/attestation_specs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class AggregatedAttestationSpec(AttestationSpec):
145145
validator_indices: list[ValidatorIndex]
146146
"""The indices of validators making the attestation (required)."""
147147

148-
signer_ids: list[ValidatorIndex] | None = None
148+
signer_indices: list[ValidatorIndex] | None = None
149149
"""
150150
Override which validators actually sign the attestation.
151151
@@ -187,7 +187,7 @@ def build_signed(
187187
# - Actual signers produce the cryptographic material.
188188
# They default to the same set for honest attestations.
189189
validator_indices = self.validator_indices
190-
signer_ids = self.signer_ids or self.validator_indices
190+
signer_indices = self.signer_indices or self.validator_indices
191191

192192
# Path 1: Invalid signature.
193193
#
@@ -202,7 +202,7 @@ def build_signed(
202202
return SignedAggregatedAttestation(data=attestation_data, proof=proof)
203203

204204
# Path 2: Valid signature.
205-
proof = key_manager.sign_and_aggregate(signer_ids, attestation_data)
205+
proof = key_manager.sign_and_aggregate(signer_indices, attestation_data)
206206

207207
# Path 3: Participant mismatch.
208208
#
@@ -211,7 +211,7 @@ def build_signed(
211211
# The proof is cryptographically valid for the actual signers,
212212
# but the claimed participants no longer match.
213213
# The store must detect and reject this inconsistency.
214-
if self.signer_ids and self.signer_ids != self.validator_indices:
214+
if self.signer_indices and self.signer_indices != self.validator_indices:
215215
proof = SingleMessageAggregate(
216216
participants=AggregationBits.from_indices(validator_indices),
217217
proof=proof.proof,
@@ -257,9 +257,9 @@ def build_invalid_proof(
257257

258258
if not self.valid_signature:
259259
invalid_proof = SingleMessageAggregate(participants=aggregation_bits, proof=placeholder)
260-
elif self.signer_ids is not None:
260+
elif self.signer_indices is not None:
261261
# Valid proof from wrong validators (participant mismatch).
262-
valid_proof = key_manager.sign_and_aggregate(self.signer_ids, attestation_data)
262+
valid_proof = key_manager.sign_and_aggregate(self.signer_indices, attestation_data)
263263
invalid_proof = SingleMessageAggregate(
264264
participants=aggregation_bits, proof=valid_proof.proof
265265
)

packages/testing/src/consensus_testing/test_types/block_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def build_signed_block(
365365
for attestation_spec in (self.attestations or [])
366366
if not attestation_spec.valid_signature
367367
or (
368-
attestation_spec.signer_ids is not None
369-
and attestation_spec.signer_ids != attestation_spec.validator_indices
368+
attestation_spec.signer_indices is not None
369+
and attestation_spec.signer_indices != attestation_spec.validator_indices
370370
)
371371
]
372372

tests/consensus/lstar/fork_choice/test_gossip_aggregated_registry_and_signature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_aggregated_attestation_proof_verification_failure_rejected(
103103
GossipAggregatedAttestationStep(
104104
attestation=AggregatedAttestationSpec(
105105
validator_indices=[ValidatorIndex(1)],
106-
signer_ids=[ValidatorIndex(2)],
106+
signer_indices=[ValidatorIndex(2)],
107107
slot=Slot(2),
108108
target_slot=Slot(2),
109109
target_root_label="block_2",

0 commit comments

Comments
 (0)