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
b4feae2f
Commit
b4feae2f
authored
Dec 14, 2020
by
ben-chain
Committed by
GitHub
Dec 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add L2Relayer check (#144)
parent
6b7ed526
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
OVM_L1CrossDomainMessenger.sol
...mistic-ethereum/OVM/bridge/OVM_L1CrossDomainMessenger.sol
+20
-0
OVM_L1CrossDomainMessenger.spec.ts
...t/contracts/OVM/bridge/OVM_L1CrossDomainMessenger.spec.ts
+18
-0
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/OVM_L1CrossDomainMessenger.sol
View file @
b4feae2f
...
...
@@ -45,6 +45,25 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
}
/**********************
* Function Modifiers *
**********************/
/**
* Modifier to enforce that, if configured, only the OVM_L2MessageRelayer contract may successfully call a method.
*/
modifier onlyRelayer() {
address relayer = resolve("OVM_L2MessageRelayer");
if (relayer != address(0)) {
require(
msg.sender == relayer,
"Only OVM_L2MessageRelayer can relay L2-to-L1 messages."
);
}
_;
}
/********************
* Public Functions *
********************/
...
...
@@ -62,6 +81,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
)
override
public
onlyRelayer()
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
...
...
packages/contracts/test/contracts/OVM/bridge/OVM_L1CrossDomainMessenger.spec.ts
View file @
b4feae2f
...
...
@@ -352,5 +352,23 @@ describe('OVM_L1CrossDomainMessenger', () => {
)
).
to
.
be
.
revertedWith
(
'
Provided message has already been received.
'
)
})
it
(
'
when the OVM_L2MessageRelayer address is set, should revert if called by a different account
'
,
async
()
=>
{
// set to a random NON-ZERO address
await
AddressManager
.
setAddress
(
'
OVM_L2MessageRelayer
'
,
'
0x1234123412341234123412341234123412341234
'
)
await
expect
(
OVM_L1CrossDomainMessenger
.
relayMessage
(
target
,
sender
,
message
,
0
,
proof
)
).
to
.
be
.
revertedWith
(
'
Only OVM_L2MessageRelayer can relay L2-to-L1 messages.
'
)
})
})
})
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