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
453ebf04
Commit
453ebf04
authored
Jun 27, 2021
by
Liam Horne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prevent batch submitter from submitting batches if low on ETH
parent
154aab39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
batch-submitter.ts
...es/batch-submitter/src/batch-submitter/batch-submitter.ts
+11
-3
No files found.
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
View file @
453ebf04
...
...
@@ -3,7 +3,7 @@ import { Contract, Signer, utils, providers } from 'ethers'
import
{
TransactionReceipt
}
from
'
@ethersproject/abstract-provider
'
import
{
Gauge
,
Histogram
,
Counter
}
from
'
prom-client
'
import
*
as
ynatm
from
'
@eth-optimism/ynatm
'
import
{
RollupInfo
}
from
'
@eth-optimism/core-utils
'
import
{
RollupInfo
,
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
getContractFactory
}
from
'
old-contracts
'
...
...
@@ -73,7 +73,11 @@ export abstract class BatchSubmitter {
this
.
l2ChainId
=
await
this
.
_getL2ChainId
()
}
await
this
.
_updateChainInfo
()
await
this
.
_checkBalance
()
if
(
!
(
await
this
.
_hasEnoughETHToCoverGasCosts
()))
{
await
sleep
(
this
.
resubmissionTimeout
)
return
}
this
.
logger
.
info
(
'
Readying to submit next batch...
'
,
{
l2ChainId
:
this
.
l2ChainId
,
...
...
@@ -94,7 +98,7 @@ export abstract class BatchSubmitter {
return
this
.
_submitBatch
(
range
.
start
,
range
.
end
)
}
protected
async
_
checkBalance
():
Promise
<
void
>
{
protected
async
_
hasEnoughETHToCoverGasCosts
():
Promise
<
boolean
>
{
const
address
=
await
this
.
signer
.
getAddress
()
const
balance
=
await
this
.
signer
.
getBalance
()
const
ether
=
utils
.
formatEther
(
balance
)
...
...
@@ -104,6 +108,7 @@ export abstract class BatchSubmitter {
address
,
ether
,
})
this
.
metrics
.
batchSubmitterETHBalance
.
set
(
num
)
if
(
num
<
this
.
minBalanceEther
)
{
...
...
@@ -111,7 +116,10 @@ export abstract class BatchSubmitter {
current
:
num
,
safeBalance
:
this
.
minBalanceEther
,
})
return
false
}
return
true
}
protected
async
_getRollupInfo
():
Promise
<
RollupInfo
>
{
...
...
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