linera-protocol
linera-protocol copied to clipboard
Add a close_chain endpoint for contracts.
Applications should be given the opportunity to clean up, e.g. unsubscribe from everything, when a chain is closed.
I'm not convinced anymore that a close_chain endpoint on the contract is a good idea: What if running all the close_chain calls on all installed applications takes too much gas for a single block?
Maybe it should rather be an uninstall endpoint that allows deregistering apps from chains. CloseChain would then fail if there are any applications left—and have a flag to override this and close the chain anyway.
Or each application can optionally provide custom cleanup functions, and have a flag recognized by the system whether it's okay to deregister it. Applications that do require cleanup can set this flag to false until cleanup has been performed.
Another use case is for e.g. the fungible or non-fungible applications to move all assets elsewhere before closing a chain.
Done in https://github.com/linera-io/linera-protocol/pull/1746.