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
5651672e
Commit
5651672e
authored
Jan 24, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address Mark's feedback
parent
f2292db3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
57 deletions
+54
-57
garbage_channel_out.go
op-e2e/actions/garbage_channel_out.go
+27
-4
l2_batcher.go
op-e2e/actions/l2_batcher.go
+16
-53
channel_out.go
op-node/rollup/derive/channel_out.go
+11
-0
No files found.
op-e2e/actions/garbage_channel_out.go
View file @
5651672e
...
...
@@ -16,8 +16,31 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
var
ErrNotDepositTx
=
errors
.
New
(
"first transaction in block is not a deposit tx"
)
var
ErrTooManyRLPBytes
=
errors
.
New
(
"batch would cause RLP bytes to go over limit"
)
type
GarbageKind
int64
const
(
STRIP_VERSION
GarbageKind
=
iota
RANDOM
TRUNCATE_END
DIRTY_APPEND
INVALID_COMPRESSION
MALFORM_RLP
)
var
GarbageKinds
=
[]
GarbageKind
{
STRIP_VERSION
,
RANDOM
,
TRUNCATE_END
,
DIRTY_APPEND
,
INVALID_COMPRESSION
,
MALFORM_RLP
,
}
// GarbageChannelCfg is the configuration for a `GarbageChannelOut`
type
GarbageChannelCfg
struct
{
useInvalidCompression
bool
malformRLP
bool
}
// WriterApi is the interface shared between `zlib.Writer` and `gzip.Writer`
type
WriterApi
interface
{
...
...
@@ -118,7 +141,7 @@ func (co *GarbageChannelOut) AddBlock(block *types.Block) error {
}
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"
,
buf
.
Len
(),
co
.
rlpLength
,
derive
.
MaxRLPBytesPerChannel
,
ErrTooManyRLPBytes
)
buf
.
Len
(),
co
.
rlpLength
,
derive
.
MaxRLPBytesPerChannel
,
derive
.
ErrTooManyRLPBytes
)
}
co
.
rlpLength
+=
buf
.
Len
()
...
...
@@ -204,7 +227,7 @@ func blockToBatch(block *types.Block) (*derive.BatchData, error) {
}
l1InfoTx
:=
block
.
Transactions
()[
0
]
if
l1InfoTx
.
Type
()
!=
types
.
DepositTxType
{
return
nil
,
ErrNotDepositTx
return
nil
,
derive
.
ErrNotDepositTx
}
l1Info
,
err
:=
derive
.
L1InfoDepositTxData
(
l1InfoTx
.
Data
())
if
err
!=
nil
{
...
...
op-e2e/actions/l2_batcher.go
View file @
5651672e
...
...
@@ -35,16 +35,6 @@ type L1TxAPI interface {
SendTransaction
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
error
}
type
ChannelOutApi
interface
{
ID
()
derive
.
ChannelID
Reset
()
error
AddBlock
(
block
*
types
.
Block
)
error
ReadyBytes
()
int
Flush
()
error
Close
()
error
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
error
}
type
BatcherCfg
struct
{
// Limit the size of txs
MinL1TxSize
uint64
...
...
@@ -71,7 +61,7 @@ type L2Batcher struct {
l1Signer
types
.
Signer
l2ChannelOut
ChannelOutApi
l2ChannelOut
derive
.
ChannelOutApi
l2Submitting
bool
// when the channel out is being submitted, and not safe to write to without resetting
l2BufferedBlock
eth
.
BlockID
l2SubmittedBlock
eth
.
BlockID
...
...
@@ -135,7 +125,7 @@ func (s *L2Batcher) ActL2BatchBuffer(t Testing) {
}
// Create channel if we don't have one yet
if
s
.
l2ChannelOut
==
nil
{
var
ch
ChannelOutApi
var
ch
derive
.
ChannelOutApi
if
s
.
l2BatcherCfg
.
GarbageCfg
!=
nil
{
ch
,
err
=
NewGarbageChannelOut
(
s
.
l2BatcherCfg
.
GarbageCfg
)
}
else
{
...
...
@@ -213,47 +203,6 @@ func (s *L2Batcher) ActL2BatchSubmit(t Testing) {
require
.
NoError
(
t
,
err
,
"need to send tx"
)
}
func
(
s
*
L2Batcher
)
ActBufferAll
(
t
Testing
)
{
stat
,
err
:=
s
.
syncStatusAPI
.
SyncStatus
(
t
.
Ctx
())
require
.
NoError
(
t
,
err
)
for
s
.
l2BufferedBlock
.
Number
<
stat
.
UnsafeL2
.
Number
{
s
.
ActL2BatchBuffer
(
t
)
}
}
func
(
s
*
L2Batcher
)
ActSubmitAll
(
t
Testing
)
{
s
.
ActBufferAll
(
t
)
s
.
ActL2ChannelClose
(
t
)
s
.
ActL2BatchSubmit
(
t
)
}
// TODO: Move this to a better location
type
GarbageKind
int64
const
(
STRIP_VERSION
GarbageKind
=
iota
RANDOM
TRUNCATE_END
DIRTY_APPEND
INVALID_COMPRESSION
MALFORM_RLP
)
var
GarbageKinds
=
[]
GarbageKind
{
STRIP_VERSION
,
RANDOM
,
TRUNCATE_END
,
DIRTY_APPEND
,
INVALID_COMPRESSION
,
MALFORM_RLP
,
}
// Configuration for a garbage channel (`ChannelOut` in the `actions` pkg)
type
GarbageChannelCfg
struct
{
useInvalidCompression
bool
malformRLP
bool
}
// ActL2BatchSubmitGarbage constructs a malformed channel frame and submits it to the
// batch inbox. This *should* cause the batch inbox to reject the blocks
// encoded within the frame, even if the blocks themselves are valid.
...
...
@@ -336,3 +285,17 @@ func (s *L2Batcher) ActL2BatchSubmitGarbage(t Testing, kind GarbageKind) {
err
=
s
.
l1
.
SendTransaction
(
t
.
Ctx
(),
tx
)
require
.
NoError
(
t
,
err
,
"need to send tx"
)
}
func
(
s
*
L2Batcher
)
ActBufferAll
(
t
Testing
)
{
stat
,
err
:=
s
.
syncStatusAPI
.
SyncStatus
(
t
.
Ctx
())
require
.
NoError
(
t
,
err
)
for
s
.
l2BufferedBlock
.
Number
<
stat
.
UnsafeL2
.
Number
{
s
.
ActL2BatchBuffer
(
t
)
}
}
func
(
s
*
L2Batcher
)
ActSubmitAll
(
t
Testing
)
{
s
.
ActBufferAll
(
t
)
s
.
ActL2ChannelClose
(
t
)
s
.
ActL2BatchSubmit
(
t
)
}
op-node/rollup/derive/channel_out.go
View file @
5651672e
...
...
@@ -17,6 +17,17 @@ import (
var
ErrNotDepositTx
=
errors
.
New
(
"first transaction in block is not a deposit tx"
)
var
ErrTooManyRLPBytes
=
errors
.
New
(
"batch would cause RLP bytes to go over limit"
)
// ChannelOutApi is the interface implemented by ChannelOut
type
ChannelOutApi
interface
{
ID
()
ChannelID
Reset
()
error
AddBlock
(
block
*
types
.
Block
)
error
ReadyBytes
()
int
Flush
()
error
Close
()
error
OutputFrame
(
w
*
bytes
.
Buffer
,
maxSize
uint64
)
error
}
type
ChannelOut
struct
{
id
ChannelID
// Frame ID of the next frame to emit. Increment after emitting
...
...
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