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
5dc9f18f
Commit
5dc9f18f
authored
May 30, 2023
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-wheel: Fix post-shanghai
parent
db852f6c
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 @
5dc9f18f
...
@@ -2,6 +2,7 @@ package engine
...
@@ -2,6 +2,7 @@ package engine
import
(
import
(
"context"
"context"
"encoding/json"
"fmt"
"fmt"
"math/big"
"math/big"
"time"
"time"
...
@@ -18,6 +19,28 @@ import (
...
@@ -18,6 +19,28 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"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
)
{
func
DialClient
(
ctx
context
.
Context
,
endpoint
string
,
jwtSecret
[
32
]
byte
)
(
client
.
RPC
,
error
)
{
auth
:=
node
.
NewJWTAuth
(
jwtSecret
)
auth
:=
node
.
NewJWTAuth
(
jwtSecret
)
...
@@ -69,7 +92,7 @@ func headSafeFinalized(ctx context.Context, client client.RPC) (head *types.Bloc
...
@@ -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
{
func
insertBlock
(
ctx
context
.
Context
,
client
client
.
RPC
,
payload
*
engine
.
ExecutableData
)
error
{
var
payloadResult
*
engine
.
PayloadStatusV1
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
)
return
fmt
.
Errorf
(
"failed to insert block %d: %w"
,
payload
.
Number
,
err
)
}
}
if
payloadResult
.
Status
!=
string
(
eth
.
ExecutionValid
)
{
if
payloadResult
.
Status
!=
string
(
eth
.
ExecutionValid
)
{
...
@@ -80,7 +103,7 @@ func insertBlock(ctx context.Context, client client.RPC, payload *engine.Executa
...
@@ -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
{
func
updateForkchoice
(
ctx
context
.
Context
,
client
client
.
RPC
,
head
,
safe
,
finalized
common
.
Hash
)
error
{
var
post
engine
.
ForkChoiceResponse
var
post
engine
.
ForkChoiceResponse
if
err
:=
client
.
CallContext
(
ctx
,
&
post
,
"engine_forkchoiceUpdatedV
1
"
,
if
err
:=
client
.
CallContext
(
ctx
,
&
post
,
"engine_forkchoiceUpdatedV
2
"
,
engine
.
ForkchoiceStateV1
{
engine
.
ForkchoiceStateV1
{
HeadBlockHash
:
head
,
HeadBlockHash
:
head
,
SafeBlockHash
:
safe
,
SafeBlockHash
:
safe
,
...
@@ -112,21 +135,17 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
...
@@ -112,21 +135,17 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
}
}
}
}
var
pre
engine
.
ForkChoiceResponse
var
pre
engine
.
ForkChoiceResponse
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV
1
"
,
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV
2
"
,
engine
.
ForkchoiceStateV1
{
engine
.
ForkchoiceStateV1
{
HeadBlockHash
:
status
.
Head
.
Hash
,
HeadBlockHash
:
status
.
Head
.
Hash
,
SafeBlockHash
:
status
.
Safe
.
Hash
,
SafeBlockHash
:
status
.
Safe
.
Hash
,
FinalizedBlockHash
:
status
.
Finalized
.
Hash
,
FinalizedBlockHash
:
status
.
Finalized
.
Hash
,
},
engine
.
PayloadAttributes
{
},
PayloadAttributesV2
{
Timestamp
:
timestamp
,
Timestamp
:
timestamp
,
Random
:
settings
.
Random
,
Random
:
settings
.
Random
,
SuggestedFeeRecipient
:
settings
.
FeeRecipient
,
SuggestedFeeRecipient
:
settings
.
FeeRecipient
,
// TODO: maybe use the L2 fields to hack in tx embedding CLI option?
//Transactions: nil,
//NoTxPool: false,
//GasLimit: nil,
});
err
!=
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
)
{
if
pre
.
PayloadStatus
.
Status
!=
string
(
eth
.
ExecutionValid
)
{
return
nil
,
fmt
.
Errorf
(
"pre-block forkchoice update was not valid: %v"
,
pre
.
PayloadStatus
.
ValidationError
)
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
...
@@ -139,19 +158,19 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
case
<-
time
.
After
(
settings
.
BuildTime
)
:
case
<-
time
.
After
(
settings
.
BuildTime
)
:
}
}
var
payload
*
engine
.
Execut
ableData
var
payload
*
engine
.
Execut
ionPayloadEnvelope
if
err
:=
client
.
CallContext
(
ctx
,
&
payload
,
"engine_getPayloadV
1
"
,
pre
.
PayloadID
);
err
!=
nil
{
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
)
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
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
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
{
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