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

Feature/bm powered sink #2

Merged
merged 8 commits into from
May 9, 2024
Merged

Feature/bm powered sink #2

merged 8 commits into from
May 9, 2024

Conversation

ArnaudBger
Copy link
Contributor

No description provided.

Copy link
Contributor

@sduchesneau sduchesneau left a comment

Choose a reason for hiding this comment

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

Very good, just a few things I'd like you to change for clarity, reducing logs fatigue.

break
}

zlog.Info("retrying block range computation", zap.Uint64("session_counter", sessionCounter), zap.Int("start_block_computed", startBlock), zap.Int("end_block_computed", endBlock))
Copy link
Contributor

Choose a reason for hiding this comment

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

The "retrying" message is unclear, it looks like something failed, but it didn't. Also, start_block and end_block will always be equal, no need to print them both...
Replace with something like:
"waiting for head block to reach next threshold", zap.Uint64("target", startBlock+substreamsSegmentSize + reversibleSegmentSize), zap.Uint64("current_head", ... this would be a lot more useful to the guy trying to figure out what's going on!

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, printed every 5 seconds may be too many. Use a counter and only zlog.Info one when counter % 6 == 0 (so around 30 seconds)
Another approach is to use zlog.Check() to specify debug level at runtime: always zap.DebugLevel until counter%6==0, then use zap.InfoLevel.

}
}

func computeBlockRangeFromHead(ctx context.Context, blockmetaClient pbbmsrvconnect.BlockClient, reversibleSegmentSize uint64, substreamsSegmentSize uint64, blockRangeArg string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should get the blockHead in the run() function and keep the 'computeBlockRangeFromHead' function's purpose to actually compute it (not fetch it.)
Easier to test, clearer separation of concerns, and will allow you to use the headBlockNum in the logs I asked in my last comment.


if err := app.Err(); err != nil {
return err
apiKey := os.Getenv("SUBSTREAMS_API_KEY")
Copy link
Contributor

Choose a reason for hiding this comment

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

Once you move this to run() function, you can check this environment variable just once, and maybe return an error that specifies that this environment variable is required especially for Blockmeta. It wouldn't be clear to a user using the substreams_api_token (JWT) why he is required to use the api_key too !

@ArnaudBger ArnaudBger merged commit 8a795bf into develop May 9, 2024
5 checks passed
ArnaudBger added a commit that referenced this pull request Jun 25, 2024
…ink"

This reverts commit 8a795bf, reversing
changes made to 23b0ba4.
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