You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/stack/differences.mdx
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,18 +39,24 @@ Because of the behavior of the `CREATE` opcode, it is possible to create a contr
39
39
Even though these contracts share the same address, they are fundamentally two different smart contracts and cannot be treated as the same contract.
40
40
As a result, the sender of a transaction sent from L1 to L2 by a smart contract cannot be the address of the smart contract on L1 or the smart contract on L1 could act as if it were the smart contract on L2 (because the two contracts share the same address).
41
41
42
-
To prevent this sort of impersonation, the sender of a transaction is slightly modified when a transaction is sent from L1 to L2 by a smart contract.
43
-
Instead of appearing to be sent from the actual L1 contract address, the L2 transaction appears to be sent from an "aliased" version of the L1 contract address.
44
-
This aliased address is a constant offset from the actual L1 contract address such that the aliased address will never conflict with any other address on L2 and the original L1 address can easily be recovered from the aliased address.
42
+
To prevent this sort of impersonation, the sender of a transaction is slightly modified by the `OptimismPortal` when a smart contract calls `depositTransaction` to send a transaction from L1 to L2.
43
+
This alias is applied when the caller has code, and that code is not a valid EIP-7702 delegation.
44
+
When the address has no code, or the code present at the address is a valid EIP-7702 delegation, the sender is not modified.
45
+
Note that ephemeral contracts (those that are created and self-destructed in the same transaction) WILL be aliased, despite having no code at the start or end of transaction execution.
45
46
46
-
This change in sender address is only applied to L2 transactions sent by L1 smart contracts.
47
+
Instead of appearing to be sent from the actual L1 contract address, the L2 transaction is sent from an "aliased" version of the L1 contract address.
48
+
This aliased address is produced by treating the address as a 160-bit integer, adding a constant offset with overflows allowed, and then truncating the result to a 20-byte address.
49
+
The address hashing function ensures that aliased address will never conflict with any other address on L2.
50
+
The simple offset original L1 address can easily be recovered from the aliased address.
51
+
52
+
The `OptimismPortal` applies this change only to L2 transactions sent by L1 smart contracts.
47
53
In all other cases, the transaction sender address is set according to the same rules used by Ethereum.
0 commit comments