Skip to content

Commit 3e079ec

Browse files
authored
Caplin: remove extra delay in attestation production (#14128)
1 parent 3e98a04 commit 3e079ec

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

cl/beacon/handler/block_production.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -75,43 +75,6 @@ var (
7575

7676
var defaultGraffitiString = "Caplin"
7777

78-
const missedTimeout = 500 * time.Millisecond
79-
80-
func (a *ApiHandler) waitUntilHeadStateAtEpochIsReadyOrCountAsMissed(ctx context.Context, syncedData synced_data.SyncedData, epoch uint64) error {
81-
timer := time.NewTimer(missedTimeout)
82-
checkIfSlotIsThere := func() (bool, error) {
83-
tx, err := a.indiciesDB.BeginRo(ctx)
84-
if err != nil {
85-
return false, err
86-
}
87-
defer tx.Rollback()
88-
blockRoot, err := beacon_indicies.ReadCanonicalBlockRoot(tx, epoch*a.beaconChainCfg.SlotsPerEpoch)
89-
if err != nil {
90-
return false, err
91-
}
92-
return blockRoot != (libcommon.Hash{}), nil
93-
}
94-
95-
defer timer.Stop()
96-
for {
97-
select {
98-
case <-timer.C:
99-
return nil
100-
case <-ctx.Done():
101-
return fmt.Errorf("waiting for head state to reach slot %d: %w", epoch, ctx.Err())
102-
default:
103-
}
104-
ready, err := checkIfSlotIsThere()
105-
if err != nil {
106-
return err
107-
}
108-
if ready {
109-
return nil
110-
}
111-
time.Sleep(30 * time.Millisecond)
112-
}
113-
}
114-
11578
func (a *ApiHandler) waitForHeadSlot(slot uint64) {
11679
stopCh := time.After(time.Second)
11780
for {
@@ -149,11 +112,6 @@ func (a *ApiHandler) GetEthV1ValidatorAttestationData(
149112
}
150113
start := time.Now()
151114

152-
// wait until the head state is at the target slot or later
153-
err = a.waitUntilHeadStateAtEpochIsReadyOrCountAsMissed(r.Context(), a.syncedData, *slot/a.beaconChainCfg.SlotsPerEpoch)
154-
if err != nil {
155-
return nil, beaconhttp.NewEndpointError(http.StatusServiceUnavailable, err)
156-
}
157115
tx, err := a.indiciesDB.BeginRo(r.Context())
158116
if err != nil {
159117
return nil, err

0 commit comments

Comments
 (0)