Commit 6f380e2b authored by Karl Floersch's avatar Karl Floersch Committed by GitHub

Add events to xDomain messengers (#61)

parent fc07158e
...@@ -50,6 +50,8 @@ contract OVM_BaseCrossDomainMessenger is iOVM_BaseCrossDomainMessenger { ...@@ -50,6 +50,8 @@ contract OVM_BaseCrossDomainMessenger is iOVM_BaseCrossDomainMessenger {
messageNonce += 1; messageNonce += 1;
sentMessages[keccak256(xDomainCalldata)] = true; sentMessages[keccak256(xDomainCalldata)] = true;
emit SentMessage(xDomainCalldata);
} }
/********************** /**********************
......
...@@ -78,8 +78,10 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros ...@@ -78,8 +78,10 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
"Provided message could not be verified." "Provided message could not be verified."
); );
bytes32 xDomainCalldataHash = keccak256(xDomainCalldata);
require( require(
successfulMessages[keccak256(xDomainCalldata)] == false, successfulMessages[xDomainCalldataHash] == false,
"Provided message has already been received." "Provided message has already been received."
); );
...@@ -89,7 +91,8 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros ...@@ -89,7 +91,8 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
// Mark the message as received if the call was successful. Ensures that a message can be // Mark the message as received if the call was successful. Ensures that a message can be
// relayed multiple times in the case that the call reverted. // relayed multiple times in the case that the call reverted.
if (success == true) { if (success == true) {
successfulMessages[keccak256(xDomainCalldata)] = true; successfulMessages[xDomainCalldataHash] = true;
emit RelayedMessage(xDomainCalldataHash);
} }
// Store an identifier that can be used to prove that the given message was relayed by some // Store an identifier that can be used to prove that the given message was relayed by some
......
...@@ -60,8 +60,10 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros ...@@ -60,8 +60,10 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
_messageNonce _messageNonce
); );
bytes32 xDomainCalldataHash = keccak256(xDomainCalldata);
require( require(
successfulMessages[keccak256(xDomainCalldata)] == false, successfulMessages[xDomainCalldataHash] == false,
"Provided message has already been received." "Provided message has already been received."
); );
...@@ -71,7 +73,8 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros ...@@ -71,7 +73,8 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
// Mark the message as received if the call was successful. Ensures that a message can be // Mark the message as received if the call was successful. Ensures that a message can be
// relayed multiple times in the case that the call reverted. // relayed multiple times in the case that the call reverted.
if (success == true) { if (success == true) {
successfulMessages[keccak256(xDomainCalldata)] = true; successfulMessages[xDomainCalldataHash] = true;
emit RelayedMessage(xDomainCalldataHash);
} }
// Store an identifier that can be used to prove that the given message was relayed by some // Store an identifier that can be used to prove that the given message was relayed by some
......
...@@ -6,6 +6,13 @@ pragma experimental ABIEncoderV2; ...@@ -6,6 +6,13 @@ pragma experimental ABIEncoderV2;
* @title iOVM_BaseCrossDomainMessenger * @title iOVM_BaseCrossDomainMessenger
*/ */
interface iOVM_BaseCrossDomainMessenger { interface iOVM_BaseCrossDomainMessenger {
/**********
* Events *
**********/
event SentMessage(bytes message);
event RelayedMessage(bytes32 msgHash);
/********************** /**********************
* Contract Variables * * Contract Variables *
**********************/ **********************/
......
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