From 8309852158baf707d0751d248f947c05ead05c18 Mon Sep 17 00:00:00 2001 From: Angel Valkov Date: Mon, 20 Jan 2025 16:37:35 +0200 Subject: [PATCH] Remove FetchMilestoneByID --- consensus/bor/heimdall.go | 1 - consensus/bor/heimdall/client.go | 29 ------------------------- consensus/bor/heimdallapp/milestone.go | 13 ----------- consensus/bor/heimdallgrpc/milestone.go | 21 ------------------ 4 files changed, 64 deletions(-) diff --git a/consensus/bor/heimdall.go b/consensus/bor/heimdall.go index fbd5cfb7f9..38afc3e5f0 100644 --- a/consensus/bor/heimdall.go +++ b/consensus/bor/heimdall.go @@ -22,6 +22,5 @@ type IHeimdallClient interface { FetchMilestoneCount(ctx context.Context) (int64, error) FetchNoAckMilestone(ctx context.Context, milestoneID string) error // Fetch the bool value whether milestone corresponding to the given id failed in the Heimdall FetchLastNoAckMilestone(ctx context.Context) (string, error) // Fetch latest failed milestone id - FetchMilestoneID(ctx context.Context, milestoneID string) error // Fetch the bool value whether milestone corresponding to the given id is in process in Heimdall Close() } diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index dbe1e466a4..ce9ac55cb1 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -87,7 +87,6 @@ const ( fetchLastNoAckMilestone = "/milestone/last-no-ack" fetchNoAckMilestone = "/milestone/no-ack/%s" - fetchMilestoneByID = "/milestone/%s" fetchSpanFormat = "bor/span/%d" ) @@ -268,29 +267,6 @@ func (h *HeimdallClient) FetchNoAckMilestone(ctx context.Context, milestoneID st return nil } -// FetchMilestoneByID fetches the bool result from Heimdal whether the ID corresponding -// to the given milestone is in process in Heimdall -func (h *HeimdallClient) FetchMilestoneByID(ctx context.Context, milestoneID string) error { - url, err := milestoneIDURL(h.urlString, milestoneID) - if err != nil { - return err - } - - ctx = withRequestType(ctx, milestoneIDRequest) - - response, err := FetchWithRetry[milestone.MilestoneResponse](ctx, h.client, url, h.closeCh) - - if err != nil { - return err - } - - if response.Result.EndBlock == 0 { - return fmt.Errorf("%w: milestoneID %q", ErrNotInMilestoneList, milestoneID) - } - - return nil -} - // FetchWithRetry returns data from heimdall with retry func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL, closeCh chan struct{}) (*T, error) { // request data once @@ -450,11 +426,6 @@ func noAckMilestoneURL(urlString string, id string) (*url.URL, error) { return makeURL(urlString, url, "") } -func milestoneIDURL(urlString string, id string) (*url.URL, error) { - url := fmt.Sprintf(fetchMilestoneByID, id) - return makeURL(urlString, url, "") -} - func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) { u, err := url.Parse(urlString) if err != nil { diff --git a/consensus/bor/heimdallapp/milestone.go b/consensus/bor/heimdallapp/milestone.go index 27eac343cb..d7b5a01572 100644 --- a/consensus/bor/heimdallapp/milestone.go +++ b/consensus/bor/heimdallapp/milestone.go @@ -68,19 +68,6 @@ func (h *HeimdallAppClient) FetchLastNoAckMilestone(_ context.Context) (string, return res, nil } -// TODO HV2: Uncomment once the implementation is done -// func (h *HeimdallAppClient) FetchMilestoneID(_ context.Context, milestoneID string) error { -// log.Debug("Fetching Milestone ID ", "MilestoneID", milestoneID) - -// res := milestoneTypes.GetMilestoneID() - -// if res == milestoneID { -// return nil -// } - -// return fmt.Errorf("milestone corresponding to milestoneID: %v doesn't exist in heimdall", milestoneID) -// } - func toBorMilestone(hdMilestone *milestoneTypes.Milestone) *milestone.Milestone { return &milestone.Milestone{ Proposer: common.HexToAddress(hdMilestone.Proposer), diff --git a/consensus/bor/heimdallgrpc/milestone.go b/consensus/bor/heimdallgrpc/milestone.go index 83ae902a6a..d9361fc143 100644 --- a/consensus/bor/heimdallgrpc/milestone.go +++ b/consensus/bor/heimdallgrpc/milestone.go @@ -80,24 +80,3 @@ func (h *HeimdallGRPCClient) FetchNoAckMilestone(ctx context.Context, milestoneI return nil } - -func (h *HeimdallGRPCClient) FetchMilestoneID(ctx context.Context, milestoneID string) error { - req := &proto.FetchMilestoneIDRequest{ - MilestoneID: milestoneID, - } - - log.Debug("Fetching milestone id", "milestoneID", milestoneID) - - res, err := h.client.FetchMilestoneID(ctx, req) - if err != nil { - return err - } - - if !res.Result.Result { - return fmt.Errorf("%w: milestoneID %q", heimdall.ErrNotInMilestoneList, milestoneID) - } - - log.Debug("Fetched milestone id", "milestoneID", milestoneID) - - return nil -}