Skip to content

Commit 3d2de22

Browse files
committed
feat: init aggregate all block signatures as naive list
Signed-off-by: Chen Kai <281165273grape@gmail.com>
1 parent 715653c commit 3d2de22

26 files changed

+1314
-687
lines changed

src/lean_spec/subspecs/containers/__init__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
from .checkpoint import Checkpoint
55
from .config import Config
66
from .state import State
7-
from .vote import SignedVote, Vote
7+
from .validator import Validator
8+
from .vote import (
9+
Attestation,
10+
AttestationData,
11+
ProposerAttestationData,
12+
SignedAttestation,
13+
SignedValidatorAttestation,
14+
ValidatorAttestation,
15+
)
816

917
__all__ = [
1018
"Block",
@@ -13,7 +21,12 @@
1321
"Checkpoint",
1422
"Config",
1523
"SignedBlock",
16-
"SignedVote",
24+
"Validator",
25+
"AttestationData",
26+
"ValidatorAttestation",
27+
"SignedValidatorAttestation",
28+
"SignedAttestation",
29+
"ProposerAttestationData",
30+
"Attestation",
1731
"State",
18-
"Vote",
1932
]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""Block containers and related types for the Lean Ethereum consensus specification."""
22

33
from .block import Block, BlockBody, BlockHeader, SignedBlock
4-
from .types import Attestations
4+
from .types import Attestations, BlockSignatures
55

66
__all__ = [
77
"Block",
88
"BlockBody",
99
"BlockHeader",
1010
"SignedBlock",
1111
"Attestations",
12+
"BlockSignatures",
1213
]

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
from lean_spec.types import Bytes32, Uint64
55
from lean_spec.types.container import Container
66

7-
from .types import Attestations
7+
from ..checkpoint import Checkpoint
8+
from ..vote.vote import ProposerAttestationData
9+
from .types import Attestations, BlockSignatures
10+
11+
_DEFAULT_PROPOSER_ATTESTATION = ProposerAttestationData(
12+
target=Checkpoint(root=Bytes32.zero(), slot=Slot(0)),
13+
source=Checkpoint(root=Bytes32.zero(), slot=Slot(0)),
14+
)
815

916

1017
class BlockBody(Container):
@@ -17,6 +24,11 @@ class BlockBody(Container):
1724
Note: This will eventually be replaced by aggregated attestations.
1825
"""
1926

27+
proposer_attestation: ProposerAttestationData = (
28+
_DEFAULT_PROPOSER_ATTESTATION
29+
)
30+
"""The proposer sourced attestation kept separate from the list."""
31+
2032

2133
class BlockHeader(Container):
2234
"""The header of a block, containing metadata."""
@@ -57,13 +69,10 @@ class Block(Container):
5769

5870

5971
class SignedBlock(Container):
60-
"""A container for a block and the proposer's signature."""
72+
"""A container for a block and its aggregated signatures."""
6173

6274
message: Block
6375
"""The block being signed."""
6476

65-
signature: Bytes32
66-
"""
67-
The proposer's signature of the block message.
68-
Note: Bytes32 is a placeholder; the actual signature is much larger.
69-
"""
77+
signature: BlockSignatures
78+
"""Naive list of signatures aggregated for the block."""
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
"""Block-specific SSZ types for the Lean Ethereum consensus specification."""
22

3-
from lean_spec.types import SSZList
3+
from lean_spec.types import Bytes4000, SSZList
44

55
from ...chain.config import VALIDATOR_REGISTRY_LIMIT
6-
from ..vote import SignedVote
6+
from ..vote.vote import ValidatorAttestation
77

88

99
class Attestations(SSZList):
10-
"""List of signed votes (attestations) included in a block."""
10+
"""List of validator attestations included in a block."""
1111

12-
ELEMENT_TYPE = SignedVote
12+
ELEMENT_TYPE = ValidatorAttestation
13+
LIMIT = int(VALIDATOR_REGISTRY_LIMIT)
14+
15+
16+
class BlockSignatures(SSZList):
17+
"""Aggregated signature list included alongside the block."""
18+
19+
ELEMENT_TYPE = Bytes4000
1320
LIMIT = int(VALIDATOR_REGISTRY_LIMIT)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
JustificationRoots,
77
JustificationValidators,
88
JustifiedSlots,
9+
Validators,
910
)
1011

1112
__all__ = [
@@ -14,4 +15,5 @@
1415
"JustificationRoots",
1516
"JustificationValidators",
1617
"JustifiedSlots",
18+
"Validators",
1719
]

0 commit comments

Comments
 (0)