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: refactor protobufs and utils to remove grpc-js dependency #798

Merged
merged 12 commits into from
Apr 4, 2023

Conversation

PangZhi
Copy link
Contributor

@PangZhi PangZhi commented Apr 3, 2023

Motivation

Part of #573, removed grpc-js dependency from protobufs (thus utils).

Change Summary

  • separate rpc.proto to request_response.proto and rpc.proto (only have service definition), remove grpc-js dependency from protobufs (thus utils)
  • move all grpc-js code generation to hub-nodejs
  • refactor hubble app to use hub-nodejs
  • add protobufs & utils as dependency for hub-web and add new exports

Merge Checklist

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

  • PR title adheres to the conventional commits standard
  • PR has a changeset
  • PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore)
  • PR does not require changes to the protocol

Additional Context

@PangZhi PangZhi added the t-feat Add a new feature or protocol improvement label Apr 3, 2023
@changeset-bot
Copy link

changeset-bot bot commented Apr 3, 2023

🦋 Changeset detected

Latest commit: f95eed5

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

This PR includes changesets to release 5 packages
Name Type
@farcaster/protobufs Minor
@farcaster/hub-web Minor
@farcaster/utils Minor
@farcaster/hub-nodejs Patch
@farcaster/hubble 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

@@ -0,0 +1,10 @@
---
'@farcaster/protobufs': minor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally it's major change for protobufs and utils (interface not backward compatible). However, it seems that we haven't released major version of protobufs & utils yet, so I made it minor.

@socket-security
Copy link

socket-security bot commented Apr 3, 2023

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
@farcaster/[email protected] None +1 varunsrin
⬆️ Updated Package Version Diff Added Capability Access +/- Transitive Count Publisher
@grpc/[email protected] 1.8.7...1.8.13 None +0/-0 murgatroid99

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Patch coverage: 85.58% and project coverage change: -0.43 ⚠️

Comparison is base (71d6494) 73.03% compared to head (a043e15) 72.61%.

❗ Current head a043e15 differs from pull request most recent head f95eed5. Consider uploading reports for the commit f95eed5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #798      +/-   ##
==========================================
- Coverage   73.03%   72.61%   -0.43%     
==========================================
  Files          61       62       +1     
  Lines        5359     5379      +20     
  Branches     1216     1212       -4     
