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

Move generalizable genesis logic out of gaia #3006

Closed
rigelrozanski opened this issue Dec 5, 2018 · 3 comments · Fixed by #4159
Closed

Move generalizable genesis logic out of gaia #3006

rigelrozanski opened this issue Dec 5, 2018 · 3 comments · Fixed by #4159
Assignees
Labels
C:genesis relating to chain genesis S:needs more info This bug can't be addressed until more information is provided by the reporter. S:proposed
Milestone

Comments

@rigelrozanski
Copy link
Contributor

rigelrozanski commented Dec 5, 2018

There is a lot of genesis logic which could be generalized and moved out of gaia. Likely this should go in it's own package, but maybe it could be lumped in withserver/? not totally sure. Certain gaia genesis logic of course does belong in gaia such as the "free" tokens which all genesis validators are assigned in this current incarnation of the gaia genesis logic. However much of the module logic could be generalized I believe. Namely:

  • genesis processing (tasks a modules should perform before initialization)
    • one example of this would be totalling up "loose" tokens for staking
  • genesis verification
  • export genesis parameters

We could create a genesis interface which genesis modules could satisfy. Might look somethings like:

type ModuleGenesis interface {
    func Preprocess(sdk.Context)
    func ValidateInput()
    func ExportGenesis(sdk.Context)
}

Each module would then include custom function NewModuleGenesis, which may have arbitrary inputs, for instance for staking, as Preprocess() would calculate the total "loose" tokens, it would need an array of the accounts as input to its NewModuleGenesis function.

I'd expect that the genesis logic would be initialized with an array of the modules as well as custom application processing. Here custom application processing means things independant of the modules, for instance in gaia right now we give all the validators some free tokens arbitrarily, this type of things would go in applicationGenLogic. Might look something like this (although not sure applicationGenLogic should only be a func()):

func PerformGenesis(mgs []ModuleGenesis, applicationGenLogic func()) 

Ultimately, using a predefined genesis logic set as is being proposed here should be optional, aka, we should not enforce the use of this genesis flow if a project wants to have the level of control which gaia currently holds over genesis. - but I think that the most projects can likely fit into a generalized scheme.

CC @alessio @jackzampolin @ValarDragon @cwgoes @alexanderbez
-> feel free to edit/expand on this main comment here!

@jackzampolin
Copy link
Member

jackzampolin commented Dec 5, 2018

This is pretty similar to what I did with the ModuleClient interface. I really like this approach.

One note, we should have a standard applicationGenLogic that can be exported.

@alexanderbez
Copy link
Contributor

Dope! I think this does warrant having a genesis package or sub-package somewhere though.

@cwgoes
Copy link
Contributor

cwgoes commented Jan 21, 2019

cc @alessio

@jackzampolin jackzampolin added this to the v0.32.0 milestone Jan 29, 2019
@jackzampolin jackzampolin added the S:needs more info This bug can't be addressed until more information is provided by the reporter. label Feb 7, 2019
@alexanderbez alexanderbez modified the milestones: v0.34.0, Backlog Mar 15, 2019
@rigelrozanski rigelrozanski modified the milestones: Backlog, Migrate Gaia out of the SDK repo Apr 2, 2019
@alessio alessio modified the milestones: Migrate Gaia out of the SDK repo, v0.35.0 Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:genesis relating to chain genesis S:needs more info This bug can't be addressed until more information is provided by the reporter. S:proposed
Projects
None yet
5 participants