Forbidden opcodes
Forbidden Opcodes Explained
In the context of the described system, there are certain opcodes that are prohibited when they are executed at depth levels greater than 2. This basically implies that when core contracts like the factory, account, paymaster, and others are being executed, these opcodes should not be permitted. The motivation for this restriction is to ensure consistency and reliability during the simulation and execution processes.
Let's dive deeper:
List of Forbidden Opcodes:
GASPRICE: Returns the gas price of the transaction.
GASLIMIT: Provides the maximum gas that is allowed in a block.
DIFFICULTY: Returns the difficulty of the current block.
TIMESTAMP: Gives the timestamp of the current block.
BASEFEE: Indicates the base fee of the current block.
BLOCKHASH: Returns the hash of one of the 256 most recent blocks.
NUMBER: Provides the block number.
SELFBALANCE: Returns the contract's balance.
BALANCE: Fetches the Ether balance of a specific address.
ORIGIN: Gives the sender of the transaction.
GAS: Returns the amount of gas left.
CREATE: Initiates a new contract.
COINBASE: Returns the miner of the current block.
SELFDESTRUCT: Causes the contract to terminate.
Rationale Behind Prohibition:
The primary reason for forbidding these opcodes is to maintain the consistency of the simulation process.
The outputs of these opcodes can change between the simulation and the actual on-chain execution. This variability makes them unreliable. For instance, the gas price or block timestamp can change between when a transaction is simulated and when it is actually executed, leading to potential discrepancies.
If transactions are simulated using these opcodes, it's hard to guarantee that the actual on-chain execution would yield the same results as the simulation.
Exceptions to the Rule:
While these opcodes are generally forbidden, there are specific exceptions:
CREATE2: This opcode is permitted only if the
op.initcode.length
is not zero. The use ofCREATE2
should result in the deployment of a new UserOperation.sender that hasn't been deployed before.GAS: Using the
GAS
opcode is allowed if it is immediately followed by a call-type opcode such asCALL
,DELEGATECALL
,CALLCODE
, orSTATICCALL
. Essentially, while making contract calls is permitted, directly querying the amount of gas left using thegasleft()
function or theGAS
opcode is not.
In conclusion, these forbidden opcodes are essentially a safeguard to ensure that the simulation process provides a reliable indication of what would occur during the actual on-chain execution. By regulating their usage, the system aims to achieve a higher degree of consistency and predictability.
Last updated