Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions arbos/arbosState/arbosstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ func InitializeArbosState(stateDB vm.StateDB, burner burn.Burner, chainConfig *p
merkleAccumulator.InitializeMerkleAccumulator(sto.OpenSubStorage(sendMerkleSubspace))
blockhash.InitializeBlockhashes(sto.OpenSubStorage(blockhashesSubspace))

// by default, the remapped zero address is the initial chain owner
initialChainOwner := util.RemapL1Address(common.Address{})
if chainConfig.ArbitrumChainParams.InitialChainOwner != (common.Address{}) {
initialChainOwner = chainConfig.ArbitrumChainParams.InitialChainOwner
}
// may be the zero address
initialChainOwner := chainConfig.ArbitrumChainParams.InitialChainOwner
ownersStorage := sto.OpenSubStorage(chainOwnerSubspace)
_ = addressSet.Initialize(ownersStorage)
_ = addressSet.OpenAddressSet(ownersStorage).Add(initialChainOwner)
Expand Down
15 changes: 10 additions & 5 deletions arbos/incomingmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (msg *L1IncomingMessage) ParseL2Transactions(chainId *big.Int, batchFetcher
ChainId: chainId,
L1RequestId: depositRequestId,
// Matches the From of parseUnsignedTx
To: util.RemapL1Address(msg.Header.Poster),
To: msg.Header.Poster,
Value: tx.Value(),
})
return types.Transactions{deposit, tx}, nil
Expand Down Expand Up @@ -380,7 +380,7 @@ func parseUnsignedTx(rd io.Reader, poster common.Address, requestId *common.Hash
case L2MessageKind_UnsignedUserTx:
inner = &types.ArbitrumUnsignedTx{
ChainId: chainId,
From: util.RemapL1Address(poster),
From: poster,
Nonce: nonce,
GasFeeCap: maxFeePerGas.Big(),
Gas: gasLimit.Big().Uint64(),
Expand All @@ -395,7 +395,7 @@ func parseUnsignedTx(rd io.Reader, poster common.Address, requestId *common.Hash
inner = &types.ArbitrumContractTx{
ChainId: chainId,
RequestId: *requestId,
From: util.RemapL1Address(poster),
From: poster,
GasFeeCap: maxFeePerGas.Big(),
Gas: gasLimit.Big().Uint64(),
To: destination,
Expand All @@ -410,6 +410,10 @@ func parseUnsignedTx(rd io.Reader, poster common.Address, requestId *common.Hash
}

func parseEthDepositMessage(rd io.Reader, header *L1IncomingMessageHeader, chainId *big.Int) (*types.Transaction, error) {
to, err := util.AddressFromReader(rd)
if err != nil {
return nil, err
}
balance, err := util.HashFromReader(rd)
if err != nil {
return nil, err
Expand All @@ -420,7 +424,8 @@ func parseEthDepositMessage(rd io.Reader, header *L1IncomingMessageHeader, chain
tx := &types.ArbitrumDepositTx{
ChainId: chainId,
L1RequestId: *header.RequestId,
To: util.RemapL1Address(header.Poster),
From: header.Poster,
To: to,
Value: balance.Big(),
}
return types.NewTx(tx), nil
Expand Down Expand Up @@ -491,7 +496,7 @@ func parseSubmitRetryableMessage(rd io.Reader, header *L1IncomingMessageHeader,
tx := &types.ArbitrumSubmitRetryableTx{
ChainId: chainId,
RequestId: *header.RequestId,
From: util.RemapL1Address(header.Poster),
From: header.Poster,
L1BaseFee: header.L1BaseFee,
DepositValue: depositValue.Big(),
GasFeeCap: maxFeePerGas.Big(),
Expand Down
3 changes: 0 additions & 3 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
switch tx := underlyingTx.GetInner().(type) {
case *types.ArbitrumDepositTx:
defer (startTracer())()
if p.msg.From() != arbosAddress {
return false, 0, errors.New("deposit not from arbAddress"), nil
}
util.MintBalance(p.msg.To(), p.msg.Value(), evm, util.TracingDuringEVM)
return true, 0, nil, nil
case *types.ArbitrumInternalTx:
Expand Down
9 changes: 8 additions & 1 deletion arbstate/geth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func TestEthDepositMessage(t *testing.T) {
L1BaseFee: big.NewInt(10000000000000),
}
msgBuf := bytes.Buffer{}
if err := util.AddressToWriter(addr, &msgBuf); err != nil {
t.Error(err)
}
if err := util.HashToWriter(balance, &msgBuf); err != nil {
t.Error(err)
}
Expand All @@ -88,7 +91,11 @@ func TestEthDepositMessage(t *testing.T) {

secondRequestId := common.BigToHash(big.NewInt(4))
header.RequestId = &secondRequestId
header.Poster = util.RemapL1Address(addr)
msgBuf2 := bytes.Buffer{}
if err := util.AddressToWriter(addr, &msgBuf2); err != nil {
t.Error(err)
}
if err := util.HashToWriter(balance2, &msgBuf2); err != nil {
t.Error(err)
}
Expand All @@ -103,7 +110,7 @@ func TestEthDepositMessage(t *testing.T) {

RunMessagesThroughAPI(t, [][]byte{serialized, serialized2}, statedb)

balanceAfter := statedb.GetBalance(util.RemapL1Address(addr))
balanceAfter := statedb.GetBalance(addr)
if balanceAfter.Cmp(new(big.Int).Add(balance.Big(), balance2.Big())) != 0 {
Fail(t)
}
Expand Down
31 changes: 18 additions & 13 deletions contracts/src/bridge/Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
if (msg.sender != tx.origin) revert NotOrigin();
if (messageData.length > MAX_DATA_SIZE)
revert DataTooLarge(messageData.length, MAX_DATA_SIZE);
uint256 msgNum = deliverToBridge(L2_MSG, msg.sender, keccak256(messageData));
uint256 msgNum = deliverToBridge(
L2_MSG,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
keccak256(messageData)
);
emit InboxMessageDeliveredFromOrigin(msgNum);
return msgNum;
}
Expand All @@ -104,7 +108,8 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
whenNotPaused
returns (uint256)
{
return _deliverMessage(L2_MSG, msg.sender, messageData);
return
_deliverMessage(L2_MSG, AddressAliasHelper.applyL1ToL2Alias(msg.sender), messageData);
}

function sendL1FundedUnsignedTransaction(
Expand All @@ -117,7 +122,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
return
_deliverMessage(
L1MessageType_L2FundedByL1,
msg.sender,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
abi.encodePacked(
L2MessageType_unsignedEOATx,
gasLimit,
Expand All @@ -139,7 +144,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
return
_deliverMessage(
L1MessageType_L2FundedByL1,
msg.sender,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
abi.encodePacked(
L2MessageType_unsignedContractTx,
gasLimit,
Expand All @@ -162,7 +167,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
return
_deliverMessage(
L2_MSG,
msg.sender,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
abi.encodePacked(
L2MessageType_unsignedEOATx,
gasLimit,
Expand All @@ -185,7 +190,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
return
_deliverMessage(
L2_MSG,
msg.sender,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
abi.encodePacked(
L2MessageType_unsignedContractTx,
gasLimit,
Expand Down Expand Up @@ -217,24 +222,24 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
/// Look into retryable tickets if you are interested in this functionality.
/// @dev this function should not be called inside contract constructors
function depositEth() public payable override whenNotPaused returns (uint256) {
address sender = msg.sender;
address dest = msg.sender;
address aliasedSender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);

// solhint-disable-next-line avoid-tx-origin
if (!AddressUpgradeable.isContract(sender) && tx.origin == msg.sender) {
if (AddressUpgradeable.isContract(msg.sender) || tx.origin != msg.sender) {
// isContract check fails if this function is called during a contract's constructor.
// We don't adjust the address for calls coming from L1 contracts since their addresses get remapped
// If the caller is an EOA, we adjust the address.
// This is needed because unsigned messages to the L2 (such as retryables)
// have the L1 sender address mapped.
// Here we preemptively reverse the mapping for EOAs so deposits work as expected
sender = AddressAliasHelper.undoL1ToL2Alias(sender);
dest = aliasedSender;
}

return
_deliverMessage(
L1MessageType_ethDeposit,
sender, // arb-os will add the alias to this value
abi.encodePacked(msg.value)
aliasedSender,
abi.encodePacked(dest, msg.value)
);
}

Expand Down Expand Up @@ -382,7 +387,7 @@ contract Inbox is DelegateCallAware, PausableUpgradeable, IInbox {
return
_deliverMessage(
L1MessageType_submitRetryableTx,
msg.sender,
AddressAliasHelper.applyL1ToL2Alias(msg.sender),
abi.encodePacked(
uint256(uint160(to)),
l2CallValue,
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
3 changes: 1 addition & 2 deletions precompiles/ArbOwner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ func TestAddressSet(t *testing.T) {
callCtx := testContext(caller, evm)

// the zero address is an owner by default
ZeroAddressL2 := util.RemapL1Address(common.Address{})
Require(t, prec.RemoveChainOwner(callCtx, evm, ZeroAddressL2))
Require(t, prec.RemoveChainOwner(callCtx, evm, common.Address{}))

Require(t, prec.AddChainOwner(callCtx, evm, addr1))
Require(t, prec.AddChainOwner(callCtx, evm, addr2))
Expand Down