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
805a9027
Unverified
Commit
805a9027
authored
Jan 11, 2023
by
Matthew Slipper
Committed by
GitHub
Jan 11, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4665 from ethereum-optimism/bugfix/indexer-startup
indexer: Fix startup errors
parents
2fa33162
ecf0cc59
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
33 deletions
+65
-33
slimy-files-suffer.md
.changeset/slimy-files-suffer.md
+5
-0
config.go
indexer/config.go
+9
-4
flags.go
indexer/flags/flags.go
+12
-5
indexer.go
indexer/indexer.go
+2
-2
bedrock_test.go
indexer/integration_tests/bedrock_test.go
+2
-1
service.go
indexer/services/l1/service.go
+35
-21
No files found.
.changeset/slimy-files-suffer.md
0 → 100644
View file @
805a9027
---
'
@eth-optimism/indexer'
:
minor
---
Fix startup issues, add L2 conf depth
indexer/config.go
View file @
805a9027
...
...
@@ -65,9 +65,13 @@ type Config struct {
// L1StartBlockNumber is the block number to start indexing L1 from.
L1StartBlockNumber
uint64
// ConfDepth is the number of confirmations after which headers are
// considered confirmed.
ConfDepth
uint64
// L1ConfDepth is the number of confirmations after which headers are
// considered confirmed on L1.
L1ConfDepth
uint64
// L2ConfDepth is the number of confirmations after which headers are
// considered confirmed on L2.
L2ConfDepth
uint64
// MaxHeaderBatchSize is the maximum number of headers to request as a
// batch.
...
...
@@ -122,7 +126,8 @@ func NewConfig(ctx *cli.Context) (Config, error) {
LogLevel
:
ctx
.
GlobalString
(
flags
.
LogLevelFlag
.
Name
),
LogTerminal
:
ctx
.
GlobalBool
(
flags
.
LogTerminalFlag
.
Name
),
L1StartBlockNumber
:
ctx
.
GlobalUint64
(
flags
.
L1StartBlockNumberFlag
.
Name
),
ConfDepth
:
ctx
.
GlobalUint64
(
flags
.
ConfDepthFlag
.
Name
),
L1ConfDepth
:
ctx
.
GlobalUint64
(
flags
.
L1ConfDepthFlag
.
Name
),
L2ConfDepth
:
ctx
.
GlobalUint64
(
flags
.
L2ConfDepthFlag
.
Name
),
MaxHeaderBatchSize
:
ctx
.
GlobalUint64
(
flags
.
MaxHeaderBatchSizeFlag
.
Name
),
MetricsServerEnable
:
ctx
.
GlobalBool
(
flags
.
MetricsServerEnableFlag
.
Name
),
RESTHostname
:
ctx
.
GlobalString
(
flags
.
RESTHostnameFlag
.
Name
),
...
...
indexer/flags/flags.go
View file @
805a9027
...
...
@@ -137,11 +137,17 @@ var (
Value
:
0
,
EnvVar
:
prefixEnvVar
(
"START_BLOCK_NUMBER"
),
}
ConfDepthFlag
=
cli
.
Uint64Flag
{
Name
:
"conf-depth"
,
Usage
:
"The number of confirmations after which headers are considered confirmed"
,
L1
ConfDepthFlag
=
cli
.
Uint64Flag
{
Name
:
"
l1-
conf-depth"
,
Usage
:
"The number of confirmations after which headers are considered confirmed
on L1
"
,
Value
:
20
,
EnvVar
:
prefixEnvVar
(
"CONF_DEPTH"
),
EnvVar
:
prefixEnvVar
(
"L1_CONF_DEPTH"
),
}
L2ConfDepthFlag
=
cli
.
Uint64Flag
{
Name
:
"l2-conf-depth"
,
Usage
:
"The number of confirmations after which headers are considered confirmed on L1"
,
Value
:
24
,
EnvVar
:
prefixEnvVar
(
"L2_CONF_DEPTH"
),
}
MaxHeaderBatchSizeFlag
=
cli
.
Uint64Flag
{
Name
:
"max-header-batch-size"
,
...
...
@@ -203,7 +209,8 @@ var optionalFlags = []cli.Flag{
SentryEnableFlag
,
SentryDsnFlag
,
SentryTraceRateFlag
,
ConfDepthFlag
,
L1ConfDepthFlag
,
L2ConfDepthFlag
,
MaxHeaderBatchSizeFlag
,
L1StartBlockNumberFlag
,
RESTHostnameFlag
,
...
...
indexer/indexer.go
View file @
805a9027
...
...
@@ -164,7 +164,7 @@ func NewIndexer(cfg Config) (*Indexer, error) {
ChainID
:
new
(
big
.
Int
)
.
SetUint64
(
cfg
.
ChainID
),
AddressManager
:
addrManager
,
DB
:
db
,
ConfDepth
:
cfg
.
ConfDepth
,
ConfDepth
:
cfg
.
L1
ConfDepth
,
MaxHeaderBatchSize
:
cfg
.
MaxHeaderBatchSize
,
StartBlockNumber
:
cfg
.
L1StartBlockNumber
,
Bedrock
:
cfg
.
Bedrock
,
...
...
@@ -179,7 +179,7 @@ func NewIndexer(cfg Config) (*Indexer, error) {
L2RPC
:
l2RPC
,
L2Client
:
l2Client
,
DB
:
db
,
ConfDepth
:
cfg
.
ConfDepth
,
ConfDepth
:
cfg
.
L2
ConfDepth
,
MaxHeaderBatchSize
:
cfg
.
MaxHeaderBatchSize
,
StartBlockNumber
:
uint64
(
0
),
Bedrock
:
cfg
.
Bedrock
,
...
...
indexer/integration_tests/bedrock_test.go
View file @
805a9027
...
...
@@ -73,7 +73,8 @@ func TestBedrockIndexer(t *testing.T) {
LogLevel
:
"info"
,
LogTerminal
:
true
,
L1StartBlockNumber
:
0
,
ConfDepth
:
1
,
L1ConfDepth
:
1
,
L2ConfDepth
:
1
,
MaxHeaderBatchSize
:
2
,
RESTHostname
:
"127.0.0.1"
,
RESTPort
:
7980
,
...
...
indexer/services/l1/service.go
View file @
805a9027
...
...
@@ -71,6 +71,7 @@ type Service struct {
batchScanner
*
scc
.
StateCommitmentChainFilterer
latestHeader
uint64
headerSelector
*
ConfirmedHeaderSelector
l1Client
*
ethclient
.
Client
metrics
*
metrics
.
Metrics
tokenCache
map
[
common
.
Address
]
*
db
.
Token
...
...
@@ -143,6 +144,7 @@ func NewService(cfg ServiceConfig) (*Service, error) {
ZeroAddress
:
db
.
ETHL1Token
,
},
isBedrock
:
cfg
.
Bedrock
,
l1Client
:
cfg
.
L1Client
,
}
service
.
wg
.
Add
(
1
)
return
service
,
nil
...
...
@@ -202,16 +204,22 @@ func (s *Service) loop() {
}
func
(
s
*
Service
)
Update
(
newHeader
*
types
.
Header
)
error
{
var
lowest
=
db
.
BlockLocator
{
Number
:
s
.
cfg
.
StartBlockNumber
,
}
var
lowest
db
.
BlockLocator
highestConfirmed
,
err
:=
s
.
cfg
.
DB
.
GetHighestL1Block
()
if
err
!=
nil
{
return
err
}
if
highestConfirmed
!=
nil
{
lowest
=
*
highestConfirmed
if
highestConfirmed
==
nil
{
startHeader
,
err
:=
s
.
l1Client
.
HeaderByNumber
(
s
.
ctx
,
new
(
big
.
Int
)
.
SetUint64
(
s
.
cfg
.
StartBlockNumber
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error fetching header by number: %w"
,
err
)
}
highestConfirmed
=
&
db
.
BlockLocator
{
Number
:
s
.
cfg
.
StartBlockNumber
,
Hash
:
startHeader
.
Hash
(),
}
}
lowest
=
*
highestConfirmed
headers
,
err
:=
s
.
headerSelector
.
NewHead
(
s
.
ctx
,
lowest
.
Number
,
newHeader
,
s
.
cfg
.
RawL1Client
)
if
err
!=
nil
{
...
...
@@ -260,22 +268,28 @@ func (s *Service) Update(newHeader *types.Header) error {
bridgeDepositsCh
<-
deposits
}(
bridgeImpl
)
}
go
func
()
{
provenWithdrawals
,
err
:=
s
.
portal
.
GetProvenWithdrawalsByBlockRange
(
s
.
ctx
,
startHeight
,
endHeight
)
if
err
!=
nil
{
errCh
<-
err
return
}
provenWithdrawalsCh
<-
provenWithdrawals
}()
go
func
()
{
finalizedWithdrawals
,
err
:=
s
.
portal
.
GetFinalizedWithdrawalsByBlockRange
(
s
.
ctx
,
startHeight
,
endHeight
)
if
err
!=
nil
{
errCh
<-
err
return
}
finalizedWithdrawalsCh
<-
finalizedWithdrawals
}()
if
s
.
isBedrock
{
go
func
()
{
provenWithdrawals
,
err
:=
s
.
portal
.
GetProvenWithdrawalsByBlockRange
(
s
.
ctx
,
startHeight
,
endHeight
)
if
err
!=
nil
{
errCh
<-
err
return
}
provenWithdrawalsCh
<-
provenWithdrawals
}()
go
func
()
{
finalizedWithdrawals
,
err
:=
s
.
portal
.
GetFinalizedWithdrawalsByBlockRange
(
s
.
ctx
,
startHeight
,
endHeight
)
if
err
!=
nil
{
errCh
<-
err
return
}
finalizedWithdrawalsCh
<-
finalizedWithdrawals
}()
}
else
{
provenWithdrawalsCh
<-
make
(
bridge
.
ProvenWithdrawalsMap
)
finalizedWithdrawalsCh
<-
make
(
bridge
.
FinalizedWithdrawalsMap
)
}
var
receives
int
for
{
...
...
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