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
2707b281
Unverified
Commit
2707b281
authored
Apr 06, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-wheel: add --allow-gaps flag to engine block building commands
parent
6edd9903
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
commands.go
op-wheel/commands.go
+8
-2
engine.go
op-wheel/engine/engine.go
+12
-2
No files found.
op-wheel/commands.go
View file @
2707b281
...
@@ -78,11 +78,17 @@ var (
...
@@ -78,11 +78,17 @@ var (
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"BUILDING_TIME"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"BUILDING_TIME"
),
Value
:
time
.
Second
*
6
,
Value
:
time
.
Second
*
6
,
}
}
AllowGaps
=
cli
.
BoolFlag
{
Name
:
"allow-gaps"
,
Usage
:
"allow gaps in block building, like missed slots on the beacon chain."
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ALLOW_GAPS"
),
}
)
)
func
ParseBuildingArgs
(
ctx
*
cli
.
Context
)
*
engine
.
BlockBuildingSettings
{
func
ParseBuildingArgs
(
ctx
*
cli
.
Context
)
*
engine
.
BlockBuildingSettings
{
return
&
engine
.
BlockBuildingSettings
{
return
&
engine
.
BlockBuildingSettings
{
BlockTime
:
ctx
.
Uint64
(
BlockTimeFlag
.
Name
),
BlockTime
:
ctx
.
Uint64
(
BlockTimeFlag
.
Name
),
AllowGaps
:
ctx
.
Bool
(
AllowGaps
.
Name
),
Random
:
hashFlagValue
(
RandaoFlag
.
Name
,
ctx
),
Random
:
hashFlagValue
(
RandaoFlag
.
Name
,
ctx
),
FeeRecipient
:
addrFlagValue
(
FeeRecipientFlag
.
Name
,
ctx
),
FeeRecipient
:
addrFlagValue
(
FeeRecipientFlag
.
Name
,
ctx
),
BuildTime
:
ctx
.
Duration
(
BuildingTime
.
Name
),
BuildTime
:
ctx
.
Duration
(
BuildingTime
.
Name
),
...
@@ -336,7 +342,7 @@ var (
...
@@ -336,7 +342,7 @@ var (
Usage
:
"build the next block using the Engine API"
,
Usage
:
"build the next block using the Engine API"
,
Flags
:
[]
cli
.
Flag
{
Flags
:
[]
cli
.
Flag
{
EngineEndpoint
,
EngineJWTPath
,
EngineEndpoint
,
EngineJWTPath
,
FeeRecipientFlag
,
RandaoFlag
,
BlockTimeFlag
,
BuildingTime
,
FeeRecipientFlag
,
RandaoFlag
,
BlockTimeFlag
,
BuildingTime
,
AllowGaps
,
},
},
// TODO: maybe support transaction and tx pool engine flags, since we use op-geth?
// TODO: maybe support transaction and tx pool engine flags, since we use op-geth?
// TODO: reorg flag
// TODO: reorg flag
...
@@ -362,7 +368,7 @@ var (
...
@@ -362,7 +368,7 @@ var (
Description
:
"The block time can be changed. The execution engine must be synced to a post-Merge state first."
,
Description
:
"The block time can be changed. The execution engine must be synced to a post-Merge state first."
,
Flags
:
append
(
append
([]
cli
.
Flag
{
Flags
:
append
(
append
([]
cli
.
Flag
{
EngineEndpoint
,
EngineJWTPath
,
EngineEndpoint
,
EngineJWTPath
,
FeeRecipientFlag
,
RandaoFlag
,
BlockTimeFlag
,
BuildingTime
,
FeeRecipientFlag
,
RandaoFlag
,
BlockTimeFlag
,
BuildingTime
,
AllowGaps
,
},
oplog
.
CLIFlags
(
envVarPrefix
)
...
),
opmetrics
.
CLIFlags
(
envVarPrefix
)
...
),
},
oplog
.
CLIFlags
(
envVarPrefix
)
...
),
opmetrics
.
CLIFlags
(
envVarPrefix
)
...
),
Action
:
EngineAction
(
func
(
ctx
*
cli
.
Context
,
client
client
.
RPC
)
error
{
Action
:
EngineAction
(
func
(
ctx
*
cli
.
Context
,
client
client
.
RPC
)
error
{
logCfg
:=
oplog
.
ReadLocalCLIConfig
(
ctx
)
logCfg
:=
oplog
.
ReadLocalCLIConfig
(
ctx
)
...
...
op-wheel/engine/engine.go
View file @
2707b281
...
@@ -95,13 +95,22 @@ func updateForkchoice(ctx context.Context, client client.RPC, head, safe, finali
...
@@ -95,13 +95,22 @@ func updateForkchoice(ctx context.Context, client client.RPC, head, safe, finali
}
}
type
BlockBuildingSettings
struct
{
type
BlockBuildingSettings
struct
{
BlockTime
uint64
BlockTime
uint64
// skip a block; timestamps will still increase in multiples of BlockTime like L1, but there may be gaps.
AllowGaps
bool
Random
common
.
Hash
Random
common
.
Hash
FeeRecipient
common
.
Address
FeeRecipient
common
.
Address
BuildTime
time
.
Duration
BuildTime
time
.
Duration
}
}
func
BuildBlock
(
ctx
context
.
Context
,
client
client
.
RPC
,
status
*
StatusData
,
settings
*
BlockBuildingSettings
)
(
*
engine
.
ExecutableData
,
error
)
{
func
BuildBlock
(
ctx
context
.
Context
,
client
client
.
RPC
,
status
*
StatusData
,
settings
*
BlockBuildingSettings
)
(
*
engine
.
ExecutableData
,
error
)
{
timestamp
:=
status
.
Head
.
Time
+
settings
.
BlockTime
if
settings
.
AllowGaps
{
now
:=
uint64
(
time
.
Now
()
.
Unix
())
if
now
>
timestamp
{
timestamp
=
now
-
((
now
-
timestamp
)
%
settings
.
BlockTime
)
}
}
var
pre
engine
.
ForkChoiceResponse
var
pre
engine
.
ForkChoiceResponse
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV1"
,
if
err
:=
client
.
CallContext
(
ctx
,
&
pre
,
"engine_forkchoiceUpdatedV1"
,
engine
.
ForkchoiceStateV1
{
engine
.
ForkchoiceStateV1
{
...
@@ -109,7 +118,7 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
...
@@ -109,7 +118,7 @@ func BuildBlock(ctx context.Context, client client.RPC, status *StatusData, sett
SafeBlockHash
:
status
.
Safe
.
Hash
,
SafeBlockHash
:
status
.
Safe
.
Hash
,
FinalizedBlockHash
:
status
.
Finalized
.
Hash
,
FinalizedBlockHash
:
status
.
Finalized
.
Hash
,
},
engine
.
PayloadAttributes
{
},
engine
.
PayloadAttributes
{
Timestamp
:
status
.
Head
.
Time
+
settings
.
BlockTime
,
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?
// TODO: maybe use the L2 fields to hack in tx embedding CLI option?
...
@@ -210,6 +219,7 @@ func Auto(ctx context.Context, metrics Metricer, client client.RPC, log log.Logg
...
@@ -210,6 +219,7 @@ func Auto(ctx context.Context, metrics Metricer, client client.RPC, log log.Logg
payload
,
err
:=
BuildBlock
(
ctx
,
client
,
status
,
&
BlockBuildingSettings
{
payload
,
err
:=
BuildBlock
(
ctx
,
client
,
status
,
&
BlockBuildingSettings
{
BlockTime
:
settings
.
BlockTime
,
BlockTime
:
settings
.
BlockTime
,
AllowGaps
:
settings
.
AllowGaps
,
Random
:
settings
.
Random
,
Random
:
settings
.
Random
,
FeeRecipient
:
settings
.
FeeRecipient
,
FeeRecipient
:
settings
.
FeeRecipient
,
BuildTime
:
buildTime
,
BuildTime
:
buildTime
,
...
...
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