Skip to content

Commit ac47e76

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

26 files changed

+1318
-695
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: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
"""Block Containers for the Lean Ethereum consensus specification."""
1+
"""Block containers for the Lean Ethereum consensus specification."""
22

33
from lean_spec.subspecs.containers.slot import Slot
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):
1118
"""The body of a block, containing payload data."""
1219

1320
attestations: Attestations
14-
"""
15-
A list of votes included in the block.
21+
"""Validator attestations included in the block."""
1622

17-
Note: This will eventually be replaced by aggregated attestations.
18-
"""
23+
proposer_attestation: ProposerAttestationData = (
24+
_DEFAULT_PROPOSER_ATTESTATION
25+
)
26+
"""The proposer sourced attestation kept separate from the list."""
1927

2028

2129
class BlockHeader(Container):
@@ -57,13 +65,10 @@ class Block(Container):
5765

5866

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

6270
message: Block
6371
"""The block being signed."""
6472

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-
"""
73+
signature: BlockSignatures
74+
"""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)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
"""State container and related types for the Lean Ethereum consensus specification."""
1+
"""State container and related types for the Lean consensus specification."""
22

33
from .state import State
44
from .types import (
55
HistoricalBlockHashes,
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)