Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Disallow relayMessage to L2 to L1 Message Passer #360

Merged
merged 3 commits into from
Apr 7, 2021

Conversation

maurelian
Copy link
Collaborator

This change prevents call spoofing on L2.
Adds a test based on logs and successfulMessages mapping.

@@ -159,7 +159,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
override
public
{
require(transactionContext.ovmNUMBER == 0, "Only be callable at the start of a transaction");
require(transactionContext.ovmNUMBER == 0, "Only callable at the start of a transaction");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sneaking in a fix to this error message that has been bothering me for a while.

* via this contract's replay function.
* @dev The L1 Cross Domain Messenger contract sends messages from L1 to L2, and relays messages from L2 onto L1.
* In the event that a message sent from L1 to L2 is rejected for exceeding the L2 epoch gas limit, it can be resubmitted
* via this contract's replay function.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of whitespace fixes in this PR from the recently added editorConfig file.

// a call from any L2 account.
if(_target == resolve("OVM_L2ToL1MessagePasser")){
// Write to the successfulMessages mapping and return immediately.
successfulMessages[xDomainCalldataHash] = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue against calling this a 'successful message', but I think preventing future attempts to relay it is the right move.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, nice one!

@maurelian maurelian force-pushed the feat/802/removeL2MessagePasser branch from c6fc5bc to c2d8b0d Compare April 6, 2021 14:16
This change prevents call spoofing on L2.
Adds a test based on logs and successfulMessages mapping.
@maurelian maurelian force-pushed the feat/802/removeL2MessagePasser branch from c2d8b0d to ca563f4 Compare April 6, 2021 14:19
Comment on lines +179 to +184
const logs = (
await Mock__OVM_L2ToL1MessagePasser.provider.getTransactionReceipt(
(await resProm).hash
)
).logs
expect(logs).to.deep.equal([])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is an indirect way of verifying that "no call was made to the Message Passer", I would have preferred to use Mock__OVM_L2ToL1MessagePasser.smocked.passMessageToL1.calls.length === 0, but smock doesn't actually handle the case where no calls are made to a function. I spend some time on a fix, but other tests broke, so I went with this.

@maurelian maurelian force-pushed the feat/802/removeL2MessagePasser branch from 872c98f to 54d138e Compare April 6, 2021 15:46
Copy link
Collaborator

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM!

// a call from any L2 account.
if(_target == resolve("OVM_L2ToL1MessagePasser")){
// Write to the successfulMessages mapping and return immediately.
successfulMessages[xDomainCalldataHash] = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, nice one!

@ben-chain ben-chain merged commit 06cdfb4 into master Apr 7, 2021
@ben-chain ben-chain deleted the feat/802/removeL2MessagePasser branch April 7, 2021 03:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants