Skip to content

Commit

Permalink
Remove FetchMilestoneByID
Browse files Browse the repository at this point in the history
  • Loading branch information
avalkov committed Jan 20, 2025
1 parent ca91db6 commit 8309852
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 64 deletions.
1 change: 0 additions & 1 deletion consensus/bor/heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
29 changes: 0 additions & 29 deletions consensus/bor/heimdall/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const (

fetchLastNoAckMilestone = "/milestone/last-no-ack"
fetchNoAckMilestone = "/milestone/no-ack/%s"
fetchMilestoneByID = "/milestone/%s"

fetchSpanFormat = "bor/span/%d"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions consensus/bor/heimdallapp/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
21 changes: 0 additions & 21 deletions consensus/bor/heimdallgrpc/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8309852

Please sign in to comment.