Skip to content

Commit

Permalink
chore(depositdb): Remove consensus-types as a dep (berachain#1218)
Browse files Browse the repository at this point in the history
* modular

* x

* bet

* bet

* remove unused deps
  • Loading branch information
itsdevbear authored May 29, 2024
1 parent 97b5cfd commit 9ccb6f9
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 150 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ docs/
networks/
proto/
tools/
kurtosis/
.github/
.git/
.vscode/
Expand Down
4 changes: 2 additions & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kurtosis-tech/kurtosis/api/golang v0.89.11 h1:+bkOA6UMOchLHZ27n09JLy3TudyBwZZyUUgg87jnN7Y=
github.com/kurtosis-tech/kurtosis/api/golang v0.89.11/go.mod h1:9T22P7Vv3j5g6sbm78DxHQ4s9C4Cj3s9JjFQ7DFyYpM=
github.com/kurtosis-tech/kurtosis/api/golang v0.89.12 h1:wM2a4fk9zbQC/ypTQujPB9IGtK0uJ3dWIFV04On8bOI=
github.com/kurtosis-tech/kurtosis/api/golang v0.89.12/go.mod h1:9T22P7Vv3j5g6sbm78DxHQ4s9C4Cj3s9JjFQ7DFyYpM=
github.com/kurtosis-tech/kurtosis/cloud/api/golang v0.0.0-20230803130419-099ee7a4e3dc h1:/6Ffp1LIbBf8nL9EyCSmNps5PGwWu65ogHk8LBGaP5E=
github.com/kurtosis-tech/kurtosis/cloud/api/golang v0.0.0-20230803130419-099ee7a4e3dc/go.mod h1:+dhneovUimcuMPeYhMRXbit5kII/SIqvtfj6jTShOLo=
github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g=
Expand Down
2 changes: 1 addition & 1 deletion mod/node-builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (nb *NodeBuilder[T]) BuildRootCmd() error {
log.NewLogger(os.Stdout),
viper.GetViper(),
nb.chainSpec,
&depositdb.KVStore{},
&depositdb.KVStore[*types.Deposit]{},
&engineclient.EngineClient[*types.ExecutableDataDeneb]{},
&gokzg4844.JSONTrustedSetup{},
&dastore.Store[types.BeaconBlockBody]{},
Expand Down
7 changes: 5 additions & 2 deletions mod/node-builder/pkg/components/deposit_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package components
import (
"cosmossdk.io/depinject"
storev2 "cosmossdk.io/store/v2/db"
"github.com/berachain/beacon-kit/mod/consensus-types/pkg/types"
"github.com/berachain/beacon-kit/mod/storage/pkg/deposit"
"github.com/cosmos/cosmos-sdk/client/flags"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand All @@ -42,15 +43,17 @@ type DepositStoreInput struct {

// ProvideDepositStore is a function that provides the module to the
// application.
func ProvideDepositStore(in DepositStoreInput) (*deposit.KVStore, error) {
func ProvideDepositStore(
in DepositStoreInput,
) (*deposit.KVStore[*types.Deposit], error) {
name := "deposits"
dir := cast.ToString(in.AppOpts.Get(flags.FlagHome)) + "/data"
kvp, err := storev2.NewDB(storev2.DBTypePebbleDB, name, dir, nil)
if err != nil {
return nil, err
}

return deposit.NewStore(&deposit.KVStoreProvider{
return deposit.NewStore[*types.Deposit](&deposit.KVStoreProvider{
KVStoreWithBatch: kvp,
}), nil
}
2 changes: 1 addition & 1 deletion mod/node-builder/pkg/components/module/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type DepInjectInput struct {
AvailabilityStore *dastore.Store[types.BeaconBlockBody]
BeaconConfig *config.Config
ChainSpec primitives.ChainSpec
DepositStore *depositdb.KVStore
DepositStore *depositdb.KVStore[*types.Deposit]
EngineClient *engineclient.EngineClient[*types.ExecutableDataDeneb]
KzgTrustedSetup *gokzg4844.JSONTrustedSetup
Signer crypto.BLSSigner
Expand Down
10 changes: 5 additions & 5 deletions mod/node-builder/pkg/components/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ type BeaconKitRuntime = runtime.BeaconKitRuntime[
types.BeaconBlockBody,
core.BeaconState[*types.Validator],
*datypes.BlobSidecars,
*depositdb.KVStore,
*depositdb.KVStore[*types.Deposit],
runtime.StorageBackend[
*dastore.Store[types.BeaconBlockBody],
types.BeaconBlockBody,
core.BeaconState[*types.Validator],
*datypes.BlobSidecars,
*depositdb.KVStore,
*depositdb.KVStore[*types.Deposit],
],
]

Expand All @@ -87,7 +87,7 @@ func ProvideRuntime(
types.BeaconBlockBody,
core.BeaconState[*types.Validator],
*datypes.BlobSidecars,
*depositdb.KVStore,
*depositdb.KVStore[*types.Deposit],
],
ts *metrics.TelemetrySink,
logger log.Logger,
Expand Down Expand Up @@ -227,7 +227,7 @@ func ProvideRuntime(
depositService := deposit.NewService[
types.BeaconBlock,
events.Block[types.BeaconBlock],
*depositdb.KVStore,
*depositdb.KVStore[*types.Deposit],
event.Subscription,
](
logger.With("service", "deposit"),
Expand All @@ -252,7 +252,7 @@ func ProvideRuntime(
types.BeaconBlockBody,
core.BeaconState[*types.Validator],
*datypes.BlobSidecars,
*depositdb.KVStore,
*depositdb.KVStore[*types.Deposit],
](
chainSpec,
logger,
Expand Down
28 changes: 19 additions & 9 deletions mod/node-builder/pkg/components/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,27 @@ type Backend[
types.BeaconBlockBody, *datypes.BlobSidecars,
],
BeaconStateT core.BeaconState[*types.Validator],
DepositT deposit.Deposit,
] struct {
cs primitives.ChainSpec
availabilityStore AvailabilityStoreT
beaconStore *KVStore
depositStore *deposit.KVStore
depositStore *deposit.KVStore[DepositT]
}

func NewBackend[
AvailabilityStoreT runtime.AvailabilityStore[
types.BeaconBlockBody, *datypes.BlobSidecars,
],
BeaconStateT core.BeaconState[*types.Validator],
DepositT deposit.Deposit,
](
cs primitives.ChainSpec,
availabilityStore AvailabilityStoreT,
beaconStore *KVStore,
depositStore *deposit.KVStore,
) *Backend[AvailabilityStoreT, BeaconStateT] {
return &Backend[AvailabilityStoreT, BeaconStateT]{
depositStore *deposit.KVStore[DepositT],
) *Backend[AvailabilityStoreT, BeaconStateT, DepositT] {
return &Backend[AvailabilityStoreT, BeaconStateT, DepositT]{
cs: cs,
availabilityStore: availabilityStore,
beaconStore: beaconStore,
Expand All @@ -84,15 +86,19 @@ func NewBackend[
}

// AvailabilityStore returns the availability store struct initialized with a.
func (k *Backend[AvailabilityStoreT, BeaconStateT]) AvailabilityStore(
func (k *Backend[
AvailabilityStoreT, BeaconStateT, DepositT,
]) AvailabilityStore(
_ context.Context,
) AvailabilityStoreT {
return k.availabilityStore
}

// BeaconState returns the beacon state struct initialized with a given
// context and the store key.
func (k *Backend[AvailabilityStoreT, BeaconStateT]) StateFromContext(
func (k *Backend[
AvailabilityStoreT, BeaconStateT, DepositT,
]) StateFromContext(
ctx context.Context,
) BeaconStateT {
return state.NewBeaconStateFromDB[BeaconStateT](
Expand All @@ -102,13 +108,17 @@ func (k *Backend[AvailabilityStoreT, BeaconStateT]) StateFromContext(
}

// BeaconStore returns the beacon store struct.
func (k *Backend[AvailabilityStoreT, BeaconStateT]) BeaconStore() *KVStore {
func (k *Backend[
AvailabilityStoreT, BeaconStateT, DepositT,
]) BeaconStore() *KVStore {
return k.beaconStore
}

// DepositStore returns the deposit store struct initialized with a.
func (k *Backend[AvailabilityStoreT, BeaconStateT]) DepositStore(
func (k *Backend[
AvailabilityStoreT, BeaconStateT, DepositT,
]) DepositStore(
_ context.Context,
) *deposit.KVStore {
) *deposit.KVStore[DepositT] {
return k.depositStore
}
26 changes: 2 additions & 24 deletions mod/storage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.22.3

replace (
// TODO consensus-types should be decoupleable.
github.com/berachain/beacon-kit/mod/consensus-types => ../consensus-types
github.com/berachain/beacon-kit/mod/engine-primitives => ../engine-primitives
github.com/berachain/beacon-kit/mod/errors => ../errors
github.com/berachain/beacon-kit/mod/log => ../log
Expand All @@ -15,7 +14,6 @@ require (
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/log v1.3.1
github.com/berachain/beacon-kit/mod/consensus-types v0.0.0-00010101000000-000000000000
github.com/berachain/beacon-kit/mod/errors v0.0.0-00010101000000-000000000000
github.com/berachain/beacon-kit/mod/log v0.0.0-00010101000000-000000000000
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240429161625-c105cec3420c
Expand All @@ -34,11 +32,9 @@ require (
cosmossdk.io/store v1.1.0 // indirect
cosmossdk.io/x/tx v0.13.2 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/berachain/beacon-kit/mod/engine-primitives v0.0.0-00010101000000-000000000000 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
Expand All @@ -48,30 +44,21 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.6 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/gogoproto v1.4.12 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ethereum/c-kzg-4844 v1.0.1 // indirect
github.com/ethereum/go-ethereum v1.14.3 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -94,12 +81,10 @@ require (
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/gomega v1.33.1 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand All @@ -108,21 +93,15 @@ require (
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.14.0 // indirect
github.com/prysmaticlabs/gohashtree v0.0.4-beta // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/zerolog v1.32.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
Expand All @@ -137,6 +116,5 @@ require (
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 9ccb6f9

Please sign in to comment.