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
e03b5073
Commit
e03b5073
authored
Feb 04, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Reorder channel builder types
parent
8d5109e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
66 deletions
+64
-66
channel_builder.go
op-batcher/batcher/channel_builder.go
+64
-66
No files found.
op-batcher/batcher/channel_builder.go
View file @
e03b5073
...
@@ -11,80 +11,60 @@ import (
...
@@ -11,80 +11,60 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
)
)
type
(
type
ChannelConfig
struct
{
// channelBuilder uses a ChannelOut to create a channel with output frame
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// size approximation.
// L1 origin block itself
channelBuilder
struct
{
SeqWindowSize
uint64
cfg
ChannelConfig
// The maximum number of L1 blocks that the inclusion transactions of a
// channel's frames can span.
// L1 block timestamp of combined channel & sequencing window timeout. 0 if
ChannelTimeout
uint64
// no timeout set yet.
// The batcher tx submission safety margin (in #L1-blocks) to subtract from
timeout
uint64
// a channel's timeout and sequencing window, to guarantee safe inclusion of
// a channel on L1.
// marked as full if a) max RLP input bytes, b) max num frames or c) max
SubSafetyMargin
uint64
// allowed frame index (uint16) has been reached
// The maximum byte-size a frame can have.
fullErr
error
MaxFrameSize
uint64
// current channel
// The target number of frames to create per channel. Note that if the
co
*
derive
.
ChannelOut
// realized compression ratio is worse than the approximate, more frames may
// list of blocks in the channel. Saved in case the channel must be rebuilt
// actually be created. This also depends on how close TargetFrameSize is to
blocks
[]
*
types
.
Block
// MaxFrameSize.
// frames data queue, to be send as txs
TargetFrameSize
uint64
frames
[]
taggedData
// The target number of frames to create in this channel. If the realized
}
// compression ratio is worse than approxComprRatio, additional leftover
// frame(s) might get created.
ChannelConfig
struct
{
TargetNumFrames
int
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// Approximated compression ratio to assume. Should be slightly smaller than
// L1 origin block itself
// average from experiments to avoid the chances of creating a small
SeqWindowSize
uint64
// additional leftover frame.
// The maximum number of L1 blocks that the inclusion transactions of a
ApproxComprRatio
float64
// channel's frames can span.
ChannelTimeout
uint64
// The batcher tx submission safety margin (in #L1-blocks) to subtract from
// a channel's timeout and sequencing window, to guarantee safe inclusion of
// a channel on L1.
SubSafetyMargin
uint64
// The maximum byte-size a frame can have.
MaxFrameSize
uint64
// The target number of frames to create per channel. Note that if the
// realized compression ratio is worse than the approximate, more frames may
// actually be created. This also depends on how close TargetFrameSize is to
// MaxFrameSize.
TargetFrameSize
uint64
// The target number of frames to create in this channel. If the realized
// compression ratio is worse than approxComprRatio, additional leftover
// frame(s) might get created.
TargetNumFrames
int
// Approximated compression ratio to assume. Should be slightly smaller than
// average from experiments to avoid the chances of creating a small
// additional leftover frame.
ApproxComprRatio
float64
}
ChannelFullError
struct
{
Err
error
}
)
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
var
(
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrChannelTimedOut
=
errors
.
New
(
"channel timed out"
)
)
// InputThreshold calculates the input data threshold in bytes from the given
// InputThreshold calculates the input data threshold in bytes from the given
// parameters.
// parameters.
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
return
uint64
(
float64
(
c
.
TargetNumFrames
)
*
float64
(
c
.
TargetFrameSize
)
/
c
.
ApproxComprRatio
)
return
uint64
(
float64
(
c
.
TargetNumFrames
)
*
float64
(
c
.
TargetFrameSize
)
/
c
.
ApproxComprRatio
)
}
}
// channelBuilder uses a ChannelOut to create a channel with output frame
// size approximation.
type
channelBuilder
struct
{
cfg
ChannelConfig
// L1 block timestamp of combined channel & sequencing window timeout. 0 if
// no timeout set yet.
timeout
uint64
// marked as full if a) max RLP input bytes, b) max num frames or c) max
// allowed frame index (uint16) has been reached
fullErr
error
// current channel
co
*
derive
.
ChannelOut
// list of blocks in the channel. Saved in case the channel must be rebuilt
blocks
[]
*
types
.
Block
// frames data queue, to be send as txs
frames
[]
taggedData
}
func
newChannelBuilder
(
cfg
ChannelConfig
)
(
*
channelBuilder
,
error
)
{
func
newChannelBuilder
(
cfg
ChannelConfig
)
(
*
channelBuilder
,
error
)
{
co
,
err
:=
derive
.
NewChannelOut
()
co
,
err
:=
derive
.
NewChannelOut
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -336,3 +316,21 @@ func (c *channelBuilder) PushFrame(id txID, frame []byte) {
...
@@ -336,3 +316,21 @@ func (c *channelBuilder) PushFrame(id txID, frame []byte) {
}
}
c
.
frames
=
append
(
c
.
frames
,
taggedData
{
id
:
id
,
data
:
frame
})
c
.
frames
=
append
(
c
.
frames
,
taggedData
{
id
:
id
,
data
:
frame
})
}
}
var
(
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrChannelTimedOut
=
errors
.
New
(
"channel timed out"
)
)
type
ChannelFullError
struct
{
Err
error
}
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
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