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

Improve UX/docs of OnGenesis #2790

Open
mrcnski opened this issue Dec 22, 2023 · 2 comments
Open

Improve UX/docs of OnGenesis #2790

mrcnski opened this issue Dec 22, 2023 · 2 comments
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.

Comments

@mrcnski
Copy link
Contributor

mrcnski commented Dec 22, 2023

Attempting to implement OnGenesis gives this error:

error[E0119]: conflicting implementations of trait `frame_support::traits::OnGenesis` for type `coretime::pallet::Pallet<_>`
   --> polkadot/runtime/parachains/src/coretime/mod.rs:86:12
    |
86  |     #[pallet::pallet]
    |               ^^^^^^ conflicting implementation for `coretime::pallet::Pallet<_>`
...
123 |     impl<T: Config> OnGenesis for Pallet<T> {
    |     --------------------------------------- first implementation here

The docs are sparse and there aren't any examples of usage in the repo.

If it's not intended to be implemented directly, this should be documented, with an alternative provided.

Also, the Hooks trait could expose on_genesis (it's kind of weird that it does not).

@mrcnski mrcnski added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Dec 22, 2023
@mrcnski mrcnski changed the title Improve UX of OnGenesis Improve UX/docs of OnGenesis Dec 22, 2023
@mrcnski mrcnski added the T11-documentation This PR/Issue is related to documentation. label Dec 22, 2023
@gui1117
Copy link
Contributor

gui1117 commented Jan 1, 2024

In FRAME, OnGenesis is generated by the pallet macro unconditionally:

// Implement `OnGenesis` for `Pallet`
impl<#type_impl_gen> #frame_support::traits::OnGenesis
for #pallet_ident<#type_use_gen>
#config_where_clause
{
fn on_genesis() {
let storage_version: #frame_support::traits::StorageVersion = #storage_version;
storage_version.put::<Self>();
}
}

You may want to use GenesisBuild: https://docs.rs/frame-support/latest/frame_support/attr.pallet.html#genesis-build-palletgenesis_build-optional

That said, I agree with your complains on docs.

@bkchr
Copy link
Member

bkchr commented Jan 1, 2024

No we don't want GenesisBuild ;) Actually having a way to run something after having setup the state would be nice.

bkchr pushed a commit that referenced this issue Apr 10, 2024
* Bump sysinfo from 0.29.11 to 0.30.5

Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.29.11 to 0.30.5.
- [Changelog](https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/GuillaumeGomez/sysinfo/commits)

---
updated-dependencies:
- dependency-name: sysinfo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix build

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.
Projects
None yet
Development

No branches or pull requests

3 participants