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
22094b4d
Unverified
Commit
22094b4d
authored
Sep 24, 2024
by
Hamdi Allam
Committed by
GitHub
Sep 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check deposit on validateMessage (#12088)
parent
9c02f544
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+2
-2
CrossL2Inbox.sol
packages/contracts-bedrock/src/L2/CrossL2Inbox.sol
+5
-2
CrossL2Inbox.t.sol
packages/contracts-bedrock/test/L2/CrossL2Inbox.t.sol
+48
-0
No files found.
packages/contracts-bedrock/semver-lock.json
View file @
22094b4d
...
@@ -68,8 +68,8 @@
...
@@ -68,8 +68,8 @@
"sourceCodeHash"
:
"0x2dc2284cf7c68e743da50e4113e96ffeab435de2390aeba2eab2f1e8ca411ce9"
"sourceCodeHash"
:
"0x2dc2284cf7c68e743da50e4113e96ffeab435de2390aeba2eab2f1e8ca411ce9"
},
},
"src/L2/CrossL2Inbox.sol"
:
{
"src/L2/CrossL2Inbox.sol"
:
{
"initCodeHash"
:
"0x
79c5deb404605b42ef917b5e7308a9015dacfb71225d957a634e6d0a3a5bc621
"
,
"initCodeHash"
:
"0x
0ee27866b4bf864a0b68ab25ea9559d7f2722b0396d02f2e8e089c6a1a5a6a93
"
,
"sourceCodeHash"
:
"0x
d219408d99f627770dfcdb3243a183dec7429372787f0aec3bdbff5b3c294f2a
"
"sourceCodeHash"
:
"0x
e6f453049035e0d77e4d7a92904b448bc17e04dd3d99e738b9af20e20986ce64
"
},
},
"src/L2/ETHLiquidity.sol"
:
{
"src/L2/ETHLiquidity.sol"
:
{
"initCodeHash"
:
"0x713c18f95a6a746d0703f475f3ae10c106c9b9ecb64d881a2e61b8969b581371"
,
"initCodeHash"
:
"0x713c18f95a6a746d0703f475f3ae10c106c9b9ecb64d881a2e61b8969b581371"
,
...
...
packages/contracts-bedrock/src/L2/CrossL2Inbox.sol
View file @
22094b4d
...
@@ -65,8 +65,8 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
...
@@ -65,8 +65,8 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
/// @notice Semantic version.
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.
6
/// @custom:semver 1.0.0-beta.
7
string public constant version = "1.0.0-beta.
6
";
string public constant version = "1.0.0-beta.
7
";
/// @notice Emitted when a cross chain message is being executed.
/// @notice Emitted when a cross chain message is being executed.
/// @param msgHash Hash of message payload being executed.
/// @param msgHash Hash of message payload being executed.
...
@@ -164,6 +164,9 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
...
@@ -164,6 +164,9 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
/// @param _id Identifier of the message.
/// @param _id Identifier of the message.
/// @param _msgHash Hash of the message payload to call target with.
/// @param _msgHash Hash of the message payload to call target with.
function validateMessage(Identifier calldata _id, bytes32 _msgHash) external {
function validateMessage(Identifier calldata _id, bytes32 _msgHash) external {
// We need to know if this is being called on a depositTx
if (IL1BlockIsthmus(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();
// Check the Identifier.
// Check the Identifier.
_checkIdentifier(_id);
_checkIdentifier(_id);
...
...
packages/contracts-bedrock/test/L2/CrossL2Inbox.t.sol
View file @
22094b4d
...
@@ -461,6 +461,13 @@ contract CrossL2InboxTest is Test {
...
@@ -461,6 +461,13 @@ contract CrossL2InboxTest is Test {
returnData: abi.encode(true)
returnData: abi.encode(true)
});
});
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
returnData: abi.encode(false)
});
// Look for the emit ExecutingMessage event
// Look for the emit ExecutingMessage event
vm.expectEmit(Predeploys.CROSS_L2_INBOX);
vm.expectEmit(Predeploys.CROSS_L2_INBOX);
emit CrossL2Inbox.ExecutingMessage(_messageHash, _id);
emit CrossL2Inbox.ExecutingMessage(_messageHash, _id);
...
@@ -469,6 +476,26 @@ contract CrossL2InboxTest is Test {
...
@@ -469,6 +476,26 @@ contract CrossL2InboxTest is Test {
crossL2Inbox.validateMessage(_id, _messageHash);
crossL2Inbox.validateMessage(_id, _messageHash);
}
}
function testFuzz_validateMessage_isDeposit_reverts(
ICrossL2Inbox.Identifier calldata _id,
bytes32 _messageHash
)
external
{
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
returnData: abi.encode(true)
});
// Expect a revert with the NoExecutingDeposits selector
vm.expectRevert(NoExecutingDeposits.selector);
// Call the executeMessage function
crossL2Inbox.validateMessage(_id, _messageHash);
}
/// @dev Tests that the `validateMessage` function reverts when called with an identifier with a timestamp later
/// @dev Tests that the `validateMessage` function reverts when called with an identifier with a timestamp later
/// than current block.timestamp.
/// than current block.timestamp.
function testFuzz_validateMessage_invalidTimestamp_reverts(
function testFuzz_validateMessage_invalidTimestamp_reverts(
...
@@ -478,6 +505,13 @@ contract CrossL2InboxTest is Test {
...
@@ -478,6 +505,13 @@ contract CrossL2InboxTest is Test {
external
external
setInteropStart
setInteropStart
{
{
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
returnData: abi.encode(false)
});
// Ensure that the id's timestamp is invalid (greater than the current block timestamp)
// Ensure that the id's timestamp is invalid (greater than the current block timestamp)
vm.assume(_id.timestamp > block.timestamp);
vm.assume(_id.timestamp > block.timestamp);
...
@@ -500,6 +534,13 @@ contract CrossL2InboxTest is Test {
...
@@ -500,6 +534,13 @@ contract CrossL2InboxTest is Test {
// Ensure that the id's timestamp is invalid (less than or equal to interopStartTime)
// Ensure that the id's timestamp is invalid (less than or equal to interopStartTime)
_id.timestamp = bound(_id.timestamp, 0, crossL2Inbox.interopStart());
_id.timestamp = bound(_id.timestamp, 0, crossL2Inbox.interopStart());
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
returnData: abi.encode(false)
});
// Expect a revert with the InvalidTimestamp selector
// Expect a revert with the InvalidTimestamp selector
vm.expectRevert(InvalidTimestamp.selector);
vm.expectRevert(InvalidTimestamp.selector);
...
@@ -527,6 +568,13 @@ contract CrossL2InboxTest is Test {
...
@@ -527,6 +568,13 @@ contract CrossL2InboxTest is Test {
returnData: abi.encode(false)
returnData: abi.encode(false)
});
});
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
returnData: abi.encode(false)
});
// Expect a revert with the InvalidChainId selector
// Expect a revert with the InvalidChainId selector
vm.expectRevert(InvalidChainId.selector);
vm.expectRevert(InvalidChainId.selector);
...
...
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