Skip to content

Comments

feat(rpc-types-beacon): add SignedBeaconBlock and BeaconBlock types#3565

Merged
mattsse merged 1 commit intomainfrom
feat/add-signed-beacon-block-types
Jan 21, 2026
Merged

feat(rpc-types-beacon): add SignedBeaconBlock and BeaconBlock types#3565
mattsse merged 1 commit intomainfrom
feat/add-signed-beacon-block-types

Conversation

@mattsse
Copy link
Member

@mattsse mattsse commented Jan 21, 2026

Motivation

Closes #3436

This adds the missing type definitions for SignedBeaconBlock and BeaconBlock as requested in the issue.

Solution

Added a new block.rs module with comprehensive beacon block types based on the Beacon API spec and consensus specs.

New types added:

Core types:

  • BlockResponse<T> - API response wrapper with version and finalization info
  • SignedBeaconBlock<T> - Generic signed beacon block with message and signature
  • BeaconBlock<T> - Generic block with slot, proposer_index, parent_root, state_root, body

Fork-specific block bodies:

  • BeaconBlockBodyPhase0 - Phase0 block body
  • BeaconBlockBodyAltair - Altair block body (adds sync_aggregate)
  • BeaconBlockBodyBellatrix - Bellatrix block body (adds execution_payload)
  • BeaconBlockBodyCapella - Capella block body (adds bls_to_execution_changes)
  • BeaconBlockBodyDeneb - Deneb block body (adds blob_kzg_commitments)
  • BeaconBlockBodyElectra - Electra block body (adds execution_requests)

Supporting types:

  • Eth1Data, Checkpoint, AttestationData, Attestation, IndexedAttestation
  • ProposerSlashing, SignedBeaconBlockHeader, AttesterSlashing
  • DepositData, Deposit, VoluntaryExit, SignedVoluntaryExit
  • SyncAggregate, BlsToExecutionChange, SignedBlsToExecutionChange

Type aliases for convenience:

  • SignedBeaconBlockPhase0, SignedBeaconBlockAltair
  • SignedBeaconBlockBellatrix, SignedBeaconBlockCapella
  • SignedBeaconBlockDeneb, SignedBeaconBlockElectra

All types use proper serde serialization with quoted decimals (DisplayFromStr) as per the Beacon API format.

Testing

Added comprehensive tests for serde serialization/deserialization of all major types.

This adds the missing type definitions for  and
as requested in issue #3436.

New types added:
-  - API response wrapper with version and finalization info
-  - Generic signed beacon block with message and signature
-  - Generic block with slot, proposer_index, parent_root, state_root, body
-  - Phase0 block body
-  - Altair block body with sync_aggregate
-  - Bellatrix block body with execution_payload
-  - Capella block body with bls_to_execution_changes
-  - Deneb block body with blob_kzg_commitments
-  - Electra block body with execution_requests

Also includes supporting types:
- Eth1Data, Checkpoint, AttestationData, Attestation, IndexedAttestation
- ProposerSlashing, SignedBeaconBlockHeader, AttesterSlashing
- DepositData, Deposit, VoluntaryExit, SignedVoluntaryExit
- SyncAggregate, BlsToExecutionChange, SignedBlsToExecutionChange

Type aliases for convenience:
- SignedBeaconBlockPhase0, SignedBeaconBlockAltair
- SignedBeaconBlockBellatrix, SignedBeaconBlockCapella
- SignedBeaconBlockDeneb, SignedBeaconBlockElectra

Closes #3436

Amp-Thread-ID: https://ampcode.com/threads/T-019be0a4-b308-7698-a02e-eae4195ef3f7
Co-authored-by: Amp <[email protected]>
@mattsse mattsse merged commit 8631c51 into main Jan 21, 2026
30 checks passed
@github-project-automation github-project-automation bot moved this to Done in Alloy Jan 21, 2026
@mattsse mattsse deleted the feat/add-signed-beacon-block-types branch January 21, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature] Add missing types for signedBeaconBlock

1 participant