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
29e19fe4
Unverified
Commit
29e19fe4
authored
May 11, 2022
by
Matthew Slipper
Committed by
GitHub
May 11, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2558 from ethereum-optimism/develop
Develop -> Master
parents
52cbb56a
b2aa08e0
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
40 deletions
+77
-40
smart-readers-remember.md
.changeset/smart-readers-remember.md
+5
-0
sweet-trains-hunt.md
.changeset/sweet-trains-hunt.md
+5
-0
batch_submitter.go
batch-submitter/batch_submitter.go
+11
-10
config.go
batch-submitter/config.go
+5
-0
driver.go
batch-submitter/drivers/sequencer/driver.go
+19
-28
flags.go
batch-submitter/flags/flags.go
+8
-0
batch-submitter.env
ops/envs/batch-submitter.env
+1
-0
l2-provider.ts
packages/sdk/src/l2-provider.ts
+23
-2
No files found.
.changeset/smart-readers-remember.md
0 → 100644
View file @
29e19fe4
---
'
@eth-optimism/sdk'
:
patch
---
Fixes a bug in the SDK which would cause the SDK to throw if no tx nonce is provided
.changeset/sweet-trains-hunt.md
0 → 100644
View file @
29e19fe4
---
'
@eth-optimism/batch-submitter-service'
:
patch
---
Add MAX_PLAINTEXT_BATCH_SIZE parameter to max out compression
batch-submitter/batch_submitter.go
View file @
29e19fe4
...
@@ -127,6 +127,7 @@ func Main(gitVersion string) func(ctx *cli.Context) error {
...
@@ -127,6 +127,7 @@ func Main(gitVersion string) func(ctx *cli.Context) error {
BlockOffset
:
cfg
.
BlockOffset
,
BlockOffset
:
cfg
.
BlockOffset
,
MinTxSize
:
cfg
.
MinL1TxSize
,
MinTxSize
:
cfg
.
MinL1TxSize
,
MaxTxSize
:
cfg
.
MaxL1TxSize
,
MaxTxSize
:
cfg
.
MaxL1TxSize
,
MaxPlaintextBatchSize
:
cfg
.
MaxPlaintextBatchSize
,
CTCAddr
:
ctcAddress
,
CTCAddr
:
ctcAddress
,
ChainID
:
chainID
,
ChainID
:
chainID
,
PrivKey
:
sequencerPrivKey
,
PrivKey
:
sequencerPrivKey
,
...
...
batch-submitter/config.go
View file @
29e19fe4
...
@@ -74,6 +74,10 @@ type Config struct {
...
@@ -74,6 +74,10 @@ type Config struct {
// by the batch submitter.
// by the batch submitter.
MaxL1TxSize
uint64
MaxL1TxSize
uint64
// MaxPlaintextL1TxSize is the maximum size in bytes of the plaintext tx
// data encoded in batches.
MaxPlaintextBatchSize
uint64
// MinStateRootElements is the minimum number of state root elements that
// MinStateRootElements is the minimum number of state root elements that
// can be submitted in single proposer batch.
// can be submitted in single proposer batch.
MinStateRootElements
uint64
MinStateRootElements
uint64
...
@@ -203,6 +207,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
...
@@ -203,6 +207,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
SCCAddress
:
ctx
.
GlobalString
(
flags
.
SCCAddressFlag
.
Name
),
SCCAddress
:
ctx
.
GlobalString
(
flags
.
SCCAddressFlag
.
Name
),
MinL1TxSize
:
ctx
.
GlobalUint64
(
flags
.
MinL1TxSizeFlag
.
Name
),
MinL1TxSize
:
ctx
.
GlobalUint64
(
flags
.
MinL1TxSizeFlag
.
Name
),
MaxL1TxSize
:
ctx
.
GlobalUint64
(
flags
.
MaxL1TxSizeFlag
.
Name
),
MaxL1TxSize
:
ctx
.
GlobalUint64
(
flags
.
MaxL1TxSizeFlag
.
Name
),
MaxPlaintextBatchSize
:
ctx
.
GlobalUint64
(
flags
.
MaxPlaintextBatchSizeFlag
.
Name
),
MinStateRootElements
:
ctx
.
GlobalUint64
(
flags
.
MinStateRootElementsFlag
.
Name
),
MinStateRootElements
:
ctx
.
GlobalUint64
(
flags
.
MinStateRootElementsFlag
.
Name
),
MaxStateRootElements
:
ctx
.
GlobalUint64
(
flags
.
MinStateRootElementsFlag
.
Name
),
MaxStateRootElements
:
ctx
.
GlobalUint64
(
flags
.
MinStateRootElementsFlag
.
Name
),
MaxBatchSubmissionTime
:
ctx
.
GlobalDuration
(
flags
.
MaxBatchSubmissionTimeFlag
.
Name
),
MaxBatchSubmissionTime
:
ctx
.
GlobalDuration
(
flags
.
MaxBatchSubmissionTimeFlag
.
Name
),
...
...
batch-submitter/drivers/sequencer/driver.go
View file @
29e19fe4
...
@@ -35,6 +35,7 @@ type Config struct {
...
@@ -35,6 +35,7 @@ type Config struct {
BlockOffset
uint64
BlockOffset
uint64
MinTxSize
uint64
MinTxSize
uint64
MaxTxSize
uint64
MaxTxSize
uint64
MaxPlaintextBatchSize
uint64
CTCAddr
common
.
Address
CTCAddr
common
.
Address
ChainID
*
big
.
Int
ChainID
*
big
.
Int
PrivKey
*
ecdsa
.
PrivateKey
PrivKey
*
ecdsa
.
PrivateKey
...
@@ -187,7 +188,7 @@ func (d *Driver) CraftBatchTx(
...
@@ -187,7 +188,7 @@ func (d *Driver) CraftBatchTx(
// Below this set will be further whittled until the raw call data
// Below this set will be further whittled until the raw call data
// size also adheres to this constraint.
// size also adheres to this constraint.
txLen
:=
batchElement
.
Tx
.
Size
()
txLen
:=
batchElement
.
Tx
.
Size
()
if
totalTxSize
+
uint64
(
TxLenSize
+
txLen
)
>
d
.
cfg
.
Max
Tx
Size
{
if
totalTxSize
+
uint64
(
TxLenSize
+
txLen
)
>
d
.
cfg
.
Max
PlaintextBatch
Size
{
// Adding this transaction causes the batch to be too large, but
// Adding this transaction causes the batch to be too large, but
// we also record if the batch size without the transaction
// we also record if the batch size without the transaction
// fails to meet our minimum size constraint. This is used below
// fails to meet our minimum size constraint. This is used below
...
@@ -212,24 +213,24 @@ func (d *Driver) CraftBatchTx(
...
@@ -212,24 +213,24 @@ func (d *Driver) CraftBatchTx(
return
nil
,
err
return
nil
,
err
}
}
//
Use plaintext encoding to enforce size constraints
.
//
Encode the batch arguments using the configured encoding type
.
plaintextBatchArguments
,
err
:=
batchParams
.
Serialize
(
BatchTypeLegacy
)
batchArguments
,
err
:=
batchParams
.
Serialize
(
d
.
cfg
.
BatchType
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
appendSequencerBatchID
:=
d
.
ctcABI
.
Methods
[
appendSequencerBatchMethodName
]
.
ID
appendSequencerBatchID
:=
d
.
ctcABI
.
Methods
[
appendSequencerBatchMethodName
]
.
ID
plaintextCalldata
:=
append
(
appendSequencerBatchID
,
plaintextB
atchArguments
...
)
calldata
:=
append
(
appendSequencerBatchID
,
b
atchArguments
...
)
log
.
Info
(
name
+
" testing batch size"
,
log
.
Info
(
name
+
" testing batch size"
,
"
plaintext_size"
,
len
(
plaintextC
alldata
),
"
calldata_size"
,
len
(
c
alldata
),
"min_tx_size"
,
d
.
cfg
.
MinTxSize
,
"min_tx_size"
,
d
.
cfg
.
MinTxSize
,
"max_tx_size"
,
d
.
cfg
.
MaxTxSize
)
"max_tx_size"
,
d
.
cfg
.
MaxTxSize
)
// Continue pruning until plaintext calldata size is less than
// Continue pruning until plaintext calldata size is less than
// configured max.
// configured max.
plaintextCalldataSize
:=
uint64
(
len
(
plaintextC
alldata
))
calldataSize
:=
uint64
(
len
(
c
alldata
))
if
plaintextC
alldataSize
>
d
.
cfg
.
MaxTxSize
{
if
c
alldataSize
>
d
.
cfg
.
MaxTxSize
{
oldLen
:=
len
(
batchElements
)
oldLen
:=
len
(
batchElements
)
newBatchElementsLen
:=
(
oldLen
*
9
)
/
10
newBatchElementsLen
:=
(
oldLen
*
9
)
/
10
batchElements
=
batchElements
[
:
newBatchElementsLen
]
batchElements
=
batchElements
[
:
newBatchElementsLen
]
...
@@ -259,7 +260,7 @@ func (d *Driver) CraftBatchTx(
...
@@ -259,7 +260,7 @@ func (d *Driver) CraftBatchTx(
// becomes too small as a result. This is avoided by only applying
// becomes too small as a result. This is avoided by only applying
// the min size check when the pruneCount is zero.
// the min size check when the pruneCount is zero.
ignoreMinTxSize
:=
pruneCount
>
0
||
hasLargeNextTx
ignoreMinTxSize
:=
pruneCount
>
0
||
hasLargeNextTx
if
!
ignoreMinTxSize
&&
plaintextC
alldataSize
<
d
.
cfg
.
MinTxSize
{
if
!
ignoreMinTxSize
&&
c
alldataSize
<
d
.
cfg
.
MinTxSize
{
log
.
Info
(
name
+
" batch tx size below minimum"
,
log
.
Info
(
name
+
" batch tx size below minimum"
,
"num_txs"
,
len
(
batchElements
))
"num_txs"
,
len
(
batchElements
))
return
nil
,
nil
return
nil
,
nil
...
@@ -268,16 +269,6 @@ func (d *Driver) CraftBatchTx(
...
@@ -268,16 +269,6 @@ func (d *Driver) CraftBatchTx(
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
))
// 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"
,
log
.
Info
(
name
+
" batch constructed"
,
"num_txs"
,
len
(
batchElements
),
"num_txs"
,
len
(
batchElements
),
"final_size"
,
len
(
calldata
),
"final_size"
,
len
(
calldata
),
...
...
batch-submitter/flags/flags.go
View file @
29e19fe4
...
@@ -66,6 +66,13 @@ var (
...
@@ -66,6 +66,13 @@ var (
Required
:
true
,
Required
:
true
,
EnvVar
:
prefixEnvVar
(
"MAX_L1_TX_SIZE"
),
EnvVar
:
prefixEnvVar
(
"MAX_L1_TX_SIZE"
),
}
}
MaxPlaintextBatchSizeFlag
=
cli
.
Uint64Flag
{
Name
:
"max-plaintext-batch-size"
,
Usage
:
"Maximum size in bytes of of the plaintext tx data "
+
"encoded in batches"
,
Required
:
true
,
EnvVar
:
prefixEnvVar
(
"MAX_PLAINTEXT_BATCH_SIZE"
),
}
MinStateRootElementsFlag
=
cli
.
Uint64Flag
{
MinStateRootElementsFlag
=
cli
.
Uint64Flag
{
Name
:
"min-state-root-elements"
,
Name
:
"min-state-root-elements"
,
Usage
:
"Minimum number of elements required to submit a state "
+
Usage
:
"Minimum number of elements required to submit a state "
+
...
@@ -254,6 +261,7 @@ var requiredFlags = []cli.Flag{
...
@@ -254,6 +261,7 @@ var requiredFlags = []cli.Flag{
SCCAddressFlag
,
SCCAddressFlag
,
MinL1TxSizeFlag
,
MinL1TxSizeFlag
,
MaxL1TxSizeFlag
,
MaxL1TxSizeFlag
,
MaxPlaintextBatchSizeFlag
,
MinStateRootElementsFlag
,
MinStateRootElementsFlag
,
MaxStateRootElementsFlag
,
MaxStateRootElementsFlag
,
MaxBatchSubmissionTimeFlag
,
MaxBatchSubmissionTimeFlag
,
...
...
ops/envs/batch-submitter.env
View file @
29e19fe4
...
@@ -6,6 +6,7 @@ BATCH_SUBMITTER_LOG_LEVEL=debug
...
@@ -6,6 +6,7 @@ BATCH_SUBMITTER_LOG_LEVEL=debug
BATCH_SUBMITTER_LOG_TERMINAL=true
BATCH_SUBMITTER_LOG_TERMINAL=true
BATCH_SUBMITTER_MIN_L1_TX_SIZE=32
BATCH_SUBMITTER_MIN_L1_TX_SIZE=32
BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000
BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000
BATCH_SUBMITTER_MAX_PLAINTEXT_BATCH_SIZE=120000
BATCH_SUBMITTER_MIN_STATE_ROOT_ELEMENTS=1
BATCH_SUBMITTER_MIN_STATE_ROOT_ELEMENTS=1
BATCH_SUBMITTER_MAX_STATE_ROOT_ELEMENTS=3000
BATCH_SUBMITTER_MAX_STATE_ROOT_ELEMENTS=3000
BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0
BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0
...
...
packages/sdk/src/l2-provider.ts
View file @
29e19fe4
...
@@ -11,6 +11,27 @@ import { toProvider, toNumber, toBigNumber } from './utils'
...
@@ -11,6 +11,27 @@ import { toProvider, toNumber, toBigNumber } from './utils'
type
ProviderTypeIsWrong
=
any
type
ProviderTypeIsWrong
=
any
/**
* Gets a reasonable nonce for the transaction.
*
* @param provider Provider to get the nonce from.
* @param tx Requested transaction.
* @returns A reasonable nonce for the transaction.
*/
const
getNonceForTx
=
async
(
provider
:
ProviderLike
,
tx
:
TransactionRequest
):
Promise
<
number
>
=>
{
if
(
tx
.
nonce
!==
undefined
)
{
return
toNumber
(
tx
.
nonce
as
NumberLike
)
}
else
if
(
tx
.
from
!==
undefined
)
{
return
toProvider
(
provider
).
getTransactionCount
(
tx
.
from
)
}
else
{
// Large nonce with lots of non-zero bytes
return
0xffffffff
}
}
/**
/**
* Returns a Contract object for the GasPriceOracle.
* Returns a Contract object for the GasPriceOracle.
*
*
...
@@ -57,7 +78,7 @@ export const estimateL1Gas = async (
...
@@ -57,7 +78,7 @@ export const estimateL1Gas = async (
gasPrice
:
tx
.
gasPrice
,
gasPrice
:
tx
.
gasPrice
,
type
:
tx
.
type
,
type
:
tx
.
type
,
gasLimit
:
tx
.
gasLimit
,
gasLimit
:
tx
.
gasLimit
,
nonce
:
toNumber
(
tx
.
nonce
as
NumberLike
),
nonce
:
await
getNonceForTx
(
l2Provider
,
tx
),
})
})
)
)
}
}
...
@@ -81,7 +102,7 @@ export const estimateL1GasCost = async (
...
@@ -81,7 +102,7 @@ export const estimateL1GasCost = async (
gasPrice
:
tx
.
gasPrice
,
gasPrice
:
tx
.
gasPrice
,
type
:
tx
.
type
,
type
:
tx
.
type
,
gasLimit
:
tx
.
gasLimit
,
gasLimit
:
tx
.
gasLimit
,
nonce
:
toNumber
(
tx
.
nonce
as
NumberLike
),
nonce
:
await
getNonceForTx
(
l2Provider
,
tx
),
})
})
)
)
}
}
...
...
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