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

Clean Up Old Runtimes on Canonical Chain #2767

Open
danforbes opened this issue Aug 22, 2022 · 1 comment
Open

Clean Up Old Runtimes on Canonical Chain #2767

danforbes opened this issue Aug 22, 2022 · 1 comment
Assignees

Comments

@danforbes
Copy link
Contributor

danforbes commented Aug 22, 2022

(EDIT by Quentin on 2023-01-16)

Currently, Gossamer maintains running instances of all runtimes that were included in the canonical chain. This leads to a build up in memory usage for each runtime upgrade, since the previous instance (and all its associated wasmer/cgo resources) are kept running (see #1973).

So far, all calls need the best block runtime except:

Changes to be made:

Runtimes to keep instantiated:

  • Best block runtime
  • Finalised block runtime
  • Unfinalised runtimes

Note each of these runtimes might be the same runtime pointer in most cases.

  • Keep the best block runtime instantiated
  • Keep the finalised block runtime instantiated (might be the same pointer as best block)
  • Keep a mapping from runtime-upgrade block hash <-> runtime location (hash, db key etc.)
  • When needed, find the ancestor runtime-upgrade block OR finalised block (whichever is found first) for a given block hash, then find the corresponding runtime and instantiate it from disk
  • Remove mapping block hash <-> runtime pointer

Unanswered questions:

  1. Can an upgrade happen on some but not all of the unfinalised forks? -> Yes
  2. Do we need the runtime substitution feature?
@EclesioMeloJunior
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants