-
Notifications
You must be signed in to change notification settings - Fork 118
Disallow relayMessage to L2 to L1 Message Passer #360
Conversation
fbb2240
to
c6fc5bc
Compare
@@ -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"); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, nice one!
c6fc5bc
to
c2d8b0d
Compare
This change prevents call spoofing on L2. Adds a test based on logs and successfulMessages mapping.
c2d8b0d
to
ca563f4
Compare
const logs = ( | ||
await Mock__OVM_L2ToL1MessagePasser.provider.getTransactionReceipt( | ||
(await resProm).hash | ||
) | ||
).logs | ||
expect(logs).to.deep.equal([]) |
There was a problem hiding this comment.
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.
872c98f
to
54d138e
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, nice one!
This change prevents call spoofing on L2.
Adds a test based on logs and successfulMessages mapping.