Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion packages/contracts/contracts/arbitrum/AddressAliasHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@

pragma solidity ^0.7.6;

/**
* @title Address Alias Helper Library
* @author Edge & Node
* @notice Utility library for converting addresses between L1 and L2 in Arbitrum
*/
library AddressAliasHelper {
uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);
/// @dev Offset used for L1 to L2 address aliasing
// solhint-disable-next-line const-name-snakecase
uint160 internal constant offset = uint160(0x1111000000000000000000000000000000001111);

/// @notice Utility function that converts the address in the L1 that submitted a tx to
/// the inbox to the msg.sender viewed in the L2
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts/contracts/arbitrum/IArbToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,28 @@
*/
pragma solidity ^0.7.6;

/**
* @title Arbitrum Token Interface
* @author Edge & Node
* @notice Interface for tokens that can be minted and burned on Arbitrum L2
*/
interface IArbToken {
/**
* @notice should increase token supply by amount, and should (probably) only be callable by the L1 bridge.
* @param account Account to mint tokens to
* @param amount Amount of tokens to mint
*/
function bridgeMint(address account, uint256 amount) external;

/**
* @notice should decrease token supply by amount, and should (probably) only be callable by the L1 bridge.
* @param account Account to burn tokens from
* @param amount Amount of tokens to burn
*/
function bridgeBurn(address account, uint256 amount) external;

/**
* @notice Get the L1 token address
* @return address of layer 1 token
*/
function l1Address() external view returns (address);
Expand Down
83 changes: 82 additions & 1 deletion packages/contracts/contracts/arbitrum/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,24 @@

pragma solidity ^0.7.6;

// TODO: Re-enable and fix issues when publishing a new version
// solhint-disable gas-indexed-events

/**
* @title Bridge Interface
* @author Edge & Node
* @notice Interface for the Arbitrum Bridge contract
*/
interface IBridge {
/**
* @notice Emitted when a message is delivered to the inbox
* @param messageIndex Index of the message
* @param beforeInboxAcc Inbox accumulator before this message
* @param inbox Address of the inbox
* @param kind Type of the message
* @param sender Address that sent the message
* @param messageDataHash Hash of the message data
*/
event MessageDelivered(
uint256 indexed messageIndex,
bytes32 indexed beforeInboxAcc,
Expand All @@ -35,38 +52,102 @@ interface IBridge {
bytes32 messageDataHash
);

/**
* @notice Emitted when a bridge call is triggered
* @param outbox Address of the outbox
* @param destAddr Destination address for the call
* @param amount ETH amount sent with the call
* @param data Calldata for the function call
*/
event BridgeCallTriggered(address indexed outbox, address indexed destAddr, uint256 amount, bytes data);

/**
* @notice Emitted when an inbox is enabled or disabled
* @param inbox Address of the inbox
* @param enabled Whether the inbox is enabled
*/
event InboxToggle(address indexed inbox, bool enabled);

/**
* @notice Emitted when an outbox is enabled or disabled
* @param outbox Address of the outbox
* @param enabled Whether the outbox is enabled
*/
event OutboxToggle(address indexed outbox, bool enabled);

/**
* @notice Deliver a message to the inbox
* @param kind Type of the message
* @param sender Address that is sending the message
* @param messageDataHash keccak256 hash of the message data
* @return The message index
*/
function deliverMessageToInbox(
uint8 kind,
address sender,
bytes32 messageDataHash
) external payable returns (uint256);

/**
* @notice Execute a call from L2 to L1
* @param destAddr Contract to call
* @param amount ETH value to send
* @param data Calldata for the function call
* @return success True if the call was successful, false otherwise
* @return returnData Return data from the call
*/
function executeCall(
address destAddr,
uint256 amount,
bytes calldata data
) external returns (bool success, bytes memory returnData);

// These are only callable by the admin
/**
* @notice Set the address of an inbox
* @param inbox Address of the inbox
* @param enabled Whether to enable the inbox
*/
function setInbox(address inbox, bool enabled) external;

/**
* @notice Set the address of an outbox
* @param inbox Address of the outbox
* @param enabled Whether to enable the outbox
*/
function setOutbox(address inbox, bool enabled) external;

// View functions

/**
* @notice Get the active outbox address
* @return The active outbox address
*/
function activeOutbox() external view returns (address);

/**
* @notice Check if an address is an allowed inbox
* @param inbox Address to check
* @return True if the address is an allowed inbox, false otherwise
*/
function allowedInboxes(address inbox) external view returns (bool);

/**
* @notice Check if an address is an allowed outbox
* @param outbox Address to check
* @return True if the address is an allowed outbox, false otherwise
*/
function allowedOutboxes(address outbox) external view returns (bool);

/**
* @notice Get the inbox accumulator at a specific index
* @param index Index to query
* @return The inbox accumulator at the given index
*/
function inboxAccs(uint256 index) external view returns (bytes32);

/**
* @notice Get the count of messages in the inbox
* @return Number of messages in the inbox
*/
function messageCount() external view returns (uint256);
}
83 changes: 81 additions & 2 deletions packages/contracts/contracts/arbitrum/IInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,32 @@

pragma solidity ^0.7.6;

import "./IBridge.sol";
import "./IMessageProvider.sol";
import { IBridge } from "./IBridge.sol";
import { IMessageProvider } from "./IMessageProvider.sol";

/**
* @title Inbox Interface
* @author Edge & Node
* @notice Interface for the Arbitrum Inbox contract
*/
interface IInbox is IMessageProvider {
/**
* @notice Send a message to L2
* @param messageData Encoded data to send in the message
* @return Message number returned by the inbox
*/
function sendL2Message(bytes calldata messageData) external returns (uint256);

/**
* @notice Send an unsigned transaction to L2
* @param maxGas Maximum gas for the L2 transaction
* @param gasPriceBid Gas price bid for the L2 transaction
* @param nonce Nonce for the transaction
* @param destAddr Destination address on L2
* @param amount Amount of ETH to send
* @param data Transaction data
* @return Message number returned by the inbox
*/
function sendUnsignedTransaction(
uint256 maxGas,
uint256 gasPriceBid,
Expand All @@ -40,6 +60,15 @@ interface IInbox is IMessageProvider {
bytes calldata data
) external returns (uint256);

/**
* @notice Send a contract transaction to L2
* @param maxGas Maximum gas for the L2 transaction
* @param gasPriceBid Gas price bid for the L2 transaction
* @param destAddr Destination address on L2
* @param amount Amount of ETH to send
* @param data Transaction data
* @return Message number returned by the inbox
*/
function sendContractTransaction(
uint256 maxGas,
uint256 gasPriceBid,
Expand All @@ -48,6 +77,15 @@ interface IInbox is IMessageProvider {
bytes calldata data
) external returns (uint256);

/**
* @notice Send an L1-funded unsigned transaction to L2
* @param maxGas Maximum gas for the L2 transaction
* @param gasPriceBid Gas price bid for the L2 transaction
* @param nonce Nonce for the transaction
* @param destAddr Destination address on L2
* @param data Transaction data
* @return Message number returned by the inbox
*/
function sendL1FundedUnsignedTransaction(
uint256 maxGas,
uint256 gasPriceBid,
Expand All @@ -56,13 +94,33 @@ interface IInbox is IMessageProvider {
bytes calldata data
) external payable returns (uint256);

/**
* @notice Send an L1-funded contract transaction to L2
* @param maxGas Maximum gas for the L2 transaction
* @param gasPriceBid Gas price bid for the L2 transaction
* @param destAddr Destination address on L2
* @param data Transaction data
* @return Message number returned by the inbox
*/
function sendL1FundedContractTransaction(
uint256 maxGas,
uint256 gasPriceBid,
address destAddr,
bytes calldata data
) external payable returns (uint256);

/**
* @notice Create a retryable ticket for an L2 transaction
* @param destAddr Destination address on L2
* @param arbTxCallValue Call value for the L2 transaction
* @param maxSubmissionCost Maximum cost for submitting the ticket
* @param submissionRefundAddress Address to refund submission cost to
* @param valueRefundAddress Address to refund excess value to
* @param maxGas Maximum gas for the L2 transaction
* @param gasPriceBid Gas price bid for the L2 transaction
* @param data Transaction data
* @return Message number returned by the inbox
*/
function createRetryableTicket(
address destAddr,
uint256 arbTxCallValue,
Expand All @@ -74,15 +132,36 @@ interface IInbox is IMessageProvider {
bytes calldata data
) external payable returns (uint256);

/**
* @notice Deposit ETH to L2
* @param maxSubmissionCost Maximum cost for submitting the deposit
* @return Message number returned by the inbox
*/
function depositEth(uint256 maxSubmissionCost) external payable returns (uint256);

/**
* @notice Get the bridge contract
* @return The bridge contract address
*/
function bridge() external view returns (IBridge);

/**
* @notice Pause the creation of retryable tickets
*/
function pauseCreateRetryables() external;

/**
* @notice Unpause the creation of retryable tickets
*/
function unpauseCreateRetryables() external;

/**
* @notice Start rewriting addresses
*/
function startRewriteAddress() external;

/**
* @notice Stop rewriting addresses
*/
function stopRewriteAddress() external;
}
14 changes: 14 additions & 0 deletions packages/contracts/contracts/arbitrum/IMessageProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@

pragma solidity ^0.7.6;

/**
* @title Message Provider Interface
* @author Edge & Node
* @notice Interface for Arbitrum message providers
*/
interface IMessageProvider {
/**
* @notice Emitted when a message is delivered to the inbox
* @param messageNum Message number
* @param data Message data
*/
event InboxMessageDelivered(uint256 indexed messageNum, bytes data);

/**
* @notice Emitted when a message is delivered from origin
* @param messageNum Message number
*/
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum);
}
Loading
Loading