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
1904e4ff
Commit
1904e4ff
authored
Jun 13, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(c-mon): Refactor to clean up network config
parent
d6388be4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
43 deletions
+54
-43
.env.example
packages/chain-mon/.env.example
+1
-0
service.ts
packages/chain-mon/src/wallet-mon/service.ts
+53
-43
No files found.
packages/chain-mon/.env.example
View file @
1904e4ff
...
...
@@ -16,6 +16,7 @@ BALANCE_MON__ACCOUNTS=
WALLET_MON__RPC=
# The block number to start monitoring from
# Defaults to the first bedrock block if unset.
WALLET_MON__START_BLOCK_NUMBER=
###############################################################################
...
...
packages/chain-mon/src/wallet-mon/service.ts
View file @
1904e4ff
...
...
@@ -16,62 +16,65 @@ import l2OutputOracleArtifactsGoerli from '@eth-optimism/contracts-bedrock/deplo
import
{
version
}
from
'
../../package.json
'
const
networks
=
{
1
:
'
mainnet
'
,
10
:
'
goerli
'
,
}
const
bedrockAccounts
=
{
mainnet
:
[
{
label
:
'
Proposer
'
,
wallet
:
mainnetConfig
.
l2OutputOracleProposer
,
target
:
l2OutputOracleArtifactsMainnet
.
address
,
},
{
label
:
'
Batcher
'
,
wallet
:
mainnetConfig
.
batchSenderAddress
,
target
:
mainnetConfig
.
batchInboxAddress
,
},
],
goerli
:
[
{
label
:
'
Proposer
'
,
wallet
:
goerliConfig
.
l2OutputOracleProposer
,
target
:
l2OutputOracleArtifactsGoerli
.
address
,
},
{
label
:
'
Batcher
'
,
wallet
:
goerliConfig
.
batchSenderAddress
,
target
:
goerliConfig
.
batchInboxAddress
,
},
],
1
:
{
name
:
'
mainnet
'
,
l1StartingBlockTag
:
mainnetConfig
.
l1StartingBlockTag
,
accounts
:
[
{
label
:
'
Proposer
'
,
wallet
:
mainnetConfig
.
l2OutputOracleProposer
,
target
:
l2OutputOracleArtifactsMainnet
.
address
,
},
{
label
:
'
Batcher
'
,
wallet
:
mainnetConfig
.
batchSenderAddress
,
target
:
mainnetConfig
.
batchInboxAddress
,
},
],
},
10
:
{
name
:
'
goerli
'
,
l1StartingBlockTag
:
goerliConfig
.
l1StartingBlockTag
,
accounts
:
[
{
label
:
'
Proposer
'
,
wallet
:
goerliConfig
.
l2OutputOracleProposer
,
target
:
l2OutputOracleArtifactsGoerli
.
address
,
},
{
label
:
'
Batcher
'
,
wallet
:
goerliConfig
.
batchSenderAddress
,
target
:
goerliConfig
.
batchInboxAddress
,
},
],
},
}
type
Transfer
MonOptions
=
{
type
Wallet
MonOptions
=
{
rpc
:
Provider
startBlockNumber
:
number
}
type
Transfer
MonMetrics
=
{
type
Wallet
MonMetrics
=
{
validatedCalls
:
Counter
unexpectedCalls
:
Counter
unexpectedRpcErrors
:
Counter
}
type
Transfer
MonState
=
{
type
Wallet
MonState
=
{
chainId
:
number
highestUncheckedBlockNumber
:
number
}
export
class
Transfer
MonService
extends
BaseServiceV2
<
Transfer
MonOptions
,
Transfer
MonMetrics
,
Transfer
MonState
export
class
Wallet
MonService
extends
BaseServiceV2
<
Wallet
MonOptions
,
Wallet
MonMetrics
,
Wallet
MonState
>
{
constructor
(
options
?:
Partial
<
Transfer
MonOptions
&
StandardOptions
>
)
{
constructor
(
options
?:
Partial
<
Wallet
MonOptions
&
StandardOptions
>
)
{
super
({
version
,
name
:
'
transfer
-mon
'
,
name
:
'
wallet
-mon
'
,
loop
:
true
,
options
:
{
loopIntervalMs
:
60
_000
,
...
...
@@ -97,7 +100,7 @@ export class TransferMonService extends BaseServiceV2<
},
unexpectedCalls
:
{
type
:
Counter
,
desc
:
'
Number of unexpected
transfer
s
'
,
desc
:
'
Number of unexpected
wallet
s
'
,
labels
:
[
'
wallet
'
,
'
target
'
,
'
nickname
'
],
},
unexpectedRpcErrors
:
{
...
...
@@ -117,10 +120,11 @@ export class TransferMonService extends BaseServiceV2<
})
this
.
state
.
chainId
=
await
getChainId
(
this
.
options
.
rpc
)
const
l1StartingBlockTag
=
networks
[
this
.
state
.
chainId
].
l1StartingBlockTag
if
(
this
.
options
.
startBlockNumber
===
-
1
)
{
this
.
state
.
highestUncheckedBlockNumber
=
await
this
.
options
.
rpc
.
getBlockNumber
()
const
block
=
await
this
.
options
.
rpc
.
getBlock
(
l1StartingBlockTag
)
this
.
state
.
highestUncheckedBlockNumber
=
block
.
number
}
else
{
this
.
state
.
highestUncheckedBlockNumber
=
this
.
options
.
startBlockNumber
}
...
...
@@ -129,14 +133,19 @@ export class TransferMonService extends BaseServiceV2<
protected
async
main
():
Promise
<
void
>
{
// get the next unchecked block
const
network
=
networks
[
this
.
state
.
chainId
]
const
accounts
=
bedrockAccounts
[
network
]
const
accounts
=
network
.
accounts
const
block
=
await
this
.
options
.
rpc
.
getBlock
(
this
.
state
.
highestUncheckedBlockNumber
)
this
.
logger
.
info
(
'
Checking block
'
,
{
number
:
block
.
number
,
})
for
(
const
txHash
of
block
.
transactions
)
{
console
.
log
(
'
txHash:
'
,
txHash
)
for
(
const
account
of
accounts
)
{
console
.
log
(
'
account:
'
,
account
)
const
tx
=
await
this
.
options
.
rpc
.
getTransaction
(
txHash
)
if
(
compareAddrs
(
account
.
wallet
,
tx
.
from
))
{
...
...
@@ -166,10 +175,11 @@ export class TransferMonService extends BaseServiceV2<
}
}
}
this
.
state
.
highestUncheckedBlockNumber
++
}
}
if
(
require
.
main
===
module
)
{
const
service
=
new
Transfer
MonService
()
const
service
=
new
Wallet
MonService
()
service
.
run
()
}
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