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
a5b1b5a5
Commit
a5b1b5a5
authored
Apr 11, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Bundle parent with pending attributes
parent
5bbef930
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
engine_queue.go
op-node/rollup/derive/engine_queue.go
+21
-14
No files found.
op-node/rollup/derive/engine_queue.go
View file @
a5b1b5a5
...
@@ -17,6 +17,11 @@ import (
...
@@ -17,6 +17,11 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
)
)
type
attributesWithParent
struct
{
attributes
*
eth
.
PayloadAttributes
parent
eth
.
L2BlockRef
}
type
NextAttributesProvider
interface
{
type
NextAttributesProvider
interface
{
Origin
()
eth
.
L1BlockRef
Origin
()
eth
.
L1BlockRef
NextAttributes
(
context
.
Context
,
eth
.
L2BlockRef
)
(
*
eth
.
PayloadAttributes
,
error
)
NextAttributes
(
context
.
Context
,
eth
.
L2BlockRef
)
(
*
eth
.
PayloadAttributes
,
error
)
...
@@ -105,9 +110,8 @@ type EngineQueue struct {
...
@@ -105,9 +110,8 @@ type EngineQueue struct {
finalizedL1
eth
.
L1BlockRef
finalizedL1
eth
.
L1BlockRef
// The queued-up attributes
// The queued-up attributes
safeAttributesParent
eth
.
L2BlockRef
safeAttributes
*
attributesWithParent
safeAttributes
*
eth
.
PayloadAttributes
unsafePayloads
*
PayloadsQueue
// queue of unsafe payloads, ordered by ascending block number, may have gaps and duplicates
unsafePayloads
*
PayloadsQueue
// queue of unsafe payloads, ordered by ascending block number, may have gaps and duplicates
// Tracks which L2 blocks where last derived from which L1 block. At most finalityLookback large.
// Tracks which L2 blocks where last derived from which L1 block. At most finalityLookback large.
finalityData
[]
FinalityData
finalityData
[]
FinalityData
...
@@ -222,9 +226,11 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
...
@@ -222,9 +226,11 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
err
return
err
}
else
{
}
else
{
eq
.
safeAttributes
=
next
eq
.
safeAttributes
=
&
attributesWithParent
{
eq
.
safeAttributesParent
=
eq
.
safeHead
attributes
:
next
,
eq
.
log
.
Debug
(
"Adding next safe attributes"
,
"safe_head"
,
eq
.
safeHead
,
"next"
,
eq
.
safeAttributes
)
parent
:
eq
.
safeHead
,
}
eq
.
log
.
Debug
(
"Adding next safe attributes"
,
"safe_head"
,
eq
.
safeHead
,
"next"
,
next
)
return
NotEnoughData
return
NotEnoughData
}
}
...
@@ -430,15 +436,17 @@ func (eq *EngineQueue) tryNextSafeAttributes(ctx context.Context) error {
...
@@ -430,15 +436,17 @@ func (eq *EngineQueue) tryNextSafeAttributes(ctx context.Context) error {
return
nil
return
nil
}
}
// validate the safe attributes before processing them. The engine may have completed processing them through other means.
// validate the safe attributes before processing them. The engine may have completed processing them through other means.
if
eq
.
safeHead
!=
eq
.
safeAttributesParent
{
if
eq
.
safeHead
!=
eq
.
safeAttributes
.
parent
{
if
eq
.
safeHead
.
ParentHash
!=
eq
.
safeAttributesParent
.
Hash
{
// TODO: when is this condition true? It appears to be so in tests, but shouldn't be true otherwise.
if
eq
.
safeHead
.
ParentHash
!=
eq
.
safeAttributes
.
parent
.
Hash
{
return
NewResetError
(
fmt
.
Errorf
(
"safe head changed to %s with parent %s, conflicting with queued safe attributes on top of %s"
,
return
NewResetError
(
fmt
.
Errorf
(
"safe head changed to %s with parent %s, conflicting with queued safe attributes on top of %s"
,
eq
.
safeHead
,
eq
.
safeHead
.
ParentID
(),
eq
.
safeAttributes
P
arent
))
eq
.
safeHead
,
eq
.
safeHead
.
ParentID
(),
eq
.
safeAttributes
.
p
arent
))
}
}
eq
.
log
.
Warn
(
"queued safe attributes are stale, safe
-
head progressed"
,
eq
.
log
.
Warn
(
"queued safe attributes are stale, safehead progressed"
,
"safe_head"
,
eq
.
safeHead
,
"safe_head_parent"
,
eq
.
safeHead
.
ParentID
(),
"attributes_parent"
,
eq
.
safeAttributes
P
arent
)
"safe_head"
,
eq
.
safeHead
,
"safe_head_parent"
,
eq
.
safeHead
.
ParentID
(),
"attributes_parent"
,
eq
.
safeAttributes
.
p
arent
)
eq
.
safeAttributes
=
nil
eq
.
safeAttributes
=
nil
return
nil
return
nil
}
}
if
eq
.
safeHead
.
Number
<
eq
.
unsafeHead
.
Number
{
if
eq
.
safeHead
.
Number
<
eq
.
unsafeHead
.
Number
{
return
eq
.
consolidateNextSafeAttributes
(
ctx
)
return
eq
.
consolidateNextSafeAttributes
(
ctx
)
...
@@ -468,7 +476,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error
...
@@ -468,7 +476,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error
}
}
return
NewTemporaryError
(
fmt
.
Errorf
(
"failed to get existing unsafe payload to compare against derived attributes from L1: %w"
,
err
))
return
NewTemporaryError
(
fmt
.
Errorf
(
"failed to get existing unsafe payload to compare against derived attributes from L1: %w"
,
err
))
}
}
if
err
:=
AttributesMatchBlock
(
eq
.
safeAttributes
,
eq
.
safeHead
.
Hash
,
payload
,
eq
.
log
);
err
!=
nil
{
if
err
:=
AttributesMatchBlock
(
eq
.
safeAttributes
.
attributes
,
eq
.
safeHead
.
Hash
,
payload
,
eq
.
log
);
err
!=
nil
{
eq
.
log
.
Warn
(
"L2 reorg: existing unsafe block does not match derived attributes from L1"
,
"err"
,
err
,
"unsafe"
,
eq
.
unsafeHead
,
"safe"
,
eq
.
safeHead
)
eq
.
log
.
Warn
(
"L2 reorg: existing unsafe block does not match derived attributes from L1"
,
"err"
,
err
,
"unsafe"
,
eq
.
unsafeHead
,
"safe"
,
eq
.
safeHead
)
// geth cannot wind back a chain without reorging to a new, previously non-canonical, block
// geth cannot wind back a chain without reorging to a new, previously non-canonical, block
return
eq
.
forceNextSafeAttributes
(
ctx
)
return
eq
.
forceNextSafeAttributes
(
ctx
)
...
@@ -493,7 +501,7 @@ func (eq *EngineQueue) forceNextSafeAttributes(ctx context.Context) error {
...
@@ -493,7 +501,7 @@ func (eq *EngineQueue) forceNextSafeAttributes(ctx context.Context) error {
if
eq
.
safeAttributes
==
nil
{
if
eq
.
safeAttributes
==
nil
{
return
nil
return
nil
}
}
attrs
:=
eq
.
safeAttributes
attrs
:=
eq
.
safeAttributes
.
attributes
errType
,
err
:=
eq
.
StartPayload
(
ctx
,
eq
.
safeHead
,
attrs
,
true
)
errType
,
err
:=
eq
.
StartPayload
(
ctx
,
eq
.
safeHead
,
attrs
,
true
)
if
err
==
nil
{
if
err
==
nil
{
_
,
errType
,
err
=
eq
.
ConfirmPayload
(
ctx
)
_
,
errType
,
err
=
eq
.
ConfirmPayload
(
ctx
)
...
@@ -664,7 +672,6 @@ func (eq *EngineQueue) Reset(ctx context.Context, _ eth.L1BlockRef, _ eth.System
...
@@ -664,7 +672,6 @@ func (eq *EngineQueue) Reset(ctx context.Context, _ eth.L1BlockRef, _ eth.System
eq
.
log
.
Debug
(
"Reset engine queue"
,
"safeHead"
,
safe
,
"unsafe"
,
unsafe
,
"safe_timestamp"
,
safe
.
Time
,
"unsafe_timestamp"
,
unsafe
.
Time
,
"l1Origin"
,
l1Origin
)
eq
.
log
.
Debug
(
"Reset engine queue"
,
"safeHead"
,
safe
,
"unsafe"
,
unsafe
,
"safe_timestamp"
,
safe
.
Time
,
"unsafe_timestamp"
,
unsafe
.
Time
,
"l1Origin"
,
l1Origin
)
eq
.
unsafeHead
=
unsafe
eq
.
unsafeHead
=
unsafe
eq
.
safeHead
=
safe
eq
.
safeHead
=
safe
eq
.
safeAttributesParent
=
eth
.
L2BlockRef
{}
eq
.
safeAttributes
=
nil
eq
.
safeAttributes
=
nil
eq
.
finalized
=
finalized
eq
.
finalized
=
finalized
eq
.
resetBuildingState
()
eq
.
resetBuildingState
()
...
...
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