-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Delegation changes trigger changes in the CODE_HASH of accounts without raising deployment numbers or anything else. In order to properly track these code hash changes, that is to say: in order to track their consistency across the trace, we require a new number to identify code fragment indices
hub.acc/DELEGATION_NUMBER
hub.acc/DELEGATION_NUMBER_NEWThese numbers must be added to the ROM_LEX module where they will be used to produce the CFI. The CFI will be derived from lexicographically ordering the tuples
rom_lex.ADDRESS_HI
rom_lex.ADDRESS_LO
rom_lex.DEPLOYMENT_NUMBER
rom_lex.DEPLOYMENT_STATUS
rom_lex.DELEGATION_NUMBERAnd in the HUB we will impose that the delegation number reset to 0 with every new deployment at a given address.
WARNING: (fixed) misconception below
What follows is erroneous. I keep it in here just to prevent future confusion.
Note. There are two moments when the DELEGATION_NUMBER may change
- upon explicit delegation in the pre-processing of type 4 transactions
- upon (temporary)
RETURN-induced deployments of byte code of the form0x ef 01 00 <20 bytes><-- WRONG
Correction. The above is wrong given EIP-3541: Reject new contract code starting with the 0xEF byte. Note that prior to the London harfork, which contains EIP-3541, see here, one could deploy accounts that would be de facto delegated accounts as of the Osaka hardfork.
Note. We will have to write tests with multiple deployments / redeployments / deletions / reverts of accounts at the same address (thus via CREATE2) where the deployed byte code is of the form 0x ef0100 <20 Bytes>.
The 2nd way of "accidentally" creating delegation is real, see this code snippet from the execution specs
def is_valid_delegation(code: bytes) -> bool:
"""
Whether the code is a valid delegation designation.
Parameters
----------
code: `bytes`
The code to check.
Returns
-------
valid : `bool`
True if the code is a valid delegation designation,
False otherwise.
"""
if (
len(code) == EOA_DELEGATED_CODE_LENGTH
and code[:EOA_DELEGATION_MARKER_LENGTH] == EOA_DELEGATION_MARKER
):
return True
return False