Skip to content

Commit

Permalink
bet
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed May 26, 2024
2 parents 4fb1c7d + 5fca81e commit b1ad503
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions mod/beacon/blockchain/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,41 +118,50 @@ func (s *Service[

// No matter what happens we always want to forkchoice at the end of post
// block processing.
defer func() {
go s.sendPostBlockFCU(ctx, st, blk, optimisticEngine)
}()
// TODO: this is hood as fuck.
go s.sendPostBlockFCU(ctx, st, blk, optimisticEngine)
go s.postBlockProcessTasks(ctx, st)

//
//
//
//
//
// TODO: EVERYTHING BELOW THIS LINE SHOULD NOT PART OF THE
// MAIN BLOCK PROCESSING THREAD.
//
//
//
//
//
//
return valUpdates, nil
}

// postBlockProcessTasks performs post block processing tasks.
//
// TODO: Deprecate this function and move it's usage outside of the main block
// processing thread.
func (s *Service[
AvailabilityStoreT, ReadOnlyBeaconStateT,
BlobSidecarsT, DepositStoreT,
]) postBlockProcessTasks(
ctx context.Context,
st ReadOnlyBeaconStateT,
) {
// Prune deposits.
// TODO: This should be moved into a go-routine in the background.
// Watching for logs should be completely decoupled as well.
idx, err := st.GetEth1DepositIndex()
if err != nil {
return nil, err
s.logger.Error(
"failed to get eth1 deposit index in postBlockProcessTasks",
"error", err)
return
}

// TODO: pruner shouldn't be in main block processing thread.
if err = s.PruneDepositEvents(ctx, idx); err != nil {
return nil, err
s.logger.Error(
"failed to prune deposit events in postBlockProcessTasks",
"error", err)
return
}

var lph engineprimitives.ExecutionPayloadHeader
lph, err = st.GetLatestExecutionPayloadHeader()
if err != nil {
return nil, err
s.logger.Error(
"failed to get latest execution payload in postBlockProcessTasks",
"error", err)
return
}

// Process the logs from the previous blocks execution payload.
Expand All @@ -162,11 +171,10 @@ func (s *Service[
if err = s.retrieveDepositsFromBlock(
ctx, lph.GetNumber()-eth1FollowDistance,
); err != nil {
s.logger.Error("failed to process logs", "error", err)
return nil, err
s.logger.Error(
"failed to retrieve deposits from block in postBlockProcessTasks",
"error", err)
}

return valUpdates, nil
}

// ProcessBeaconBlock processes the beacon block.
Expand Down

0 comments on commit b1ad503

Please sign in to comment.