-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore: loosen assertions in SetOrderBeginBlockers() and SetOrderEndBlockers() #14415
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I provide the supplementary comments.
simapp/app.go
Outdated
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, | ||
evidencetypes.ModuleName, stakingtypes.ModuleName, | ||
authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, | ||
authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, | ||
paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, | ||
upgradetypes.ModuleName, | ||
capabilitytypes.ModuleName, | ||
minttypes.ModuleName, | ||
distrtypes.ModuleName, | ||
slashingtypes.ModuleName, | ||
evidencetypes.ModuleName, | ||
stakingtypes.ModuleName, | ||
authz.ModuleName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the main reason of the PR is to make the list clean, I removed module names which does not have BeginBlock()
.
But, it's not mandatory.
func(moduleName string) bool { | ||
module := m.Modules[moduleName] | ||
_, hasBeginBlock := module.(BeginBlockAppModule) | ||
return !hasBeginBlock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion passes if the module does not have BeginBlock()
.
{"less modules", false, []string{"a"}, nil}, | ||
{"same modules", true, []string{"a", "b"}, nil}, | ||
{"more modules", true, []string{"a", "b", "c"}, nil}, | ||
{"pass module b", true, []string{"a"}, func(moduleName string) bool { return moduleName == "b" }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relevant unit test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nicer but the reason we added it before was that a developer forgot to add the begin blocker and it caused issue. I think we should keep that functionality but instead, if possible, we should check all the modules if they have the interface(s) somewhere else, if so then error out telling the user they forgot to add a module this prevents the problem we faced earlier but without forcing users to list all the modules
You mean, the developer forgot to add the module name into the argument of
I thought following procedures are necessary:
Hence, while sequencing them, we can also check whether the modules which have If a module has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! It seems like a nice improvement!
Have you checked it the docs (docs/) are up to date?
I think we should add a changelog under improvements too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
Thanks to #12603, we can omit the methods
BeginBlock()
andEndBlock()
from a module. This patch goes one step further, allowing one not to add the module name intoSetOrderBeginBlockers()
orSetOrderEndBlockers()
if the module does not have the corresponding method.Before implementing the method, we cannot know its order in the modules, so I think it would be better not to add a module into the order list before implementing it.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change