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
58e60965
Commit
58e60965
authored
Oct 19, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
track low-level ETH inflows/outflows in metrics
parent
ec26a414
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
12 deletions
+39
-12
l1_bridge_processor.go
indexer/processors/bridge/l1_bridge_processor.go
+19
-7
l2_bridge_processor.go
indexer/processors/bridge/l2_bridge_processor.go
+7
-0
legacy_bridge_processor.go
indexer/processors/bridge/legacy_bridge_processor.go
+13
-5
No files found.
indexer/processors/bridge/l1_bridge_processor.go
View file @
58e60965
...
...
@@ -28,11 +28,16 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
log
.
Info
(
"detected transaction deposits"
,
"size"
,
len
(
optimismPortalTxDeposits
))
}
totalDepositAmount
:=
0
portalDeposits
:=
make
(
map
[
logKey
]
*
contracts
.
OptimismPortalTransactionDepositEvent
,
len
(
optimismPortalTxDeposits
))
transactionDeposits
:=
make
([]
database
.
L1TransactionDeposit
,
len
(
optimismPortalTxDeposits
))
for
i
:=
range
optimismPortalTxDeposits
{
depositTx
:=
optimismPortalTxDeposits
[
i
]
portalDeposits
[
logKey
{
depositTx
.
Event
.
BlockHash
,
depositTx
.
Event
.
LogIndex
}]
=
&
depositTx
if
len
(
depositTx
.
Tx
.
Data
)
==
0
{
totalDepositAmount
=
totalDepositAmount
+
int
(
depositTx
.
Tx
.
Amount
.
Uint64
())
}
transactionDeposits
[
i
]
=
database
.
L1TransactionDeposit
{
SourceHash
:
depositTx
.
DepositTx
.
SourceHash
,
L2TransactionHash
:
types
.
NewTx
(
depositTx
.
DepositTx
)
.
Hash
(),
...
...
@@ -46,6 +51,7 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
return
err
}
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
))
metrics
.
RecordL1InitiatedBridgeTransfers
(
database
.
ETHTokenPair
.
LocalTokenAddress
,
totalDepositAmount
)
}
// (2) L1CrossDomainMessenger
...
...
@@ -115,8 +121,8 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
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
bridgeDeposits
[
i
]
=
database
.
L1BridgeDeposit
{
TransactionSourceHash
:
portalDeposit
.
DepositTx
.
SourceHash
,
BridgeTransfer
:
initiatedBridge
.
BridgeTransfer
,
...
...
@@ -177,23 +183,29 @@ func L1ProcessFinalizedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
log
.
Info
(
"detected finalized withdrawals"
,
"size"
,
len
(
finalizedWithdrawals
))
}
totalWithdrawalAmount
:=
0
for
i
:=
range
finalizedWithdrawals
{
finalized
:=
finalizedWithdrawals
[
i
]
withdrawal
,
err
:=
db
.
BridgeTransactions
.
L2TransactionWithdrawal
(
finalized
.
WithdrawalHash
)
finalized
Withdrawal
:=
finalizedWithdrawals
[
i
]
withdrawal
,
err
:=
db
.
BridgeTransactions
.
L2TransactionWithdrawal
(
finalized
Withdrawal
.
WithdrawalHash
)
if
err
!=
nil
{
return
err
}
else
if
withdrawal
==
nil
{
log
.
Error
(
"missing indexed withdrawal on finalization event!"
,
"tx_hash"
,
finalized
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"missing indexed withdrawal on finalization! tx_hash: %s"
,
finalized
.
Event
.
TransactionHash
.
String
())
log
.
Error
(
"missing indexed withdrawal on finalization event!"
,
"tx_hash"
,
finalizedWithdrawal
.
Event
.
TransactionHash
.
String
())
return
fmt
.
Errorf
(
"missing indexed withdrawal on finalization! tx_hash: %s"
,
finalizedWithdrawal
.
Event
.
TransactionHash
.
String
())
}
if
len
(
withdrawal
.
Tx
.
Data
)
==
0
{
totalWithdrawalAmount
=
totalWithdrawalAmount
+
int
(
withdrawal
.
Tx
.
Amount
.
Int64
())
}
if
err
=
db
.
BridgeTransactions
.
MarkL2TransactionWithdrawalFinalizedEvent
(
finalized
.
WithdrawalHash
,
finalized
.
Event
.
GUID
,
finalized
.
Success
);
err
!=
nil
{
log
.
Error
(
"failed to mark withdrawal as finalized"
,
"err"
,
err
,
"tx_hash"
,
finalized
.
Event
.
TransactionHash
.
String
())
if
err
=
db
.
BridgeTransactions
.
MarkL2TransactionWithdrawalFinalizedEvent
(
finalized
Withdrawal
.
WithdrawalHash
,
finalizedWithdrawal
.
Event
.
GUID
,
finalizedWithdrawal
.
Success
);
err
!=
nil
{
log
.
Error
(
"failed to mark withdrawal as finalized"
,
"err"
,
err
,
"tx_hash"
,
finalized
Withdrawal
.
Event
.
TransactionHash
.
String
())
return
err
}
}
if
len
(
finalizedWithdrawals
)
>
0
{
metrics
.
RecordL1FinalizedWithdrawals
(
len
(
finalizedWithdrawals
))
metrics
.
RecordL1FinalizedBridgeTransfers
(
database
.
ETHTokenPair
.
LocalTokenAddress
,
totalWithdrawalAmount
)
}
// (3) L1CrossDomainMessenger
...
...
indexer/processors/bridge/l2_bridge_processor.go
View file @
58e60965
...
...
@@ -28,11 +28,16 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
log
.
Info
(
"detected transaction withdrawals"
,
"size"
,
len
(
l2ToL1MPMessagesPassed
))
}
totalWithdrawalAmount
:=
0
messagesPassed
:=
make
(
map
[
logKey
]
*
contracts
.
L2ToL1MessagePasserMessagePassed
,
len
(
l2ToL1MPMessagesPassed
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
l2ToL1MPMessagesPassed
))
for
i
:=
range
l2ToL1MPMessagesPassed
{
messagePassed
:=
l2ToL1MPMessagesPassed
[
i
]
messagesPassed
[
logKey
{
messagePassed
.
Event
.
BlockHash
,
messagePassed
.
Event
.
LogIndex
}]
=
&
messagePassed
if
len
(
messagePassed
.
Tx
.
Data
)
==
0
{
totalWithdrawalAmount
=
totalWithdrawalAmount
+
int
(
messagePassed
.
Tx
.
Amount
.
Int64
())
}
transactionWithdrawals
[
i
]
=
database
.
L2TransactionWithdrawal
{
WithdrawalHash
:
messagePassed
.
WithdrawalHash
,
InitiatedL2EventGUID
:
messagePassed
.
Event
.
GUID
,
...
...
@@ -45,6 +50,8 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
if
err
:=
db
.
BridgeTransactions
.
StoreL2TransactionWithdrawals
(
transactionWithdrawals
);
err
!=
nil
{
return
err
}
metrics
.
RecordL2InitiatedBridgeTransfers
(
database
.
ETHTokenPair
.
LocalTokenAddress
,
totalWithdrawalAmount
)
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
))
}
...
...
indexer/processors/bridge/legacy_bridge_processor.go
View file @
58e60965
...
...
@@ -31,17 +31,19 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
log
.
Info
(
"detected legacy transaction deposits"
,
"size"
,
len
(
ctcTxDepositEvents
))
}
totalDepositAmount
:=
0
ctcTxDeposits
:=
make
(
map
[
logKey
]
*
contracts
.
LegacyCTCDepositEvent
,
len
(
ctcTxDepositEvents
))
transactionDeposits
:=
make
([]
database
.
L1TransactionDeposit
,
len
(
ctcTxDepositEvents
))
for
i
:=
range
ctcTxDepositEvents
{
deposit
:=
ctcTxDepositEvents
[
i
]
ctcTxDeposits
[
logKey
{
deposit
.
Event
.
BlockHash
,
deposit
.
Event
.
LogIndex
}]
=
&
deposit
if
len
(
deposit
.
Tx
.
Data
)
==
0
{
totalDepositAmount
=
totalDepositAmount
+
int
(
deposit
.
Tx
.
Amount
.
Uint64
())
}
transactionDeposits
[
i
]
=
database
.
L1TransactionDeposit
{
// We re-use the L2 Transaction hash as the source hash
// to remain consistent in the schema.
SourceHash
:
deposit
.
TxHash
,
L2TransactionHash
:
deposit
.
TxHash
,
// We re-use the L2 Transaction hash as the source hash to remain consistent in the schema.
SourceHash
:
deposit
.
TxHash
,
L2TransactionHash
:
deposit
.
TxHash
,
InitiatedL1EventGUID
:
deposit
.
Event
.
GUID
,
GasLimit
:
deposit
.
GasLimit
,
Tx
:
deposit
.
Tx
,
...
...
@@ -52,6 +54,7 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
return
err
}
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
))
metrics
.
RecordL1InitiatedBridgeTransfers
(
database
.
ETHTokenPair
.
LocalTokenAddress
,
totalDepositAmount
)
}
// (2) L1CrossDomainMessenger
...
...
@@ -158,12 +161,16 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
log
.
Info
(
"detected legacy transaction withdrawals (via L2CrossDomainMessenger)"
,
"size"
,
len
(
crossDomainSentMessages
))
}
totalWithdrawalAmount
:=
0
sentMessages
:=
make
(
map
[
logKey
]
*
contracts
.
CrossDomainMessengerSentMessageEvent
,
len
(
crossDomainSentMessages
))
bridgeMessages
:=
make
([]
database
.
L2BridgeMessage
,
len
(
crossDomainSentMessages
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
crossDomainSentMessages
))
for
i
:=
range
crossDomainSentMessages
{
sentMessage
:=
crossDomainSentMessages
[
i
]
sentMessages
[
logKey
{
sentMessage
.
Event
.
BlockHash
,
sentMessage
.
Event
.
LogIndex
}]
=
&
sentMessage
if
len
(
sentMessage
.
BridgeMessage
.
Tx
.
Data
)
==
0
{
totalWithdrawalAmount
=
totalWithdrawalAmount
+
int
(
sentMessage
.
BridgeMessage
.
Tx
.
Amount
.
Int64
())
}
// To ensure consistency in the schema, we duplicate this as the "root" transaction withdrawal. The storage key in the message
// passer contract is sha3(calldata + sender). The sender always being the L2CrossDomainMessenger pre-bedrock.
...
...
@@ -196,6 +203,7 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
}
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
))
metrics
.
RecordL2CrossDomainSentMessages
(
len
(
bridgeMessages
))
metrics
.
RecordL2InitiatedBridgeTransfers
(
database
.
ETHTokenPair
.
LocalTokenAddress
,
totalWithdrawalAmount
)
}
// (2) L2StandardBridge
...
...
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