Skip to content

Move generalizable genesis logic out of gaia #3006

Closed
@rigelrozanski

Description

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C:genesisrelating to chain genesisS:needs more infoThis bug can't be addressed until more information is provided by the reporter.S:proposed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions