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
fb3513c0
Commit
fb3513c0
authored
Mar 15, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batcher config validation
✅
parent
7bdcb0ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
20 deletions
+48
-20
channel_builder.go
op-batcher/batcher/channel_builder.go
+32
-20
config.go
op-batcher/batcher/config.go
+11
-0
driver.go
op-batcher/batcher/driver.go
+5
-0
No files found.
op-batcher/batcher/channel_builder.go
View file @
fb3513c0
...
...
@@ -11,6 +11,27 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)
var
(
ErrChannelTimeoutTooSmall
=
errors
.
New
(
"channel timeout is less than the safety margin"
)
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrMaxDurationReached
=
errors
.
New
(
"max channel duration reached"
)
ErrChannelTimeoutClose
=
errors
.
New
(
"close to channel timeout"
)
ErrSeqWindowClose
=
errors
.
New
(
"close to sequencer window timeout"
)
)
type
ChannelFullError
struct
{
Err
error
}
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
type
ChannelConfig
struct
{
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// L1 origin block itself
...
...
@@ -48,6 +69,17 @@ type ChannelConfig struct {
ApproxComprRatio
float64
}
// Check validates the [ChannelConfig] parameters.
func
(
cc
*
ChannelConfig
)
Check
()
error
{
// The [ChannelTimeout] must be larger than the [SubSafetyMargin].
// Otherwise, new blocks would always be considered timed out.
if
cc
.
ChannelTimeout
<
cc
.
SubSafetyMargin
{
return
ErrChannelTimeoutTooSmall
}
return
nil
}
// InputThreshold calculates the input data threshold in bytes from the given
// parameters.
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
...
...
@@ -371,23 +403,3 @@ func (c *channelBuilder) PushFrame(frame frameData) {
}
c
.
frames
=
append
(
c
.
frames
,
frame
)
}
var
(
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrMaxDurationReached
=
errors
.
New
(
"max channel duration reached"
)
ErrChannelTimeoutClose
=
errors
.
New
(
"close to channel timeout"
)
ErrSeqWindowClose
=
errors
.
New
(
"close to sequencer window timeout"
)
)
type
ChannelFullError
struct
{
Err
error
}
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
op-batcher/batcher/config.go
View file @
fb3513c0
...
...
@@ -35,6 +35,17 @@ type Config struct {
Channel
ChannelConfig
}
// Check ensures that the [Config] is valid.
func
(
c
*
Config
)
Check
()
error
{
if
err
:=
c
.
Rollup
.
Check
();
err
!=
nil
{
return
err
}
if
err
:=
c
.
Channel
.
Check
();
err
!=
nil
{
return
err
}
return
nil
}
type
CLIConfig
struct
{
/* Required Params */
...
...
op-batcher/batcher/driver.go
View file @
fb3513c0
...
...
@@ -99,6 +99,11 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*BatchSubmitte
},
}
// Validate the batcher config
if
err
:=
batcherCfg
.
Check
();
err
!=
nil
{
return
nil
,
err
}
return
NewBatchSubmitter
(
ctx
,
batcherCfg
,
l
)
}
...
...
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