Skip to content

Commit af22b05

Browse files
authored
types: cleanup (#244)
* types: cleanup * fix tests
1 parent e5b9140 commit af22b05

File tree

13 files changed

+66
-89
lines changed

13 files changed

+66
-89
lines changed

packages/testing/src/consensus_testing/keys.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
AttestationSignatures,
4545
)
4646
from lean_spec.subspecs.containers.slot import Slot
47-
from lean_spec.subspecs.containers.state.types import AttestationSignatureKey
48-
from lean_spec.subspecs.xmss.aggregation import MultisigAggregatedSignature
47+
from lean_spec.subspecs.xmss.aggregation import (
48+
AttestationSignatureKey,
49+
MultisigAggregatedSignature,
50+
)
4951
from lean_spec.subspecs.xmss.containers import KeyPair, PublicKey, Signature
5052
from lean_spec.subspecs.xmss.interface import (
5153
PROD_SIGNATURE_SCHEME,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
from lean_spec.subspecs.containers.slot import Slot
2727
from lean_spec.subspecs.containers.state import Validators
2828
from lean_spec.subspecs.containers.state.state import State
29-
from lean_spec.subspecs.containers.state.types import AttestationSignatureKey
3029
from lean_spec.subspecs.forkchoice import Store
3130
from lean_spec.subspecs.koalabear import Fp
3231
from lean_spec.subspecs.ssz import hash_tree_root
32+
from lean_spec.subspecs.xmss.aggregation import AttestationSignatureKey
3333
from lean_spec.subspecs.xmss.containers import Signature
3434
from lean_spec.subspecs.xmss.types import HashDigestList, HashTreeOpening, Randomness
3535
from lean_spec.types import Bytes32, Uint64

src/lean_spec/subspecs/containers/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
AggregationBits,
1414
Attestation,
1515
AttestationData,
16-
NaiveAggregatedSignature,
17-
SignedAggregatedAttestation,
16+
AttestationsByValidator,
1817
SignedAttestation,
1918
)
2019
from .block import (
@@ -31,19 +30,18 @@
3130

3231
__all__ = [
3332
"AggregatedAttestation",
34-
"NaiveAggregatedSignature",
3533
"AggregationBits",
36-
"AttestationData",
3734
"Attestation",
38-
"SignedAttestation",
39-
"SignedAggregatedAttestation",
35+
"AttestationData",
36+
"AttestationsByValidator",
4037
"Block",
41-
"BlockWithAttestation",
4238
"BlockBody",
4339
"BlockHeader",
40+
"BlockWithAttestation",
4441
"Checkpoint",
4542
"Config",
43+
"SignedAttestation",
4644
"SignedBlockWithAttestation",
47-
"Validator",
4845
"State",
46+
"Validator",
4947
]

src/lean_spec/subspecs/containers/attestation/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
AggregatedAttestation,
55
Attestation,
66
AttestationData,
7-
SignedAggregatedAttestation,
87
SignedAttestation,
98
)
10-
from .types import AggregationBits, NaiveAggregatedSignature
9+
from .types import AggregationBits, AttestationsByValidator
1110

1211
__all__ = [
13-
"AttestationData",
14-
"Attestation",
15-
"SignedAttestation",
16-
"SignedAggregatedAttestation",
1712
"AggregatedAttestation",
18-
"NaiveAggregatedSignature",
1913
"AggregationBits",
14+
"Attestation",
15+
"AttestationData",
16+
"AttestationsByValidator",
17+
"SignedAttestation",
2018
]

src/lean_spec/subspecs/containers/attestation/attestation.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from ...xmss.containers import Signature
2424
from ..checkpoint import Checkpoint
25-
from .types import AggregationBits, NaiveAggregatedSignature
25+
from .types import AggregationBits
2626

2727

2828
class AttestationData(Container):
@@ -107,22 +107,3 @@ def aggregate_by_data(
107107
)
108108
for data, validator_ids in data_to_validator_ids.items()
109109
]
110-
111-
112-
class SignedAggregatedAttestation(Container):
113-
"""Aggregated attestation bundled with aggregated signatures."""
114-
115-
message: AggregatedAttestation
116-
"""Aggregated attestation data."""
117-
118-
signature: NaiveAggregatedSignature
119-
"""Aggregated attestation plus its combined signature.
120-
121-
Stores a naive list of validator signatures that mirrors the attestation
122-
order.
123-
124-
TODO:
125-
- signatures will be replaced by MegaBytes in next PR to include leanVM proof.
126-
- this will be replaced by a SNARK in future devnets.
127-
- this will be aggregated by aggregators in future devnets.
128-
"""

