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

error returning epoch hooks #2526

Merged

Conversation

puneet2019
Copy link
Member

@puneet2019 puneet2019 commented Aug 27, 2022

Closes: #XXX
A part of #2520 only implemented for epochs module.
If it looks good, can go ahead and implement for other modules as well.
would wait for #2519 to be merged before. (rebase, etc. then open up)

What is the purpose of the change

  • Hooks errors can now be handled with ApplyFuncIfNoError
  • This implementation allows hooks interface functions to return an error.
  • If functions return an error any state changes will not be written to the state.
  • Currently it is only done for EpochHooks interface

Brief Changelog

  • Epoch Hooks now allow returning of error.
  • All modules implementing EpochHooks also return error in place of panic.

Testing and Verifying

  • Updated and fixed test cases :::NOTE: unable to verify errorMessage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? - no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no) yes
  • How is the feature or change documented? - not applicable

@puneet2019 puneet2019 requested a review from a team August 27, 2022 12:28
@github-actions github-actions bot added C:x/epochs C:x/incentives C:x/mint C:x/superfluid C:x/twap Changes to the twap module C:x/txfees C:docs Improvements or additions to documentation labels Aug 27, 2022
@puneet2019 puneet2019 marked this pull request as draft August 27, 2022 12:30
@puneet2019 puneet2019 changed the title Puneet/error returning epoch hooks error returning epoch hooks Aug 27, 2022
@puneet2019 puneet2019 force-pushed the puneet/error-returning-epoch-hooks branch from c5e4efe to 8cca90c Compare August 29, 2022 19:27
@puneet2019 puneet2019 marked this pull request as ready for review August 29, 2022 19:29
Comment on lines 8 to 14
func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) {
k.hooks.AfterEpochEnd(ctx, identifier, epochNumber)
func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) error {
return k.hooks.AfterEpochEnd(ctx, identifier, epochNumber)
}

// BeforeEpochStart new epoch is next block of epoch end block
func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) {
k.hooks.BeforeEpochStart(ctx, identifier, epochNumber)
Copy link
Member

Choose a reason for hiding this comment

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

Can we ignore the error in here, instead of in abci.go?

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

@@ -395,7 +395,10 @@ func (suite *KeeperTestSuite) TestAfterEpochEnd() {

osmoassert.ConditionalPanic(suite.T(), tc.expectedPanic, func() {
Copy link
Member

Choose a reason for hiding this comment

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

We should change the variable here to expectedError, and then just do an if statement for checking if error vs checking no error

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

This LGTM, thanks for doing this!

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

All suggestions have been applied. Should be ready for merge. Thanks @puneet2019

@p0mvn p0mvn merged commit 1ec83c3 into osmosis-labs:main Aug 30, 2022
@github-actions github-actions bot mentioned this pull request Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:docs Improvements or additions to documentation C:x/epochs C:x/incentives C:x/mint C:x/superfluid C:x/twap Changes to the twap module C:x/txfees
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants