Skip to content

Commit

Permalink
chore(async): fix weird import aliases (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocnc2 authored Aug 20, 2024
1 parent 410b352 commit f652491
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 62 deletions.
16 changes: 8 additions & 8 deletions mod/beacon/block_store/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package blockstore
import (
"context"

async "github.com/berachain/beacon-kit/mod/async/pkg/types"
asynctypes "github.com/berachain/beacon-kit/mod/async/pkg/types"
"github.com/berachain/beacon-kit/mod/log"
async1 "github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/async"
)

// Service is a Service that listens for blocks and stores them in a KVStore.
Expand All @@ -38,11 +38,11 @@ type Service[
// logger is used for logging information and errors.
logger log.Logger[any]
// dispatcher is the dispatcher for the service.
dispatcher async.EventDispatcher
dispatcher asynctypes.EventDispatcher
// store is the block store for the service.
store BlockStoreT
// subFinalizedBlkEvents is a channel for receiving finalized block events.
subFinalizedBlkEvents chan async1.Event[BeaconBlockT]
subFinalizedBlkEvents chan async.Event[BeaconBlockT]
}

// NewService creates a new block service.
Expand All @@ -52,15 +52,15 @@ func NewService[
](
config Config,
logger log.Logger[any],
dispatcher async.EventDispatcher,
dispatcher asynctypes.EventDispatcher,
store BlockStoreT,
) *Service[BeaconBlockT, BlockStoreT] {
return &Service[BeaconBlockT, BlockStoreT]{
config: config,
logger: logger,
dispatcher: dispatcher,
store: store,
subFinalizedBlkEvents: make(chan async1.Event[BeaconBlockT]),
subFinalizedBlkEvents: make(chan async.Event[BeaconBlockT]),
}
}

Expand All @@ -78,7 +78,7 @@ func (s *Service[BeaconBlockT, _]) Start(ctx context.Context) error {

// subscribe a channel to the finalized block events.
if err := s.dispatcher.Subscribe(
async1.BeaconBlockFinalizedEvent, s.subFinalizedBlkEvents,
async.BeaconBlockFinalizedEvent, s.subFinalizedBlkEvents,
); err != nil {
s.logger.Error("failed to subscribe to block events", "error", err)
return err
Expand All @@ -102,7 +102,7 @@ func (s *Service[BeaconBlockT, BlockStoreT]) eventLoop(ctx context.Context) {
// onFinalizeBlock is triggered when a finalized block event is received.
// It stores the block in the KVStore.
func (s *Service[BeaconBlockT, _]) onFinalizeBlock(
event async1.Event[BeaconBlockT],
event async.Event[BeaconBlockT],
) {
slot := event.Data().GetSlot()
if err := s.store.Set(event.Data()); err != nil {
Expand Down
44 changes: 22 additions & 22 deletions mod/beacon/blockchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"context"
"sync"

async "github.com/berachain/beacon-kit/mod/async/pkg/types"
asynctypes "github.com/berachain/beacon-kit/mod/async/pkg/types"
"github.com/berachain/beacon-kit/mod/log"
async1 "github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/transition"
)
Expand Down Expand Up @@ -57,7 +57,7 @@ type Service[
// chainSpec holds the chain specifications.
chainSpec common.ChainSpec
// dispatcher is the dispatcher for the service.
dispatcher async.Dispatcher
dispatcher asynctypes.Dispatcher
// executionEngine is the execution engine responsible for processing
//
// execution payloads.
Expand All @@ -82,12 +82,12 @@ type Service[

// subFinalBlkReceived is a channel for receiving finalize beacon block
// requests.
subFinalBlkReceived chan async1.Event[BeaconBlockT]
subFinalBlkReceived chan async.Event[BeaconBlockT]
// subBlockReceived is a channel for receiving verify beacon block requests.
subBlockReceived chan async1.Event[BeaconBlockT]
subBlockReceived chan async.Event[BeaconBlockT]
// subGenDataReceived is a subscription for receiving genesis data
// received events.
subGenDataReceived chan async1.Event[GenesisT]
subGenDataReceived chan async.Event[GenesisT]
}

// NewService creates a new validator service.
Expand All @@ -112,7 +112,7 @@ func NewService[
],
logger log.Logger[any],
chainSpec common.ChainSpec,
dispatcher async.Dispatcher,
dispatcher asynctypes.Dispatcher,
executionEngine ExecutionEngine[PayloadAttributesT],
localBuilder LocalBuilder[BeaconStateT],
stateProcessor StateProcessor[
Expand Down Expand Up @@ -144,9 +144,9 @@ func NewService[
metrics: newChainMetrics(telemetrySink),
optimisticPayloadBuilds: optimisticPayloadBuilds,
forceStartupSyncOnce: new(sync.Once),
subFinalBlkReceived: make(chan async1.Event[BeaconBlockT]),
subBlockReceived: make(chan async1.Event[BeaconBlockT]),
subGenDataReceived: make(chan async1.Event[GenesisT]),
subFinalBlkReceived: make(chan async.Event[BeaconBlockT]),
subBlockReceived: make(chan async.Event[BeaconBlockT]),
subGenDataReceived: make(chan async.Event[GenesisT]),
}
}

Expand All @@ -164,19 +164,19 @@ func (s *Service[
_, BeaconBlockT, _, _, _, _, _, _, GenesisT, _,
]) Start(ctx context.Context) error {
if err := s.dispatcher.Subscribe(
async1.GenesisDataReceived, s.subGenDataReceived,
async.GenesisDataReceived, s.subGenDataReceived,
); err != nil {
return err
}

if err := s.dispatcher.Subscribe(
async1.BeaconBlockReceived, s.subBlockReceived,
async.BeaconBlockReceived, s.subBlockReceived,
); err != nil {
return err
}

if err := s.dispatcher.Subscribe(
async1.FinalBeaconBlockReceived, s.subFinalBlkReceived,
async.FinalBeaconBlockReceived, s.subFinalBlkReceived,
); err != nil {
return err
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func (s *Service[

func (s *Service[
_, _, _, _, _, _, _, _, GenesisT, _,
]) handleGenDataReceived(msg async1.Event[GenesisT]) {
]) handleGenDataReceived(msg async.Event[GenesisT]) {
var (
valUpdates transition.ValidatorUpdates
genesisErr error
Expand All @@ -227,9 +227,9 @@ func (s *Service[

// Emit the event containing the validator updates.
if err := s.dispatcher.Publish(
async1.NewEvent(
async.NewEvent(
msg.Context(),
async1.GenesisDataProcessed,
async.GenesisDataProcessed,
valUpdates,
genesisErr,
),
Expand All @@ -245,7 +245,7 @@ func (s *Service[
func (s *Service[
_, BeaconBlockT, _, _, _, _, _, _, _, _,
]) handleBeaconBlockReceived(
msg async1.Event[BeaconBlockT],
msg async.Event[BeaconBlockT],
) {
// If the block is nil, exit early.
if msg.Error() != nil {
Expand All @@ -256,9 +256,9 @@ func (s *Service[
// emit a BeaconBlockVerified event with the error result from \
// VerifyIncomingBlock
if err := s.dispatcher.Publish(
async1.NewEvent(
async.NewEvent(
msg.Context(),
async1.BeaconBlockVerified,
async.BeaconBlockVerified,
msg.Data(),
s.VerifyIncomingBlock(msg.Context(), msg.Data()),
),
Expand All @@ -273,7 +273,7 @@ func (s *Service[
func (s *Service[
_, BeaconBlockT, _, _, _, _, _, _, _, _,
]) handleBeaconBlockFinalization(
msg async1.Event[BeaconBlockT],
msg async.Event[BeaconBlockT],
) {
var (
valUpdates transition.ValidatorUpdates
Expand All @@ -295,9 +295,9 @@ func (s *Service[

// Emit the event containing the validator updates.
if err := s.dispatcher.Publish(
async1.NewEvent(
async.NewEvent(
msg.Context(),
async1.FinalValidatorUpdatesProcessed,
async.FinalValidatorUpdatesProcessed,
valUpdates,
finalizeErr,
),
Expand Down
20 changes: 10 additions & 10 deletions mod/beacon/validator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package validator
import (
"context"

async "github.com/berachain/beacon-kit/mod/async/pkg/types"
asynctypes "github.com/berachain/beacon-kit/mod/async/pkg/types"
"github.com/berachain/beacon-kit/mod/log"
async1 "github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/crypto"
"github.com/berachain/beacon-kit/mod/primitives/pkg/transition"
Expand Down Expand Up @@ -62,7 +62,7 @@ type Service[
// sb is the beacon state backend.
sb StorageBackend[BeaconStateT, DepositStoreT]
// dispatcher is the dispatcher.
dispatcher async.EventDispatcher
dispatcher asynctypes.EventDispatcher
// stateProcessor is responsible for processing the state.
stateProcessor StateProcessor[
BeaconBlockT,
Expand All @@ -81,7 +81,7 @@ type Service[
// metrics is a metrics collector.
metrics *validatorMetrics
// subNewSlot is a channel for new slot events.
subNewSlot chan async1.Event[SlotDataT]
subNewSlot chan async.Event[SlotDataT]
}

// NewService creates a new validator service.
Expand Down Expand Up @@ -117,7 +117,7 @@ func NewService[
localPayloadBuilder PayloadBuilder[BeaconStateT, ExecutionPayloadT],
remotePayloadBuilders []PayloadBuilder[BeaconStateT, ExecutionPayloadT],
ts TelemetrySink,
dispatcher async.EventDispatcher,
dispatcher asynctypes.EventDispatcher,
) *Service[
AttestationDataT, BeaconBlockT, BeaconBlockBodyT, BeaconStateT,
BlobSidecarsT, DepositT, DepositStoreT, Eth1DataT, ExecutionPayloadT,
Expand All @@ -140,7 +140,7 @@ func NewService[
remotePayloadBuilders: remotePayloadBuilders,
metrics: newValidatorMetrics(ts),
dispatcher: dispatcher,
subNewSlot: make(chan async1.Event[SlotDataT]),
subNewSlot: make(chan async.Event[SlotDataT]),
}
}

Expand All @@ -159,7 +159,7 @@ func (s *Service[
ctx context.Context,
) error {
// subscribe to new slot events
err := s.dispatcher.Subscribe(async1.NewSlot, s.subNewSlot)
err := s.dispatcher.Subscribe(async.NewSlot, s.subNewSlot)
if err != nil {
return err
}
Expand All @@ -185,7 +185,7 @@ func (s *Service[_, _, _, _, _, _, _, _, _, _, _, _, SlotDataT]) eventLoop(
// slot data and emits an event containing the built block and sidecars.
func (s *Service[
_, BeaconBlockT, _, _, BlobSidecarsT, _, _, _, _, _, _, _, SlotDataT,
]) handleNewSlot(req async1.Event[SlotDataT]) {
]) handleNewSlot(req async.Event[SlotDataT]) {
var (
blk BeaconBlockT
sidecars BlobSidecarsT
Expand All @@ -201,14 +201,14 @@ func (s *Service[

// emit a built block event with the built block and the error
if bbErr := s.dispatcher.Publish(
async1.NewEvent(req.Context(), async1.BuiltBeaconBlock, blk, err),
async.NewEvent(req.Context(), async.BuiltBeaconBlock, blk, err),
); bbErr != nil {
s.logger.Error("failed to dispatch built block", "err", err)
}

// emit a built sidecars event with the built sidecars and the error
if scErr := s.dispatcher.Publish(
async1.NewEvent(req.Context(), async1.BuiltSidecars, sidecars, err),
async.NewEvent(req.Context(), async.BuiltSidecars, sidecars, err),
); scErr != nil {
s.logger.Error("failed to dispatch built sidecars", "err", err)
}
Expand Down
28 changes: 14 additions & 14 deletions mod/da/pkg/da/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package da
import (
"context"

async "github.com/berachain/beacon-kit/mod/async/pkg/types"
asynctypes "github.com/berachain/beacon-kit/mod/async/pkg/types"
"github.com/berachain/beacon-kit/mod/log"
async1 "github.com/berachain/beacon-kit/mod/primitives/pkg/async"
"github.com/berachain/beacon-kit/mod/primitives/pkg/async"
)

// The Data Availability service is responsible for verifying and processing
Expand All @@ -41,10 +41,10 @@ type Service[
AvailabilityStoreT,
BlobSidecarsT,
]
dispatcher async.EventDispatcher
dispatcher asynctypes.EventDispatcher
logger log.Logger[any]
subSidecarsReceived chan async1.Event[BlobSidecarsT]
subFinalBlobSidecars chan async1.Event[BlobSidecarsT]
subSidecarsReceived chan async.Event[BlobSidecarsT]
subFinalBlobSidecars chan async.Event[BlobSidecarsT]
}

// NewService returns a new DA service.
Expand All @@ -56,7 +56,7 @@ func NewService[
bp BlobProcessor[
AvailabilityStoreT, BlobSidecarsT,
],
dispatcher async.EventDispatcher,
dispatcher asynctypes.EventDispatcher,
logger log.Logger[any],
) *Service[
AvailabilityStoreT, BlobSidecarsT,
Expand All @@ -68,8 +68,8 @@ func NewService[
bp: bp,
dispatcher: dispatcher,
logger: logger,
subSidecarsReceived: make(chan async1.Event[BlobSidecarsT]),
subFinalBlobSidecars: make(chan async1.Event[BlobSidecarsT]),
subSidecarsReceived: make(chan async.Event[BlobSidecarsT]),
subFinalBlobSidecars: make(chan async.Event[BlobSidecarsT]),
}
}

Expand All @@ -85,14 +85,14 @@ func (s *Service[_, BlobSidecarsT]) Start(ctx context.Context) error {

// subscribe to SidecarsReceived events
if err = s.dispatcher.Subscribe(
async1.SidecarsReceived, s.subSidecarsReceived,
async.SidecarsReceived, s.subSidecarsReceived,
); err != nil {
return err
}

// subscribe to FinalSidecarsReceived events
if err = s.dispatcher.Subscribe(
async1.FinalSidecarsReceived, s.subFinalBlobSidecars,
async.FinalSidecarsReceived, s.subFinalBlobSidecars,
); err != nil {
return err
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func (s *Service[_, BlobSidecarsT]) eventLoop(ctx context.Context) {
// event.
// It processes the sidecars and publishes a BlobSidecarsProcessed event.
func (s *Service[_, BlobSidecarsT]) handleFinalSidecarsReceived(
msg async1.Event[BlobSidecarsT],
msg async.Event[BlobSidecarsT],
) {
if err := s.processSidecars(msg.Context(), msg.Data()); err != nil {
s.logger.Error(
Expand All @@ -137,7 +137,7 @@ func (s *Service[_, BlobSidecarsT]) handleFinalSidecarsReceived(
// handleSidecarsReceived handles the SidecarsVerifyRequest event.
// It verifies the sidecars and publishes a SidecarsVerified event.
func (s *Service[_, BlobSidecarsT]) handleSidecarsReceived(
msg async1.Event[BlobSidecarsT],
msg async.Event[BlobSidecarsT],
) {
var sidecarsErr error
// verify the sidecars.
Expand All @@ -151,8 +151,8 @@ func (s *Service[_, BlobSidecarsT]) handleSidecarsReceived(

// emit the sidecars verification event with error from verifySidecars
if err := s.dispatcher.Publish(
async1.NewEvent(
msg.Context(), async1.SidecarsVerified, msg.Data(), sidecarsErr,
async.NewEvent(
msg.Context(), async.SidecarsVerified, msg.Data(), sidecarsErr,
),
); err != nil {
s.logger.Error("failed to publish event", "err", err)
Expand Down
Loading

0 comments on commit f652491

Please sign in to comment.