src/lean_spec/subspecs/containers/attestation/types.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
from __future__ import annotations
44

5-
from lean_spec.types import SSZList, Uint64
5+
from typing import TYPE_CHECKING
6+
7+
from lean_spec.types import Uint64
68
from lean_spec.types.bitfields import BaseBitlist
79

810
from ...chain.config import VALIDATOR_REGISTRY_LIMIT
9-
from ...xmss.containers import Signature
11+
12+
if TYPE_CHECKING:
13+
from .attestation import AttestationData
14+
15+
AttestationsByValidator = dict[Uint64, "AttestationData"]
16+
"""Mapping from validator index to attestation data."""
1017

1118

1219
class AggregationBits(BaseBitlist):
@@ -57,10 +64,3 @@ def to_validator_indices(self) -> list[Uint64]:
5764
raise AssertionError("Aggregated attestation must reference at least one validator")
5865

5966
return indices
60-
61-
62-
class NaiveAggregatedSignature(SSZList[Signature]):
63-
"""Naive list of validator signatures used for aggregation placeholders."""
64-
65-
ELEMENT_TYPE = Signature
66-
LIMIT = int(VALIDATOR_REGISTRY_LIMIT)

src/lean_spec/subspecs/containers/block/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
from .types import (
1212
AggregatedAttestations,
1313
AttestationSignatures,
14+
BlockLookup,
1415
)
1516

1617
__all__ = [
1718
"Block",
1819
"BlockBody",
1920
"BlockHeader",
21+
"BlockLookup",
2022
"BlockSignatures",
2123
"BlockWithAttestation",
2224
"SignedBlockWithAttestation",

src/lean_spec/subspecs/containers/block/types.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
"""Block-specific SSZ types for the Lean Ethereum consensus specification."""
22

3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
37
from lean_spec.subspecs.xmss.aggregation import MultisigAggregatedSignature
4-
from lean_spec.types import SSZList
8+
from lean_spec.types import Bytes32, SSZList
59

610
from ...chain.config import VALIDATOR_REGISTRY_LIMIT
711
from ..attestation import AggregatedAttestation
812

13+
if TYPE_CHECKING:
14+
from .block import Block
15+
16+
BlockLookup = dict[Bytes32, "Block"]
17+
"""Mapping from block root to Block objects."""
18+
919

1020
class AggregatedAttestations(SSZList[AggregatedAttestation]):
1121
"""List of aggregated attestations included in a block."""

src/lean_spec/subspecs/containers/state/__init__.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
from .state import State
44
from .types import (
5-
AggregatedSignaturePayload,
6-
AggregatedSignaturePayloads,
7-
AttestationsByValidator,
8-
AttestationSignatureKey,
9-
BlockLookup,
105
HistoricalBlockHashes,
116
JustificationRoots,
127
JustificationValidators,
@@ -16,16 +11,11 @@
1611
)
1712

1813
__all__ = [
19-
"State",
20-
"AggregatedSignaturePayload",
21-
"AggregatedSignaturePayloads",
22-
"AttestationSignatureKey",
23-
"AttestationsByValidator",
24-
"BlockLookup",
2514
"HistoricalBlockHashes",
2615
"JustificationRoots",
2716
"JustificationValidators",
2817
"JustifiedSlots",
18+
"State",
2919
"StateLookup",
3020
"Validators",
3121
]

src/lean_spec/subspecs/containers/state/state.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from typing import AbstractSet, Iterable
44

55
from lean_spec.subspecs.ssz.hash import hash_tree_root
6-
from lean_spec.subspecs.xmss.aggregation import MultisigAggregatedSignature
6+
from lean_spec.subspecs.xmss.aggregation import (
7+
AggregatedSignaturePayloads,
8+
AttestationSignatureKey,
9+
MultisigAggregatedSignature,
10+
)
711
from lean_spec.subspecs.xmss.containers import PublicKey, Signature
812
from lean_spec.types import (
913
ZERO_HASH,
@@ -21,8 +25,6 @@
2125
from ..config import Config
2226
from ..slot import Slot
2327
from .types import (
24-
AggregatedSignaturePayloads,
25-
AttestationSignatureKey,
2628
HistoricalBlockHashes,
2729
JustificationRoots,
2830
JustificationValidators,

0 commit comments

Comments
 (0)