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
727b0582
Unverified
Commit
727b0582
authored
Mar 16, 2022
by
Conner Fromknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: enforce min/max tx size contraints on legacy encoding
parent
467fa165
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
11 deletions
+34
-11
stale-ladybugs-smell.md
.changeset/stale-ladybugs-smell.md
+5
-0
driver.go
go/batch-submitter/drivers/sequencer/driver.go
+29
-11
No files found.
.changeset/stale-ladybugs-smell.md
0 → 100644
View file @
727b0582
---
'
@eth-optimism/batch-submitter-service'
:
patch
---
Enforce min/max tx size on plaintext batch encoding
go/batch-submitter/drivers/sequencer/driver.go
View file @
727b0582
...
@@ -205,33 +205,51 @@ func (d *Driver) CraftBatchTx(
...
@@ -205,33 +205,51 @@ func (d *Driver) CraftBatchTx(
return
nil
,
err
return
nil
,
err
}
}
batchArguments
,
err
:=
batchParams
.
Serialize
(
d
.
cfg
.
BatchType
)
// Use plaintext encoding to enforce size constraints.
plaintextBatchArguments
,
err
:=
batchParams
.
Serialize
(
BatchTypeLegacy
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
appendSequencerBatchID
:=
d
.
ctcABI
.
Methods
[
appendSequencerBatchMethodName
]
.
ID
appendSequencerBatchID
:=
d
.
ctcABI
.
Methods
[
appendSequencerBatchMethodName
]
.
ID
batchCallData
:=
append
(
appendSequencerBatchID
,
b
atchArguments
...
)
plaintextCalldata
:=
append
(
appendSequencerBatchID
,
plaintextB
atchArguments
...
)
// Continue pruning until calldata size is less than configured max.
// Continue pruning until plaintext calldata size is less than
calldataSize
:=
uint64
(
len
(
batchCallData
))
// configured max.
if
calldataSize
>
d
.
cfg
.
MaxTxSize
{
plaintextCalldataSize
:=
uint64
(
len
(
plaintextCalldata
))
if
plaintextCalldataSize
>
d
.
cfg
.
MaxTxSize
{
oldLen
:=
len
(
batchElements
)
oldLen
:=
len
(
batchElements
)
newBatchElementsLen
:=
(
oldLen
*
9
)
/
10
newBatchElementsLen
:=
(
oldLen
*
9
)
/
10
batchElements
=
batchElements
[
:
newBatchElementsLen
]
batchElements
=
batchElements
[
:
newBatchElementsLen
]
log
.
Info
(
name
+
" pruned batch"
,
"old_num_txs"
,
oldLen
,
"new_num_txs"
,
newBatchElementsLen
)
log
.
Info
(
name
+
" pruned batch"
,
"plaintext_size"
,
plaintextCalldataSize
,
"max_tx_size"
,
d
.
cfg
.
MaxTxSize
,
"old_num_txs"
,
oldLen
,
"new_num_txs"
,
newBatchElementsLen
)
pruneCount
++
pruneCount
++
continue
continue
}
else
if
c
alldataSize
<
d
.
cfg
.
MinTxSize
{
}
else
if
plaintextC
alldataSize
<
d
.
cfg
.
MinTxSize
{
log
.
Info
(
name
+
" batch tx size below minimum"
,
log
.
Info
(
name
+
" batch tx size below minimum"
,
"size"
,
calldataSize
,
"min_tx_size"
,
d
.
cfg
.
MinTxSize
)
"plaintext_size"
,
plaintextCalldataSize
,
"min_tx_size"
,
d
.
cfg
.
MinTxSize
,
"num_txs"
,
len
(
batchElements
))
return
nil
,
nil
return
nil
,
nil
}
}
d
.
metrics
.
NumElementsPerBatch
()
.
Observe
(
float64
(
len
(
batchElements
)))
d
.
metrics
.
NumElementsPerBatch
()
.
Observe
(
float64
(
len
(
batchElements
)))
d
.
metrics
.
BatchPruneCount
.
Set
(
float64
(
pruneCount
))
d
.
metrics
.
BatchPruneCount
.
Set
(
float64
(
pruneCount
))
log
.
Info
(
name
+
" batch constructed"
,
"num_txs"
,
len
(
batchElements
),
"length"
,
len
(
batchCallData
))
// Finally, encode the batch using the configured batch type.
var
calldata
=
plaintextCalldata
if
d
.
cfg
.
BatchType
!=
BatchTypeLegacy
{
batchArguments
,
err
:=
batchParams
.
Serialize
(
d
.
cfg
.
BatchType
)
if
err
!=
nil
{
return
nil
,
err
}
calldata
=
append
(
appendSequencerBatchID
,
batchArguments
...
)
}
log
.
Info
(
name
+
" batch constructed"
,
"num_txs"
,
len
(
batchElements
),
"length"
,
len
(
calldata
))
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
d
.
cfg
.
PrivKey
,
d
.
cfg
.
ChainID
,
d
.
cfg
.
PrivKey
,
d
.
cfg
.
ChainID
,
...
@@ -243,7 +261,7 @@ func (d *Driver) CraftBatchTx(
...
@@ -243,7 +261,7 @@ func (d *Driver) CraftBatchTx(
opts
.
Nonce
=
nonce
opts
.
Nonce
=
nonce
opts
.
NoSend
=
true
opts
.
NoSend
=
true
tx
,
err
:=
d
.
rawCtcContract
.
RawTransact
(
opts
,
batchCallD
ata
)
tx
,
err
:=
d
.
rawCtcContract
.
RawTransact
(
opts
,
calld
ata
)
switch
{
switch
{
case
err
==
nil
:
case
err
==
nil
:
return
tx
,
nil
return
tx
,
nil
...
@@ -258,7 +276,7 @@ func (d *Driver) CraftBatchTx(
...
@@ -258,7 +276,7 @@ func (d *Driver) CraftBatchTx(
log
.
Warn
(
d
.
cfg
.
Name
+
" eth_maxPriorityFeePerGas is unsupported "
+
log
.
Warn
(
d
.
cfg
.
Name
+
" eth_maxPriorityFeePerGas is unsupported "
+
"by current backend, using fallback gasTipCap"
)
"by current backend, using fallback gasTipCap"
)
opts
.
GasTipCap
=
drivers
.
FallbackGasTipCap
opts
.
GasTipCap
=
drivers
.
FallbackGasTipCap
return
d
.
rawCtcContract
.
RawTransact
(
opts
,
batchCallD
ata
)
return
d
.
rawCtcContract
.
RawTransact
(
opts
,
calld
ata
)
default
:
default
:
return
nil
,
err
return
nil
,
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