Replies: 1 comment 2 replies
-
Thank you for sharing your proposal @mshakeg, we appreciate your inputs inside and outside the scope of this discussion. With respect to this proposal, if you want to guarantee that a contract can only be deleted internally with Additionally, in the case of rent archiving/cold storing contract state, if a contract is being archived because it didn't pay rent, all its state and bytecode gets archived into cold storage which can be later retrievable for a fee. It won't be removed or need cleaning in that sense. Does that make sense? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
Currently, when a smart contract deployed on the Hedera network is deleted due to for example failure to pay rent, the contract is removed from the network without giving the contract an opportunity to perform any cleanup actions. This can lead to situations where the contract leaves behind unwanted data or invalid state on contracts it may be coupled to, which may cause issues for contracts that may depend on the deleted contract. Specifically, a contract may want to perform any of the following common(i.e. typical on Ethereum) cleanup actions before being deleted:
Child
contract created by aFactory
contract may want to invoke aFactory
contract function indicating that theChild
is about to be deleted.Unlike Hedera, a contract on Ethereum may only ever be deleted by the contract itself by invoking the (recently deprecated)SELFDESTRUCT opcode. Thus any cleanup a contract may require can be executed before that opcode is invoked. A simple example of how this typically works is as follows:
Proposal
Before the Hedera network deletes a smart contract it should attempt to execute a transaction that calls a
cleanup()
function with a predefined gas limit(say500_000
) and withmsg.sender
equal to a predefined address that identifies that the transaction is being executed by the Hedera network. If this transaction fails due to:cleanup()
function not being implemented by the contract orcleanup()
function reverting orcleanup()
function to not exceed the predefined gas limit)then the contract is deleted in any case.
A simple example of how this would work is as follows:
Beta Was this translation helpful? Give feedback.
All reactions