Skip to content

Commit

Permalink
chore(store): remove save from flow (berachain#1866)
Browse files Browse the repository at this point in the history
  • Loading branch information
archbear authored Aug 8, 2024
1 parent 18e0842 commit ebda135
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 23 deletions.
2 changes: 0 additions & 2 deletions mod/node-core/pkg/components/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ type KVStore[
WithContext(
ctx context.Context,
) T
// Save saves the key-value store.
Save()
// Copy returns a copy of the key-value store.
Copy() T
// GetLatestExecutionPayloadHeader retrieves the latest execution payload
Expand Down
1 change: 0 additions & 1 deletion mod/state-transition/pkg/core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type BeaconState[
cs common.ChainSpec,
) T
Copy() T
Save()
Context() context.Context
HashTreeRoot() common.Root
ReadOnlyBeaconState[
Expand Down
2 changes: 0 additions & 2 deletions mod/state-transition/pkg/core/state/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ type KVStore[
Context() context.Context
// WithContext returns a new key-value store with the given context.
WithContext(ctx context.Context) T
// Save saves the key-value store.
Save()
// Copy returns a copy of the key-value store.
Copy() T
// GetLatestExecutionPayloadHeader retrieves the latest execution payload
Expand Down
3 changes: 0 additions & 3 deletions mod/state-transition/pkg/core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ func (sp *StateProcessor[
return nil, err
}

// We only want to persist state changes if we successfully
// processed the block.
st.Save()
return validatorUpdates, nil
}

Expand Down
1 change: 0 additions & 1 deletion mod/state-transition/pkg/core/state_processor_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,5 @@ func (sp *StateProcessor[
if err != nil {
return nil, err
}
st.Save()
return updates, nil
}
16 changes: 2 additions & 14 deletions mod/storage/pkg/beacondb/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ type KVStore[
ValidatorT Validator[ValidatorT],
ValidatorsT ~[]ValidatorT,
] struct {
ctx context.Context
write func()
ctx context.Context
// Versioning
// genesisValidatorsRoot is the root of the genesis validators.
genesisValidatorsRoot sdkcollections.Item[[]byte]
Expand Down Expand Up @@ -280,9 +279,8 @@ func (kv *KVStore[
ForkT, ValidatorT, ValidatorsT,
] {
// TODO: Decouple the KVStore type from the Cosmos-SDK.
cctx, write := sdk.UnwrapSDKContext(kv.ctx).CacheContext()
cctx, _ := sdk.UnwrapSDKContext(kv.ctx).CacheContext()
ss := kv.WithContext(cctx)
ss.write = write
return ss
}

Expand All @@ -308,13 +306,3 @@ func (kv *KVStore[
cpy.ctx = ctx
return &cpy
}

// Save saves the Store.
func (kv *KVStore[
BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT,
ForkT, ValidatorT, ValidatorsT,
]) Save() {
if kv.write != nil {
kv.write()
}
}

0 comments on commit ebda135

Please sign in to comment.