Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5b057af
moved deposit store to v1 package
abi87 May 17, 2025
5873665
wip: adding deposits store v2
abi87 May 17, 2025
7af6ded
nit
abi87 May 17, 2025
b6e0b37
wip: still on deposits store v2
abi87 May 17, 2025
df562f3
wip: deposits store v2, adding simple UTs
abi87 May 17, 2025
504045e
deposits store v2 fixed logging
abi87 May 17, 2025
a6827bd
added general deposit store
abi87 May 17, 2025
c050991
aligned v1 and v2 deposit stores interfaces
abi87 May 17, 2025
fb67963
general deposit store: instantiated v2
abi87 May 17, 2025
49d1889
nit: introduced cache multi store
abi87 May 17, 2025
ab575f6
simplified ProvideDepositStore
abi87 May 18, 2025
50d1f8a
reduced some code duplication
abi87 May 18, 2025
44013f3
further simplification of deposits v1 + better encapsulation
abi87 May 18, 2025
7f5214d
nits
abi87 May 18, 2025
57e128c
wip: adding data migration logic and deposit version selection
abi87 May 18, 2025
5f001ac
fixed deposit store version selection
abi87 May 18, 2025
c19ea3a
wip: activate deposits v2 in unit tests
abi87 May 18, 2025
87fc2da
wip: added post Electra non-genesis deposits verification
abi87 May 18, 2025
ab25469
added DepositsV2ActivationSlot config
abi87 May 18, 2025
a4eb665
made deposit store migration idempotent
abi87 May 18, 2025
af10c24
simplified StoreManager interface
abi87 May 18, 2025
6f1ca2b
wip: check for migration upon genesis processing
abi87 May 18, 2025
38e932e
moved concurrency protection from v1 deposit to general deposit
abi87 May 18, 2025
c954b29
wip: check for migration upon deposits loading from contract
abi87 May 18, 2025
708a6bd
wip: fixed deposits checks in state processor + fixed UTs
abi87 May 18, 2025
28d88ac
activate deposit store V2 in devnet
abi87 May 18, 2025
5539bd1
wip: fixing block building
abi87 May 18, 2025
d721bc4
wip: some more fork activation fixing
abi87 May 19, 2025
6cea92f
improved deposits store migration logging
abi87 May 19, 2025
4defa2f
wip: fixing some UTs leftover post deposits store V2 activation in de…
abi87 May 19, 2025
613bc8b
nit: drop unused mutex
abi87 May 19, 2025
2192fe3
reused storage.KVStoreService
abi87 May 19, 2025
a5335c4
simplified store v2
abi87 May 19, 2025
5207610
added deposits store benchmarks
abi87 May 19, 2025
d857fe4
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 May 20, 2025
6d7d695
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 May 20, 2025
d68bf61
fixed DBCheck command
abi87 May 20, 2025
d387f09
logging nit
abi87 May 21, 2025
6ceccd1
fix pruning options for deposits store v2
abi87 May 21, 2025
66e9240
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 May 25, 2025
5ab0fdb
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 May 27, 2025
e8bcde8
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 Jul 7, 2025
5b2e151
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 Jul 21, 2025
1217324
Merge branch 'consolidate-deposits-storage-pt2' into consolidate-depo…
abi87 Aug 25, 2025
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
4 changes: 2 additions & 2 deletions beacon/blockchain/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/berachain/beacon-kit/state-transition/core"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
"github.com/berachain/beacon-kit/storage/block"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
cmtabci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down Expand Up @@ -115,7 +115,7 @@ type StorageBackend interface {
// StateFromContext retrieves the beacon state from the given context.
StateFromContext(context.Context) *statedb.StateDB
// DepositStore retrieves the deposit store.
DepositStore() *depositdb.KVStore
DepositStore() deposit.Store
// BlockStore retrieves the block store.
BlockStore() *block.KVStore[*ctypes.BeaconBlock]
}
Expand Down
2 changes: 1 addition & 1 deletion beacon/validator/block_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (s *Service) buildBlockBody(
}

