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
36a43683
Commit
36a43683
authored
Jan 07, 2022
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review updates
parent
6f566a47
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
25 deletions
+33
-25
driver.go
go/batch-submitter/drivers/proposer/driver.go
+7
-7
driver.go
go/batch-submitter/drivers/sequencer/driver.go
+5
-6
metrics.go
go/batch-submitter/metrics/metrics.go
+4
-4
service.go
go/batch-submitter/service.go
+17
-8
No files found.
go/batch-submitter/drivers/proposer/driver.go
View file @
36a43683
...
@@ -131,27 +131,27 @@ func (d *Driver) SubmitBatchTx(
...
@@ -131,27 +131,27 @@ func (d *Driver) SubmitBatchTx(
batchTxBuildStart
:=
time
.
Now
()
batchTxBuildStart
:=
time
.
Now
()
var
(
var
(
stateRoots
[][
32
]
byte
stateRoots
[][
stateRootSize
]
byte
totalStateRootSize
uint64
totalStateRootSize
uint64
)
)
for
i
:=
new
(
big
.
Int
)
.
Set
(
start
);
i
.
Cmp
(
end
)
<
0
;
i
.
Add
(
i
,
bigOne
)
{
for
i
:=
new
(
big
.
Int
)
.
Set
(
start
);
i
.
Cmp
(
end
)
<
0
;
i
.
Add
(
i
,
bigOne
)
{
// Consume state roots until reach our maximum tx size.
if
totalStateRootSize
+
stateRootSize
>
d
.
cfg
.
MaxTxSize
{
break
}
block
,
err
:=
d
.
cfg
.
L2Client
.
BlockByNumber
(
ctx
,
i
)
block
,
err
:=
d
.
cfg
.
L2Client
.
BlockByNumber
(
ctx
,
i
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// Consume state roots until reach our maximum tx size.
if
totalStateRootSize
+
stateRootSize
>
d
.
cfg
.
MaxTxSize
{
break
}
totalStateRootSize
+=
stateRootSize
totalStateRootSize
+=
stateRootSize
stateRoots
=
append
(
stateRoots
,
block
.
Root
())
stateRoots
=
append
(
stateRoots
,
block
.
Root
())
}
}
batchTxBuildTime
:=
float64
(
time
.
Since
(
batchTxBuildStart
)
/
time
.
Millisecond
)
batchTxBuildTime
:=
float64
(
time
.
Since
(
batchTxBuildStart
)
/
time
.
Millisecond
)
d
.
metrics
.
BatchTxBuildTime
.
Set
(
batchTxBuildTime
)
d
.
metrics
.
BatchTxBuildTime
.
Set
(
batchTxBuildTime
)
d
.
metrics
.
Num
Tx
PerBatch
.
Observe
(
float64
(
len
(
stateRoots
)))
d
.
metrics
.
Num
Elements
PerBatch
.
Observe
(
float64
(
len
(
stateRoots
)))
log
.
Info
(
name
+
" batch constructed"
,
"num_state_roots"
,
len
(
stateRoots
))
log
.
Info
(
name
+
" batch constructed"
,
"num_state_roots"
,
len
(
stateRoots
))
...
...
go/batch-submitter/drivers/sequencer/driver.go
View file @
36a43683
...
@@ -193,20 +193,19 @@ func (d *Driver) SubmitBatchTx(
...
@@ -193,20 +193,19 @@ func (d *Driver) SubmitBatchTx(
// Continue pruning until calldata size is less than configured max.
// Continue pruning until calldata size is less than configured max.
if
uint64
(
len
(
batchCallData
))
>
d
.
cfg
.
MaxTxSize
{
if
uint64
(
len
(
batchCallData
))
>
d
.
cfg
.
MaxTxSize
{
newBatchElementsLen
:=
(
len
(
batchElements
)
*
9
)
/
10
oldLen
:=
len
(
batchElements
)
newBatchElementsLen
:=
(
oldLen
*
9
)
/
10
batchElements
=
batchElements
[
:
newBatchElementsLen
]
batchElements
=
batchElements
[
:
newBatchElementsLen
]
log
.
Info
(
"pruned batch"
,
"old_num_txs"
,
oldLen
,
"new_num_txs"
,
newBatchElementsLen
)
continue
continue
}
}
// Record the batch_tx_build_time.
// Record the batch_tx_build_time.
batchTxBuildTime
:=
float64
(
time
.
Since
(
batchTxBuildStart
)
/
time
.
Millisecond
)
batchTxBuildTime
:=
float64
(
time
.
Since
(
batchTxBuildStart
)
/
time
.
Millisecond
)
d
.
metrics
.
BatchTxBuildTime
.
Set
(
batchTxBuildTime
)
d
.
metrics
.
BatchTxBuildTime
.
Set
(
batchTxBuildTime
)
d
.
metrics
.
Num
Tx
PerBatch
.
Observe
(
float64
(
len
(
batchElements
)))
d
.
metrics
.
Num
Elements
PerBatch
.
Observe
(
float64
(
len
(
batchElements
)))
log
.
Info
(
name
+
" batch constructed"
,
"num_txs"
,
len
(
batchElements
),
log
.
Info
(
name
+
" batch constructed"
,
"num_txs"
,
len
(
batchElements
),
"length"
,
len
(
batchCallData
))
batchTxBuildTime
:=
float64
(
time
.
Since
(
batchTxBuildStart
)
/
time
.
Millisecond
)
d
.
metrics
.
BatchTxBuildTime
.
Set
(
batchTxBuildTime
)
"length"
,
len
(
batchCallData
))
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
d
.
cfg
.
PrivKey
,
d
.
cfg
.
ChainID
,
d
.
cfg
.
PrivKey
,
d
.
cfg
.
ChainID
,
...
...
go/batch-submitter/metrics/metrics.go
View file @
36a43683
...
@@ -12,9 +12,9 @@ type Metrics struct {
...
@@ -12,9 +12,9 @@ type Metrics struct {
// BatchSizeInBytes tracks the size of batch submission transactions.
// BatchSizeInBytes tracks the size of batch submission transactions.
BatchSizeInBytes
prometheus
.
Histogram
BatchSizeInBytes
prometheus
.
Histogram
// Num
Tx
PerBatch tracks the number of L2 transactions in each batch
// Num
Elements
PerBatch tracks the number of L2 transactions in each batch
// submission.
// submission.
Num
Tx
PerBatch
prometheus
.
Histogram
Num
Elements
PerBatch
prometheus
.
Histogram
// SubmissionTimestamp tracks the time at which each batch was confirmed.
// SubmissionTimestamp tracks the time at which each batch was confirmed.
SubmissionTimestamp
prometheus
.
Histogram
SubmissionTimestamp
prometheus
.
Histogram
...
@@ -49,8 +49,8 @@ func NewMetrics(subsystem string) *Metrics {
...
@@ -49,8 +49,8 @@ func NewMetrics(subsystem string) *Metrics {
Help
:
"Size of batches in bytes"
,
Help
:
"Size of batches in bytes"
,
Subsystem
:
subsystem
,
Subsystem
:
subsystem
,
}),
}),
Num
Tx
PerBatch
:
promauto
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Num
Elements
PerBatch
:
promauto
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Name
:
"num_
tx
s_per_batch"
,
Name
:
"num_
element
s_per_batch"
,
Help
:
"Number of transaction in each batch"
,
Help
:
"Number of transaction in each batch"
,
Subsystem
:
subsystem
,
Subsystem
:
subsystem
,
}),
}),
...
...
go/batch-submitter/service.go
View file @
36a43683
...
@@ -15,8 +15,8 @@ import (
...
@@ -15,8 +15,8 @@ import (
)
)
var
(
var
(
// weiTo
Gwei is the conversion rate from wei to gwei
.
// weiTo
Eth is the conversion rate from wei to ether
.
weiTo
Gwei
=
new
(
big
.
Float
)
.
SetFloat64
(
1e-18
)
weiTo
Eth
=
new
(
big
.
Float
)
.
SetFloat64
(
1e-18
)
)
)
// Driver is an interface for creating and submitting batch transactions for a
// Driver is an interface for creating and submitting batch transactions for a
...
@@ -112,7 +112,7 @@ func (s *Service) eventLoop() {
...
@@ -112,7 +112,7 @@ func (s *Service) eventLoop() {
log
.
Error
(
name
+
" unable to get current balance"
,
"err"
,
err
)
log
.
Error
(
name
+
" unable to get current balance"
,
"err"
,
err
)
continue
continue
}
}
s
.
metrics
.
ETHBalance
.
Set
(
weiTo
Gwei
64
(
balance
))
s
.
metrics
.
ETHBalance
.
Set
(
weiTo
Eth
64
(
balance
))
// Determine the range of L2 blocks that the batch submitter has not
// Determine the range of L2 blocks that the batch submitter has not
// processed, and needs to take action on.
// processed, and needs to take action on.
...
@@ -158,6 +158,15 @@ func (s *Service) eventLoop() {
...
@@ -158,6 +158,15 @@ func (s *Service) eventLoop() {
return
nil
,
err
return
nil
,
err
}
}
log
.
Info
(
name
+
" submitted batch tx"
,
"start"
,
start
,
"end"
,
end
,
"nonce"
,
nonce
,
"tx_hash"
,
tx
.
Hash
(),
"gasPrice"
,
gasPrice
,
)
s
.
metrics
.
BatchSizeInBytes
.
Observe
(
float64
(
tx
.
Size
()))
s
.
metrics
.
BatchSizeInBytes
.
Observe
(
float64
(
tx
.
Size
()))
return
tx
,
nil
return
tx
,
nil
...
@@ -191,9 +200,9 @@ func (s *Service) eventLoop() {
...
@@ -191,9 +200,9 @@ func (s *Service) eventLoop() {
}
}
}
}
func
weiTo
Gwei
64
(
wei
*
big
.
Int
)
float64
{
func
weiTo
Eth
64
(
wei
*
big
.
Int
)
float64
{
gwei
:=
new
(
big
.
Float
)
.
SetInt
(
wei
)
eth
:=
new
(
big
.
Float
)
.
SetInt
(
wei
)
gwei
.
Mul
(
gwei
,
weiToGwei
)
eth
.
Mul
(
eth
,
weiToEth
)
gwei64
,
_
:=
gwei
.
Float64
()
eth64
,
_
:=
eth
.
Float64
()
return
gwei
64
return
eth
64
}
}
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