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

Substreams-powered subgraphs cookbook #401

Merged
merged 10 commits into from
Jun 13, 2023
Merged

Conversation

azf20
Copy link
Contributor

@azf20 azf20 commented Jun 7, 2023

Simple integration using a contract-tracking substreams package and the latest Tables helper, this is an end-to-end example

Depends on: graphprotocol/graph-tooling#1371

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

📦 Next.js Bundle Analysis for @graphprotocol/docs

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 639.95 KB (🟡 +72 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/en/cookbook/substreams-powered-subgraphs 65.63 KB 705.59 KB 201.60%

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/en/querying/graph-client/[[...slug]] 62.74 KB 702.69 KB 200.77% (🟡 +0.03%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.


In order to serve Substreams-powered subgraphs, Graph Node must be configured with a Substreams provider for the relevant network, as well as a Firehose or RPC to track the chain head. These providers can be configured via a `config.toml` file:

```js
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
```js
```toml


imports:
eth: 'https://github.com/streamingfast/sf-ethereum/releases/download/v0.10.2/ethereum-v0.10.4.spkg'
entity: 'https://github.com/streamingfast/substreams-entity-change/releases/download/v0.2.1/substreams-entity-change-v0.2.1.spkg'
Copy link

Choose a reason for hiding this comment

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

Given the above, subgraph developers can use Graph CLI >=0.51.0 to build and deploy this Substreams-powered subgraph.

```bash
graph build
Copy link

Choose a reason for hiding this comment

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

Does graph build detect that it is working with substreams? Compiling & packing it into the spkg?

I've been doing cargo build + substreams pack + graph deploy all this time 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah - good catch, graph build actually isn't necessary in this step (you have been doing the right thing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But with substreams-js... we actually could build the spkg as part of the Graph CLI in the future (?)

Copy link

Choose a reason for hiding this comment

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

If that doesn't work, I'd add a note to remind people of building and packing for their changes to be reflected in the subgraph they deploy (or to work at all the first time).

But with substreams-js... we actually could build the spkg as part of the Graph CLI in the future (?)

This could be good :)

@azf20 azf20 marked this pull request as ready for review June 11, 2023 22:45
@azf20 azf20 requested a review from a team as a code owner June 11, 2023 22:45
@azf20 azf20 merged commit 5bf0d98 into main Jun 13, 2023
2 checks passed
@azf20 azf20 deleted the azf20/substreams-powered-subgraphs branch June 13, 2023 12:32
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.

None yet

4 participants