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
e87edd22
Unverified
Commit
e87edd22
authored
Oct 20, 2023
by
Ethen Pociask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[indexer.bridge_accounting_fix] Added conversions across legacy/bedrock processors
parent
d8744f91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
17 deletions
+28
-17
bigint.go
indexer/bigint/bigint.go
+6
-0
l1_bridge_processor.go
indexer/processors/bridge/l1_bridge_processor.go
+2
-2
l2_bridge_processor.go
indexer/processors/bridge/l2_bridge_processor.go
+5
-5
legacy_bridge_processor.go
indexer/processors/bridge/legacy_bridge_processor.go
+9
-4
metrics.go
indexer/processors/bridge/metrics.go
+6
-6
No files found.
indexer/bigint/bigint.go
View file @
e87edd22
...
@@ -25,3 +25,9 @@ func Clamp(start, end *big.Int, size uint64) *big.Int {
...
@@ -25,3 +25,9 @@ func Clamp(start, end *big.Int, size uint64) *big.Int {
func
Matcher
(
num
int64
)
func
(
*
big
.
Int
)
bool
{
func
Matcher
(
num
int64
)
func
(
*
big
.
Int
)
bool
{
return
func
(
bi
*
big
.
Int
)
bool
{
return
bi
.
Int64
()
==
num
}
return
func
(
bi
*
big
.
Int
)
bool
{
return
bi
.
Int64
()
==
num
}
}
}
func
WeiToETH
(
wei
*
big
.
Int
)
*
big
.
Float
{
f
:=
new
(
big
.
Float
)
f
.
SetString
(
wei
.
String
())
return
f
.
Quo
(
f
,
big
.
NewFloat
(
1e18
))
}
indexer/processors/bridge/l1_bridge_processor.go
View file @
e87edd22
...
@@ -53,8 +53,8 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
...
@@ -53,8 +53,8 @@ func L1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L1M
}
}
// Convert to from wei to eth
// Convert to from wei to eth
mintedETH
:=
new
(
big
.
Int
)
.
Div
(
mintedGWEI
,
big
.
NewInt
(
1e18
))
.
Uin
t64
()
mintedETH
,
_
:=
bigint
.
WeiToETH
(
mintedGWEI
)
.
Floa
t64
()
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
int
(
mintedETH
)
)
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
mintedETH
)
}
}
// (2) L1CrossDomainMessenger
// (2) L1CrossDomainMessenger
...
...
indexer/processors/bridge/l2_bridge_processor.go
View file @
e87edd22
...
@@ -29,13 +29,13 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
...
@@ -29,13 +29,13 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
log
.
Info
(
"detected transaction withdrawals"
,
"size"
,
len
(
l2ToL1MPMessagesPassed
))
log
.
Info
(
"detected transaction withdrawals"
,
"size"
,
len
(
l2ToL1MPMessagesPassed
))
}
}
var
withdrawn
G
WEI
=
bigint
.
Zero
var
withdrawnWEI
=
bigint
.
Zero
messagesPassed
:=
make
(
map
[
logKey
]
*
contracts
.
L2ToL1MessagePasserMessagePassed
,
len
(
l2ToL1MPMessagesPassed
))
messagesPassed
:=
make
(
map
[
logKey
]
*
contracts
.
L2ToL1MessagePasserMessagePassed
,
len
(
l2ToL1MPMessagesPassed
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
l2ToL1MPMessagesPassed
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
l2ToL1MPMessagesPassed
))
for
i
:=
range
l2ToL1MPMessagesPassed
{
for
i
:=
range
l2ToL1MPMessagesPassed
{
messagePassed
:=
l2ToL1MPMessagesPassed
[
i
]
messagePassed
:=
l2ToL1MPMessagesPassed
[
i
]
messagesPassed
[
logKey
{
messagePassed
.
Event
.
BlockHash
,
messagePassed
.
Event
.
LogIndex
}]
=
&
messagePassed
messagesPassed
[
logKey
{
messagePassed
.
Event
.
BlockHash
,
messagePassed
.
Event
.
LogIndex
}]
=
&
messagePassed
withdrawn
GWEI
=
new
(
big
.
Int
)
.
Add
(
withdrawnG
WEI
,
messagePassed
.
Tx
.
Amount
)
withdrawn
WEI
=
new
(
big
.
Int
)
.
Add
(
withdrawn
WEI
,
messagePassed
.
Tx
.
Amount
)
transactionWithdrawals
[
i
]
=
database
.
L2TransactionWithdrawal
{
transactionWithdrawals
[
i
]
=
database
.
L2TransactionWithdrawal
{
WithdrawalHash
:
messagePassed
.
WithdrawalHash
,
WithdrawalHash
:
messagePassed
.
WithdrawalHash
,
...
@@ -50,9 +50,9 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
...
@@ -50,9 +50,9 @@ func L2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metrics L2M
return
err
return
err
}
}
// Convert the withdrawn
G
WEI to ETH
// Convert the withdrawn WEI to ETH
withdrawnETH
:=
new
(
big
.
Int
)
.
Div
(
withdrawnGWEI
,
big
.
NewInt
(
1e9
))
.
Uin
t64
()
withdrawnETH
,
_
:=
bigint
.
WeiToETH
(
withdrawnWEI
)
.
Floa
t64
()
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
int
(
withdrawnETH
)
)
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
withdrawnETH
)
}
}
// (2) L2CrossDomainMessenger
// (2) L2CrossDomainMessenger
...
...
indexer/processors/bridge/legacy_bridge_processor.go
View file @
e87edd22
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/indexer/bigint"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/indexer/node"
...
@@ -31,13 +32,13 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
...
@@ -31,13 +32,13 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
log
.
Info
(
"detected legacy transaction deposits"
,
"size"
,
len
(
ctcTxDepositEvents
))
log
.
Info
(
"detected legacy transaction deposits"
,
"size"
,
len
(
ctcTxDepositEvents
))
}
}
minted
ETH
:=
0
minted
WEI
:=
bigint
.
Zero
ctcTxDeposits
:=
make
(
map
[
logKey
]
*
contracts
.
LegacyCTCDepositEvent
,
len
(
ctcTxDepositEvents
))
ctcTxDeposits
:=
make
(
map
[
logKey
]
*
contracts
.
LegacyCTCDepositEvent
,
len
(
ctcTxDepositEvents
))
transactionDeposits
:=
make
([]
database
.
L1TransactionDeposit
,
len
(
ctcTxDepositEvents
))
transactionDeposits
:=
make
([]
database
.
L1TransactionDeposit
,
len
(
ctcTxDepositEvents
))
for
i
:=
range
ctcTxDepositEvents
{
for
i
:=
range
ctcTxDepositEvents
{
deposit
:=
ctcTxDepositEvents
[
i
]
deposit
:=
ctcTxDepositEvents
[
i
]
ctcTxDeposits
[
logKey
{
deposit
.
Event
.
BlockHash
,
deposit
.
Event
.
LogIndex
}]
=
&
deposit
ctcTxDeposits
[
logKey
{
deposit
.
Event
.
BlockHash
,
deposit
.
Event
.
LogIndex
}]
=
&
deposit
minted
ETH
=
mintedETH
+
int
(
deposit
.
Tx
.
Amount
.
Uint64
()
)
minted
WEI
=
new
(
big
.
Int
)
.
Add
(
mintedWEI
,
deposit
.
Tx
.
Amount
)
transactionDeposits
[
i
]
=
database
.
L1TransactionDeposit
{
transactionDeposits
[
i
]
=
database
.
L1TransactionDeposit
{
// We re-use the L2 Transaction hash as the source hash to remain consistent in the schema.
// We re-use the L2 Transaction hash as the source hash to remain consistent in the schema.
...
@@ -52,6 +53,8 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
...
@@ -52,6 +53,8 @@ func LegacyL1ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
if
err
:=
db
.
BridgeTransactions
.
StoreL1TransactionDeposits
(
transactionDeposits
);
err
!=
nil
{
if
err
:=
db
.
BridgeTransactions
.
StoreL1TransactionDeposits
(
transactionDeposits
);
err
!=
nil
{
return
err
return
err
}
}
mintedETH
,
_
:=
bigint
.
WeiToETH
(
mintedWEI
)
.
Float64
()
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
mintedETH
)
metrics
.
RecordL1TransactionDeposits
(
len
(
transactionDeposits
),
mintedETH
)
}
}
...
@@ -159,14 +162,14 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
...
@@ -159,14 +162,14 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
log
.
Info
(
"detected legacy transaction withdrawals (via L2CrossDomainMessenger)"
,
"size"
,
len
(
crossDomainSentMessages
))
log
.
Info
(
"detected legacy transaction withdrawals (via L2CrossDomainMessenger)"
,
"size"
,
len
(
crossDomainSentMessages
))
}
}
withdrawn
ETH
:=
0
withdrawn
WEI
:=
bigint
.
Zero
sentMessages
:=
make
(
map
[
logKey
]
*
contracts
.
CrossDomainMessengerSentMessageEvent
,
len
(
crossDomainSentMessages
))
sentMessages
:=
make
(
map
[
logKey
]
*
contracts
.
CrossDomainMessengerSentMessageEvent
,
len
(
crossDomainSentMessages
))
bridgeMessages
:=
make
([]
database
.
L2BridgeMessage
,
len
(
crossDomainSentMessages
))
bridgeMessages
:=
make
([]
database
.
L2BridgeMessage
,
len
(
crossDomainSentMessages
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
crossDomainSentMessages
))
transactionWithdrawals
:=
make
([]
database
.
L2TransactionWithdrawal
,
len
(
crossDomainSentMessages
))
for
i
:=
range
crossDomainSentMessages
{
for
i
:=
range
crossDomainSentMessages
{
sentMessage
:=
crossDomainSentMessages
[
i
]
sentMessage
:=
crossDomainSentMessages
[
i
]
sentMessages
[
logKey
{
sentMessage
.
Event
.
BlockHash
,
sentMessage
.
Event
.
LogIndex
}]
=
&
sentMessage
sentMessages
[
logKey
{
sentMessage
.
Event
.
BlockHash
,
sentMessage
.
Event
.
LogIndex
}]
=
&
sentMessage
withdrawn
ETH
=
withdrawnETH
+
int
(
sentMessage
.
BridgeMessage
.
Tx
.
Amount
.
Int64
()
)
withdrawn
WEI
=
new
(
big
.
Int
)
.
Add
(
withdrawnWEI
,
sentMessage
.
BridgeMessage
.
Tx
.
Amount
)
// To ensure consistency in the schema, we duplicate this as the "root" transaction withdrawal. The storage key in the message
// 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.
// passer contract is sha3(calldata + sender). The sender always being the L2CrossDomainMessenger pre-bedrock.
...
@@ -197,6 +200,8 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
...
@@ -197,6 +200,8 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, metri
if
err
:=
db
.
BridgeMessages
.
StoreL2BridgeMessages
(
bridgeMessages
);
err
!=
nil
{
if
err
:=
db
.
BridgeMessages
.
StoreL2BridgeMessages
(
bridgeMessages
);
err
!=
nil
{
return
err
return
err
}
}
withdrawnETH
,
_
:=
bigint
.
WeiToETH
(
withdrawnWEI
)
.
Float64
()
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
withdrawnETH
)
metrics
.
RecordL2TransactionWithdrawals
(
len
(
transactionWithdrawals
),
withdrawnETH
)
metrics
.
RecordL2CrossDomainSentMessages
(
len
(
bridgeMessages
))
metrics
.
RecordL2CrossDomainSentMessages
(
len
(
bridgeMessages
))
}
}
...
...
indexer/processors/bridge/metrics.go
View file @
e87edd22
...
@@ -16,7 +16,7 @@ var (
...
@@ -16,7 +16,7 @@ var (
type
L1Metricer
interface
{
type
L1Metricer
interface
{
RecordLatestIndexedL1Height
(
height
*
big
.
Int
)
RecordLatestIndexedL1Height
(
height
*
big
.
Int
)
RecordL1TransactionDeposits
(
size
int
,
mintedETH
int
)
RecordL1TransactionDeposits
(
size
int
,
mintedETH
float64
)
RecordL1ProvenWithdrawals
(
size
int
)
RecordL1ProvenWithdrawals
(
size
int
)
RecordL1FinalizedWithdrawals
(
size
int
)
RecordL1FinalizedWithdrawals
(
size
int
)
...
@@ -30,7 +30,7 @@ type L1Metricer interface {
...
@@ -30,7 +30,7 @@ type L1Metricer interface {
type
L2Metricer
interface
{
type
L2Metricer
interface
{
RecordLatestIndexedL2Height
(
height
*
big
.
Int
)
RecordLatestIndexedL2Height
(
height
*
big
.
Int
)
RecordL2TransactionWithdrawals
(
size
int
,
withdrawnETH
int
)
RecordL2TransactionWithdrawals
(
size
int
,
withdrawnETH
float64
)
RecordL2CrossDomainSentMessages
(
size
int
)
RecordL2CrossDomainSentMessages
(
size
int
)
RecordL2CrossDomainRelayedMessages
(
size
int
)
RecordL2CrossDomainRelayedMessages
(
size
int
)
...
@@ -178,9 +178,9 @@ func (m *bridgeMetrics) RecordLatestIndexedL1Height(height *big.Int) {
...
@@ -178,9 +178,9 @@ func (m *bridgeMetrics) RecordLatestIndexedL1Height(height *big.Int) {
m
.
latestL1Height
.
Set
(
float64
(
height
.
Uint64
()))
m
.
latestL1Height
.
Set
(
float64
(
height
.
Uint64
()))
}
}
func
(
m
*
bridgeMetrics
)
RecordL1TransactionDeposits
(
size
,
mintedETH
int
)
{
func
(
m
*
bridgeMetrics
)
RecordL1TransactionDeposits
(
size
int
,
mintedETH
float64
)
{
m
.
txDeposits
.
Add
(
float64
(
size
))
m
.
txDeposits
.
Add
(
float64
(
size
))
m
.
txMintedETH
.
Add
(
float64
(
mintedETH
)
)
m
.
txMintedETH
.
Add
(
mintedETH
)
}
}
func
(
m
*
bridgeMetrics
)
RecordL1ProvenWithdrawals
(
size
int
)
{
func
(
m
*
bridgeMetrics
)
RecordL1ProvenWithdrawals
(
size
int
)
{
...
@@ -213,9 +213,9 @@ func (m *bridgeMetrics) RecordLatestIndexedL2Height(height *big.Int) {
...
@@ -213,9 +213,9 @@ func (m *bridgeMetrics) RecordLatestIndexedL2Height(height *big.Int) {
m
.
latestL2Height
.
Set
(
float64
(
height
.
Uint64
()))
m
.
latestL2Height
.
Set
(
float64
(
height
.
Uint64
()))
}
}
func
(
m
*
bridgeMetrics
)
RecordL2TransactionWithdrawals
(
size
,
withdrawnETH
int
)
{
func
(
m
*
bridgeMetrics
)
RecordL2TransactionWithdrawals
(
size
int
,
withdrawnETH
float64
)
{
m
.
txWithdrawals
.
Add
(
float64
(
size
))
m
.
txWithdrawals
.
Add
(
float64
(
size
))
m
.
txWithdrawnETH
.
Add
(
float64
(
withdrawnETH
)
)
m
.
txWithdrawnETH
.
Add
(
withdrawnETH
)
}
}
func
(
m
*
bridgeMetrics
)
RecordL2CrossDomainSentMessages
(
size
int
)
{
func
(
m
*
bridgeMetrics
)
RecordL2CrossDomainSentMessages
(
size
int
)
{
...
...
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