---
tags: hard_fork_1
---
# Beacon State Hard Fork Examples
## Currently:
### Interface
```go=
type BeaconState interface {
PreviousEpochAttestations() []*pbp2p.PendingAttestation
CurrentEpochAttestations() []*pbp2p.PendingAttestation
AppendCurrentEpochAttestations(val *pbp2p.PendingAttestation) error
AppendPreviousEpochAttestations(val *pbp2p.PendingAttestation) error
}
type BeaconStateV1 interface {
BeaconState
PreviousEpochParticipations() []byte
CurrentEpochParticipations() []byte
SetPreviousParticipationByteAtIndex(i uint64) error
SetCurrentParticipationByteAtIndex(i uint64) error
}
```
### Process pending attestations into the state (setter)
```go=
func ProcessAttestationNoVerifySignature(
ctx context.Context,
beaconState iface.BeaconState,
att *ethpb.Attestation,
) (iface.BeaconState, error) {
...
if err := beaconState.AppendCurrentEpochAttestations(pendingAtt); err != nil {
return nil, err
}
if err := beaconState.AppendPreviousEpochAttestations(pendingAtt); err != nil {
return nil, err
}
return beaconState, nil
}
```
### Get pending attestations into the state (getter)
```go=
func ProcessAttestations(
ctx context.Context,
state iface.ReadOnlyBeaconState,
vp []*Validator,
pBal *Balance,
) ([]*Validator, *Balance, error) {
for _, a := range append(state.PreviousEpochAttestations(),
state.CurrentEpochAttestations()...) {
```
## What we want:
```go=
// Apply hardfork 1 getters and setters into existing phase 0 code path
type BeaconState interface {
// HF1
PreviousEpochParticipations() []byte
CurrentEpochParticipations() []byte
SetPreviousParticipationByteAtIndex(i uint64) error
SetCurrentParticipationByteAtIndex(i uint64) error
}
```
### Now to process pending attestations into the state (setter)
```go=
// Phase 0 code path
func ProcessAttestationNoVerifySignature(
ctx context.Context,
beaconState iface.BeaconState,
att *ethpb.Attestation,
) (iface.BeaconState, error) {
...
// Convert pendingAtt to bits
if err := beaconState.SetCurrentParticipationByteAtIndex(bits); err != nil {
return nil, err
}
if err := beaconState.SetPreviousParticipationByteAtIndex(bits); err != nil {
return nil, err
}
// We still need the following because we need to save the attestations right?
if err := beaconState.AppendCurrentEpochAttestations(pendingAtt); err != nil {
return nil, err
}
if err := beaconState.AppendPreviousEpochAttestations(pendingAtt); err != nil {
return nil, err
}
return beaconState, nil
}
```
## Outcome
* One single interface
* Still need 2 protobuf states
* We still need 2 different state pkgs `BeaconState` and `BeaconStateAltair` for HTR
* The processing paths no longer need to be duplicated. (ie. No `ProcessAttestationNoVerifySignature` and `ProcessAttestationNoVerifySignatureV1`)