// Grab all previous deposits from genesis up to the current index + max deposits per block.
deposits, err := s.sb.DepositStore().GetDepositsByIndex(
deposits, _, err := s.sb.DepositStore().GetDepositsByIndex(
ctx,
constants.FirstDepositIndex,
depositIndex+s.chainSpec.MaxDepositsPerBlock(),
Expand Down
4 changes: 2 additions & 2 deletions beacon/validator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/berachain/beacon-kit/primitives/transition"
"github.com/berachain/beacon-kit/state-transition/core"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

// BlobFactory represents a blob factory interface.
Expand Down Expand Up @@ -91,7 +91,7 @@ type StateProcessor interface {
// StorageBackend is the interface for the storage backend.
type StorageBackend interface {
// DepositStore retrieves the deposit store.
DepositStore() *depositdb.KVStore
DepositStore() deposit.Store
// StateFromContext retrieves the beacon state from the context.
StateFromContext(context.Context) *statedb.StateDB
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/cometbft/service/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Service) processProposal(
// called
// again in a subsequent round. However, we only want to do this after we've
// processed the first block, as we want to avoid overwriting the
// finalizeState
// finalizeBlockState
// after state changes during InitChain.
s.processProposalState = s.resetState(ctx)
if req.Height > s.initialHeight {
Expand Down
2 changes: 1 addition & 1 deletion node-api/backend/mocks/storage_backend.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node-core/components/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/berachain/beacon-kit/node-core/components/storage"
"github.com/berachain/beacon-kit/storage/beacondb"
"github.com/berachain/beacon-kit/storage/block"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

// StorageBackendInput is the input for the ProvideStorageBackend function.
Expand All @@ -39,7 +39,7 @@ type StorageBackendInput struct {
AvailabilityStore *dastore.Store
BlockStore *block.KVStore[*types.BeaconBlock]
ChainSpec chain.Spec
DepositStore *depositdb.KVStore
DepositStore deposit.Store
BeaconStore *beacondb.KVStore
Logger *phuslu.Logger
TelemetrySink *metrics.TelemetrySink
Expand Down
28 changes: 18 additions & 10 deletions node-core/components/deposit_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"github.com/berachain/beacon-kit/config"
"github.com/berachain/beacon-kit/log/phuslu"
"github.com/berachain/beacon-kit/node-core/components/storage"
depositstore "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
depositstorev1 "github.com/berachain/beacon-kit/storage/deposit/v1"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cast"
Expand All @@ -40,24 +41,31 @@ type DepositStoreInput struct {
AppOpts config.AppOptions
}

// ProvideDepositStore is a function that provides the module to the
// application.
func ProvideDepositStore(in DepositStoreInput) (*depositstore.KVStore, error) {
// ProvideDepositStore is a function that provides the module to the application.
func ProvideDepositStore(in DepositStoreInput) (deposit.Store, error) {
var (
rootDir = cast.ToString(in.AppOpts.Get(flags.FlagHome))
dataDir = filepath.Join(rootDir, "data")
name = "deposits"
nameV1 = "deposits"
nameV2 = "depositsV2"
)

pdb, err := dbm.NewDB(name, dbm.PebbleDBBackend, dataDir)
dbV1, err := dbm.NewDB(nameV1, dbm.PebbleDBBackend, dataDir)
if err != nil {
return nil, err
}
spdb := depositstore.NewSynced(pdb)
spdbV1 := depositstorev1.NewSynced(dbV1)

return depositstore.NewStore(
storage.NewKVStoreProvider(spdb),
spdb.Close,
dbV2, err := dbm.NewDB(nameV2, dbm.PebbleDBBackend, dataDir)
if err != nil {
return nil, err
}

return deposit.NewStore(
nil,
storage.NewKVStoreProvider(spdbV1),
spdbV1.Close,
dbV2,
in.Logger.With("service", "deposit-store"),
), nil
}
4 changes: 2 additions & 2 deletions node-core/components/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/berachain/beacon-kit/state-transition/core"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
"github.com/berachain/beacon-kit/storage/block"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

type (
Expand Down Expand Up @@ -163,7 +163,7 @@ type (
StorageBackend interface {
AvailabilityStore() *dastore.Store
BlockStore() *block.KVStore[*ctypes.BeaconBlock]
DepositStore() *depositdb.KVStore
DepositStore() deposit.Store
// StateFromContext retrieves the beacon state from the given context.
StateFromContext(context.Context) *statedb.StateDB
}
Expand Down
4 changes: 2 additions & 2 deletions node-core/components/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/berachain/beacon-kit/node-core/components/metrics"
"github.com/berachain/beacon-kit/primitives/crypto"
"github.com/berachain/beacon-kit/state-transition/core"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

// StateProcessorInput is the input for the state processor for the depinject
Expand All @@ -38,7 +38,7 @@ type StateProcessorInput struct {
Logger *phuslu.Logger
ChainSpec chain.Spec
ExecutionEngine *engine.Engine
DepositStore *depositdb.KVStore
DepositStore deposit.Store
Signer crypto.BLSSigner
TelemetrySink *metrics.TelemetrySink
}
Expand Down
8 changes: 4 additions & 4 deletions node-core/components/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
"github.com/berachain/beacon-kit/storage/beacondb"
"github.com/berachain/beacon-kit/storage/block"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

// Backend is a struct that holds the storage backend. It provides a simple
Expand All @@ -39,7 +39,7 @@ type Backend struct {
chainSpec chain.Spec
availabilityStore *dastore.Store
kvStore *beacondb.KVStore
depositStore *depositdb.KVStore
depositStore deposit.Store
blockStore *block.KVStore[*types.BeaconBlock]
logger log.Logger
telemetrySink statedb.TelemetrySink
Expand All @@ -49,7 +49,7 @@ func NewBackend(
chainSpec chain.Spec,
availabilityStore *dastore.Store,
kvStore *beacondb.KVStore,
depositStore *depositdb.KVStore,
depositStore deposit.Store,
blockStore *block.KVStore[*types.BeaconBlock],
logger log.Logger,
telemetrySink statedb.TelemetrySink,
Expand Down Expand Up @@ -92,6 +92,6 @@ func (k Backend) BlockStore() *block.KVStore[*types.BeaconBlock] {
}

// DepositStore returns the deposit store struct initialized with a.
func (k Backend) DepositStore() *depositdb.KVStore {
func (k Backend) DepositStore() deposit.Store {
return k.depositStore
}
6 changes: 3 additions & 3 deletions state-transition/core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/berachain/beacon-kit/primitives/math"
"github.com/berachain/beacon-kit/primitives/transition"
"github.com/berachain/beacon-kit/state-transition/core/state"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

// StateProcessor is a basic Processor, which takes care of the
Expand All @@ -52,7 +52,7 @@ type StateProcessor struct {
// executionEngine is the engine responsible for executing transactions.
executionEngine ExecutionEngine
// ds allows checking payload deposits against the deposit contract
ds *depositdb.KVStore
ds deposit.Store
// metrics is the metrics for the service.
metrics *stateProcessorMetrics
// logDeneb1Once enforces logging the Deneb1 fork information at most once.
Expand All @@ -64,7 +64,7 @@ func NewStateProcessor(
logger log.Logger,
cs ChainSpec,
executionEngine ExecutionEngine,
ds *depositdb.KVStore,
ds deposit.Store,
signer crypto.BLSSigner,
fGetAddressFromPubKey func(crypto.BLSPubkey) ([]byte, error),
telemetrySink TelemetrySink,
Expand Down
6 changes: 3 additions & 3 deletions state-transition/core/validation_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/berachain/beacon-kit/primitives/constants"
"github.com/berachain/beacon-kit/primitives/math"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
depositdb "github.com/berachain/beacon-kit/storage/deposit"
"github.com/berachain/beacon-kit/storage/deposit"
)

func validateGenesisDeposits(
Expand Down Expand Up @@ -73,7 +73,7 @@ func validateGenesisDeposits(
func ValidateNonGenesisDeposits(
ctx context.Context,
st *statedb.StateDB,
depositStore *depositdb.KVStore,
depositStore deposit.Store,
maxDepositsPerBlock uint64,
blkDeposits []*ctypes.Deposit,
blkDepositRoot common.Root,
Expand All @@ -84,7 +84,7 @@ func ValidateNonGenesisDeposits(
}

// Grab all previous deposits from genesis up to the current index + max deposits per block.
localDeposits, err := depositStore.GetDepositsByIndex(
localDeposits, _, err := depositStore.GetDepositsByIndex(
ctx,
constants.FirstDepositIndex,
depositIndex+maxDepositsPerBlock,
Expand Down
Loading
Loading