Commit 858b3dfc authored by elenadimitrova's avatar elenadimitrova Committed by Kelvin Fichter

Rename iOVM_L2CrossDomainMessenger to IL2CrossDomainMessenger

parent 61ee1c52
......@@ -78,7 +78,7 @@ export class OptimismEnv {
.attach(watcher.l1.messengerAddress)
const ovmEth = getOvmEth(l2Wallet)
const l2Bridge = await getL2Bridge(l2Wallet)
const l2Messenger = getContractFactory('iOVM_L2CrossDomainMessenger')
const l2Messenger = getContractFactory('IL2CrossDomainMessenger')
.connect(l2Wallet)
.attach(watcher.l2.messengerAddress)
......@@ -140,7 +140,7 @@ export class OptimismEnv {
l1Provider,
l2Provider,
this.scc.address,
predeploys.OVM_L2CrossDomainMessenger,
predeploys.L2CrossDomainMessenger,
tx.hash
)
break
......
......@@ -16,7 +16,7 @@ export const initWatcher = async (
'Proxy__OVM_L1CrossDomainMessenger'
)
const l2MessengerAddress = await AddressManager.getAddress(
'OVM_L2CrossDomainMessenger'
'L2CrossDomainMessenger'
)
return new Watcher({
l1: {
......
......@@ -6,9 +6,9 @@ pragma experimental ABIEncoderV2;
import { iOVM_CrossDomainMessenger } from "../../libraries/bridge/iOVM_CrossDomainMessenger.sol";
/**
* @title iOVM_L2CrossDomainMessenger
* @title IL2CrossDomainMessenger
*/
interface iOVM_L2CrossDomainMessenger is iOVM_CrossDomainMessenger {
interface IL2CrossDomainMessenger is iOVM_CrossDomainMessenger {
/********************
* Public Functions *
......
......@@ -8,7 +8,7 @@ import { Lib_DefaultValues } from "../../libraries/constants/Lib_DefaultValues.s
import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol";
/* Interface Imports */
import { iOVM_L2CrossDomainMessenger } from "./iOVM_L2CrossDomainMessenger.sol";
import { IL2CrossDomainMessenger } from "./IL2CrossDomainMessenger.sol";
import { iOVM_L1MessageSender } from "../predeploys/iOVM_L1MessageSender.sol";
import { iOVM_L2ToL1MessagePasser } from "../predeploys/iOVM_L2ToL1MessagePasser.sol";
......@@ -19,14 +19,14 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.s
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
/**
* @title OVM_L2CrossDomainMessenger
* @title L2CrossDomainMessenger
* @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point
* for L2 messages sent via the L1 Cross Domain Messenger.
*
* Runtime target: OVM
*/
contract OVM_L2CrossDomainMessenger is
iOVM_L2CrossDomainMessenger,
contract L2CrossDomainMessenger is
IL2CrossDomainMessenger,
ReentrancyGuard
{
......@@ -100,7 +100,7 @@ contract OVM_L2CrossDomainMessenger is
/**
* Relays a cross domain message to a contract.
* @inheritdoc iOVM_L2CrossDomainMessenger
* @inheritdoc IL2CrossDomainMessenger
*/
function relayMessage(
address _target,
......
......@@ -36,7 +36,7 @@ contract OVM_L2ToL1MessagePasser is iOVM_L2ToL1MessagePasser {
public
{
// Note: although this function is public, only messages sent from the
// OVM_L2CrossDomainMessenger will be relayed by the L1CrossDomainMessenger.
// L2CrossDomainMessenger will be relayed by the L1CrossDomainMessenger.
// This is enforced by a check in L1CrossDomainMessenger._verifyStorageProof().
sentMessages[keccak256(
abi.encodePacked(
......
......@@ -17,8 +17,8 @@ const deployFn: DeployFunction = async (hre) => {
await registerAddress({
hre,
name: 'OVM_L2CrossDomainMessenger',
address: predeploys.OVM_L2CrossDomainMessenger,
name: 'L2CrossDomainMessenger',
address: predeploys.L2CrossDomainMessenger,
})
await registerAddress({
......
......@@ -92,7 +92,7 @@ export const connectL2Contracts = async (
return {
eth: getEthersContract('OVM_ETH'),
xDomainMessenger: getEthersContract('OVM_L2CrossDomainMessenger'),
xDomainMessenger: getEthersContract('L2CrossDomainMessenger'),
messagePasser: getEthersContract('OVM_L2ToL1MessagePasser'),
messageSender: getEthersContract(
'OVM_L1MessageSender',
......
......@@ -65,7 +65,7 @@ export const getL1ContractData = (network: Network) => {
}
const OVM_ETH = require('../artifacts/contracts/L2/predeploys/OVM_ETH.sol/OVM_ETH.json')
const OVM_L2CrossDomainMessenger = require('../artifacts/contracts/L2/messaging/OVM_L2CrossDomainMessenger.sol/OVM_L2CrossDomainMessenger.json')
const L2CrossDomainMessenger = require('../artifacts/contracts/L2/messaging/L2CrossDomainMessenger.sol/L2CrossDomainMessenger.json')
const OVM_L2ToL1MessagePasser = require('../artifacts/contracts/L2/predeploys/OVM_L2ToL1MessagePasser.sol/OVM_L2ToL1MessagePasser.json')
const OVM_L1MessageSender = require('../artifacts/contracts/L2/predeploys/iOVM_L1MessageSender.sol/iOVM_L1MessageSender.json')
const OVM_DeployerWhitelist = require('../artifacts/contracts/L2/predeploys/OVM_DeployerWhitelist.sol/OVM_DeployerWhitelist.json')
......@@ -76,9 +76,9 @@ export const getL2ContractData = () => {
abi: OVM_ETH.abi,
address: l2Addresses.OVM_ETH,
},
OVM_L2CrossDomainMessenger: {
abi: OVM_L2CrossDomainMessenger.abi,
address: l2Addresses.OVM_L2CrossDomainMessenger,
L2CrossDomainMessenger: {
abi: L2CrossDomainMessenger.abi,
address: l2Addresses.L2CrossDomainMessenger,
},
OVM_L2ToL1MessagePasser: {
abi: OVM_L2ToL1MessagePasser.abi,
......
......@@ -56,7 +56,7 @@ export const makeL2GenesisFile = async (
},
OVM_L2StandardBridge: {
l1TokenBridge: cfg.l1StandardBridgeAddress,
messenger: predeploys.OVM_L2CrossDomainMessenger,
messenger: predeploys.L2CrossDomainMessenger,
},
OVM_SequencerFeeVault: {
l1FeeWallet: cfg.l1FeeWalletAddress,
......@@ -67,7 +67,7 @@ export const makeL2GenesisFile = async (
_symbol: 'ETH',
_decimals: 18,
},
OVM_L2CrossDomainMessenger: {
L2CrossDomainMessenger: {
_status: 1,
l1CrossDomainMessenger: cfg.l1CrossDomainMessengerAddress,
},
......
......@@ -11,7 +11,7 @@ export const predeploys = {
OVM_L2ToL1MessagePasser: '0x4200000000000000000000000000000000000000',
OVM_L1MessageSender: '0x4200000000000000000000000000000000000001',
OVM_DeployerWhitelist: '0x4200000000000000000000000000000000000002',
OVM_L2CrossDomainMessenger: '0x4200000000000000000000000000000000000007',
L2CrossDomainMessenger: '0x4200000000000000000000000000000000000007',
OVM_GasPriceOracle: '0x420000000000000000000000000000000000000F',
OVM_L2StandardBridge: '0x4200000000000000000000000000000000000010',
OVM_SequencerFeeVault: '0x4200000000000000000000000000000000000011',
......
......@@ -52,7 +52,7 @@ describe('L1CrossDomainMessenger', () => {
})
let Mock__TargetContract: MockContract
let Mock__OVM_L2CrossDomainMessenger: MockContract
let Mock__L2CrossDomainMessenger: MockContract
let Mock__OVM_StateCommitmentChain: MockContract
let Factory__OVM_CanonicalTransactionChain: ContractFactory
......@@ -64,10 +64,10 @@ describe('L1CrossDomainMessenger', () => {
Mock__TargetContract = await smockit(
await ethers.getContractFactory('Helper_SimpleProxy')
)
Mock__OVM_L2CrossDomainMessenger = await smockit(
await ethers.getContractFactory('OVM_L2CrossDomainMessenger'),
Mock__L2CrossDomainMessenger = await smockit(
await ethers.getContractFactory('L2CrossDomainMessenger'),
{
address: predeploys.OVM_L2CrossDomainMessenger,
address: predeploys.L2CrossDomainMessenger,
}
)
Mock__OVM_StateCommitmentChain = await smockit(
......@@ -75,8 +75,8 @@ describe('L1CrossDomainMessenger', () => {
)
await AddressManager.setAddress(
'OVM_L2CrossDomainMessenger',
Mock__OVM_L2CrossDomainMessenger.address
'L2CrossDomainMessenger',
Mock__L2CrossDomainMessenger.address
)
await setProxyTarget(
......@@ -197,7 +197,7 @@ describe('L1CrossDomainMessenger', () => {
)
const transactionHash = getTransactionHash(
L1CrossDomainMessenger.address,
Mock__OVM_L2CrossDomainMessenger.address,
Mock__L2CrossDomainMessenger.address,
gasLimit,
calldata
)
......@@ -250,7 +250,7 @@ describe('L1CrossDomainMessenger', () => {
)
await expect(
L1CrossDomainMessenger.replayMessage(
Mock__OVM_L2CrossDomainMessenger.address,
Mock__L2CrossDomainMessenger.address,
await signer.getAddress(),
calldata,
queueLength - 1,
......@@ -277,7 +277,7 @@ describe('L1CrossDomainMessenger', () => {
)
const storageKey = keccak256(
keccak256(calldata + remove0x(Mock__OVM_L2CrossDomainMessenger.address)) +
keccak256(calldata + remove0x(Mock__L2CrossDomainMessenger.address)) +
'00'.repeat(32)
)
const storageGenerator = await TrieTestGenerator.fromNodes({
......
......@@ -58,7 +58,7 @@ describe('L1StandardBridge', () => {
// Get a new mock L1 messenger
Mock__OVM_L1CrossDomainMessenger = await smockit(
await ethers.getContractFactory('L1CrossDomainMessenger'),
{ address: await l1MessengerImpersonator.getAddress() } // This allows us to use an ethers override {from: Mock__OVM_L2CrossDomainMessenger.address} to mock calls
{ address: await l1MessengerImpersonator.getAddress() } // This allows us to use an ethers override {from: Mock__L2CrossDomainMessenger.address} to mock calls
)
// Deploy the contract under test
......
......@@ -15,7 +15,7 @@ import {
} from '../../../helpers'
import { getContractInterface, predeploys } from '../../../../src'
describe('OVM_L2CrossDomainMessenger', () => {
describe('L2CrossDomainMessenger', () => {
let signer: Signer
before(async () => {
;[signer] = await ethers.getSigners()
......@@ -42,17 +42,17 @@ describe('OVM_L2CrossDomainMessenger', () => {
)
})
let Factory__OVM_L2CrossDomainMessenger: ContractFactory
let Factory__L2CrossDomainMessenger: ContractFactory
before(async () => {
Factory__OVM_L2CrossDomainMessenger = await ethers.getContractFactory(
'OVM_L2CrossDomainMessenger'
Factory__L2CrossDomainMessenger = await ethers.getContractFactory(
'L2CrossDomainMessenger'
)
})
let OVM_L2CrossDomainMessenger: Contract
let L2CrossDomainMessenger: Contract
beforeEach(async () => {
OVM_L2CrossDomainMessenger =
await Factory__OVM_L2CrossDomainMessenger.deploy(
L2CrossDomainMessenger =
await Factory__L2CrossDomainMessenger.deploy(
Mock__OVM_L1CrossDomainMessenger.address
)
})
......@@ -64,7 +64,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
it('should be able to send a single message', async () => {
await expect(
OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
).to.not.be.reverted
expect(
......@@ -75,10 +75,10 @@ describe('OVM_L2CrossDomainMessenger', () => {
})
it('should be able to send the same message twice', async () => {
await OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
await L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
await expect(
OVM_L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
L2CrossDomainMessenger.sendMessage(target, message, gasLimit)
).to.not.be.reverted
})
})
......@@ -107,12 +107,12 @@ describe('OVM_L2CrossDomainMessenger', () => {
)
await expect(
OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
).to.be.revertedWith('Provided message could not be verified.')
})
it('should send a call to the target contract', async () => {
await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
await L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
expect(Mock__TargetContract.smocked.setTarget.calls[0]).to.deep.equal([
NON_ZERO_ADDRESS,
......@@ -121,11 +121,11 @@ describe('OVM_L2CrossDomainMessenger', () => {
it('the xDomainMessageSender is reset to the original value', async () => {
await expect(
OVM_L2CrossDomainMessenger.xDomainMessageSender()
L2CrossDomainMessenger.xDomainMessageSender()
).to.be.revertedWith('xDomainMessageSender is not set')
await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
await L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
await expect(
OVM_L2CrossDomainMessenger.xDomainMessageSender()
L2CrossDomainMessenger.xDomainMessageSender()
).to.be.revertedWith('xDomainMessageSender is not set')
})
......@@ -134,10 +134,10 @@ describe('OVM_L2CrossDomainMessenger', () => {
Mock__OVM_L1CrossDomainMessenger.address
)
await OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
await L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
await expect(
OVM_L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
L2CrossDomainMessenger.relayMessage(target, sender, message, 0)
).to.be.revertedWith('Provided message has already been received.')
})
......@@ -151,7 +151,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
[NON_NULL_BYTES32]
)
const resProm = OVM_L2CrossDomainMessenger.relayMessage(
const resProm = L2CrossDomainMessenger.relayMessage(
target,
sender,
message,
......@@ -173,7 +173,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
// The message should be registered as successful.
expect(
await OVM_L2CrossDomainMessenger.successfulMessages(
await L2CrossDomainMessenger.successfulMessages(
solidityKeccak256(
['bytes'],
[encodeXDomainCalldata(target, sender, message, 0)]
......@@ -188,7 +188,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
)
const reentrantMessage =
OVM_L2CrossDomainMessenger.interface.encodeFunctionData(
L2CrossDomainMessenger.interface.encodeFunctionData(
'relayMessage',
[target, sender, message, 1]
)
......@@ -196,15 +196,15 @@ describe('OVM_L2CrossDomainMessenger', () => {
// Calculate xDomainCallData used for indexing
// (within the first call to the L2 Messenger).
const xDomainCallData = encodeXDomainCalldata(
OVM_L2CrossDomainMessenger.address,
L2CrossDomainMessenger.address,
sender,
reentrantMessage,
0
)
// Make the call.
await OVM_L2CrossDomainMessenger.relayMessage(
OVM_L2CrossDomainMessenger.address,
await L2CrossDomainMessenger.relayMessage(
L2CrossDomainMessenger.address,
sender,
reentrantMessage,
0
......@@ -215,7 +215,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
// right things are happening.
// Criteria 1: the reentrant message is NOT listed in successful messages.
expect(
await OVM_L2CrossDomainMessenger.successfulMessages(
await L2CrossDomainMessenger.successfulMessages(
solidityKeccak256(['bytes'], [xDomainCallData])
)
).to.be.false
......@@ -233,7 +233,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
]
)
expect(await OVM_L2CrossDomainMessenger.relayedMessages(relayId)).to.be
expect(await L2CrossDomainMessenger.relayedMessages(relayId)).to.be
.true
// Criteria 3: the target contract did not receive a call.
......
......@@ -49,19 +49,19 @@ describe('OVM_L2StandardBridge', () => {
let OVM_L2StandardBridge: Contract
let L2ERC20: Contract
let Mock__OVM_L2CrossDomainMessenger: MockContract
let Mock__L2CrossDomainMessenger: MockContract
beforeEach(async () => {
// Get a new mock L2 messenger
Mock__OVM_L2CrossDomainMessenger = await smockit(
await ethers.getContractFactory('OVM_L2CrossDomainMessenger'),
// This allows us to use an ethers override {from: Mock__OVM_L2CrossDomainMessenger.address} to mock calls
Mock__L2CrossDomainMessenger = await smockit(
await ethers.getContractFactory('L2CrossDomainMessenger'),
// This allows us to use an ethers override {from: Mock__L2CrossDomainMessenger.address} to mock calls
{ address: await l2MessengerImpersonator.getAddress() }
)
// Deploy the contract under test
OVM_L2StandardBridge = await (
await ethers.getContractFactory('OVM_L2StandardBridge')
).deploy(Mock__OVM_L2CrossDomainMessenger.address, DUMMY_L1BRIDGE_ADDRESS)
).deploy(Mock__L2CrossDomainMessenger.address, DUMMY_L1BRIDGE_ADDRESS)
// Deploy an L2 ERC20
L2ERC20 = await (
......@@ -90,7 +90,7 @@ describe('OVM_L2StandardBridge', () => {
})
it('onlyFromCrossDomainAccount: should revert on calls from the right crossDomainMessenger, but wrong xDomainMessageSender (ie. not the L1L1StandardBridge)', async () => {
Mock__OVM_L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
Mock__L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
NON_ZERO_ADDRESS
)
......@@ -103,7 +103,7 @@ describe('OVM_L2StandardBridge', () => {
0,
NON_NULL_BYTES32,
{
from: Mock__OVM_L2CrossDomainMessenger.address,
from: Mock__L2CrossDomainMessenger.address,
}
)
).to.be.revertedWith(ERR_INVALID_X_DOMAIN_MSG_SENDER)
......@@ -125,11 +125,11 @@ describe('OVM_L2StandardBridge', () => {
0,
NON_NULL_BYTES32,
{
from: Mock__OVM_L2CrossDomainMessenger.address,
from: Mock__L2CrossDomainMessenger.address,
}
)
Mock__OVM_L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
Mock__L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
() => DUMMY_L1BRIDGE_ADDRESS
)
......@@ -143,12 +143,12 @@ describe('OVM_L2StandardBridge', () => {
100,
NON_NULL_BYTES32,
{
from: Mock__OVM_L2CrossDomainMessenger.address,
from: Mock__L2CrossDomainMessenger.address,
}
)
const withdrawalCallToMessenger =
Mock__OVM_L2CrossDomainMessenger.smocked.sendMessage.calls[0]
Mock__L2CrossDomainMessenger.smocked.sendMessage.calls[0]
expect(withdrawalCallToMessenger._target).to.equal(DUMMY_L1BRIDGE_ADDRESS)
expect(withdrawalCallToMessenger._message).to.equal(
......@@ -169,7 +169,7 @@ describe('OVM_L2StandardBridge', () => {
it('should credit funds to the depositor', async () => {
const depositAmount = 100
Mock__OVM_L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
Mock__L2CrossDomainMessenger.smocked.xDomainMessageSender.will.return.with(
() => DUMMY_L1BRIDGE_ADDRESS
)
......@@ -183,7 +183,7 @@ describe('OVM_L2StandardBridge', () => {
depositAmount,
NON_NULL_BYTES32,
{
from: Mock__OVM_L2CrossDomainMessenger.address,
from: Mock__L2CrossDomainMessenger.address,
}
)
......@@ -224,7 +224,7 @@ describe('OVM_L2StandardBridge', () => {
NON_NULL_BYTES32
)
const withdrawalCallToMessenger =
Mock__OVM_L2CrossDomainMessenger.smocked.sendMessage.calls[0]
Mock__L2CrossDomainMessenger.smocked.sendMessage.calls[0]
// Assert Alice's balance went down
const aliceBalance = await SmoddedL2Token.balanceOf(
......@@ -270,7 +270,7 @@ describe('OVM_L2StandardBridge', () => {
NON_NULL_BYTES32
)
const withdrawalCallToMessenger =
Mock__OVM_L2CrossDomainMessenger.smocked.sendMessage.calls[0]
Mock__L2CrossDomainMessenger.smocked.sendMessage.calls[0]
// Assert Alice's balance went down
const aliceBalance = await SmoddedL2Token.balanceOf(
......
......@@ -7,7 +7,7 @@ export const encodeXDomainCalldata = (
message: string,
messageNonce: number
): string => {
return getContractInterface('OVM_L2CrossDomainMessenger').encodeFunctionData(
return getContractInterface('L2CrossDomainMessenger').encodeFunctionData(
'relayMessage',
[target, sender, message, messageNonce]
)
......
......@@ -27,7 +27,7 @@ const main = async () => {
const l1RpcProviderUrl = 'https://layer1.endpoint'
const l2RpcProviderUrl = 'https://layer2.endpoint'
const l1StateCommitmentChainAddress = 'address of OVM_StateCommitmentChain from deployments page'
const l2CrossDomainMessengerAddress = 'address of OVM_L2CrossDomainMessenger from deployments page'
const l2CrossDomainMessengerAddress = 'address of L2CrossDomainMessenger from deployments page'
const l2TransactionHash = 'hash of the transaction with messages to relay'
const messagePairs = await getMessagesAndProofsForL2Transaction(
......
......@@ -48,7 +48,7 @@ const main = async () => {
l1RpcProviderUrl,
l2RpcProviderUrl,
l1StateCommitmentChainAddress,
predeploys.OVM_L2CrossDomainMessenger,
predeploys.L2CrossDomainMessenger,
l2TransactionHash
)
break
......
......@@ -78,7 +78,7 @@ export const getMessagesByTransactionHash = async (
const l2CrossDomainMessenger = new ethers.Contract(
l2CrossDomainMessengerAddress,
getContractInterface('OVM_L2CrossDomainMessenger'),
getContractInterface('L2CrossDomainMessenger'),
l2RpcProvider
)
......@@ -110,7 +110,7 @@ export const getMessagesByTransactionHash = async (
* @returns Encoded message.
*/
const encodeCrossDomainMessage = (message: CrossDomainMessage): string => {
return getContractInterface('OVM_L2CrossDomainMessenger').encodeFunctionData(
return getContractInterface('L2CrossDomainMessenger').encodeFunctionData(
'relayMessage',
[message.target, message.sender, message.message, message.messageNonce]
)
......
......@@ -74,7 +74,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
Lib_AddressManager: Contract
OVM_StateCommitmentChain: Contract
L1CrossDomainMessenger: Contract
OVM_L2CrossDomainMessenger: Contract
L2CrossDomainMessenger: Contract
OVM_L2ToL1MessagePasser: Contract
}
......@@ -119,14 +119,14 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
address: this.state.L1CrossDomainMessenger.address,
})
this.logger.info('Connecting to OVM_L2CrossDomainMessenger...')
this.state.OVM_L2CrossDomainMessenger = await loadContractFromManager({
name: 'OVM_L2CrossDomainMessenger',
this.logger.info('Connecting to L2CrossDomainMessenger...')
this.state.L2CrossDomainMessenger = await loadContractFromManager({
name: 'L2CrossDomainMessenger',
Lib_AddressManager: this.state.Lib_AddressManager,
provider: this.options.l2RpcProvider,
})
this.logger.info('Connected to OVM_L2CrossDomainMessenger', {
address: this.state.OVM_L2CrossDomainMessenger.address,
this.logger.info('Connected to L2CrossDomainMessenger', {
address: this.state.L2CrossDomainMessenger.address,
})
this.logger.info('Connecting to OVM_L2ToL1MessagePasser...')
......@@ -379,8 +379,8 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
startHeight: number,
endHeight: number
): Promise<SentMessage[]> {
const filter = this.state.OVM_L2CrossDomainMessenger.filters.SentMessage()
const events = await this.state.OVM_L2CrossDomainMessenger.queryFilter(
const filter = this.state.L2CrossDomainMessenger.filters.SentMessage()
const events = await this.state.L2CrossDomainMessenger.queryFilter(
filter,
startHeight + this.options.l2BlockOffset,
endHeight + this.options.l2BlockOffset - 1
......@@ -388,7 +388,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
const messages = events.map((event) => {
const encodedMessage =
this.state.OVM_L2CrossDomainMessenger.interface.encodeFunctionData(
this.state.L2CrossDomainMessenger.interface.encodeFunctionData(
'relayMessage',
[
event.args.target,
......@@ -428,7 +428,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
const messageSlot = ethers.utils.keccak256(
ethers.utils.keccak256(
message.encodedMessage +
this.state.OVM_L2CrossDomainMessenger.address.slice(2)
this.state.L2CrossDomainMessenger.address.slice(2)
) + '00'.repeat(32)
)
......
......@@ -15,11 +15,11 @@ There are two 'low level' bridge contracts (the L1 and L2 Cross Domain Messenger
**Starting on L2:**
- Any account on L2 may call `OVM_L2CrossDomainMessenger.sendMessage()` with the information for the L1 message (aka `xDomainCalldata`)
- Any account on L2 may call `L2CrossDomainMessenger.sendMessage()` with the information for the L1 message (aka `xDomainCalldata`)
- (ie. `_target`, `msg.sender`, `_message`)
- This data is hashed with the `messageNonce` storage variable, and the hash is store in the `sentMessages` mapping (this is not actually used AFAIK)
- The `messageNonce` is then incremented.
- The `OVM_L2CrossDomainMessenger` then passes the `xDomainCalldata` to `OVM_L2ToL1MessagePasser.passMessageToL1()`
- The `L2CrossDomainMessenger` then passes the `xDomainCalldata` to `OVM_L2ToL1MessagePasser.passMessageToL1()`
- the `xDomainCalldata` is hashed with `msg.sender` (ie. `ovmCaller`), and written to the `sentMessages` mapping.
**Then on L1:**
......@@ -47,11 +47,11 @@ There are two 'low level' bridge contracts (the L1 and L2 Cross Domain Messenger
- Any account may call the L1xDM's `sendMessage()`, specifying the details of the call that the L2xDM should make.
- The L1xDM call `enqueue` on the CTC to add to the Transaction Queue, with the L2xDM as the `target`.
- The [`Transaction.data`](../data-structures.md#transaction) field should be ABI encoded to call `OVM_L2CrossDomainMessenger.relayMessage()`.
- The [`Transaction.data`](../data-structures.md#transaction) field should be ABI encoded to call `L2CrossDomainMessenger.relayMessage()`.
**Then on L2:**
- A transaction will be sent to the `OVM_L2CrossDomainMessenger`.
- A transaction will be sent to the `L2CrossDomainMessenger`.
- The cross-domain message is deemed valid if the `ovmL1TXORIGIN` is the `L1CrossDomainMessenger`.
- If not valid, execution reverts.
- If the message is valid, the arguments are ABI encoded and keccak256 hashed to `xDomainCalldataHash`.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment