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
d8744f91
Unverified
Commit
d8744f91
authored
Oct 20, 2023
by
Ethen Pociask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[indexer.bridge_accounting_fix] fix(indexer) Changed Withdrawal/Deposit Counters to Use big.Int
parent
0600fe87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
l1_bridge_processor.go
indexer/processors/bridge/l1_bridge_processor.go
+9
-3
l2_bridge_processor.go
indexer/processors/bridge/l2_bridge_processor.go
+7
-3
No files found.
indexer/processors/bridge/l1_bridge_processor.go
View file @
d8744f91
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/indexer/bigint"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/processors/contracts"
...
...
@@ -28,13 +29,13 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
log
.
Info
(
"detected transaction deposits"
,
"size"
,
len
(
optimismPortalTxDeposits
))
}
mintedETH
:=
0
var
mintedGWEI
=
bigint
.
Zero
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
minted
ETH
=
mintedETH
+
int
(
depositTx
.
Tx
.
Amount
.
Uint64
()
)
minted
GWEI
=
new
(
big
.
Int
)
.
Add
(
mintedGWEI
,
depositTx
.
Tx
.
Amount
)
transactionDeposits
[
i
]
=
database
.
L1TransactionDeposit
{
SourceHash
:
depositTx
.
DepositTx
.
SourceHash
,
...
...
@@ -43,12 +44,17 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
GasLimit
:
depositTx
.
GasLimit
,
Tx
:
depositTx
.
Tx
,
}
}
if
len
(
transactionDeposits
)
>
0
{
if
err
:=
db
.
BridgeTransactions
.
StoreL1TransactionDeposits
(
transactionDeposits
);
err
!=
nil
{
return
err
}
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
mintedETH
)
// Convert to from wei to eth
mintedETH
:=
new
(
big
.
Int
)
.
Div
(
mintedGWEI
,
big
.
NewInt
(
1e18
))
.
Uint64
()
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
int
(
mintedETH
))
}
// (2) L1CrossDomainMessenger
...
...
indexer/processors/bridge/l2_bridge_processor.go
View file @
d8744f91
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/indexer/bigint"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/processors/contracts"
...
...
@@ -28,13 +29,13 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
log
.
Info
(
"detected transaction withdrawals"
,
"size"
,
len
(
l2ToL1MPMessagesPassed
))
}
withdrawnETH
:=
0
var
withdrawnGWEI
=
bigint
.
Zero
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
withdrawn
ETH
=
withdrawnETH
+
int
(
messagePassed
.
Tx
.
Amount
.
Int64
()
)
withdrawn
GWEI
=
new
(
big
.
Int
)
.
Add
(
withdrawnGWEI
,
messagePassed
.
Tx
.
Amount
)
transactionWithdrawals
[
i
]
=
database
.
L2TransactionWithdrawal
{
WithdrawalHash
:
messagePassed
.
WithdrawalHash
,
...
...
@@ -48,7 +49,10 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
if
err
:=
db
.
BridgeTransactions
.
StoreL2TransactionWithdrawals
(
transactionWithdrawals
);
err
!=
nil
{
return
err
}
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
withdrawnETH
)
// Convert the withdrawn GWEI to ETH
withdrawnETH
:=
new
(
big
.
Int
)
.
Div
(
withdrawnGWEI
,
big
.
NewInt
(
1e9
))
.
Uint64
()
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
int
(
withdrawnETH
))
}
// (2) L2CrossDomainMessenger
...
...
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