==========================================
- Hits         3914     3906       -8     
- Misses       1351     1373      +22     
- Partials       94      100       +6     
Impacted Files Coverage Δ
apps/hubble/src/eth/utils.ts 100.00% <ø> (ø)
apps/hubble/src/hubble.ts 1.86% <0.00%> (ø)
apps/hubble/src/network/p2p/protocol.ts 100.00% <ø> (ø)
apps/hubble/src/rpc/adminServer.ts 1.88% <0.00%> (ø)
apps/hubble/src/rpc/server.ts 79.24% <ø> (ø)
apps/hubble/src/storage/db/hubState.ts 36.36% <ø> (ø)
apps/hubble/src/storage/db/idRegistryEvent.ts 83.87% <ø> (ø)
apps/hubble/src/storage/db/nameRegistryEvent.ts 100.00% <ø> (ø)
apps/hubble/src/storage/db/rocksdb.ts 90.47% <ø> (ø)
apps/hubble/src/storage/engine/seed.ts 100.00% <ø> (ø)
... and 27 more

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -47,6 +47,7 @@
"dependencies": {
"@chainsafe/libp2p-gossipsub": "6.1.0",
"@chainsafe/libp2p-noise": "^11.0.0 ",
"@farcaster/hub-nodejs": "^0.6.0",
Copy link
Contributor Author

@PangZhi PangZhi Apr 3, 2023

Choose a reason for hiding this comment

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

What's the process for package release here? We need to release and update dependency to new version in order:
protobuf, utils, hub-nodejs & hub-web, hubble app

Do we need to break this PR into multiple PRs for release purpose?

Copy link
Contributor

Choose a reason for hiding this comment

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

We use changesets for version control, so we can run yarn changeset version and it will update all of these correctly.

@PangZhi
Copy link
Contributor Author

PangZhi commented Apr 3, 2023

Codecov Report

Patch coverage: 2.56% and project coverage change: -26.23 ⚠️

Comparison is base (d0239f8) 74.04% compared to head (c1a7796) 47.81%.

Additional details and impacted files
☔ View full report in Codecov by Sentry. 📢 Do you have feedback about the report comment? Let us know in this issue.

any config to ignore the coverage for generated code?

Copy link
Contributor

@pfletcherhill pfletcherhill left a comment

Choose a reason for hiding this comment

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

Exciting! I think the most important question to answer is whether we want hubble to import anything from @farcaster/protobufs or @farcaster/utils rather than getting everything from @farcaster/hub-nodejs. Right now it seems somewhat arbitrary which package a file picks for each import.

@@ -1,5 +1,6 @@
import * as protobufs from '@farcaster/protobufs';
import { Factories, getInsecureHubRpcClient, HubResult, HubRpcClient } from '@farcaster/utils';
import { Factories, HubResult } from '@farcaster/utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to continue importing these from @farcaster/utils vs from @farcaster/hub-nodejs since hub-nodejs also exports everything from utils?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking through I think it's cleaner and more consistent to just depend on hub-nodejs and use all imports there, refactored hubble

@@ -0,0 +1,124 @@
syntax = "proto3";
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for splitting rpc.proto into two files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally feel this is slightly cleaner pattern: share whatever can be shared.
Where hub-nodejs and hub-web are different is the service/client generation part (exactly the rpc.proto after splitting). After splitting, we will be able to share like SyncIds and Empty from protobufs

@@ -18,7 +18,7 @@
"scripts": {
"build": "tsup --config tsup.config.ts",
"clean": "rimraf ./dist",
"protoc": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated/ --ts_proto_opt=esModuleInterop=true,exportCommonSymbols=false,outputServices=grpc-js,useOptionals=none,unrecognizedEnum=false,removeEnumPrefix=true --proto_path=./src/schemas ./src/schemas/*",
"protoc": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated/ --ts_proto_opt=esModuleInterop=true,exportCommonSymbols=false,outputServices=false,useOptionals=none,unrecognizedEnum=false,removeEnumPrefix=true --proto_path=./src/schemas ./src/schemas/*",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we get rid of @farcaster/protobufs entirely and just add a protoc command to @farcaster/utils to generate the non-service protobuf classes for itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is exactly next step: completely merge these two into a single package. Was planning to do it in separate PR.

@PangZhi
Copy link
Contributor Author

PangZhi commented Apr 3, 2023

@sds do you know how to let codecov/path and codecov/project skip generated code from grpc? I think now they're failing because of generated code.

@sds
Copy link
Member

sds commented Apr 3, 2023

I didn't set this tool up, so I'm not familiar with it (honestly didn't even know this existed until now 🙂).

It looks like we could specify the ignore option in codecov.yml to ignore the directories with generated files?

CC @pfletcherhill @varunsrin how much do we care about code coverage requirements being met?

@varunsrin
Copy link
Member

fine to merge without code coverage requirements, theyre not meant to be blocking just a guide

but it would be nice if we added that to the ignore file to keep the code coverage metrics useful

@PangZhi
Copy link
Contributor Author

PangZhi commented Apr 3, 2023

codecov.yml

I

I didn't set this tool up, so I'm not familiar with it (honestly didn't even know this existed until now 🙂).

It looks like we could specify the ignore option in codecov.yml to ignore the directories with generated files?

CC @pfletcherhill @varunsrin how much do we care about code coverage requirements being met?

I think the codecov ignored the previous generated code in the protobufs package, but it's not in the codecov.yml. We should definitely fix so the metric is useful.

@PangZhi PangZhi force-pushed the jf/refactor_protobufs_utils branch from c1a7796 to 511ef02 Compare April 4, 2023 00:22
@PangZhi PangZhi closed this Apr 4, 2023
@PangZhi PangZhi reopened this Apr 4, 2023
@PangZhi PangZhi closed this Apr 4, 2023
@PangZhi PangZhi reopened this Apr 4, 2023
Copy link
Contributor

@pfletcherhill pfletcherhill left a comment

Choose a reason for hiding this comment

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

Looks good to me! One minor change and a question, otherwise ready to merge.

@@ -1,5 +1,5 @@
import * as protobufs from '@farcaster/protobufs';
import { Factories } from '@farcaster/utils';
import * as hub_nodejs from '@farcaster/hub-nodejs';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can you camelCase this variable?


export * from './generated/rpc';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to export from ./generated/request_response too? Or does the export of that file from @farcaster/protobufs work with the services exported from ./generated/rpc?

Copy link
Contributor Author

@PangZhi PangZhi Apr 4, 2023

Choose a reason for hiding this comment

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

I tried locally using FidRequest (one of the request_response), so the export was from @farcaster/protobufs but things work well when I feed into rpc request.

@PangZhi PangZhi merged commit 1f47906 into farcasterxyz:main Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-feat Add a new feature or protocol improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants