Skip to content

Conversation

@spooktheducks
Copy link
Contributor

Purpose of Changes and their Description

Link(s) to Ticket(s) or Issue(s) resolved by this PR

Are these changes tested and documented?

  • If tested, please describe how. If not, why tests are not needed.
  • If documented, please describe where. If not, describe why docs are not needed.
  • Added to Unreleased section of CHANGELOG.md?

Still Left Todo

Fill this out if this is a Draft PR so others can help.

@spooktheducks spooktheducks marked this pull request as draft July 3, 2025 08:10
@spooktheducks spooktheducks force-pushed the spook/cleanup-logging branch from 3ac264a to 142e49d Compare July 3, 2025 08:42
Copy link
Contributor

@amimart amimart left a comment

Choose a reason for hiding this comment

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

This seems like a good standard to adopt

However I think through this initiative we also need to carefully hunt down all the false-errors that are expected situations and non state breaking, as returning an error in an ABCI method will halt the chain.

Also as a side not, I think we should have less error types as most of them denotes the same type but in different context

Comment on lines +197 to +201
logger := sdkCtx.Logger().With(
"abci_step", "EndBlock",
"height", sdkCtx.BlockHeight(),
)
sdkCtx = sdkCtx.WithLogger(logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, I think we should also systematically set the module logger field to allow proper filtering through configuration as it is done here

Copy link
Contributor

Choose a reason for hiding this comment

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

We actually do it in mint module :D

and in the tests, although here we use "submodules"

return types.ErrNoQualifiedInferers
return errors.Wrap(err, "failed: fetch active inferrers for topic")
} else if len(activeInfererAddresses) == 0 {
return errors.Wrap(types.ErrNoQualifiedInferers, "no qualified inferrers")
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 this should not be an error as it seems to be a situation expected to happen, by returning an error for a normal behaviour we'll halt the chain

if err != nil {
sdkCtx.Logger().Info("Error closing worker nonce", "error", err)
}
return errors.WrapWithFields(err, "failed: close worker nonce", "topic_id", topicId)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to return the error here, on any case of any error, then we need to carefully review all of the errors we currently have, and either classify them as unexpected (then halt) or recoverable, or just do not return and propagate such recoverable errors on those functions if they are expected to be handled.

This change would need careful review of our error handling within all Begin/EndBlocker code, so it'd be better done in a separate effort than the current fixes on BeginBlocker/EndBlocker.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I think we would need to do that, for safety; because we are treating equally (= ignoring) both a business-as-usual error like "no inferers in this epoch" or a critical one like "no access to store".


// EndBlock returns the end blocker for the emissions module.
func (am AppModule) EndBlock(ctx context.Context) error {
func (am AppModule) EndBlock(ctx context.Context) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good one, I'll move this pattern to our current Begin/EndBlocker.

@spooktheducks spooktheducks force-pushed the spook/cleanup-logging branch from 142e49d to 7ba7ff9 Compare July 3, 2025 11:13
@spooktheducks spooktheducks changed the title wip Correct error handling in EndBlocker Jul 9, 2025
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