Skip to content

Commit

Permalink
Update the NSC on epbs (#14626)
Browse files Browse the repository at this point in the history
  • Loading branch information
potuz authored Nov 7, 2024
1 parent 05ba83b commit b22febf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion beacon-chain/blockchain/process_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ func (s *Service) postBlockProcess(cfg *postBlockProcessConfig) error {
return nil
}
if cfg.roblock.Version() >= version.EPBS {
return nil
// update the NSC and handle epoch boundaries here since we do
// not send FCU at all
return s.updateCachesPostBlockProcessing(cfg)
}
if err := s.getFCUArgs(cfg, fcuArgs); err != nil {
log.WithError(err).Error("Could not get forkchoice update argument")
Expand Down
8 changes: 6 additions & 2 deletions beacon-chain/blockchain/receive_execution_payload_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/epbs"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/das"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/execution"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
Expand Down Expand Up @@ -112,12 +113,15 @@ func (s *Service) ReceiveExecutionPayloadEnvelope(ctx context.Context, signed in
headBlk, err := s.HeadBlock(ctx)
if err != nil {
log.WithError(err).Error("could not get head block")
return nil
}
if err := s.saveHead(ctx, root, headBlk, preState); err != nil {
log.WithError(err).Error("could not save new head")
return nil
}
// update the NSC with the hash for the full block
if err := transition.UpdateNextSlotCache(ctx, blockHash[:], preState); err != nil {
log.WithError(err).Error("could not update next slot cache with payload")
}

}
timeWithoutDaWait := time.Since(receivedTime) - daWaitedTime
executionEngineProcessingTime.Observe(float64(timeWithoutDaWait.Milliseconds()))
Expand Down
7 changes: 6 additions & 1 deletion time/slots/slottime.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ func TimeIntoSlot(genesisTime uint64) time.Duration {
// WithinVotingWindow returns whether the current time is within the voting window
// (eg. 4 seconds on mainnet) of the current slot.
func WithinVotingWindow(genesisTime uint64, slot primitives.Slot) bool {
votingWindow := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot
var votingWindow uint64
if ToEpoch(slot) >= params.BeaconConfig().EPBSForkEpoch {
votingWindow = params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlotEPBS
} else {
votingWindow = params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot
}
return time.Since(StartTime(genesisTime, slot)) < time.Duration(votingWindow)*time.Second
}

Expand Down

0 comments on commit b22febf

Please sign in to comment.