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

Make a partial ordering struct #1329

Closed
ValarDragon opened this issue Apr 22, 2022 · 1 comment
Closed

Make a partial ordering struct #1329

ValarDragon opened this issue Apr 22, 2022 · 1 comment

Comments

@ValarDragon
Copy link
Member

ValarDragon commented Apr 22, 2022

A problem we face right now is that BeginBlock, EndBlock, and Upgrades require specification of a total ordering of modules in an upgrade.

This causes a number of problems:

  • It is hard to understand where to put a new module
  • Listing every module obscures the important before/after relations
  • A lot of code bloat

Ideally we should just specify the relevant partial orderings, and it can then derive a satisfying total ordering.

e.g.

BeginBlockOrdering := osmoutils.NewPartialOrdering(AllModuleNames)
BeginBlockOrdering.AfterRelation(Staking.ModuleName, Bank.ModuleName) // Staking upgrade has to come after bank
BeginBlockOrdering.BeforeRelation(Auth.ModuleName, Bank.ModuleName) // Auth has to come before bank
// can also have a First or Last method if we want

App.SetBeginBlockOrdering(BeginBlockOrdering.TotalOrdering())

(We then use this to replace

func orderBeginBlockers() []string {
)

This should be relatively simple to add, by wrapping a topological sort library, e.g. https://github.com/stevenle/topsort . See topological sorting / partial ordering -> total ordering posts for more details: https://en.wikipedia.org/wiki/Topological_sorting#Relation_to_partial_orders

@ValarDragon
Copy link
Member Author

ValarDragon commented May 4, 2022

Closed by #1335, not sure why this wasn't automatically closed

Repository owner moved this from 🔍 Needs Review to ✅ Done in Osmosis Chain Development May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant