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
536a00a9
Commit
536a00a9
authored
Sep 11, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nit
parent
51a287b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
config.go
indexer/config/config.go
+1
-1
bridge.go
indexer/processors/bridge.go
+10
-13
legacy_bridge_processor.go
indexer/processors/bridge/legacy_bridge_processor.go
+2
-2
No files found.
indexer/config/config.go
View file @
536a00a9
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/BurntSushi/toml"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
log
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
const
(
const
(
...
...
indexer/processors/bridge.go
View file @
536a00a9
...
@@ -132,15 +132,16 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
...
@@ -132,15 +132,16 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
err
=
b
.
db
.
Transaction
(
func
(
tx
*
database
.
DB
)
error
{
err
=
b
.
db
.
Transaction
(
func
(
tx
*
database
.
DB
)
error
{
// In the event where we have a large number of un-observed blocks, group the block range
// In the event where we have a large number of un-observed blocks, group the block range
// on the order of 10k blocks at a time. If this turns out to be a bottleneck, we can
// on the order of 10k blocks at a time. If this turns out to be a bottleneck, we can
// parallelize these operations for significant improvements as well
// parallelize these operations
maxBlockRange
:=
uint64
(
10
_000
)
l1BridgeLog
:=
b
.
log
.
New
(
"bridge"
,
"l1"
)
l1BridgeLog
:=
b
.
log
.
New
(
"bridge"
,
"l1"
)
l2BridgeLog
:=
b
.
log
.
New
(
"bridge"
,
"l2"
)
l2BridgeLog
:=
b
.
log
.
New
(
"bridge"
,
"l2"
)
// FOR OP-MAINNET, OP-GOERLI ONLY! Specially handle the existence of pre-bedrock blocks
// FOR OP-MAINNET, OP-GOERLI ONLY! Specially handle the existence of pre-bedrock blocks
// - Since this processor indexes bridge events on available epochs between L1 & L2, we
// can detect when we've switched into bedrock state by comparing the l1 bedrock starting
// height to the range of L1 blocks we are indexing.
if
l1BedrockStartingHeight
.
Cmp
(
fromL1Height
)
>
0
{
if
l1BedrockStartingHeight
.
Cmp
(
fromL1Height
)
>
0
{
l1BridgeLog
:=
l1BridgeLog
.
New
(
"mode"
,
"legacy"
)
l2BridgeLog
:=
l2BridgeLog
.
New
(
"mode"
,
"legacy"
)
legacyFromL1Height
,
legacyToL1Height
:=
fromL1Height
,
toL1Height
legacyFromL1Height
,
legacyToL1Height
:=
fromL1Height
,
toL1Height
legacyFromL2Height
,
legacyToL2Height
:=
fromL2Height
,
toL2Height
legacyFromL2Height
,
legacyToL2Height
:=
fromL2Height
,
toL2Height
if
l1BedrockStartingHeight
.
Cmp
(
toL1Height
)
<=
0
{
if
l1BedrockStartingHeight
.
Cmp
(
toL1Height
)
<=
0
{
...
@@ -148,12 +149,9 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
...
@@ -148,12 +149,9 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
legacyToL2Height
=
new
(
big
.
Int
)
.
Sub
(
l2BedrockStartingHeight
,
big
.
NewInt
(
1
))
legacyToL2Height
=
new
(
big
.
Int
)
.
Sub
(
l2BedrockStartingHeight
,
big
.
NewInt
(
1
))
}
}
l1BridgeLog
:=
l1BridgeLog
.
New
(
"mode"
,
"legacy"
)
// First, find all possible initiated bridge events
l2BridgeLog
:=
l2BridgeLog
.
New
(
"mode"
,
"legacy"
)
l1BlockGroups
:=
bigint
.
Grouped
(
legacyFromL1Height
,
legacyToL1Height
,
maxBlockRange
)
l1BlockGroups
:=
bigint
.
Grouped
(
legacyFromL1Height
,
legacyToL1Height
,
10
_000
)
l2BlockGroups
:=
bigint
.
Grouped
(
legacyFromL2Height
,
legacyToL2Height
,
maxBlockRange
)
l2BlockGroups
:=
bigint
.
Grouped
(
legacyFromL2Height
,
legacyToL2Height
,
10
_000
)
// Now that all initiated events have been indexed, it is ensured that all finalization can find their counterpart.
for
_
,
group
:=
range
l1BlockGroups
{
for
_
,
group
:=
range
l1BlockGroups
{
log
:=
l1BridgeLog
.
New
(
"from_l1_block_number"
,
group
.
Start
,
"to_l1_block_number"
,
group
.
End
)
log
:=
l1BridgeLog
.
New
(
"from_l1_block_number"
,
group
.
Start
,
"to_l1_block_number"
,
group
.
End
)
log
.
Info
(
"scanning for initiated bridge events"
)
log
.
Info
(
"scanning for initiated bridge events"
)
...
@@ -195,10 +193,9 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
...
@@ -195,10 +193,9 @@ func (b *BridgeProcessor) Start(ctx context.Context) error {
fromL2Height
=
l2BedrockStartingHeight
fromL2Height
=
l2BedrockStartingHeight
}
}
l1BlockGroups
:=
bigint
.
Grouped
(
fromL1Height
,
toL1Height
,
10
_000
)
l2BlockGroups
:=
bigint
.
Grouped
(
fromL2Height
,
toL2Height
,
10
_000
)
// First, find all possible initiated bridge events
// First, find all possible initiated bridge events
l1BlockGroups
:=
bigint
.
Grouped
(
fromL1Height
,
toL1Height
,
maxBlockRange
)
l2BlockGroups
:=
bigint
.
Grouped
(
fromL2Height
,
toL2Height
,
maxBlockRange
)
for
_
,
group
:=
range
l1BlockGroups
{
for
_
,
group
:=
range
l1BlockGroups
{
log
:=
l1BridgeLog
.
New
(
"from_block_number"
,
group
.
Start
,
"to_block_number"
,
group
.
End
)
log
:=
l1BridgeLog
.
New
(
"from_block_number"
,
group
.
Start
,
"to_block_number"
,
group
.
End
)
log
.
Info
(
"scanning for initiated bridge events"
)
log
.
Info
(
"scanning for initiated bridge events"
)
...
...
indexer/processors/bridge/legacy_bridge_processor.go
View file @
536a00a9
...
@@ -222,7 +222,7 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, fromH
...
@@ -222,7 +222,7 @@ func LegacyL2ProcessInitiatedBridgeEvents(log log.Logger, db *database.DB, fromH
// Legacy Bridge Finalization
// Legacy Bridge Finalization
// LegacyL1ProcessFinalizedBridgeEvents will query for bridge events within the specified block range
// LegacyL1ProcessFinalizedBridgeEvents will query for bridge events within the specified block range
// acording to the pre-bedrock protocol. This follows:
// ac
c
ording to the pre-bedrock protocol. This follows:
// 1. L1CrossDomainMessenger
// 1. L1CrossDomainMessenger
// 2. L1StandardBridge
// 2. L1StandardBridge
func
LegacyL1ProcessFinalizedBridgeEvents
(
log
log
.
Logger
,
db
*
database
.
DB
,
l1Client
node
.
EthClient
,
chainConfig
config
.
ChainConfig
,
fromHeight
*
big
.
Int
,
toHeight
*
big
.
Int
)
error
{
func
LegacyL1ProcessFinalizedBridgeEvents
(
log
log
.
Logger
,
db
*
database
.
DB
,
l1Client
node
.
EthClient
,
chainConfig
config
.
ChainConfig
,
fromHeight
*
big
.
Int
,
toHeight
*
big
.
Int
)
error
{
...
@@ -302,7 +302,7 @@ func LegacyL1ProcessFinalizedBridgeEvents(log log.Logger, db *database.DB, l1Cli
...
@@ -302,7 +302,7 @@ func LegacyL1ProcessFinalizedBridgeEvents(log log.Logger, db *database.DB, l1Cli
}
}
// LegacyL2ProcessFinalizedBridgeEvents will query for bridge events within the specified block range
// LegacyL2ProcessFinalizedBridgeEvents will query for bridge events within the specified block range
// acording to the pre-bedrock protocol. This follows:
// ac
c
ording to the pre-bedrock protocol. This follows:
// 1. L2CrossDomainMessenger
// 1. L2CrossDomainMessenger
// 2. L2StandardBridge
// 2. L2StandardBridge
func
LegacyL2ProcessFinalizedBridgeEvents
(
log
log
.
Logger
,
db
*
database
.
DB
,
fromHeight
*
big
.
Int
,
toHeight
*
big
.
Int
)
error
{
func
LegacyL2ProcessFinalizedBridgeEvents
(
log
log
.
Logger
,
db
*
database
.
DB
,
fromHeight
*
big
.
Int
,
toHeight
*
big
.
Int
)
error
{
...
...
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