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

ethstats: added some error handling in ethstats.go #29834

Closed
wants to merge 1 commit into from

Conversation

pratikspatil024
Copy link

Although the panic was already addressed in PR#29020, I thought of catching the error and modifying the approach a little bit.

I am currently throwing an ERROR, but that might be too harsh, so can change it to WARN.

@@ -610,6 +610,7 @@ func (s *Service) reportBlock(conn *connWrapper, block *types.Block) error {
if details == nil {
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

pls remove this line

Copy link
Author

Choose a reason for hiding this comment

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

Done, thanks!

@fjl
Copy link
Contributor

fjl commented May 28, 2024

The PR doesn't meaningfully improve the logic. The ethstats module will try to access the latest block repeatedly. If there is an error accessing the database, we do not really want to see it because there will be lots of other reports of the access failure already.

@fjl fjl closed this May 28, 2024
block, err = fullBackend.BlockByNumber(context.Background(), rpc.BlockNumber(head.Number.Uint64()))
// Short circuit if no block is available. It might happen when
// the blockchain is reorging.
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Keeping the old check of block == nil seems safer as it will guarantee that we won't crash later when accessing it. I don't particularly mind retrieving and printing teh error, but would keep the check.

Copy link
Author

Choose a reason for hiding this comment

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

@karalabe Its the same thing, right? If there is an error fetching the block, the the block returned will be nil and we are returning nil. If the error is not nil, that means the we have a block which is not nil.

But I agree with @fjl :

The PR doesn't meaningfully improve the logic

I can change the log level to DEBUG, but upto you guys to decide. Thanks.

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