Add a SET_INDESTRUCTIBLE (0xA8)
opcode that prevents the contract from calling SELFDESTRUCT (0xff)
.
Should it be permanent or should there be a way to rollback?
The flag set by the opcode would last for the duration of the transaction, so it is temporary (though if the first byte of a contract is the opcode then of course it will trigger every time and be unavoidable, which is the intention).
Can this new OPCODE be used to signal if the contract implement or not self destruct?
If is set to false, then you canât destroy that specific contract.
Cheers
If the first byte of the code of a contract is this opcode, then that contract cannot selfdestruct.
Iâm thinking more into if you have implement the self destruct function the opcode is âtrueâ. Is not if is possible to remove the contract, but more this contract can everything is place to be removed.
Cheers
Basically can we inside a smart contract know that other smart contract can be removed.
Is important in the case when a dev want to whitelist smart contracts on chain.
I like this EIP. It makes contracts and libraries safer.
It makes proxy contracts and diamonds safer because they rely on delegatecall which can pull in code from other contracts.
This EIP prevents delegatecall from accidentally or maliciously destroying proxy contracts and diamonds and prevents the contracts/libraries that proxy contracts and diamonds rely on from disappearing. This is good.
The intended use case would be for contracts to make their first byte of code be the
SET_INDESTRUCTIBLE
opcode if they wishâŚ
However, the spec doesnât say what should happen if SET_INDESTRUCTIBLE
is encountered on PC!=0
Some other questions.
- Letâs say we have
C
withSET_INDESTRUCTIBLE
at0
. ContractX
doesdelegatecall(c) && selfdestruct
. DoesC
successfully selfdestruct? - Same scenarion with
C
. What aboutcallcode(c)
?
In general, is the globals.indestructible
scoped? I assume it is (by which I mean itâs journalled, and scope-revertals removes stuff from it)
- I think that if
SET_INDESTRUCTIBLE
is encountered onPC!=0
, it should be treated as a no-op to avoid any weird edge cases. However, forcing it to be the first byte does make its use case less flexible and Iâm open to lifting this restriction. - C should not successfully self destruct when using delegatecall if it is set as indestructible.
- C should also not successfully self destruct when using callcode if it is set as indestructible.
I also believe SET_INDESTRUCTIBLE
should be implemented as a variable local to each execution frame. I think it is unnecessary to make it a global variable, as the delegatecall/callcode edge case can still be resolved with a local boolean variable implementation.
Proposed update to EIP-2937 spec: https://github.com/ethereum/EIPs/pull/3186
Local variable implementation in geth client: https://github.com/lightclient/go-ethereum/pull/7
I think this EIP is great, as it sets optional restriction/extension rules on the EVM context of future-deployed contracts.
But I think its scope should be extended: There might be other features we would like to enable/restrict in the future.
So I would suggest to add it as âRULESâ opcode, which receives a single bitmask param.
the first bit is SET_INDESTRUCTIBLE, with the semantics defined by this EIP.
all other bits are REQUIRED to be zero, and the opcode should REVERT in case any is set.
In a future EIP (and fork), more semantics can be given to those bits, without requiring a new opcode for each.
The downside is that the prefix this new opcode generates is 3 bytes instead of 1: "PUSH1 1 RULES"
This doesnât just make proxies / âdiamondsâ safer, it makes them so much safer that it enables a categorically different mode of interaction where proxy actions / scripts can be properly sandboxed and so trustlessly composed within a single proxy script