-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
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.
👍
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.
LGTM
@@ -388,7 +389,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); |
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 to retryMessageExecution
and receiveCrossChainMessage
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 a MessageExecuted
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 between retryMessageExecution
and receiveCrossChainMessage
is done with a bool flag or a separate MessageExecutionRetried
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 the MessageExecuted
event to differentiate
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.
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 indexed isRetry
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 only MessageExecuted
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:
- (Happy case) initial execution succeeds - observe
MessageExecuted
- Initial execution fails - observe
MessageExecutionFailed
- Successful retry - observe
MessageExecutionFailed
followed byMessageExecuted
in a later tx - Failed retry - observe
MessageExecutionFailed
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
45f2245
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.
Just one nit on comment wording, but otherwise LGTM
This reverts commit 45f2245.
Co-authored-by: Michael Kaplan <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]>
@@ -766,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 comment
The 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 comment
The 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 comment
The 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 comment
The 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.
4d2c0af
@@ -752,6 +752,7 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
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.
👍
Why this should be merged
Clean up of message execution events, consolidating event for message execution success and failure.
How this works
Previously we just had an event for successful retry
MessageExecutionRetried
and execution failureFailedMessageExecution
, but not an event emitted for successful execution. We now emitMessageExecuted
for successful initial or retry execution, andMessageExecutionFailed
when execution fails.How this was tested
How is this documented