hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
281 stars 125 forks source link

feat: For EVM compatibility, remove some existing Hedera-specific restrictions on `SELFDESTRUCT` #14764

Open david-bakin-sl opened 1 month ago

david-bakin-sl commented 1 month ago

Our SELFDESTRUCT operator is different from the EVM's. Necessarily so because we have additional semantics on accounts (and this is documented as part of EVM compatibility.). But some of those restrictions came about at the initial implementation of SELFDESTRUCT are are still enforced even though it seems likely they are unnecessary.

For example, you are allowed to sweep a balance (hbar or token) to the contract's own account. Because, if you just destructed the account, where is the hbar or token to go? But that restriction came about before we had EVM aliases and hollow accounts. Conceivably it could be lifted now.

Suggestion is to look at the current restrictions - mostly in DispatchingEvmFrameState and mostly there in the method tryTrackingSelfDestructBeneficiary) - and see which can, with some work, be lifted.

Reason to do this: SELFDESTRUCT, even post-Cancun, is still used in various interesting patterns by various services, and one of them may run into one of these limitations, which, if we didn't actually need it, would be unfortunate.