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

On Initialize should panic with input 0 #4316

Open
shawntabrizi opened this issue Apr 28, 2024 · 1 comment
Open

On Initialize should panic with input 0 #4316

shawntabrizi opened this issue Apr 28, 2024 · 1 comment

Comments

@shawntabrizi
Copy link
Member

I am fixing benchmarks in pallet_bounties because the benchmarks took advantage of some behavior when on_initialize(0) was executed.

However, in a real blockchain, there will never be an on_initialize(0), so this was a hack which later broke when it shouldn't have.

I think within the macros, we should implement some sort of debug panic (or real panic) if the input to on_initialize is zero, to discourage anyone from running the function in this scenario.

@shawntabrizi
Copy link
Member Author

The same should be applied to any of the pallet hooks where block number comes in. on_finalize, etc...

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

No branches or pull requests

1 participant