Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add currentPeers RPC Endpoint #1630

Merged
merged 12 commits into from
Feb 29, 2024

Conversation

zachterrell57
Copy link
Contributor

@zachterrell57 zachterrell57 commented Jan 21, 2024

Motivation

This endpoint was added to get an approximate list of all peers on the network

Change Summary

  • Added new Proto definitions for endpoint
  • New accessor method for current peers
  • New RPC endpoint for current peers /v1/peerList

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review

Additional Context

Response looks like the following:

{
    "contacts": [
        {
            "gossipAddress": {
                "address": "84.247.175.196",
                "family": 4,
                "port": 2282,
                "dnsName": ""
            },
            "rpcAddress": {
                "address": "84.247.175.196",
                "family": 4,
                "port": 2283,
                "dnsName": ""
            },
            "excludedHashes": [],
            "count": 10694067,
            "hubVersion": "2023.12.27",
            "network": "FARCASTER_NETWORK_MAINNET",
            "appVersion": "1.9.2",
            "timestamp": 1705796040744
        },
      ...

PR-Codex overview

This PR adds a new currentPeers API endpoint and related changes to support fetching current peer contacts in the Hub network.

Detailed summary

  • Added currentPeers RPC endpoint
  • Implemented API endpoint for getting a list of current sync peers
  • Updated documentation for the new API endpoint
  • Added protobuf message for ContactInfoResponse
  • Updated HTTP server to handle currentPeers API call
  • Updated TypeScript files to include ContactInfoResponse and related functions

The following files were skipped due to too many changes: packages/core/src/protobufs/generated/request_response.ts, packages/hub-nodejs/src/generated/rpc.ts, packages/hub-web/src/generated/rpc.ts, packages/hub-web/src/generated/gossip.ts, packages/hub-nodejs/src/generated/gossip.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Jan 21, 2024

🦋 Changeset detected

Latest commit: e9d4108

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@farcaster/hub-nodejs Minor
@farcaster/hub-web Minor
@farcaster/core Minor
@farcaster/hubble Minor
@farcaster/replicator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hub-monorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 29, 2024 5:05am

Copy link
Contributor

@sanjayprabhu sanjayprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just needs a few minor changes.

Also looks like build is failing because the docs need to be updated.

@@ -402,6 +402,10 @@ class SyncEngine extends TypedEmitter<SyncEvents> {
return this.currentHubPeerContacts.get(peerId);
}

public getCurrentHubPeerContacts() {
return this.currentHubPeerContacts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just return the .values() so it's not possible to modify this outside of this class.

//================peerList================
// @doc-tag: /peerList
this.app.get("/v1/peerList", (request, reply) => {
const call = getCallObject("getCurrentPeers", {}, request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the name consistent between the http and the rpc apis. Maybe rename the httpEndpoint to currentPeers?

Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 76.99%. Comparing base (2d5886a) to head (e9d4108).

Files Patch % Lines
apps/hubble/src/rpc/server.ts 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #1630       +/-   ##
=========================================
+ Coverage      0   76.99%   +76.99%     
=========================================
  Files         0       99       +99     
  Lines         0     9619     +9619     
  Branches      0     2348     +2348     
=========================================
+ Hits          0     7406     +7406     
- Misses        0     2183     +2183     
- Partials      0       30       +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zachterrell57 zachterrell57 changed the title feat: Add peerList RPC Endpoint feat: Add currentPeers RPC Endpoint Feb 21, 2024
Copy link
Member

@sds sds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@sds sds merged commit 419d828 into farcasterxyz:main Feb 29, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants