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 reader-node-firehose #63

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

fschoell
Copy link
Contributor

@fschoell fschoell commented Sep 4, 2024

This adds a new reader-node app that reads blocks from another Firehose endpoint. This allows indexers to bootstrap a Firehose/Substreams stack without having to set up an instrumented blockchain node initially.

Comment on lines +96 to +117
a.zlogger.Info("launching reader log plugin")
mindreaderLogPlugin, err := mindreader.NewMindReaderPlugin(
a.Config.OneBlocksStoreURL,
a.Config.WorkingDir,
firehoseReader.NoopConsoleReader,
a.Config.StartBlockNum,
a.Config.StopBlockNum,
a.Config.MindReadBlocksChanCapacity,
a.modules.MetricsAndReadinessManager.UpdateHeadBlock,
func(_ error) {},
a.Config.OneBlockSuffix,
blockStreamServer,
a.zlogger,
a.tracer,
)
if err != nil {
return err
}

a.zlogger.Debug("configuring shutter")
mindreaderLogPlugin.OnTerminated(a.Shutdown)
a.OnTerminating(mindreaderLogPlugin.Shutdown)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, we would avoid completely the mindreader plugin, there is overall little reason to use outside avoiding re-implementing two things:

  • Save received one block to one-blocks-store
  • Emit block on block stream server

I understand it make the implementation easier. But I have the overall feeling that it will make a much simpler implementation since we will move away from the node-manager.

We should also move to something else than node-manager as the top-level package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Should I move it into its own top-level package or is there another package to include it in?

Copy link
Contributor

Choose a reason for hiding this comment

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

A new top-level reader-node-firehose seems good, the package <name> could be shorter if needed.

Comment on lines +69 to +77
stream, err := f.firehoseClient.Blocks(context.Background(), &pbfirehose.Request{
StartBlockNum: int64(startBlock),
Cursor: string(cursor),
StopBlockNum: stopBlock,
FinalBlocksOnly: false,
}, f.callOpts...)
if err != nil {
return fmt.Errorf("failed to request block stream from Firehose: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we deal with connection errors?

ctx, s.cancelPeriodicLogger = context.WithCancel(ctx)

go func() {
ticker := time.NewTicker(logEach)
Copy link
Contributor

Choose a reason for hiding this comment

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

ticker has a Stop() let's defer stop it.

Copy link
Contributor

Choose a reason for hiding this comment

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

blockRate too has a Stop method. Could go in StopPeriodicLogToZap() too.

@sduchesneau
Copy link
Contributor

  1. @fschoell let's add this new app to appsNotRunningByDefault in cmd/apps/start.go

  2. I agree with @maoueh that using the consoleReader feels very hackish and I'd much prefer copying the bits that you need to reimplement something more slim.

With these fixed, I think we could merge it.

@matthewdarwin
Copy link

Fred will continue on this in the new year.

@maoueh
Copy link
Contributor

maoueh commented Dec 16, 2024

@matthewdarwin I reviewed the SQL PRs too. If there is something I missed, let me know.

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.

4 participants