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
b20ca5db
Unverified
Commit
b20ca5db
authored
Nov 05, 2024
by
Axel Kingsley
Committed by
GitHub
Nov 06, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle ErrParentTo from PreviousDerivedFrom (#12833)
parent
d627f118
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
db.go
op-supervisor/supervisor/backend/db/fromda/db.go
+2
-1
query.go
op-supervisor/supervisor/backend/db/query.go
+20
-6
error.go
op-supervisor/supervisor/types/error.go
+3
-0
No files found.
op-supervisor/supervisor/backend/db/fromda/db.go
View file @
b20ca5db
...
@@ -189,7 +189,8 @@ func (db *DB) PreviousDerivedFrom(derivedFrom eth.BlockID) (prevDerivedFrom type
...
@@ -189,7 +189,8 @@ func (db *DB) PreviousDerivedFrom(derivedFrom eth.BlockID) (prevDerivedFrom type
if
self
.
derivedFrom
.
Number
==
0
{
if
self
.
derivedFrom
.
Number
==
0
{
return
types
.
BlockSeal
{},
nil
return
types
.
BlockSeal
{},
nil
}
else
{
}
else
{
return
types
.
BlockSeal
{},
fmt
.
Errorf
(
"cannot find previous derived before start of database: %s"
,
derivedFrom
)
return
types
.
BlockSeal
{},
fmt
.
Errorf
(
"cannot find previous derived before start of database: %s (%w)"
,
derivedFrom
,
types
.
ErrPreviousToFirst
)
}
}
}
}
prev
,
err
:=
db
.
readAt
(
selfIndex
-
1
)
prev
,
err
:=
db
.
readAt
(
selfIndex
-
1
)
...
...
op-supervisor/supervisor/backend/db/query.go
View file @
b20ca5db
...
@@ -154,7 +154,11 @@ func (db *ChainsDB) CrossDerivedFromBlockRef(chainID types.ChainID, derived eth.
...
@@ -154,7 +154,11 @@ func (db *ChainsDB) CrossDerivedFromBlockRef(chainID types.ChainID, derived eth.
return
eth
.
BlockRef
{},
err
return
eth
.
BlockRef
{},
err
}
}
parent
,
err
:=
xdb
.
PreviousDerivedFrom
(
res
.
ID
())
parent
,
err
:=
xdb
.
PreviousDerivedFrom
(
res
.
ID
())
if
err
!=
nil
{
// if we are working with the first item in the database, PreviousDerivedFrom will return ErrPreviousToFirst
// in which case we can attach a zero parent to the cross-derived-from block, as the parent block is unknown
if
errors
.
Is
(
err
,
types
.
ErrPreviousToFirst
)
{
return
res
.
ForceWithParent
(
eth
.
BlockID
{}),
nil
}
else
if
err
!=
nil
{
return
eth
.
BlockRef
{},
err
return
eth
.
BlockRef
{},
err
}
}
return
res
.
MustWithParent
(
parent
.
ID
()),
nil
return
res
.
MustWithParent
(
parent
.
ID
()),
nil
...
@@ -266,7 +270,11 @@ func (db *ChainsDB) CandidateCrossSafe(chain types.ChainID) (derivedFromScope, c
...
@@ -266,7 +270,11 @@ func (db *ChainsDB) CandidateCrossSafe(chain types.ChainID) (derivedFromScope, c
candidateRef
:=
candidate
.
MustWithParent
(
crossDerived
.
ID
())
candidateRef
:=
candidate
.
MustWithParent
(
crossDerived
.
ID
())
parentDerivedFrom
,
err
:=
lDB
.
PreviousDerivedFrom
(
candidateFrom
.
ID
())
parentDerivedFrom
,
err
:=
lDB
.
PreviousDerivedFrom
(
candidateFrom
.
ID
())
if
err
!=
nil
{
// if we are working with the first item in the database, PreviousDerivedFrom will return ErrPreviousToFirst
// in which case we can attach a zero parent to the cross-derived-from block, as the parent block is unknown
if
errors
.
Is
(
err
,
types
.
ErrPreviousToFirst
)
{
parentDerivedFrom
=
types
.
BlockSeal
{}
}
else
if
err
!=
nil
{
return
eth
.
BlockRef
{},
eth
.
BlockRef
{},
fmt
.
Errorf
(
"failed to find parent-block of derived-from %s: %w"
,
candidateFrom
,
err
)
return
eth
.
BlockRef
{},
eth
.
BlockRef
{},
fmt
.
Errorf
(
"failed to find parent-block of derived-from %s: %w"
,
candidateFrom
,
err
)
}
}
candidateFromRef
:=
candidateFrom
.
MustWithParent
(
parentDerivedFrom
.
ID
())
candidateFromRef
:=
candidateFrom
.
MustWithParent
(
parentDerivedFrom
.
ID
())
...
@@ -275,12 +283,18 @@ func (db *ChainsDB) CandidateCrossSafe(chain types.ChainID) (derivedFromScope, c
...
@@ -275,12 +283,18 @@ func (db *ChainsDB) CandidateCrossSafe(chain types.ChainID) (derivedFromScope, c
if
candidateFrom
.
Number
>
crossDerivedFrom
.
Number
+
1
{
if
candidateFrom
.
Number
>
crossDerivedFrom
.
Number
+
1
{
// If we are not ready to process the candidate block,
// If we are not ready to process the candidate block,
// then we need to stick to the current scope, so the caller can bump up from there.
// then we need to stick to the current scope, so the caller can bump up from there.
var
crossDerivedFromRef
eth
.
BlockRef
parent
,
err
:=
lDB
.
PreviousDerivedFrom
(
crossDerivedFrom
.
ID
())
parent
,
err
:=
lDB
.
PreviousDerivedFrom
(
crossDerivedFrom
.
ID
())
if
err
!=
nil
{
// if we are working with the first item in the database, PreviousDerivedFrom will return ErrPreviousToFirst
return
eth
.
BlockRef
{},
eth
.
BlockRef
{},
fmt
.
Errorf
(
"failed to find parent-block of cross-derived-from %s: %w"
,
// in which case we can attach a zero parent to the cross-derived-from block, as the parent block is unknown
crossDerivedFrom
,
err
)
if
errors
.
Is
(
err
,
types
.
ErrPreviousToFirst
)
{
crossDerivedFromRef
=
crossDerivedFrom
.
ForceWithParent
(
eth
.
BlockID
{})
}
else
if
err
!=
nil
{
return
eth
.
BlockRef
{},
eth
.
BlockRef
{},
fmt
.
Errorf
(
"failed to find parent-block of cross-derived-from %s: %w"
,
crossDerivedFrom
,
err
)
}
else
{
crossDerivedFromRef
=
crossDerivedFrom
.
MustWithParent
(
parent
.
ID
())
}
}
crossDerivedFromRef
:=
crossDerivedFrom
.
MustWithParent
(
parent
.
ID
())
return
crossDerivedFromRef
,
eth
.
BlockRef
{},
return
crossDerivedFromRef
,
eth
.
BlockRef
{},
fmt
.
Errorf
(
"candidate is from %s, while current scope is %s: %w"
,
fmt
.
Errorf
(
"candidate is from %s, while current scope is %s: %w"
,
candidateFrom
,
crossDerivedFrom
,
types
.
ErrOutOfScope
)
candidateFrom
,
crossDerivedFrom
,
types
.
ErrOutOfScope
)
...
...
op-supervisor/supervisor/types/error.go
View file @
b20ca5db
...
@@ -20,6 +20,9 @@ var (
...
@@ -20,6 +20,9 @@ var (
// ErrOutOfScope is when data is accessed, but access is not allowed, because of a limited scope.
// ErrOutOfScope is when data is accessed, but access is not allowed, because of a limited scope.
// E.g. when limiting scope to L2 blocks derived from a specific subset of the L1 chain.
// E.g. when limiting scope to L2 blocks derived from a specific subset of the L1 chain.
ErrOutOfScope
=
errors
.
New
(
"out of scope"
)
ErrOutOfScope
=
errors
.
New
(
"out of scope"
)
// ErrPreviousToFirst is when you try to get the previous block of the first block
// E.g. when calling PreviousDerivedFrom on the first L1 block in the DB.
ErrPreviousToFirst
=
errors
.
New
(
"cannot get parent of first block in the database"
)
// ErrUnknownChain is when a chain is unknown, not in the dependency set.
// ErrUnknownChain is when a chain is unknown, not in the dependency set.
ErrUnknownChain
=
errors
.
New
(
"unknown chain"
)
ErrUnknownChain
=
errors
.
New
(
"unknown chain"
)
// ErrNoRPCSource happens when a sub-service needs an RPC data source, but is not configured with one.
// ErrNoRPCSource happens when a sub-service needs an RPC data source, but is not configured with one.
...
...
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