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
58593202
Commit
58593202
authored
Jan 25, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Update GarbageChannelOut to new ChannelOut interface
Necessary after rebase.
parent
abd7a807
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
garbage_channel_out.go
op-e2e/actions/garbage_channel_out.go
+15
-14
l2_batcher.go
op-e2e/actions/l2_batcher.go
+1
-1
No files found.
op-e2e/actions/garbage_channel_out.go
View file @
58593202
...
...
@@ -54,11 +54,11 @@ type Writer interface {
type
ChannelOutIface
interface
{
ID
()
derive
.
ChannelID
Reset
()
error
AddBlock
(
block
*
types
.
Block
)
error
AddBlock
(
block
*
types
.
Block
)
(
uint64
,
error
)
ReadyBytes
()
int
Flush
()
error
Close
()
error
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
error
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
(
uint16
,
error
)
}
// Compile-time check for ChannelOutIface interface implementation for the ChannelOut type.
...
...
@@ -135,19 +135,19 @@ func (co *GarbageChannelOut) Reset() error {
// error that it returns is ErrTooManyRLPBytes. If this error
// is returned, the channel should be closed and a new one
// should be made.
func
(
co
*
GarbageChannelOut
)
AddBlock
(
block
*
types
.
Block
)
error
{
func
(
co
*
GarbageChannelOut
)
AddBlock
(
block
*
types
.
Block
)
(
uint64
,
error
)
{
if
co
.
closed
{
return
errors
.
New
(
"already closed"
)
return
0
,
errors
.
New
(
"already closed"
)
}
batch
,
err
:=
blockToBatch
(
block
)
if
err
!=
nil
{
return
err
return
0
,
err
}
// We encode to a temporary buffer to determine the encoded length to
// ensure that the total size of all RLP elements is less than or equal to MAX_RLP_BYTES_PER_CHANNEL
var
buf
bytes
.
Buffer
if
err
:=
rlp
.
Encode
(
&
buf
,
batch
);
err
!=
nil
{
return
err
return
0
,
err
}
if
co
.
cfg
.
malformRLP
{
// Malform the RLP by incrementing the length prefix by 1.
...
...
@@ -157,13 +157,13 @@ func (co *GarbageChannelOut) AddBlock(block *types.Block) error {
buf
.
Write
(
bufBytes
)
}
if
co
.
rlpLength
+
buf
.
Len
()
>
derive
.
MaxRLPBytesPerChannel
{
return
fmt
.
Errorf
(
"could not add %d bytes to channel of %d bytes, max is %d. err: %w"
,
return
0
,
fmt
.
Errorf
(
"could not add %d bytes to channel of %d bytes, max is %d. err: %w"
,
buf
.
Len
(),
co
.
rlpLength
,
derive
.
MaxRLPBytesPerChannel
,
derive
.
ErrTooManyRLPBytes
)
}
co
.
rlpLength
+=
buf
.
Len
()
_
,
err
=
io
.
Copy
(
co
.
compress
,
&
buf
)
return
err
written
,
err
:
=
io
.
Copy
(
co
.
compress
,
&
buf
)
return
uint64
(
written
),
err
}
// ReadyBytes returns the number of bytes that the channel out can immediately output into a frame.
...
...
@@ -192,11 +192,12 @@ func (co *GarbageChannelOut) Close() error {
// Returns io.EOF when the channel is closed & there are no more frames
// Returns nil if there is still more buffered data.
// Returns and error if it ran into an error during processing.
func
(
co
*
GarbageChannelOut
)
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
error
{
func
(
co
*
GarbageChannelOut
)
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
(
uint16
,
error
)
{
f
:=
derive
.
Frame
{
ID
:
co
.
id
,
FrameNumber
:
uint16
(
co
.
frame
),
}
fn
:=
f
.
FrameNumber
// Copy data from the local buffer into the frame data buffer
// Don't go past the maxSize with the fixed frame overhead.
...
...
@@ -214,18 +215,18 @@ func (co *GarbageChannelOut) OutputFrame(w *bytes.Buffer, maxSize uint64) error
f
.
Data
=
make
([]
byte
,
maxDataSize
)
if
_
,
err
:=
io
.
ReadFull
(
&
co
.
buf
,
f
.
Data
);
err
!=
nil
{
return
err
return
fn
,
err
}
if
err
:=
f
.
MarshalBinary
(
w
);
err
!=
nil
{
return
err
return
fn
,
err
}
co
.
frame
+=
1
if
f
.
IsLast
{
return
io
.
EOF
return
fn
,
io
.
EOF
}
else
{
return
nil
return
fn
,
nil
}
}
...
...
op-e2e/actions/l2_batcher.go
View file @
58593202
...
...
@@ -218,7 +218,7 @@ func (s *L2Batcher) ActL2BatchSubmitGarbage(t Testing, kind GarbageKind) {
data
.
WriteByte
(
derive
.
DerivationVersion0
)
// subtract one, to account for the version byte
if
err
:=
s
.
l2ChannelOut
.
OutputFrame
(
data
,
s
.
l2BatcherCfg
.
MaxL1TxSize
-
1
);
err
==
io
.
EOF
{
if
_
,
err
:=
s
.
l2ChannelOut
.
OutputFrame
(
data
,
s
.
l2BatcherCfg
.
MaxL1TxSize
-
1
);
err
==
io
.
EOF
{
s
.
l2ChannelOut
=
nil
s
.
l2Submitting
=
false
}
else
if
err
!=
nil
{
...
...
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