-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message execution events #66
Changes from all commits
436d3e1
bb363ec
a193057
7d246ed
0c6f072
45f2245
78830f2
e01bc9b
6f32342
d042031
32bc367
b725947
b5c2bca
4d2c0af
4af5c89
535a8f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,6 +356,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { | |
* @dev See {ITeleporterMessenger-retryMessageExecution} | ||
* | ||
* Reverts if the message execution fails again on specified message. | ||
* Emits a {MessageExecuted} event if the retry is successful. | ||
* Requirements: | ||
* | ||
* - `message` must have previously failed to execute, and matches the hash of the failed message. | ||
|
@@ -387,7 +388,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { | |
|
||
// Clear the failed message hash from state prior to retrying its execution to redundantly prevent | ||
// reentrance attacks (on top of the nonReentrant guard). | ||
emit MessageExecutionRetried(originChainID, message.messageID); | ||
emit MessageExecuted(originChainID, message.messageID); | ||
delete receivedFailedMessageHashes[originChainID][message.messageID]; | ||
|
||
// Reattempt the message execution with all of the gas left available for execution of this transaction. | ||
|
@@ -701,7 +702,8 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { | |
* (including possibly storing a failed message in state). All execution specific errors (i.e. invalid call data, etc) | ||
* that are not in the relayers control are caught and handled properly. | ||
* | ||
* Emits a {FailedMessageExecution} event if the call on destination address fails with formatted call data. | ||
* Emits a {MessageExecuted} event if the call on destination address is successful. | ||
* Emits a {MessageExecutionFailed} event if the call on destination address fails with formatted call data. | ||
* Requirements: | ||
* | ||
* - There is enough gas left to cover `message.requiredGasLimit`. | ||
|
@@ -749,7 +751,10 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { | |
// provided enough gas to meet the required gas limit. | ||
if (!success) { | ||
_storeFailedMessageExecution(originChainID, message); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch |
||
} | ||
|
||
emit MessageExecuted(originChainID, message.messageID); | ||
} | ||
|
||
/** | ||
|
@@ -765,7 +770,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { | |
] = keccak256(abi.encode(message)); | ||
|
||
// Emit a failed execution event for anyone monitoring unsuccessful messages to retry. | ||
emit FailedMessageExecution(originChainID, message.messageID, message); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add the failure reason to this log? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, that is best left for consideration at a later point in time because we're not sure what the return data will contain in various failure cases. Up to @minghinmatthewlam either way though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I created an issue here: #81. @minghinmatthewlam up to you if you want to include that in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks will tackle in separate PR, definitely think will be helpful for developers for debugging so we should add. |
||
emit MessageExecutionFailed(originChainID, message.messageID, message); | ||
} | ||
|
||
/** | ||
|
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.
Won't affect correctness since we revert on execution failure, but can we move this to after the call itself and the associated
require
?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.
It might also be worth keeping
MessageExecutionRetried
so that an indexer can distinguish between calls toretryMessageExecution
andreceiveCrossChainMessage
based solely on the logs.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.
I think if we want to distinguish these two, it might be better for have a bool flag in
MessageExecuted
instead. I think it would be good to have all executed messages emit aMessageExecuted
event, so they can all be easily grouped together.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.
Yup, agreed that all executed messages should emit
MessageExecuted
. No strong preference if the distinction betweenretryMessageExecution
andreceiveCrossChainMessage
is done with a bool flag or a separateMessageExecutionRetried
event, but I think the distinction should be made one way or another.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.
Ah, yeah emitting two events is probably a little cleaner, and should be okay since retries shouldn't be too common
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.
added
isRetry
to theMessageExecuted
event to differentiateThere 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.
Actually, I have a preference for separate retry vs executed events over the boolean flag approach.
If we expect retries to be relatively rare, then it doesn't make as much sense for every
MessageExecuted
event to pay gas for the indexedisRetry
field.OTOH, if retries are common enough, then it's possible for the average gas needed to eventually execute the message would be lower by only having a single event type.
I suspect the former case to be more likely, so would prefer separate events over the bool flag.
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.
Yeah I think I agree with Cam here
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.
We synced offline and decided that it makes the most sense to not distinguish between the initial execution and retry cases, and have
retryMessageExecution
emit onlyMessageExecuted
without the bool flag. The main reason for this is gas savings by not emitting more events than are necessary to reconstruct on-chain activity. An indexer should be able to construct all the scenarios with the existing events associated with a particular message ID:MessageExecuted
MessageExecutionFailed
MessageExecutionFailed
followed byMessageExecuted
in a later txMessageExecutionFailed
followed by a tx revert on the failed call toretryMessageExecution
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.
Thanks for writing this up