Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e38bad66
Unverified
Commit
e38bad66
authored
Nov 21, 2023
by
smartcontracts
Committed by
GitHub
Nov 21, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8212 from ethereum-optimism/sc/get-message-status-fix
fix(sdk): have getMessageStatus call messenger
parents
935d6ef3
fa6a2338
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
19 deletions
+51
-19
purple-melons-explain.md
.changeset/purple-melons-explain.md
+5
-0
cross-chain-messenger.ts
packages/sdk/src/cross-chain-messenger.ts
+42
-19
MockMessenger.sol
packages/sdk/test/contracts/MockMessenger.sol
+4
-0
No files found.
.changeset/purple-melons-explain.md
0 → 100644
View file @
e38bad66
---
'
@eth-optimism/sdk'
:
patch
---
Simplifies getMessageStatus to use an O(1) lookup instead of an event query
packages/sdk/src/cross-chain-messenger.ts
View file @
e38bad66
...
...
@@ -667,25 +667,54 @@ export class CrossChainMessenger {
toBlockOrBlockHash
?:
BlockTag
):
Promise
<
MessageStatus
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
receipt
=
await
this
.
getMessageReceipt
(
resolved
,
messageIndex
,
fromBlockOrBlockHash
,
toBlockOrBlockHash
// legacy withdrawals relayed prebedrock are v1
const
messageHashV0
=
hashCrossDomainMessagev0
(
resolved
.
target
,
resolved
.
sender
,
resolved
.
message
,
resolved
.
messageNonce
)
// bedrock withdrawals are v1
// legacy withdrawals relayed postbedrock are v1
// there is no good way to differentiate between the two types of legacy
// so what we will check for both
const
messageHashV1
=
hashCrossDomainMessagev1
(
resolved
.
messageNonce
,
resolved
.
sender
,
resolved
.
target
,
resolved
.
value
,
resolved
.
minGasLimit
,
resolved
.
message
)
// Here we want the messenger that will receive the message, not the one that sent it.
const
messenger
=
resolved
.
direction
===
MessageDirection
.
L1_TO_L2
?
this
.
contracts
.
l2
.
L2CrossDomainMessenger
:
this
.
contracts
.
l1
.
L1CrossDomainMessenger
const
success
=
(
await
messenger
.
successfulMessages
(
messageHashV0
))
||
(
await
messenger
.
successfulMessages
(
messageHashV1
))
const
failure
=
(
await
messenger
.
failedMessages
(
messageHashV0
))
||
(
await
messenger
.
failedMessages
(
messageHashV1
))
if
(
resolved
.
direction
===
MessageDirection
.
L1_TO_L2
)
{
if
(
receipt
===
null
)
{
return
MessageStatus
.
UNCONFIRMED_L1_TO_L2_MESSAGE
if
(
success
)
{
return
MessageStatus
.
RELAYED
}
else
if
(
failure
)
{
return
MessageStatus
.
FAILED_L1_TO_L2_MESSAGE
}
else
{
if
(
receipt
.
receiptStatus
===
MessageReceiptStatus
.
RELAYED_SUCCEEDED
)
{
return
MessageStatus
.
RELAYED
}
else
{
return
MessageStatus
.
FAILED_L1_TO_L2_MESSAGE
}
return
MessageStatus
.
UNCONFIRMED_L1_TO_L2_MESSAGE
}
}
else
{
if
(
receipt
===
null
)
{
if
(
success
)
{
return
MessageStatus
.
RELAYED
}
else
if
(
failure
)
{
return
MessageStatus
.
READY_FOR_RELAY
}
else
{
let
timestamp
:
number
if
(
this
.
bedrock
)
{
const
output
=
await
this
.
getMessageBedrockOutput
(
...
...
@@ -737,12 +766,6 @@ export class CrossChainMessenger {
}
else
{
return
MessageStatus
.
READY_FOR_RELAY
}
}
else
{
if
(
receipt
.
receiptStatus
===
MessageReceiptStatus
.
RELAYED_SUCCEEDED
)
{
return
MessageStatus
.
RELAYED
}
else
{
return
MessageStatus
.
READY_FOR_RELAY
}
}
}
}
...
...
packages/sdk/test/contracts/MockMessenger.sol
View file @
e38bad66
...
...
@@ -8,6 +8,8 @@ contract MockMessenger is ICrossDomainMessenger {
}
uint256 public nonce;
mapping (bytes32 => bool) public successfulMessages;
mapping (bytes32 => bool) public failedMessages;
// Empty function to satisfy the interface.
function sendMessage(
...
...
@@ -81,6 +83,7 @@ contract MockMessenger is ICrossDomainMessenger {
) public {
for (uint256 i = 0; i < _params.length; i++) {
emit RelayedMessage(_params[i]);
successfulMessages[_params[i]] = true;
}
}
...
...
@@ -89,6 +92,7 @@ contract MockMessenger is ICrossDomainMessenger {
) public {
for (uint256 i = 0; i < _params.length; i++) {
emit FailedRelayedMessage(_params[i]);
failedMessages[_params[i]] = true;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment