For example say a contract with a compiler version of 0.7.5 (pragma solidity 0.7.5) contained selfdestruct(payable(address))
what happens to the contract when the self destruct opcode gets deprecated in the future? Will the contract still work the same or differently?
1 Answer
A contract that uses an opcode that is subsequently removed would no longer be working (its behavior would be unspecifiable). However, to my knowledge, no opcode has ever been removed from Ethereum.
SELFDESTRUCT will still exist as an opcode (value 0xFF) even after the Cancun hard fork - it's just that its behavior will be different. See EIP-6780.
After Cacncun, SELFDESTRUCT will only transfer ETH to the specified address if the contract is not created in the same transaction, and it will work as before in the reverse case (contract created in the same transaction).