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
ec26a414
Commit
ec26a414
authored
Oct 18, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assert tx hash equality when correlating events
parent
0343486d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
13 deletions
+52
-13
l1_bridge_processor.go
indexer/processors/bridge/l1_bridge_processor.go
+15
-2
l2_bridge_processor.go
indexer/processors/bridge/l2_bridge_processor.go
+16
-3
legacy_bridge_processor.go
indexer/processors/bridge/legacy_bridge_processor.go
+21
-8
No files found.
indexer/processors/bridge/l1_bridge_processor.go
View file @
ec26a414
...
...
@@ -68,6 +68,9 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
if
!
ok
{
log
.
Error
(
"expected TransactionDeposit preceding SentMessage event"
,
"tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected TransactionDeposit preceding SentMessage event. tx_hash = %s"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
}
else
if
portalDeposit
.
Event
.
TransactionHash
!=
sentMessage
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"deposit_tx_hash"
,
portalDeposit
.
Event
.
TransactionHash
.
String
(),
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
bridgeMessages
[
i
]
=
database
.
L1BridgeMessage
{
TransactionSourceHash
:
portalDeposit
.
DepositTx
.
SourceHash
,
BridgeMessage
:
sentMessage
.
BridgeMessage
}
...
...
@@ -98,11 +101,18 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
if
!
ok
{
log
.
Error
(
"expected TransactionDeposit following BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected TransactionDeposit following BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
portalDeposit
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"deposit_tx_hash"
,
portalDeposit
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
sentMessage
,
ok
:=
sentMessages
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
+
2
}]
if
!
ok
{
log
.
Error
(
"expected SentMessage following TransactionDeposit event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage following TransactionDeposit event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"expected SentMessage following BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage following BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
sentMessage
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
initiatedBridge
.
BridgeTransfer
.
CrossDomainMessageHash
=
&
sentMessage
.
BridgeMessage
.
MessageHash
...
...
@@ -234,6 +244,9 @@ func L1ProcessFinalizedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
if
!
ok
{
log
.
Error
(
"expected RelayedMessage following BridgeFinalized event"
,
"tx_hash"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected RelayedMessage following BridgeFinalized event. tx_hash = %s"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
relayedMessage
.
Event
.
TransactionHash
!=
finalizedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
relayedMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
// Since the message hash is computed from the relayed message, this ensures the deposit fields must match
...
...
indexer/processors/bridge/l2_bridge_processor.go
View file @
ec26a414
...
...
@@ -68,6 +68,9 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
if
!
ok
{
log
.
Error
(
"expected MessagePassedEvent preceding SentMessage"
,
"tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected MessagePassedEvent preceding SentMessage. tx_hash = %s"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
}
else
if
messagePassed
.
Event
.
TransactionHash
!=
sentMessage
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"withdraw_tx_hash"
,
messagePassed
.
Event
.
TransactionHash
.
String
(),
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
bridgeMessages
[
i
]
=
database
.
L2BridgeMessage
{
TransactionWithdrawalHash
:
messagePassed
.
WithdrawalHash
,
BridgeMessage
:
sentMessage
.
BridgeMessage
}
...
...
@@ -93,16 +96,23 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
for
i
:=
range
initiatedBridges
{
initiatedBridge
:=
initiatedBridges
[
i
]
// extract the cross domain message hash &
deposit source
hash from the following events
// extract the cross domain message hash &
withdraw
hash from the following events
messagePassed
,
ok
:=
messagesPassed
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
+
1
}]
if
!
ok
{
log
.
Error
(
"expected MessagePassed following BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected MessagePassed following BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
messagePassed
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"withdraw_tx_hash"
,
messagePassed
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
sentMessage
,
ok
:=
sentMessages
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
+
2
}]
if
!
ok
{
log
.
Error
(
"expected SentMessage following MessagePassed event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage following MessagePassed event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"expected SentMessage following BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage following BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
sentMessage
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
initiatedBridge
.
BridgeTransfer
.
CrossDomainMessageHash
=
&
sentMessage
.
BridgeMessage
.
MessageHash
...
...
@@ -180,6 +190,9 @@ func L2ProcessFinalizedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
if
!
ok
{
log
.
Error
(
"expected RelayedMessage following BridgeFinalized event"
,
"tx_hash"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected RelayedMessage following BridgeFinalized event. tx_hash = %s"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
relayedMessage
.
Event
.
TransactionHash
!=
finalizedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
relayedMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
finalizedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
// Since the message hash is computed from the relayed message, this ensures the withdrawal fields must match
...
...
indexer/processors/bridge/legacy_bridge_processor.go
View file @
ec26a414
...
...
@@ -72,8 +72,11 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
// extract the deposit hash from the previous TransactionDepositedEvent
ctcTxDeposit
,
ok
:=
ctcTxDeposits
[
logKey
{
sentMessage
.
Event
.
BlockHash
,
sentMessage
.
Event
.
LogIndex
-
1
}]
if
!
ok
{
log
.
Error
(
"missing transaction deposit for cross domain message"
,
"tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"missing preceding TransactionEnqueued for SentMessage event. tx_hash = %s"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"expected TransactionEnqueued preceding SentMessage event"
,
"tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected TransactionEnqueued preceding SentMessage event. tx_hash = %s"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
}
else
if
ctcTxDeposit
.
Event
.
TransactionHash
!=
sentMessage
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"deposit_tx_hash"
,
ctcTxDeposit
.
Event
.
TransactionHash
.
String
(),
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
bridgeMessages
[
i
]
=
database
.
L1BridgeMessage
{
TransactionSourceHash
:
ctcTxDeposit
.
TxHash
,
BridgeMessage
:
sentMessage
.
BridgeMessage
}
...
...
@@ -104,13 +107,20 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
// - Event Flow: TransactionEnqueued -> SentMessage -> DepositInitiated
sentMessage
,
ok
:=
sentMessages
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
-
1
}]
if
!
ok
{
log
.
Error
(
"
missing cross domain message for bridge transfer"
,
"tx_hash"
,
initiatedBrid
ge
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"
expected SentMessage preceding BridgeInitiated event"
,
"tx_hash"
,
sentMessa
ge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage preceding DepositInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
sentMessage
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
ctcTxDeposit
,
ok
:=
ctcTxDeposits
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
-
2
}]
if
!
ok
{
log
.
Error
(
"missing transaction deposit for bridge transfer"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected TransactionEnqueued preceding DepostInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"expected TransactionEnqueued preceding BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected TransactionEnqueued preceding BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
}
else
if
ctcTxDeposit
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"deposit_tx_hash"
,
ctcTxDeposit
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
initiatedBridge
.
BridgeTransfer
.
CrossDomainMessageHash
=
&
sentMessage
.
BridgeMessage
.
MessageHash
...
...
@@ -207,12 +217,15 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
// - Event Flow: TransactionEnqueued -> SentMessage -> DepositInitiated
sentMessage
,
ok
:=
sentMessages
[
logKey
{
initiatedBridge
.
Event
.
BlockHash
,
initiatedBridge
.
Event
.
LogIndex
-
1
}]
if
!
ok
{
log
.
Error
(
"expected SentMessage preceding DepositInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage preceding DepositInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
)
log
.
Error
(
"expected SentMessage preceding BridgeInitiated event"
,
"tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"expected SentMessage preceding BridgeInitiated event. tx_hash = %s"
,
initiatedBridge
.
Event
.
TransactionHash
)
}
else
if
sentMessage
.
Event
.
TransactionHash
!=
initiatedBridge
.
Event
.
TransactionHash
{
log
.
Error
(
"correlated events tx hash mismatch"
,
"message_tx_hash"
,
sentMessage
.
Event
.
TransactionHash
.
String
(),
"bridge_tx_hash"
,
initiatedBridge
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"correlated events tx hash mismatch"
)
}
initiatedBridge
.
BridgeTransfer
.
CrossDomainMessageHash
=
&
sentMessage
.
BridgeMessage
.
MessageHash
bridgedTokens
[
initiatedBridge
.
BridgeTransfer
.
TokenPair
.
LocalTokenAddress
]
++
initiatedBridge
.
BridgeTransfer
.
CrossDomainMessageHash
=
&
sentMessage
.
BridgeMessage
.
MessageHash
l2BridgeWithdrawals
[
i
]
=
database
.
L2BridgeWithdrawal
{
TransactionWithdrawalHash
:
sentMessage
.
BridgeMessage
.
MessageHash
,
BridgeTransfer
:
initiatedBridge
.
BridgeTransfer
,
...
...
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