What should the value of tx.origin and msg.sender be for L1 to L2 transactions? #246
-
We're doing some rethinking of the value of
So what do you think the value of these variables should be? |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 8 replies
-
What's wrong with the current solution using xchainmessager? I liked it because it's symmetrical between L1->L2 and L2->L1. I don't think that (1) applies as messages always call to xchainmessager first, and no one uses FWIW: in Arbitrum during L1->L2 calls, a call is originating from the original address sub some constant to avoid security issues. https://developer.offchainlabs.com/docs/l1_l2_messages#address-aliasing |
Beta Was this translation helpful? Give feedback.
-
How about we use an address that cannot be faked, but is easy to change to the correct source address? Maybe |
Beta Was this translation helpful? Give feedback.
-
Ok so @maurelian @qbzzt @ben-chain @karlfloersch and I got on a call about this a few minutes ago. TL;DR is that Arbitrum already has a reasonable approach to this problem and we're just going to use their approach so that we can start getting standardization around these L2 quirks. We could come up with our own way of handling this but there's really no point if it would only introduce a diff between L2 designs. @maurelian is going to reach out to the Arbitrum team to get a detailed spec of how they set msg.sender and tx.origin and we're going to follow it as closely as possible. |
Beta Was this translation helpful? Give feedback.
-
We've made a final decision here, we're standardizing with Arbitrum and using the same address aliasing scheme that they use for message passing! Specifically, we use the following aliasing function: uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);
function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
unchecked {
l2Address = address(uint160(l1Address) + offset);
}
} This aliasing ONLY applies for contracts sending messages to L2. If an EOA sends a message to L2 then the address is NOT aliased. Here's the relevant code from the CTC: address sender;
if (msg.sender == tx.origin) {
sender = msg.sender;
} else {
sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);
} |
Beta Was this translation helpful? Give feedback.
We've made a final decision here, we're standardizing with Arbitrum and using the same address aliasing scheme that they use for message passing! Specifically, we use the following aliasing function:
This aliasing ONLY applies for contracts sending messages to L2. If an EOA sends a message to L2 then the address is NOT aliased. Here's the relevant code from the CTC: