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
c12366c4
Unverified
Commit
c12366c4
authored
Mar 22, 2023
by
mergify[bot]
Committed by
GitHub
Mar 22, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5120 from ethereum-optimism/fix/allow-deposit-only-legacy-batches
batch-submitter: allow deposit only batches
parents
8a308fc1
b5606001
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
10 deletions
+81
-10
fresh-pots-move.md
.changeset/fresh-pots-move.md
+5
-0
batch_test.go
batch-submitter/drivers/sequencer/batch_test.go
+74
-0
encoding.go
batch-submitter/drivers/sequencer/encoding.go
+0
-8
valid_append_sequencer_batch_params.json
...quencer/testdata/valid_append_sequencer_batch_params.json
+2
-2
No files found.
.changeset/fresh-pots-move.md
0 → 100644
View file @
c12366c4
---
'
@eth-optimism/batch-submitter-service'
:
patch
---
Allow deposit only batches
batch-submitter/drivers/sequencer/batch_test.go
View file @
c12366c4
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum-optimism/optimism/batch-submitter/drivers/sequencer"
"github.com/ethereum-optimism/optimism/batch-submitter/drivers/sequencer"
l2common
"github.com/ethereum-optimism/optimism/l2geth/common"
l2common
"github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum-optimism/optimism/l2geth/core/types"
l2types
"github.com/ethereum-optimism/optimism/l2geth/core/types"
l2types
"github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -47,3 +48,76 @@ func TestBatchElementFromBlock(t *testing.T) {
...
@@ -47,3 +48,76 @@ func TestBatchElementFromBlock(t *testing.T) {
require
.
False
(
t
,
element
.
IsSequencerTx
())
require
.
False
(
t
,
element
.
IsSequencerTx
())
require
.
Nil
(
t
,
element
.
Tx
)
require
.
Nil
(
t
,
element
.
Tx
)
}
}
func
TestGenSequencerParams
(
t
*
testing
.
T
)
{
tx
:=
types
.
NewTransaction
(
0
,
l2common
.
Address
{},
big
.
NewInt
(
0
),
0
,
big
.
NewInt
(
0
),
[]
byte
{})
shouldStartAtElement
:=
uint64
(
1
)
blockOffset
:=
uint64
(
1
)
batches
:=
[]
sequencer
.
BatchElement
{
{
Timestamp
:
1
,
BlockNumber
:
1
},
{
Timestamp
:
1
,
BlockNumber
:
1
,
Tx
:
sequencer
.
NewCachedTx
(
tx
)},
}
params
,
err
:=
sequencer
.
GenSequencerBatchParams
(
shouldStartAtElement
,
blockOffset
,
batches
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
uint64
(
0
),
params
.
ShouldStartAtElement
)
require
.
Equal
(
t
,
uint64
(
len
(
batches
)),
params
.
TotalElementsToAppend
)
require
.
Equal
(
t
,
len
(
batches
),
len
(
params
.
Contexts
))
// There is only 1 sequencer tx
require
.
Equal
(
t
,
1
,
len
(
params
.
Txs
))
// There are 2 contexts
// The first context contains the deposit
context1
:=
params
.
Contexts
[
0
]
require
.
Equal
(
t
,
uint64
(
0
),
context1
.
NumSequencedTxs
)
require
.
Equal
(
t
,
uint64
(
1
),
context1
.
NumSubsequentQueueTxs
)
require
.
Equal
(
t
,
uint64
(
1
),
context1
.
Timestamp
)
require
.
Equal
(
t
,
uint64
(
1
),
context1
.
BlockNumber
)
// The second context contains the sequencer tx
context2
:=
params
.
Contexts
[
1
]
require
.
Equal
(
t
,
uint64
(
1
),
context2
.
NumSequencedTxs
)
require
.
Equal
(
t
,
uint64
(
0
),
context2
.
NumSubsequentQueueTxs
)
require
.
Equal
(
t
,
uint64
(
1
),
context2
.
Timestamp
)
require
.
Equal
(
t
,
uint64
(
1
),
context2
.
BlockNumber
)
}
func
TestGenSequencerParamsOnlyDeposits
(
t
*
testing
.
T
)
{
shouldStartAtElement
:=
uint64
(
1
)
blockOffset
:=
uint64
(
1
)
batches
:=
[]
sequencer
.
BatchElement
{
{
Timestamp
:
1
,
BlockNumber
:
1
},
{
Timestamp
:
1
,
BlockNumber
:
1
},
{
Timestamp
:
2
,
BlockNumber
:
2
},
}
params
,
err
:=
sequencer
.
GenSequencerBatchParams
(
shouldStartAtElement
,
blockOffset
,
batches
)
require
.
NoError
(
t
,
err
)
// The batches will pack deposits into the same context when their
// timestamps and blocknumbers are the same
require
.
Equal
(
t
,
uint64
(
0
),
params
.
ShouldStartAtElement
)
require
.
Equal
(
t
,
uint64
(
len
(
batches
)),
params
.
TotalElementsToAppend
)
// 2 deposits have the same timestamp + blocknumber, they go in the
// same context. 1 deposit has a different timestamp + blocknumber,
// it goes into a different context. Therefore there are 2 contexts
require
.
Equal
(
t
,
2
,
len
(
params
.
Contexts
))
// No sequencer txs
require
.
Equal
(
t
,
0
,
len
(
params
.
Txs
))
// There are 2 contexts
// The first context contains the deposit
context1
:=
params
.
Contexts
[
0
]
require
.
Equal
(
t
,
uint64
(
0
),
context1
.
NumSequencedTxs
)
require
.
Equal
(
t
,
uint64
(
2
),
context1
.
NumSubsequentQueueTxs
)
require
.
Equal
(
t
,
uint64
(
1
),
context1
.
Timestamp
)
require
.
Equal
(
t
,
uint64
(
1
),
context1
.
BlockNumber
)
context2
:=
params
.
Contexts
[
1
]
require
.
Equal
(
t
,
uint64
(
0
),
context2
.
NumSequencedTxs
)
require
.
Equal
(
t
,
uint64
(
1
),
context2
.
NumSubsequentQueueTxs
)
require
.
Equal
(
t
,
uint64
(
2
),
context2
.
Timestamp
)
require
.
Equal
(
t
,
uint64
(
2
),
context2
.
BlockNumber
)
}
batch-submitter/drivers/sequencer/encoding.go
View file @
c12366c4
...
@@ -222,11 +222,6 @@ func (p *AppendSequencerBatchParams) Write(
...
@@ -222,11 +222,6 @@ func (p *AppendSequencerBatchParams) Write(
return
ErrMalformedBatch
return
ErrMalformedBatch
}
}
// There must be transactions if there are contexts
if
len
(
p
.
Txs
)
==
0
&&
len
(
p
.
Contexts
)
!=
0
{
return
ErrMalformedBatch
}
// copy the contexts as to not malleate the struct
// copy the contexts as to not malleate the struct
// when it is a typed batch
// when it is a typed batch
contexts
:=
make
([]
BatchContext
,
0
,
len
(
p
.
Contexts
)
+
1
)
contexts
:=
make
([]
BatchContext
,
0
,
len
(
p
.
Contexts
)
+
1
)
...
@@ -361,9 +356,6 @@ func (p *AppendSequencerBatchParams) Read(r io.Reader) error {
...
@@ -361,9 +356,6 @@ func (p *AppendSequencerBatchParams) Read(r io.Reader) error {
if
len
(
p
.
Contexts
)
==
0
&&
len
(
p
.
Txs
)
!=
0
{
if
len
(
p
.
Contexts
)
==
0
&&
len
(
p
.
Txs
)
!=
0
{
return
ErrMalformedBatch
return
ErrMalformedBatch
}
}
if
len
(
p
.
Txs
)
==
0
&&
len
(
p
.
Contexts
)
!=
0
{
return
ErrMalformedBatch
}
return
closeReader
()
return
closeReader
()
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
err
return
err
...
...
batch-submitter/drivers/sequencer/testdata/valid_append_sequencer_batch_params.json
View file @
c12366c4
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
}
}
],
],
"txs"
:
[],
"txs"
:
[],
"error"
:
tru
e
"error"
:
fals
e
},
},
{
{
"name"
:
"multiple-contexts-no-txs"
,
"name"
:
"multiple-contexts-no-txs"
,
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
}
}
],
],
"txs"
:
[],
"txs"
:
[],
"error"
:
tru
e
"error"
:
fals
e
},
},
{
{
"name"
:
"complex"
,
"name"
:
"complex"
,
...
...
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