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
14612ccd
Unverified
Commit
14612ccd
authored
Mar 15, 2023
by
mergify[bot]
Committed by
GitHub
Mar 15, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5152 from ethereum-optimism/refcell/batcher/config
feat(op-batcher): Batcher Config Validation
parents
1e0e7c04
dcbba84c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
20 deletions
+98
-20
channel_builder.go
op-batcher/batcher/channel_builder.go
+40
-20
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+40
-0
config.go
op-batcher/batcher/config.go
+11
-0
driver.go
op-batcher/batcher/driver.go
+5
-0
system_test.go
op-e2e/system_test.go
+2
-0
No files found.
op-batcher/batcher/channel_builder.go
View file @
14612ccd
...
...
@@ -11,6 +11,28 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)
var
(
ErrInvalidMaxFrameSize
=
errors
.
New
(
"max frame size cannot be zero"
)
ErrInvalidChannelTimeout
=
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 +70,24 @@ 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
ErrInvalidChannelTimeout
}
// If the [MaxFrameSize] is set to 0, the channel builder
// will infinitely loop when trying to create frames in the
// [channelBuilder.OutputFrames] function.
if
cc
.
MaxFrameSize
==
0
{
return
ErrInvalidMaxFrameSize
}
return
nil
}
// InputThreshold calculates the input data threshold in bytes from the given
// parameters.
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
...
...
@@ -371,23 +411,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/channel_builder_test.go
0 → 100644
View file @
14612ccd
package
batcher
import
(
"testing"
"github.com/stretchr/testify/require"
)
// defaultChannelConfig returns a valid, default [ChannelConfig] struct.
func
defaultChannelConfig
()
ChannelConfig
{
return
ChannelConfig
{
SeqWindowSize
:
15
,
ChannelTimeout
:
40
,
MaxChannelDuration
:
1
,
SubSafetyMargin
:
4
,
MaxFrameSize
:
120000
,
TargetFrameSize
:
100000
,
TargetNumFrames
:
1
,
ApproxComprRatio
:
0.4
,
}
}
// TestConfigValidation tests the validation of the [ChannelConfig] struct.
func
TestConfigValidation
(
t
*
testing
.
T
)
{
// Construct a valid config.
validChannelConfig
:=
defaultChannelConfig
()
require
.
NoError
(
t
,
validChannelConfig
.
Check
())
// Set the config to have a zero max frame size.
validChannelConfig
.
MaxFrameSize
=
0
require
.
ErrorIs
(
t
,
validChannelConfig
.
Check
(),
ErrInvalidMaxFrameSize
)
// Reset the config and test the Timeout error.
// NOTE: We should be fuzzing these values with the constraint that
// SubSafetyMargin > ChannelTimeout to ensure validation.
validChannelConfig
=
defaultChannelConfig
()
validChannelConfig
.
ChannelTimeout
=
0
validChannelConfig
.
SubSafetyMargin
=
1
require
.
ErrorIs
(
t
,
validChannelConfig
.
Check
(),
ErrInvalidChannelTimeout
)
}
op-batcher/batcher/config.go
View file @
14612ccd
...
...
@@ -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 @
14612ccd
...
...
@@ -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
)
}
...
...
op-e2e/system_test.go
View file @
14612ccd
...
...
@@ -651,6 +651,8 @@ func TestSystemMockP2P(t *testing.T) {
// TestSystemDenseTopology sets up a dense p2p topology with 3 verifier nodes and 1 sequencer node.
func
TestSystemDenseTopology
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Skipping dense topology test to avoid flakiness. @refcell address in p2p scoring pr."
)
parallel
(
t
)
if
!
verboseGethNodes
{
log
.
Root
()
.
SetHandler
(
log
.
DiscardHandler
())
...
...
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