-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Labels
Description
See https://docs.optimism.io/stack/differences#address-aliasing
It's safe to set the from
of a privileged transaction to an EOA address, but not for smart contracts, since addresses don't necessarily correspond with the deployed bytecode, and an L1 contract could be deployed into the same address as an L2 contract, to make it possible to impersonate it through L1->L2 messaging.
This can be solved by using a different sender from the L1 address as the L2 sender when the L1 sender is not an EOA. Optimism does this by "address aliasing", computing the L2 sender by adding some constant to the address:
L1_contract_address + 0x1111000000000000000000000000000000001111
We can differentiate between EOA and smart contracts like Optimism does:
- if
tx.origin
==msg.sender
, sender is EOA - if the account's code is
0xef0000 || <address>
, it's an EIP 7702 delegated account, so we treat it as an EOA, else it's not an EOA
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done