Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
b02332ff
Commit
b02332ff
authored
Sep 24, 2020
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing contracts from v1 repo
parent
68b240cc
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1032 additions
and
13 deletions
+1032
-13
OVM_BaseCrossDomainMessenger.sol
...stic-ethereum/OVM/bridge/OVM_BaseCrossDomainMessenger.sol
+77
-0
OVM_L1CrossDomainMessenger.sol
...mistic-ethereum/OVM/bridge/OVM_L1CrossDomainMessenger.sol
+253
-0
OVM_L2CrossDomainMessenger.sol
...mistic-ethereum/OVM/bridge/OVM_L2CrossDomainMessenger.sol
+149
-0
OVM_DeployerWhitelist.sol
...mistic-ethereum/OVM/precompiles/OVM_DeployerWhitelist.sol
+200
-0
OVM_L1MessageSender.sol
...timistic-ethereum/OVM/precompiles/OVM_L1MessageSender.sol
+29
-0
OVM_L2ToL1MessagePasser.sol
...stic-ethereum/OVM/precompiles/OVM_L2ToL1MessagePasser.sol
+44
-0
OVM_L1ToL2TransactionQueue.sol
...imistic-ethereum/OVM/queue/OVM_L1ToL2TransactionQueue.sol
+19
-9
iOVM_BaseCrossDomainMessenger.sol
...ic-ethereum/iOVM/bridge/iOVM_BaseCrossDomainMessenger.sol
+21
-0
iOVM_L1CrossDomainMessenger.sol
...stic-ethereum/iOVM/bridge/iOVM_L1CrossDomainMessenger.sol
+76
-0
iOVM_L2CrossDomainMessenger.sol
...stic-ethereum/iOVM/bridge/iOVM_L2CrossDomainMessenger.sol
+42
-0
iOVM_DeployerWhitelist.sol
...stic-ethereum/iOVM/precompiles/iOVM_DeployerWhitelist.sol
+19
-0
iOVM_L1MessageSender.sol
...mistic-ethereum/iOVM/precompiles/iOVM_L1MessageSender.sol
+14
-0
iOVM_L2ToL1MessagePasser.sol
...ic-ethereum/iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol
+25
-0
iOVM_L1ToL2TransactionQueue.sol
...istic-ethereum/iOVM/queue/iOVM_L1ToL2TransactionQueue.sol
+2
-2
Lib_ByteUtils.sol
...cts/optimistic-ethereum/libraries/utils/Lib_ByteUtils.sol
+1
-1
Lib_Bytes32Utils.sol
.../optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol
+60
-0
Proxy_Forwarder.sol
...s/contracts/optimistic-ethereum/proxy/Proxy_Forwarder.sol
+1
-1
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/OVM_BaseCrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Interface Imports */
import { iOVM_BaseCrossDomainMessenger } from "../../iOVM/bridge/iOVM_BaseCrossDomainMessenger.sol";
/**
* @title OVM_BaseCrossDomainMessenger
*/
contract OVM_BaseCrossDomainMessenger is iOVM_BaseCrossDomainMessenger {
/**********************
* Contract Variables *
**********************/
mapping (bytes32 => bool) public receivedMessages;
mapping (bytes32 => bool) public sentMessages;
address public targetMessengerAddress;
uint256 public messageNonce;
address public xDomainMessageSender;
/********************
* Public Functions *
********************/
/**
* Sets the target messenger address.
* @dev Currently, this function is public and therefore allows anyone to modify the target
* messenger for a given xdomain messenger contract. Obviously this shouldn't be allowed,
* but we still need to determine an adequate mechanism for updating this address.
* @param _targetMessengerAddress New messenger address.
*/
function setTargetMessengerAddress(
address _targetMessengerAddress
)
override
public
{
targetMessengerAddress = _targetMessengerAddress;
}
/**********************
* Internal Functions *
**********************/
/**
* Generates the correct cross domain calldata for a message.
* @param _target Target contract address.
* @param _sender Message sender address.
* @param _message Message to send to the target.
* @param _messageNonce Nonce for the provided message.
* @return ABI encoded cross domain calldata.
*/
function _getXDomainCalldata(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce
)
internal
pure
returns (
bytes memory
)
{
return abi.encodeWithSelector(
bytes4(keccak256(bytes("relayMessage(address,address,bytes,uint256)"))),
_target,
_sender,
_message,
_messageNonce
);
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/OVM_L1CrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Proxy Imports */
import { Proxy_Resolver } from "../../proxy/Proxy_Resolver.sol";
/* Library Imports */
import { Lib_EthMerkleTrie } from "../../libraries/trie/Lib_EthMerkleTrie.sol";
import { Lib_ByteUtils } from "../../libraries/utils/Lib_ByteUtils.sol";
/* Interface Imports */
import { iOVM_L1CrossDomainMessenger } from "../../iOVM/bridge/iOVM_L1CrossDomainMessenger.sol";
import { iOVM_L1ToL2TransactionQueue } from "../../iOVM/queue/iOVM_L1ToL2TransactionQueue.sol";
import { iOVM_StateCommitmentChain } from "../../iOVM/chain/iOVM_StateCommitmentChain.sol";
/* Contract Imports */
import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol";
/**
* @title OVM_L1CrossDomainMessenger
*/
contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Proxy_Resolver {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
iOVM_L1ToL2TransactionQueue internal ovmL1ToL2TransactionQueue;
iOVM_StateCommitmentChain internal ovmStateCommitmentChain;
/***************
* Constructor *
***************/
/**
* @param _proxyManager Address of the Proxy_Manager.
*/
constructor(
address _proxyManager
)
Proxy_Resolver(_proxyManager)
{
ovmL1ToL2TransactionQueue = iOVM_L1ToL2TransactionQueue(resolve("OVM_L1ToL2TransactionQueue"));
ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
}
/********************
* Public Functions *
********************/
/**
* Relays a cross domain message to a contract.
* @inheritdoc iOVM_L1CrossDomainMessenger
*/
function relayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce,
L2MessageInclusionProof memory _proof
)
override
public
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
_sender,
_message,
_messageNonce
);
require(
_verifyXDomainMessage(
xDomainCalldata,
_proof
) == true,
"Provided message could not be verified."
);
require(
receivedMessages[keccak256(xDomainCalldata)] == false,
"Provided message has already been received."
);
xDomainMessageSender = _sender;
_target.call(_message);
// Messages are considered successfully executed if they complete
// without running out of gas (revert or not). As a result, we can
// ignore the result of the call and always mark the message as
// successfully executed because we won't get here unless we have
// enough gas left over.
receivedMessages[keccak256(xDomainCalldata)] = true;
}
/**
* Sends a cross domain message to the target messenger.
* @inheritdoc iOVM_L1CrossDomainMessenger
*/
function sendMessage(
address _target,
bytes memory _message,
uint32 _gasLimit
)
override
public
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
msg.sender,
_message,
messageNonce
);
_sendXDomainMessage(xDomainCalldata, _gasLimit);
messageNonce += 1;
sentMessages[keccak256(xDomainCalldata)] = true;
}
/**
* Replays a cross domain message to the target messenger.
* @inheritdoc iOVM_L1CrossDomainMessenger
*/
function replayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce,
uint32 _gasLimit
)
override
public
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
_sender,
_message,
_messageNonce
);
require(
sentMessages[keccak256(xDomainCalldata)] == true,
"Provided message has not already been sent."
);
_sendXDomainMessage(xDomainCalldata, _gasLimit);
}
/**********************
* Internal Functions *
**********************/
/**
* Verifies that the given message is valid.
* @param _xDomainCalldata Calldata to verify.
* @param _proof Inclusion proof for the message.
* @return Whether or not the provided message is valid.
*/
function _verifyXDomainMessage(
bytes memory _xDomainCalldata,
L2MessageInclusionProof memory _proof
)
internal
returns (
bool
)
{
return (
_verifyStateRootProof(_proof)
&& _verifyStorageProof(_xDomainCalldata, _proof)
);
}
/**
* Verifies that the state root within an inclusion proof is valid.
* @param _proof Message inclusion proof.
* @return Whether or not the provided proof is valid.
*/
function _verifyStateRootProof(
L2MessageInclusionProof memory _proof
)
internal
returns (
bool
)
{
// TODO: We *must* verify that the batch timestamp is sufficiently old.
// However, this requires that we first add timestamps to state batches
// and account for that change in various tests. Change of that size is
// out of scope for this ticket, so "TODO" for now.
return ovmStateCommitmentChain.verifyElement(
abi.encodePacked(_proof.stateRoot),
_proof.stateRootBatchHeader,
_proof.stateRootProof
);
}
/**
* Verifies that the storage proof within an inclusion proof is valid.
* @param _xDomainCalldata Encoded message calldata.
* @param _proof Message inclusion proof.
* @return Whether or not the provided proof is valid.
*/
function _verifyStorageProof(
bytes memory _xDomainCalldata,
L2MessageInclusionProof memory _proof
)
internal
returns (
bool
)
{
bytes32 storageKey = keccak256(
Lib_ByteUtils.concat(
abi.encodePacked(keccak256(_xDomainCalldata)),
abi.encodePacked(uint256(0))
)
);
return Lib_EthMerkleTrie.proveAccountStorageSlotValue(
0x4200000000000000000000000000000000000000,
storageKey,
bytes32(uint256(1)),
_proof.stateTrieWitness,
_proof.storageTrieWitness,
_proof.stateRoot
);
}
/**
* Sends a cross domain message.
* @param _message Message to send.
* @param _gasLimit OVM gas limit for the message.
*/
function _sendXDomainMessage(
bytes memory _message,
uint32 _gasLimit
)
internal
{
ovmL1ToL2TransactionQueue.enqueue(
targetMessengerAddress,
_gasLimit,
_message
);
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/OVM_L2CrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Proxy Imports */
import { Proxy_Resolver } from "../../proxy/Proxy_Resolver.sol";
/* Interface Imports */
import { iOVM_L2CrossDomainMessenger } from "../../iOVM/bridge/iOVM_L2CrossDomainMessenger.sol";
import { iOVM_L1MessageSender } from "../../iOVM/precompiles/iOVM_L1MessageSender.sol";
import { iOVM_L2ToL1MessagePasser } from "../../iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol";
/* Contract Imports */
import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol";
/**
* @title OVM_L2CrossDomainMessenger
*/
contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Proxy_Resolver {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
iOVM_L1MessageSender internal ovmL1MessageSender;
iOVM_L2ToL1MessagePasser internal ovmL2ToL1MessagePasser;
/***************
* Constructor *
***************/
/**
* @param _proxyManager Address of the Proxy_Manager.
*/
constructor(
address _proxyManager
)
Proxy_Resolver(_proxyManager)
{
ovmL1MessageSender = iOVM_L1MessageSender(resolve("OVM_L1MessageSender"));
ovmL2ToL1MessagePasser = iOVM_L2ToL1MessagePasser(resolve("OVM_L2ToL1MessagePasser"));
}
/********************
* Public Functions *
********************/
/**
* Sends a cross domain message to the target messenger.
* @inheritdoc iOVM_L2CrossDomainMessenger
*/
function sendMessage(
address _target,
bytes memory _message,
uint256 _gasLimit
)
override
public
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
msg.sender,
_message,
messageNonce
);
_sendXDomainMessage(xDomainCalldata, _gasLimit);
messageNonce += 1;
sentMessages[keccak256(xDomainCalldata)] = true;
}
/**
* Relays a cross domain message to a contract.
* @inheritdoc iOVM_L2CrossDomainMessenger
*/
function relayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce
)
override
public
{
require(
_verifyXDomainMessage() == true,
"Provided message could not be verified."
);
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
_sender,
_message,
_messageNonce
);
require(
receivedMessages[keccak256(xDomainCalldata)] == false,
"Provided message has already been received."
);
xDomainMessageSender = _sender;
_target.call(_message);
// Messages are considered successfully executed if they complete
// without running out of gas (revert or not). As a result, we can
// ignore the result of the call and always mark the message as
// successfully executed because we won't get here unless we have
// enough gas left over.
receivedMessages[keccak256(xDomainCalldata)] = true;
}
/**********************
* Internal Functions *
**********************/
/**
* Verifies that a received cross domain message is valid.
* @return _valid Whether or not the message is valid.
*/
function _verifyXDomainMessage()
internal
returns (
bool _valid
)
{
return (
ovmL1MessageSender.getL1MessageSender() == targetMessengerAddress
);
}
/**
* Sends a cross domain message.
* @param _message Message to send.
* @param _gasLimit Gas limit for the provided message.
*/
function _sendXDomainMessage(
bytes memory _message,
uint256 _gasLimit
)
internal
{
ovmL2ToL1MessagePasser.passMessageToL1(_message);
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_DeployerWhitelist.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/* Library Imports */
import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol";
/* Interface Imports */
import { iOVM_DeployerWhitelist } from "../../iOVM/precompiles/iOVM_DeployerWhitelist.sol";
import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol";
/**
* @title OVM_DeployerWhitelist
*/
contract OVM_DeployerWhitelist is iOVM_DeployerWhitelist {
/**********************
* Contract Constants *
**********************/
bytes32 internal constant KEY_INITIALIZED = 0x0000000000000000000000000000000000000000000000000000000000000010;
bytes32 internal constant KEY_OWNER = 0x0000000000000000000000000000000000000000000000000000000000000011;
bytes32 internal constant KEY_ALLOW_ARBITRARY_DEPLOYMENT = 0x0000000000000000000000000000000000000000000000000000000000000012;
/**********************
* Function Modifiers *
**********************/
/**
* Blocks functions to anyone except the contract owner.
*/
modifier onlyOwner() {
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
address owner = Lib_Bytes32Utils.toAddress(
ovmExecutionManager.ovmSLOAD(
KEY_OWNER
)
);
require(
ovmExecutionManager.ovmCALLER() == owner,
"Function can only be called by the owner of this contract."
);
_;
}
/********************
* Public Functions *
********************/
/**
* Initializes the whitelist.
* @param _owner Address of the owner for this contract.
* @param _allowArbitraryDeployment Whether or not to allow arbitrary contract deployment.
*/
function initialize(
address _owner,
bool _allowArbitraryDeployment
)
override
public
{
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
bool initialized = Lib_Bytes32Utils.toBool(
ovmExecutionManager.ovmSLOAD(KEY_INITIALIZED)
);
if (initialized == true) {
return;
}
ovmExecutionManager.ovmSSTORE(
KEY_INITIALIZED,
Lib_Bytes32Utils.fromBool(true)
);
ovmExecutionManager.ovmSSTORE(
KEY_OWNER,
Lib_Bytes32Utils.fromAddress(_owner)
);
ovmExecutionManager.ovmSSTORE(
KEY_ALLOW_ARBITRARY_DEPLOYMENT,
Lib_Bytes32Utils.fromBool(_allowArbitraryDeployment)
);
}
/**
* Adds or removes an address from the deployment whitelist.
* @param _deployer Address to update permissions for.
* @param _isWhitelisted Whether or not the address is whitelisted.
*/
function setWhitelistedDeployer(
address _deployer,
bool _isWhitelisted
)
override
public
onlyOwner
{
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
ovmExecutionManager.ovmSSTORE(
Lib_Bytes32Utils.fromAddress(_deployer),
Lib_Bytes32Utils.fromBool(_isWhitelisted)
);
}
/**
* Updates the owner of this contract.
* @param _owner Address of the new owner.
*/
function setOwner(
address _owner
)
override
public
onlyOwner
{
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
ovmExecutionManager.ovmSSTORE(
KEY_OWNER,
Lib_Bytes32Utils.fromAddress(_owner)
);
}
/**
* Updates the arbitrary deployment flag.
* @param _allowArbitraryDeployment Whether or not to allow arbitrary contract deployment.
*/
function setAllowArbitraryDeployment(
bool _allowArbitraryDeployment
)
override
public
onlyOwner
{
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
ovmExecutionManager.ovmSSTORE(
KEY_ALLOW_ARBITRARY_DEPLOYMENT,
Lib_Bytes32Utils.fromBool(_allowArbitraryDeployment)
);
}
/**
* Permanently enables arbitrary contract deployment and deletes the owner.
*/
function enableArbitraryContractDeployment()
override
public
onlyOwner
{
setAllowArbitraryDeployment(true);
setOwner(address(0));
}
/**
* Checks whether an address is allowed to deploy contracts.
* @param _deployer Address to check.
* @return _allowed Whether or not the address can deploy contracts.
*/
function isDeployerAllowed(
address _deployer
)
override
public
returns (
bool _allowed
)
{
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(msg.sender);
bool initialized = Lib_Bytes32Utils.toBool(
ovmExecutionManager.ovmSLOAD(KEY_INITIALIZED)
);
if (initialized == false) {
return true;
}
bool allowArbitraryDeployment = Lib_Bytes32Utils.toBool(
ovmExecutionManager.ovmSLOAD(KEY_ALLOW_ARBITRARY_DEPLOYMENT)
);
if (allowArbitraryDeployment == true) {
return true;
}
bool isWhitelisted = Lib_Bytes32Utils.toBool(
ovmExecutionManager.ovmSLOAD(
Lib_Bytes32Utils.fromAddress(_deployer)
)
);
return isWhitelisted;
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_L1MessageSender.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/* Interface Imports */
import { iOVM_L1MessageSender } from "../../iOVM/precompiles/iOVM_L1MessageSender.sol";
import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol";
/**
* @title OVM_L1MessageSender
*/
contract OVM_L1MessageSender is iOVM_L1MessageSender {
/********************
* Public Functions *
********************/
/**
* @return _l1MessageSender L1 message sender address (msg.sender).
*/
function getL1MessageSender()
override
public
returns (
address _l1MessageSender
)
{
return iOVM_ExecutionManager(msg.sender).ovmL1TXORIGIN();
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/precompiles/OVM_L2ToL1MessagePasser.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/* Interface Imports */
import { iOVM_L2ToL1MessagePasser } from "../../iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol";
import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol";
/**
* @title OVM_L2ToL1MessagePasser
*/
contract OVM_L2ToL1MessagePasser is iOVM_L2ToL1MessagePasser {
/**********************
* Contract Variables *
**********************/
uint256 internal nonce;
/********************
* Public Functions *
********************/
/**
* Passes a message to L1.
* @param _message Message to pass to L1.
*/
function passMessageToL1(
bytes memory _message
)
override
public
{
// For now, to be trustfully relayed by sequencer to L1, so just emit
// an event for the sequencer to pick up.
emit L2ToL1Message(
nonce,
iOVM_ExecutionManager(msg.sender).ovmCALLER(),
_message
);
nonce = nonce + 1;
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/queue/OVM_L1ToL2TransactionQueue.sol
View file @
b02332ff
...
...
@@ -47,34 +47,44 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
****************************************/
/**
* Adds an element to the queue.
* @param _element Queue element to add to the queue.
* Adds a transaction to the queue.
* @param _target Target contract to send the transaction to.
* @param _gasLimit Gas limit for the given transaction.
* @param _data Transaction data.
*/
function enqueue(
Lib_OVMCodec.QueueElement memory _element
address _target,
uint256 _gasLimit,
bytes memory _data
)
override
public
{
_enqueue(_element);
Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({
timestamp: block.timestamp,
batchRoot: keccak256(abi.encodePacked(
_target,
_gasLimit,
_data
)),
isL1ToL2Batch: true
});
_enqueue(element);
}
/**
* Pops an element from the queue.
* @return _element Queue element popped from the queue.
*/
function dequeue()
override
public
returns (
Lib_OVMCodec.QueueElement memory _element
)
{
require(
msg.sender == ovmCanonicalTransactionChain,
"Sender is not allowed to enqueue."
);
return
_dequeue();
_dequeue();
}
}
packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/iOVM_BaseCrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/**
* @title iOVM_BaseCrossDomainMessenger
*/
interface iOVM_BaseCrossDomainMessenger {
/********************
* Public Functions *
********************/
/**
* Sets the target messenger address.
* @param _targetMessengerAddress New messenger address.
*/
function setTargetMessengerAddress(
address _targetMessengerAddress
) external;
}
packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/iOVM_L1CrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Library Imports */
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
/* Interface Imports */
import { iOVM_BaseCrossDomainMessenger } from "./iOVM_BaseCrossDomainMessenger.sol";
/**
* @title iOVM_L1CrossDomainMessenger
*/
interface iOVM_L1CrossDomainMessenger is iOVM_BaseCrossDomainMessenger {
/*******************
* Data Structures *
*******************/
struct L2MessageInclusionProof {
bytes32 stateRoot;
Lib_OVMCodec.ChainBatchHeader stateRootBatchHeader;
Lib_OVMCodec.ChainInclusionProof stateRootProof;
bytes stateTrieWitness;
bytes storageTrieWitness;
}
/********************
* Public Functions *
********************/
/**
* Relays a cross domain message to a contract.
* @param _target Target contract address.
* @param _sender Message sender address.
* @param _message Message to send to the target.
* @param _messageNonce Nonce for the provided message.
* @param _proof Inclusion proof for the given message.
*/
function relayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce,
L2MessageInclusionProof memory _proof
) external;
/**
* Sends a cross domain message to the target messenger.
* @param _target Target contract address.
* @param _message Message to send to the target.
* @param _gasLimit Gas limit for the provided message.
*/
function sendMessage(
address _target,
bytes memory _message,
uint32 _gasLimit
) external;
/**
* Replays a cross domain message to the target messenger.
* @param _target Target contract address.
* @param _sender Original sender address.
* @param _message Message to send to the target.
* @param _messageNonce Nonce for the provided message.
* @param _gasLimit Gas limit for the provided message.
*/
function replayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce,
uint32 _gasLimit
) external;
}
packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/iOVM_L2CrossDomainMessenger.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/* Interface Imports */
import { iOVM_BaseCrossDomainMessenger } from "./iOVM_BaseCrossDomainMessenger.sol";
/**
* @title iOVM_L2CrossDomainMessenger
*/
interface iOVM_L2CrossDomainMessenger is iOVM_BaseCrossDomainMessenger {
/********************
* Public Functions *
********************/
/**
* Sends a cross domain message to the target messenger.
* @param _target Target contract address.
* @param _message Message to send to the target.
* @param _gasLimit Gas limit for the provided message.
*/
function sendMessage(
address _target,
bytes memory _message,
uint256 _gasLimit
) external;
/**
* Relays a cross domain message to a contract.
* @param _target Target contract address.
* @param _sender Message sender address.
* @param _message Message to send to the target.
* @param _messageNonce Nonce for the provided message.
*/
function relayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce
) external;
}
packages/contracts/contracts/optimistic-ethereum/iOVM/precompiles/iOVM_DeployerWhitelist.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/**
* @title iOVM_DeployerWhitelist
*/
interface iOVM_DeployerWhitelist {
/********************
* Public Functions *
********************/
function initialize(address _owner, bool _allowArbitraryDeployment) external;
function setWhitelistedDeployer(address _deployer, bool _isWhitelisted) external;
function setOwner(address _newOwner) external;
function setAllowArbitraryDeployment(bool _allowArbitraryDeployment) external;
function enableArbitraryContractDeployment() external;
function isDeployerAllowed(address _deployer) external returns (bool _allowed);
}
packages/contracts/contracts/optimistic-ethereum/iOVM/precompiles/iOVM_L1MessageSender.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/**
* @title iOVM_L1MessageSender
*/
interface iOVM_L1MessageSender {
/********************
* Public Functions *
********************/
function getL1MessageSender() external returns (address _l1MessageSender);
}
packages/contracts/contracts/optimistic-ethereum/iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/**
* @title iOVM_L2ToL1MessagePasser
*/
interface iOVM_L2ToL1MessagePasser {
/**********
* Events *
**********/
event L2ToL1Message(
uint _nonce,
address _sender,
bytes _data
);
/********************
* Public Functions *
********************/
function passMessageToL1(bytes memory _message) external;
}
packages/contracts/contracts/optimistic-ethereum/iOVM/queue/iOVM_L1ToL2TransactionQueue.sol
View file @
b02332ff
...
...
@@ -17,6 +17,6 @@ interface iOVM_L1ToL2TransactionQueue is iOVM_BaseQueue {
* Public Functions: Queue Manipulation *
****************************************/
function enqueue(
Lib_OVMCodec.QueueElement memory _element
) external;
function dequeue() external
returns (Lib_OVMCodec.QueueElement memory _element)
;
function enqueue(
address _target, uint256 _gasLimit, bytes memory _data
) external;
function dequeue() external;
}
packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_ByteUtils.sol
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/*
/*
*
* @title Lib_ByteUtils
*/
library Lib_ByteUtils {
...
...
packages/contracts/contracts/optimistic-ethereum/libraries/utils/Lib_Bytes32Utils.sol
0 → 100644
View file @
b02332ff
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
/**
* @title Lib_Byte32Utils
*/
library Lib_Bytes32Utils {
/**********************
* Internal Functions *
**********************/
function toBool(
bytes32 _in
)
internal
pure
returns (
bool _out
)
{
return _in != 0;
}
function fromBool(
bool _in
)
internal
pure
returns (
bytes32 _out
)
{
return bytes32(uint256(_in ? 1 : 0));
}
function toAddress(
bytes32 _in
)
internal
pure
returns (
address _out
)
{
return address(uint160(uint256(_in)));
}
function fromAddress(
address _in
)
internal
pure
returns (
bytes32 _out
)
{
return bytes32(bytes20(_in));
}
}
packages/contracts/contracts/optimistic-ethereum/proxy/Proxy_Forwarder.sol
View file @
b02332ff
...
...
@@ -67,7 +67,7 @@ contract Proxy_Forwarder {
/**
* Determines the appropriate target.
* @return Target to forward requests to.
* @return
_target
Target to forward requests to.
*/
function _getTarget()
internal
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment