---
# System prepended metadata

title: Altair DB/Cache TODOs

---

# Altair DB/Cache TODOs

## Background 

Altair has a new beacon state and beacon block. Every storage which was used for state and block need to get revamped. The storage include DB and cache. We need to figure out what's the best path forward. Duplicate the existing code? or use state.version() or block.version() internally to save or retrieve them via different bucket or cache? Or is there a better way?

## Options

1. Duplicate DB and cache into a new package. (Least desired)

2. Make Altair changes on existing DB and cache packages. (Ok desired)
```go=
type StateType int

const (
   Phase0 StateType = iota
   Altair
)

type BeaconState interface {
    Type() StateType
}

func SaveState(state) {
    switch BeaconState.Type() {
    case Phase0:
        stateV0, ok := state.(Phase0)
        if !ok {
            // error handling
        }
        // Save state to phase 0 bucket
    case Altair:
        // Save state to Altair bucket
    default:
    }
    return
}
```

3. Do we even need different buckets? Can we get the same block root link to two different forked state? If the answer is no, then this problem might become easier

## Proposed solution