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
12dbd81b
Unverified
Commit
12dbd81b
authored
May 04, 2021
by
Annie Ke
Committed by
GitHub
May 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat[batch-submitter]: add metrics (#722)
* add ethBalance gauge * add rest of bs metrics * add changeset
parent
ae1ac05d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
23 deletions
+122
-23
moody-pigs-attend.md
.changeset/moody-pigs-attend.md
+5
-0
package.json
packages/batch-submitter/package.json
+3
-2
batch-submitter.ts
...es/batch-submitter/src/batch-submitter/batch-submitter.ts
+52
-2
tx-batch-submitter.ts
...batch-submitter/src/batch-submitter/tx-batch-submitter.ts
+1
-0
yarn.lock
yarn.lock
+61
-19
No files found.
.changeset/moody-pigs-attend.md
0 → 100644
View file @
12dbd81b
---
'
@eth-optimism/batch-submitter'
:
patch
---
add key metrics to batch submitter
packages/batch-submitter/package.json
View file @
12dbd81b
...
@@ -31,16 +31,17 @@
...
@@ -31,16 +31,17 @@
"url"
:
"https://github.com/ethereum-optimism/optimism-monorepo.git"
"url"
:
"https://github.com/ethereum-optimism/optimism-monorepo.git"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@eth-optimism/common-ts"
:
"^0.0.1"
,
"@eth-optimism/contracts"
:
"^0.2.8"
,
"@eth-optimism/contracts"
:
"^0.2.8"
,
"@eth-optimism/core-utils"
:
"^0.3.2"
,
"@eth-optimism/core-utils"
:
"^0.3.2"
,
"@eth-optimism/common-ts"
:
"^0.0.1"
,
"@eth-optimism/ynatm"
:
"^0.2.2"
,
"@eth-optimism/ynatm"
:
"^0.2.2"
,
"@ethersproject/abstract-provider"
:
"^5.0.5"
,
"@ethersproject/abstract-provider"
:
"^5.0.5"
,
"@ethersproject/providers"
:
"^5.0.14"
,
"@ethersproject/providers"
:
"^5.0.14"
,
"bluebird"
:
"^3.7.2"
,
"bluebird"
:
"^3.7.2"
,
"dotenv"
:
"^8.2.0"
,
"dotenv"
:
"^8.2.0"
,
"ethers"
:
"5.0.0"
,
"ethers"
:
"5.0.0"
,
"old-contracts"
:
"npm:@eth-optimism/contracts@^0.0.2-alpha.7"
"old-contracts"
:
"npm:@eth-optimism/contracts@^0.0.2-alpha.7"
,
"prom-client"
:
"^13.1.0"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@eth-optimism/smock"
:
"^1.1.1"
,
"@eth-optimism/smock"
:
"^1.1.1"
,
...
...
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
View file @
12dbd81b
/* External Imports */
/* External Imports */
import
{
Contract
,
Signer
,
utils
,
providers
}
from
'
ethers
'
import
{
Contract
,
Signer
,
utils
,
providers
}
from
'
ethers
'
import
{
TransactionReceipt
}
from
'
@ethersproject/abstract-provider
'
import
{
TransactionReceipt
}
from
'
@ethersproject/abstract-provider
'
import
{
Gauge
,
Histogram
}
from
'
prom-client
'
import
*
as
ynatm
from
'
@eth-optimism/ynatm
'
import
*
as
ynatm
from
'
@eth-optimism/ynatm
'
import
{
RollupInfo
}
from
'
@eth-optimism/core-utils
'
import
{
RollupInfo
}
from
'
@eth-optimism/core-utils
'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
...
@@ -17,12 +18,21 @@ export interface ResubmissionConfig {
...
@@ -17,12 +18,21 @@ export interface ResubmissionConfig {
gasRetryIncrement
:
number
gasRetryIncrement
:
number
}
}
interface
BatchSubmitterMetrics
{
batchSubmitterETHBalance
:
Gauge
<
string
>
batchSizeInBytes
:
Histogram
<
string
>
numTxPerBatch
:
Histogram
<
string
>
submissionTimestamp
:
Histogram
<
string
>
submissionGasUsed
:
Histogram
<
string
>
}
export
abstract
class
BatchSubmitter
{
export
abstract
class
BatchSubmitter
{
protected
rollupInfo
:
RollupInfo
protected
rollupInfo
:
RollupInfo
protected
chainContract
:
Contract
protected
chainContract
:
Contract
protected
l2ChainId
:
number
protected
l2ChainId
:
number
protected
syncing
:
boolean
protected
syncing
:
boolean
protected
lastBatchSubmissionTimestamp
:
number
=
0
protected
lastBatchSubmissionTimestamp
:
number
=
0
protected
metrics
:
BatchSubmitterMetrics
constructor
(
constructor
(
readonly
signer
:
Signer
,
readonly
signer
:
Signer
,
...
@@ -41,8 +51,10 @@ export abstract class BatchSubmitter {
...
@@ -41,8 +51,10 @@ export abstract class BatchSubmitter {
readonly
gasRetryIncrement
:
number
,
readonly
gasRetryIncrement
:
number
,
readonly
gasThresholdInGwei
:
number
,
readonly
gasThresholdInGwei
:
number
,
readonly
logger
:
Logger
,
readonly
logger
:
Logger
,
readonly
metrics
:
Metrics
readonly
defaultMetrics
:
Metrics
)
{}
)
{
this
.
metrics
=
this
.
_registerMetrics
(
defaultMetrics
)
}
public
abstract
_submitBatch
(
public
abstract
_submitBatch
(
startBlock
:
number
,
startBlock
:
number
,
...
@@ -58,6 +70,7 @@ export abstract class BatchSubmitter {
...
@@ -58,6 +70,7 @@ export abstract class BatchSubmitter {
}
}
await
this
.
_updateChainInfo
()
await
this
.
_updateChainInfo
()
await
this
.
_checkBalance
()
await
this
.
_checkBalance
()
this
.
logger
.
info
(
'
Readying to submit next batch...
'
,
{
this
.
logger
.
info
(
'
Readying to submit next batch...
'
,
{
l2ChainId
:
this
.
l2ChainId
,
l2ChainId
:
this
.
l2ChainId
,
batchSubmitterAddress
:
await
this
.
signer
.
getAddress
(),
batchSubmitterAddress
:
await
this
.
signer
.
getAddress
(),
...
@@ -87,6 +100,7 @@ export abstract class BatchSubmitter {
...
@@ -87,6 +100,7 @@ export abstract class BatchSubmitter {
address
,
address
,
ether
,
ether
,
})
})
this
.
metrics
.
batchSubmitterETHBalance
.
set
(
num
)
if
(
num
<
this
.
minBalanceEther
)
{
if
(
num
<
this
.
minBalanceEther
)
{
this
.
logger
.
fatal
(
'
Current balance lower than min safe balance
'
,
{
this
.
logger
.
fatal
(
'
Current balance lower than min safe balance
'
,
{
...
@@ -146,6 +160,7 @@ export abstract class BatchSubmitter {
...
@@ -146,6 +160,7 @@ export abstract class BatchSubmitter {
lastBatchSubmissionTimestamp
:
this
.
lastBatchSubmissionTimestamp
,
lastBatchSubmissionTimestamp
:
this
.
lastBatchSubmissionTimestamp
,
currentTimestamp
,
currentTimestamp
,
})
})
this
.
metrics
.
batchSizeInBytes
.
observe
(
batchSizeInBytes
)
return
true
return
true
}
}
this
.
logger
.
info
(
this
.
logger
.
info
(
...
@@ -156,6 +171,7 @@ export abstract class BatchSubmitter {
...
@@ -156,6 +171,7 @@ export abstract class BatchSubmitter {
currentTimestamp
,
currentTimestamp
,
}
}
)
)
this
.
metrics
.
batchSizeInBytes
.
observe
(
batchSizeInBytes
)
return
true
return
true
}
}
...
@@ -223,6 +239,40 @@ export abstract class BatchSubmitter {
...
@@ -223,6 +239,40 @@ export abstract class BatchSubmitter {
this
.
logger
.
info
(
'
Received transaction receipt
'
,
{
receipt
})
this
.
logger
.
info
(
'
Received transaction receipt
'
,
{
receipt
})
this
.
logger
.
info
(
successMessage
)
this
.
logger
.
info
(
successMessage
)
this
.
metrics
.
submissionGasUsed
.
observe
(
receipt
.
gasUsed
.
toNumber
())
this
.
metrics
.
submissionTimestamp
.
observe
(
Date
.
now
())
return
receipt
return
receipt
}
}
private
_registerMetrics
(
metrics
:
Metrics
):
BatchSubmitterMetrics
{
metrics
.
registry
.
clear
()
return
{
batchSubmitterETHBalance
:
new
metrics
.
client
.
Gauge
({
name
:
'
batch_submitter_eth_balance
'
,
help
:
'
ETH balance of the batch submitter
'
,
registers
:
[
metrics
.
registry
],
}),
batchSizeInBytes
:
new
metrics
.
client
.
Histogram
({
name
:
'
batch_size_in_bytes
'
,
help
:
'
Size of batches in bytes
'
,
registers
:
[
metrics
.
registry
],
}),
numTxPerBatch
:
new
metrics
.
client
.
Histogram
({
name
:
'
num_txs_per_batch
'
,
help
:
'
Number of transactions in each batch
'
,
registers
:
[
metrics
.
registry
],
}),
submissionTimestamp
:
new
metrics
.
client
.
Histogram
({
name
:
'
submission_timestamp
'
,
help
:
'
Timestamp of each batch submitter submission
'
,
registers
:
[
metrics
.
registry
],
}),
submissionGasUsed
:
new
metrics
.
client
.
Histogram
({
name
:
'
submission_gash_used
'
,
help
:
'
Gas used to submit each batch
'
,
registers
:
[
metrics
.
registry
],
}),
}
}
}
}
packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts
View file @
12dbd81b
...
@@ -237,6 +237,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -237,6 +237,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
if
(
!
wasBatchTruncated
&&
!
this
.
_shouldSubmitBatch
(
batchSizeInBytes
))
{
if
(
!
wasBatchTruncated
&&
!
this
.
_shouldSubmitBatch
(
batchSizeInBytes
))
{
return
return
}
}
this
.
metrics
.
numTxPerBatch
.
observe
(
endBlock
-
startBlock
)
const
l1tipHeight
=
await
this
.
signer
.
provider
.
getBlockNumber
()
const
l1tipHeight
=
await
this
.
signer
.
provider
.
getBlockNumber
()
this
.
logger
.
debug
(
'
Submitting batch.
'
,
{
this
.
logger
.
debug
(
'
Submitting batch.
'
,
{
calldata
:
batchParams
,
calldata
:
batchParams
,
...
...
yarn.lock
View file @
12dbd81b
...
@@ -1914,15 +1914,15 @@
...
@@ -1914,15 +1914,15 @@
"@sentry/utils" "6.2.5"
"@sentry/utils" "6.2.5"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/core@6.3.
1
":
"@sentry/core@6.3.
5
":
version "6.3.
1
"
version "6.3.
5
"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.3.
1.tgz#5e32ca919c9be30fec0bb3125a556bc711584bdf
"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.3.
5.tgz#6b73de736eb9d0040be94cdbb06a744cd6b9172e
"
integrity sha512-
aVuvVbaehGeN86jZlLDGGkhEtprdOtB6lvYLfGy40Dj1Tkh2mGWE550QsRXAXAqYvQzIYwQR23r6m3o8FujgV
g==
integrity sha512-
VR2ibDy33mryD0mT6d9fGhKjdNzS2FSwwZPe9GvmNOjkyjly/oV91BKVoYJneCqOeq8fyj2lvkJGKuupdJNDq
g==
dependencies:
dependencies:
"@sentry/hub" "6.3.
1
"
"@sentry/hub" "6.3.
5
"
"@sentry/minimal" "6.3.
1
"
"@sentry/minimal" "6.3.
5
"
"@sentry/types" "6.3.
1
"
"@sentry/types" "6.3.
5
"
"@sentry/utils" "6.3.
1
"
"@sentry/utils" "6.3.
5
"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/hub@5.30.0":
"@sentry/hub@5.30.0":
...
@@ -1952,6 +1952,15 @@
...
@@ -1952,6 +1952,15 @@
"@sentry/utils" "6.3.1"
"@sentry/utils" "6.3.1"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/hub@6.3.5":
version "6.3.5"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.3.5.tgz#c5bc6760f7e4e53e87149703b106804299060389"
integrity sha512-ZYFo7VYKwdPVjuV9BDFiYn+MpANn6eZMz5QDBfZ2dugIvIVbuOyOOLx8PSa3ZXJoVTZZ7s2wD2fi/ZxKjNjZOQ==
dependencies:
"@sentry/types" "6.3.5"
"@sentry/utils" "6.3.5"
tslib "^1.9.3"
"@sentry/minimal@5.30.0":
"@sentry/minimal@5.30.0":
version "5.30.0"
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.30.0.tgz#ce3d3a6a273428e0084adcb800bc12e72d34637b"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.30.0.tgz#ce3d3a6a273428e0084adcb800bc12e72d34637b"
...
@@ -1979,6 +1988,15 @@
...
@@ -1979,6 +1988,15 @@
"@sentry/types" "6.3.1"
"@sentry/types" "6.3.1"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/minimal@6.3.5":
version "6.3.5"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.3.5.tgz#ef4894771243d01d81e91819400d2ecdcb34b411"
integrity sha512-4RqIGAU0+8iI/1sw0GYPTr4SUA88/i2+JPjFJ+qloh5ANVaNwhFPRChw+Ys9xpre8LV9JZrEsEf8AvQr4fkNbA==
dependencies:
"@sentry/hub" "6.3.5"
"@sentry/types" "6.3.5"
tslib "^1.9.3"
"@sentry/node@^5.18.1":
"@sentry/node@^5.18.1":
version "5.30.0"
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.30.0.tgz#4ca479e799b1021285d7fe12ac0858951c11cd48"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.30.0.tgz#4ca479e799b1021285d7fe12ac0858951c11cd48"
...
@@ -2010,15 +2028,15 @@
...
@@ -2010,15 +2028,15 @@
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/node@^6.3.1":
"@sentry/node@^6.3.1":
version "6.3.
1
"
version "6.3.
5
"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.3.
1.tgz#0f81a0e352fa5b3e36bcc53adb6e26cd214c637d
"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.3.
5.tgz#d5cbf941d0a4caf7b8e644d71cc6b463eeda214e
"
integrity sha512-
D0r603fdNwUPkwvy0IcQaUSTafl+7lrOytiO5dfdLdlkhtTcwivwENc/n8ER8GOC2zpIvYOEIJvzP4PGL85kh
w==
integrity sha512-
scPB+DoAEPaqkYuyb8d/gVWbFmX5PhaYSNHybeHncaP/P4itLdq/AoAWGNxl0Hj4EQokfT4OZWxaaJi7SCYna
w==
dependencies:
dependencies:
"@sentry/core" "6.3.
1
"
"@sentry/core" "6.3.
5
"
"@sentry/hub" "6.3.
1
"
"@sentry/hub" "6.3.
5
"
"@sentry/tracing" "6.3.
1
"
"@sentry/tracing" "6.3.
5
"
"@sentry/types" "6.3.
1
"
"@sentry/types" "6.3.
5
"
"@sentry/utils" "6.3.
1
"
"@sentry/utils" "6.3.
5
"
cookie "^0.4.1"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
lru_map "^0.3.3"
...
@@ -2046,7 +2064,18 @@
...
@@ -2046,7 +2064,18 @@
"@sentry/utils" "6.2.5"
"@sentry/utils" "6.2.5"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/tracing@6.3.1", "@sentry/tracing@^6.3.1":
"@sentry/tracing@6.3.5":
version "6.3.5"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.3.5.tgz#f76c362159141f860081ec7df80aa9f85b545860"
integrity sha512-TNKAST1ge2g24BlTfVxNp4gP5t3drbi0OVCh8h8ah+J7UjHSfdiqhd9W2h5qv1GO61gGlpWeN/TyioyQmOxu0Q==
dependencies:
"@sentry/hub" "6.3.5"
"@sentry/minimal" "6.3.5"
"@sentry/types" "6.3.5"
"@sentry/utils" "6.3.5"
tslib "^1.9.3"
"@sentry/tracing@^6.3.1":
version "6.3.1"
version "6.3.1"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.3.1.tgz#3b96aabf4d9cebadfec070c006db79801a68ee24"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.3.1.tgz#3b96aabf4d9cebadfec070c006db79801a68ee24"
integrity sha512-qveDmoWsXy9qLEblZJwJ1OU/zZRlEd/q7Jhd0Hnwlob8Ci96huABEbYyGdJs18BKVHEFU3gSdVfvrikUE/W17g==
integrity sha512-qveDmoWsXy9qLEblZJwJ1OU/zZRlEd/q7Jhd0Hnwlob8Ci96huABEbYyGdJs18BKVHEFU3gSdVfvrikUE/W17g==
...
@@ -2072,6 +2101,11 @@
...
@@ -2072,6 +2101,11 @@
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.3.1.tgz#af3b54728b29f633f38fbe51b8c10e3834fbc158"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.3.1.tgz#af3b54728b29f633f38fbe51b8c10e3834fbc158"
integrity sha512-BEBn8JX1yaooCAuonbaMci9z0RjwwMbQ3Eny/eyDdd+rjXprZCZaStZnCvSThbNBqAJ8YaUqY2YBMnEwJxarAw==
integrity sha512-BEBn8JX1yaooCAuonbaMci9z0RjwwMbQ3Eny/eyDdd+rjXprZCZaStZnCvSThbNBqAJ8YaUqY2YBMnEwJxarAw==
"@sentry/types@6.3.5":
version "6.3.5"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.3.5.tgz#d5eca7e76c250882ab78c01a8df894a9a9ca537d"
integrity sha512-tY/3pkAmGYJ3F0BtwInsdt/uclNvF8aNG7XHsTPQNzk7BkNVWjCXx0sjxi6CILirl5nwNxYxVeTr2ZYAEZ/dSQ==
"@sentry/utils@5.30.0":
"@sentry/utils@5.30.0":
version "5.30.0"
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.30.0.tgz#9a5bd7ccff85ccfe7856d493bffa64cabc41e980"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.30.0.tgz#9a5bd7ccff85ccfe7856d493bffa64cabc41e980"
...
@@ -2096,6 +2130,14 @@
...
@@ -2096,6 +2130,14 @@
"@sentry/types" "6.3.1"
"@sentry/types" "6.3.1"
tslib "^1.9.3"
tslib "^1.9.3"
"@sentry/utils@6.3.5":
version "6.3.5"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.3.5.tgz#a4805448cb0314d3d119688162aa695598a10bbb"
integrity sha512-kHUcZ37QYlNzz7c9LVdApITXHaNmQK7+sw/If3M/qpff1fd5XoecA8laLfcYuz+Cw5mRhVmdhPcCRM3Xi1IGXg==
dependencies:
"@sentry/types" "6.3.5"
tslib "^1.9.3"
"@sindresorhus/is@^0.14.0":
"@sindresorhus/is@^0.14.0":
version "0.14.0"
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
...
...
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