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

add sf.firehose.v2.EndpointInfo/Info endpoint and logic #60

Merged
merged 7 commits into from
Aug 26, 2024

Conversation

sduchesneau
Copy link
Contributor

  • Add sf.firehose.v2.EndpointInfo/Info service on Firehose and Substreams endpoints. This involves the following new flags:

    • advertise-chain-name Canonical name of the chain, from the list here: https://thegraph.com/docs/en/developing/supported-networks/ (required)
    • advertise-chain-aliases Alternate names for that chain (optional)
    • advertise-block-features Only required for ethereum blocks, automatically discovered if run from firehose-ethereum program
    • advertise-block-id-encoding Required, one of [BLOCK_ID_ENCODING_BASE58, BLOCK_ID_ENCODING_BASE64, BLOCK_ID_ENCODING_HEX, BLOCK_ID_ENCODING_0X_HEX]
  • The new info endpoint adds a mandatory fetching of the first streamable block on startup, with a failure if no block can be fetched after 3 minutes and you are running firehose or substreams-tier1 service.

@sduchesneau
Copy link
Contributor Author

sduchesneau commented Aug 23, 2024

Testing like this:

grpcurl --emit-defaults  --plaintext  localhost:10016  sf.substreams.rpc.v2.EndpointInfo/Info
grpcurl --emit-defaults  --plaintext  localhost:10015  sf.firehose.v2.EndpointInfo/Info

with firecore running like this:

go run ./cmd/firecore start substreams-tier1,firehose --config-file= --log-format=stackdriver --log-to-file=false --common-first-streamable-block=0 --common-live-blocks-addr="" --common-merged-blocks-store-url=/path/to/ethereum/blocks --advertise-chain-name=mainnet

It should work with or without the --advertise-chain-name flag, but fail if it is set to a wrong "known chain", ex bnb

@sduchesneau sduchesneau marked this pull request as ready for review August 23, 2024 17:53
…ore without setting the 'base/extended/hybrid' feature
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated
Comment on lines 19 to 20
* Add a well-known list of chains (hard-coded in `wellknown/chains.go` to help automatically determine the 'advertise' flag values)
* The new info endpoint adds a mandatory fetching of the first streamable block on startup, with a failure if no block can be fetched after 3 minutes and you are running `firehose` or `substreams-tier1` service.
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 also talk about how a well-known chain is determined, what checks we perform to infer it.

Comment on lines 98 to 108
for {
if ctx.Err() != nil {
return nil
}

block, err := bstream.FetchBlockFromMergedBlocksStore(ctx, blockNum, mergedBlocksStore)
if err != nil {
continue
}
return block
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This would require a sleep too, if something is severly broken and FetchBlockFromMergedBlocksStore return rapidly an error, this might burn CPUs.

Comment on lines 133 to 137
block, err := bstream.FetchBlockFromOneBlockStore(ctx, blockNum, "", oneBlockStore)
if err != nil {
continue
}
return block
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for sleep

}

type Chain struct {
Name string
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the canonical network ID of The Graph? If yes, we should document the field.


type Chain struct {
Name string
Aliases []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Aliases []string
// Genesis block here is actually the "lowest possible" first streamable block through firehose blocks.
// In most cases, it matches the "genesis block" of the chain.
GenesisBlockID string
Copy link
Contributor

Choose a reason for hiding this comment

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

Document expected format, which I think it's chain specific. Probably good to document how to retrieve it too, so PR are easy to submit.

@sduchesneau sduchesneau merged commit a5050bd into develop Aug 26, 2024
2 checks passed
@sduchesneau sduchesneau deleted the feature/info branch August 26, 2024 19:29
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.

2 participants