Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(beradb): enhance #1930

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions examples/berad/pkg/storage/fork.go

This file was deleted.

42 changes: 16 additions & 26 deletions examples/berad/pkg/storage/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
package keys

const (
WithdrawalQueuePrefix byte = iota
RandaoMixPrefix
RandaoMixPrefix byte = iota
ValidatorIndexPrefix
BlockRootsPrefix
StateRootsPrefix
ValidatorByIndexPrefix
ValidatorPubkeyToIndexPrefix
ValidatorConsAddrToIndexPrefix
ValidatorEffectiveBalanceToIndexPrefix
LatestBeaconBlockHeaderPrefix
SlotPrefix
BalancesPrefix
Eth1BlockHashPrefix
Eth1DepositIndexPrefix
LatestExecutionPayloadHeaderPrefix
LatestExecutionPayloadVersionPrefix
Expand All @@ -45,24 +40,19 @@ const (

//nolint:lll
const (
WithdrawalQueuePrefixHumanReadable = "WithdrawalQueuePrefix"
RandaoMixPrefixHumanReadable = "RandaoMixPrefix"
ValidatorIndexPrefixHumanReadable = "ValidatorIndexPrefix"
BlockRootsPrefixHumanReadable = "BlockRootsPrefix"
StateRootsPrefixHumanReadable = "StateRootsPrefix"
ValidatorByIndexPrefixHumanReadable = "ValidatorByIndexPrefix"
ValidatorPubkeyToIndexPrefixHumanReadable = "ValidatorPubkeyToIndexPrefix"
ValidatorConsAddrToIndexPrefixHumanReadable = "ValidatorConsAddrToIndexPrefix"
ValidatorEffectiveBalanceToIndexPrefixHumanReadable = "ValidatorEffectiveBalanceToIndexPrefix"
LatestBeaconBlockHeaderPrefixHumanReadable = "LatestBeaconBlockHeaderPrefix"
SlotPrefixHumanReadable = "SlotPrefix"
BalancesPrefixHumanReadable = "BalancesPrefix"
Eth1BlockHashPrefixHumanReadable = "Eth1BlockHashPrefix"
Eth1DepositIndexPrefixHumanReadable = "Eth1DepositIndexPrefix"
LatestExecutionPayloadHeaderPrefixHumanReadable = "LatestExecutionPayloadHeaderPrefix"
LatestExecutionPayloadVersionPrefixHumanReadable = "LatestExecutionPayloadVersionPrefix"
GenesisValidatorsRootPrefixHumanReadable = "GenesisValidatorsRootPrefix"
NextWithdrawalIndexPrefixHumanReadable = "NextWithdrawalIndexPrefix"
NextWithdrawalValidatorIndexPrefixHumanReadable = "NextWithdrawalValidatorIndexPrefix"
ForkPrefixHumanReadable = "ForkPrefix"
RandaoMixPrefixHumanReadable = "RandaoMixPrefix"
ValidatorIndexPrefixHumanReadable = "ValidatorIndexPrefix"
BlockRootsPrefixHumanReadable = "BlockRootsPrefix"
StateRootsPrefixHumanReadable = "StateRootsPrefix"
ValidatorByIndexPrefixHumanReadable = "ValidatorByIndexPrefix"
LatestBeaconBlockHeaderPrefixHumanReadable = "LatestBeaconBlockHeaderPrefix"
SlotPrefixHumanReadable = "SlotPrefix"
BalancesPrefixHumanReadable = "BalancesPrefix"
Eth1DepositIndexPrefixHumanReadable = "Eth1DepositIndexPrefix"
LatestExecutionPayloadHeaderPrefixHumanReadable = "LatestExecutionPayloadHeaderPrefix"
LatestExecutionPayloadVersionPrefixHumanReadable = "LatestExecutionPayloadVersionPrefix"
GenesisValidatorsRootPrefixHumanReadable = "GenesisValidatorsRootPrefix"
NextWithdrawalIndexPrefixHumanReadable = "NextWithdrawalIndexPrefix"
NextWithdrawalValidatorIndexPrefixHumanReadable = "NextWithdrawalValidatorIndexPrefix"
ForkPrefixHumanReadable = "ForkPrefix"
)
18 changes: 18 additions & 0 deletions examples/berad/pkg/storage/versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ func (kv *KVStore[
) error {
return kv.slot.Set(kv.ctx, slot.Unwrap())
}

// SetFork sets the fork version for the given epoch.
func (kv *KVStore[
BeaconBlockHeaderT, ExecutionPayloadHeaderT,
ForkT, ValidatorT, ValidatorsT,
]) SetFork(
fork ForkT,
) error {
return kv.fork.Set(kv.ctx, fork)
}

// GetFork gets the fork version for the given epoch.
func (kv *KVStore[
BeaconBlockHeaderT, ExecutionPayloadHeaderT,
ForkT, ValidatorT, ValidatorsT,
]) GetFork() (ForkT, error) {
return kv.fork.Get(kv.ctx)
}
Loading