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
ab73a035
Unverified
Commit
ab73a035
authored
May 30, 2023
by
OptimismBot
Committed by
GitHub
May 30, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5825 from ethereum-optimism/feat/op-wheel-shanghai
op-wheel: Fix post-shanghai
parents
68b4a020
aa99cac7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
engine.go
op-wheel/engine/engine.go
+33
-14
No files found.
op-wheel/engine/engine.go
View file @
ab73a035
...
...
@@ -2,6 +2,7 @@ package engine
import
(
"context"
"encoding/json"
"fmt"
"math/big"
"time"
...
...
@@ -18,6 +19,28 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
)
type
PayloadAttributesV2
struct
{
Timestamp
uint64
`json:"timestamp"`
Random
common
.
Hash
`json:"prevRandao"`
SuggestedFeeRecipient
common
.
Address
`json:"suggestedFeeRecipient"`
Withdrawals
[]
*
types
.
Withdrawal
`json:"withdrawals"`
}
func
(
p
PayloadAttributesV2
)
MarshalJSON
()
([]
byte
,
error
)
{
type
PayloadAttributes
struct
{
Timestamp
hexutil
.
Uint64
`json:"timestamp" gencodec:"required"`
Random
common
.
Hash
`json:"prevRandao" gencodec:"required"`
SuggestedFeeRecipient
common
.
Address
`json:"suggestedFeeRecipient" gencodec:"required"`
Withdrawals
[]
*
types
.
Withdrawal
`json:"withdrawals"`
}
var
enc
PayloadAttributes
enc
.
Timestamp
=
hexutil
.
Uint64
(
p
.
Timestamp
)
enc
.
Random
=
p
.
Random
enc
.
SuggestedFeeRecipient
=
p
.
SuggestedFeeRecipient
enc
.
Withdrawals
=
make
([]
*
types
.
Withdrawal
,
0
)
return
json
.
Marshal
(
&
enc
)
}
func
DialClient
(
ctx
context
.
Context
,
endpoint
string
,
jwtSecret
[
32
]
byte
)
(
client
.
RPC
,
error
)
{
auth
:=
node
.
NewJWTAuth
(
jwtSecret
)
...
...
@@ -69,7 +92,7 @@ func headSafeFinalized(ctx context.Context, client client.RPC) (head *types.Bloc
func
insertBlock
(
ctx
context
.
Context
,
client
client
.
RPC
,
payload
*
engine
.
ExecutableData
)
error
{
var
payloadResult
*
engine
.
PayloadStatusV1
if
err
:=
client
.
CallContext
(
ctx
,
&
payloadResult
,
"engine_newPayloadV
1
"
,
payload
);
err
!=
nil
{
if
err
:=
client
.
CallContext
(
ctx
,
&
payloadResult
,
"engine_newPayloadV
2
"
,
payload
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to insert block %d: %w"
,
payload
.
Number
,
err
)
}
if
payloadResult
.
Status
!=
string
(
eth
.
ExecutionValid
)
{
...
...
@@ -80,7 +103,7 @@ func insertBlock(ctx context.Context, client client.RPC, payload *engine.Executa
func
updateForkchoice
(
ctx
context
.
Context
,
client
client
.
RPC
,
head
,
safe
,
finalized
common
.
Hash
)
error
{
var
post
engine
.
ForkChoiceResponse
if
err
:=
client
.
CallContext
(
ctx
,
&
post
,
"engine_forkchoiceUpdatedV
1
"
,
if
err
:=
client
.
CallContext
(
ctx
,
&
post
,
"engine_forkchoiceUpdatedV
2
"
,
engine
.
ForkchoiceStateV1
{
HeadBlockHash
:
head
,
SafeBlockHash
:
safe
,
...
...
@@ -112,21 +135,17 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
}
}
var
pre
engine
.
ForkChoiceResponse
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV
1
"
,
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV
2
"
,
engine
.
ForkchoiceStateV1
{
HeadBlockHash
:
status
.
Head
.
Hash
,
SafeBlockHash
:
status
.
Safe
.
Hash
,
FinalizedBlockHash
:
status
.
Finalized
.
Hash
,
},
engine
.
PayloadAttributes
{
},
PayloadAttributesV2
{
Timestamp
:
timestamp
,
Random
:
settings
.
Random
,
SuggestedFeeRecipient
:
settings
.
FeeRecipient
,
// TODO: maybe use the L2 fields to hack in tx embedding CLI option?
//Transactions: nil,
//NoTxPool: false,
//GasLimit: nil,
});
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set forkchoice w
ith
new block: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to set forkchoice w
hen building
new block: %w"
,
err
)
}
if
pre
.
PayloadStatus
.
Status
!=
string
(
eth
.
ExecutionValid
)
{
return
nil
,
fmt
.
Errorf
(
"pre-block forkchoice update was not valid: %v"
,
pre
.
PayloadStatus
.
ValidationError
)
...
...
@@ -139,19 +158,19 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
case
<-
time
.
After
(
settings
.
BuildTime
)
:
}
var
payload
*
engine
.
Execut
ableData
if
err
:=
client
.
CallContext
(
ctx
,
&
payload
,
"engine_getPayloadV
1
"
,
pre
.
PayloadID
);
err
!=
nil
{
var
payload
*
engine
.
Execut
ionPayloadEnvelope
if
err
:=
client
.
CallContext
(
ctx
,
&
payload
,
"engine_getPayloadV
2
"
,
pre
.
PayloadID
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get payload %v, %d time after instructing engine to build it: %w"
,
pre
.
PayloadID
,
settings
.
BuildTime
,
err
)
}
if
err
:=
insertBlock
(
ctx
,
client
,
payload
);
err
!=
nil
{
if
err
:=
insertBlock
(
ctx
,
client
,
payload
.
ExecutionPayload
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
updateForkchoice
(
ctx
,
client
,
payload
.
BlockHash
,
status
.
Safe
.
Hash
,
status
.
Finalized
.
Hash
);
err
!=
nil
{
if
err
:=
updateForkchoice
(
ctx
,
client
,
payload
.
ExecutionPayload
.
BlockHash
,
status
.
Safe
.
Hash
,
status
.
Finalized
.
Hash
);
err
!=
nil
{
return
nil
,
err
}
return
payload
,
nil
return
payload
.
ExecutionPayload
,
nil
}
func
Auto
(
ctx
context
.
Context
,
metrics
Metricer
,
client
client
.
RPC
,
log
log
.
Logger
,
shutdown
<-
chan
struct
{},
settings
*
BlockBuildingSettings
)
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