Compare commits

...

5 Commits

Author SHA1 Message Date
james-prysm
d0e74f0ae9 Merge branch 'develop' into fix-optimistic-check 2025-03-06 11:15:44 -06:00
james-prysm
db5d03eeb1 fixing test 2025-03-05 14:30:28 -06:00
james-prysm
fff8f7276f fixing error message 2025-03-05 13:48:50 -06:00
james-prysm
5c01cd3915 Merge branch 'develop' into fix-optimistic-check 2025-03-05 13:46:03 -06:00
james-prysm
2cdbfeceff changing optimistic check in API to fix E2E 2025-03-05 13:36:09 -06:00
4 changed files with 18 additions and 5 deletions

View File

@@ -1158,11 +1158,10 @@ func (s *Server) GetBlockRoot(w http.ResponseWriter, r *http.Request) {
}
}
}
b32Root := bytesutil.ToBytes32(root)
isOptimistic, err := s.OptimisticModeFetcher.IsOptimisticForRoot(ctx, b32Root)
isOptimistic, err := s.OptimisticModeFetcher.IsOptimistic(ctx)
if err != nil {
httputil.HandleError(w, "Could not check if block is optimistic: "+err.Error(), http.StatusInternalServerError)
httputil.HandleError(w, "Could not retrieve optimistic status: "+err.Error(), http.StatusInternalServerError)
return
}
response := &structs.BlockRootResponse{

View File

@@ -636,6 +636,15 @@ func (s *Server) ProduceSyncCommitteeContribution(w http.ResponseWriter, r *http
ctx, span := trace.StartSpan(r.Context(), "validator.ProduceSyncCommitteeContribution")
defer span.End()
isOptimistic, err := s.OptimisticModeFetcher.IsOptimistic(ctx)
if err != nil {
httputil.HandleError(w, err.Error(), http.StatusInternalServerError)
return
}
if isOptimistic {
httputil.HandleError(w, "Beacon node is currently syncing and not serving request on that endpoint", http.StatusServiceUnavailable)
return
}
_, index, ok := shared.UintFromQuery(w, r, "subcommittee_index", true)
if !ok {
return

View File

@@ -1584,7 +1584,8 @@ func TestProduceSyncCommitteeContribution(t *testing.T) {
SyncCommitteeIndices: []primitives.CommitteeIndex{0},
},
},
SyncCommitteePool: syncCommitteePool,
SyncCommitteePool: syncCommitteePool,
OptimisticModeFetcher: &mockChain.ChainService{},
}
t.Run("ok", func(t *testing.T) {
url := "http://example.com?slot=1&subcommittee_index=1&beacon_block_root=0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
@@ -1672,7 +1673,8 @@ func TestProduceSyncCommitteeContribution(t *testing.T) {
SyncCommitteeIndices: []primitives.CommitteeIndex{0},
},
},
SyncCommitteePool: syncCommitteePool,
SyncCommitteePool: syncCommitteePool,
OptimisticModeFetcher: &mockChain.ChainService{},
}
server.ProduceSyncCommitteeContribution(writer, request)
assert.Equal(t, http.StatusNotFound, writer.Code)

View File

@@ -0,0 +1,3 @@
### Fixed
- fixes e2e introduced by PR#14997 by changing the optimistic check in getblockroot for rest APIs.