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

Explain how program deletion can (potentially) work, and caveats. #303

Open
1 task done
johnnymatthews opened this issue Jan 8, 2025 · 1 comment
Open
1 task done
Labels
question Further information is requested

Comments

@johnnymatthews
Copy link
Collaborator

johnnymatthews commented Jan 8, 2025

Document the behavior and rules around program deletion, specifically how reference counting prevents deletion of actively used programs while potentially allowing cleanup of unused ones.

Here's what (I'm assuming are) the facts:

  1. Each program maintains an on-chain reference count.
  2. Reference count increments when accounts register/associate with the program.
  3. Programs cannot be deleted while their reference count is > 0.

Question: how do programs with zero references get deleted? Is there some kind of garbage collection?

Example flow

  • Account-Alice deploys Program-Red.
  • Account-Bob registers as a user of Program-Red (ref count = 1).
  • Account-Alice cannot delete Program-Red while Account-Bob is registered.

Question: can accounts de-register from programs?

All nodes maintain the same chain-state, and as such once a program is used (i.e. it has references) then it's permanently saved to the chain state.

Steps to reproduce

N/a

Error messages and/or screenshots

N/a

Proposed solution (optional)

N/a

Final checks

  • I have checked to see if any existing issues cover this topic and linked any other relevant issues.
@johnnymatthews johnnymatthews added the question Further information is requested label Jan 8, 2025
@JesseAbram
Copy link
Member

Question: how do programs with zero references get deleted? Is there some kind of garbage collection?

You can call remove_program in the programs pallet with the account that deployed the program, this will also return the deposit associated with the program.

Question: can accounts de-register from programs?

Yes every account can change the programs associated with their keys see pallet Registery change_program_instance, removing a program here will reduce the ref count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants