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
a756c1f3
Unverified
Commit
a756c1f3
authored
Dec 20, 2021
by
Ben Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed OVM string, added success in calling metric
parent
71bfa3fe
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1574 additions
and
1536 deletions
+1574
-1536
Makefile
go/l2geth-exporter/Makefile
+12
-9
CanonicalTransactionChain.go
go/l2geth-exporter/bindings/CanonicalTransactionChain.go
+1522
-0
OVM_CanonicalTransactionChain.go
go/l2geth-exporter/bindings/OVM_CanonicalTransactionChain.go
+0
-1463
collector.go
go/l2geth-exporter/collector.go
+10
-4
go.mod
go/l2geth-exporter/go.mod
+2
-2
go.sum
go/l2geth-exporter/go.sum
+0
-34
main.go
go/l2geth-exporter/l1contracts/main.go
+6
-6
main.go
go/l2geth-exporter/main.go
+22
-18
No files found.
go/l2geth-exporter/Makefile
View file @
a756c1f3
SHELL
:=
/bin/bash
GITCOMMIT
:=
$(
shell
git rev-parse HEAD
)
GITDATE
:=
$(
shell
git show
-s
--format
=
'%ct'
)
GITVERSION
:=
$(
shell
cat
package.json | jq .version
)
VERSION
:=
`
git describe
--abbrev
=
0
`
GITCOMMIT
:=
`
git rev-parse HEAD
`
BUILDDATE
:=
`
date
+%Y-%m-%d
`
BUILDUSER
:=
`
whoami
`
LDFLAGSSTRING
+=
-X
main.GitCommit
=
$(GITCOMMIT)
LDFLAGSSTRING
+=
-X
main.GitDate
=
$(GITDATE)
LDFLAGSSTRING
+=
-X
main.GitVersion
=
$(GITVERSION)
LDFLAGS
:=
-ldflags
"
$(LDFLAGSSTRING)
"
l2geth-exporter
:
env
GO111MODULE
=
on go build
$(LDFLAGS)
all
:
build
build
:
CGO_ENABLED
=
0 go build
$(LDFLAGS)
clean
:
rm
l2geth-exporter
...
...
@@ -24,15 +27,15 @@ lint:
binding
:
$
(
eval
temp :
=
$(
shell
mktemp
)
)
cat
../../packages/contracts/deployments/mainnet/
OVM_
CanonicalTransactionChain.json
\
cat
../../packages/contracts/deployments/mainnet/CanonicalTransactionChain.json
\
|
jq
-r
.bytecode
>
$(temp)
cat
../../packages/contracts/deployments/mainnet/
OVM_
CanonicalTransactionChain.json
\
cat
../../packages/contracts/deployments/mainnet/CanonicalTransactionChain.json
\
|
jq
.abi
\
|
abigen
--pkg
bindings
\
--abi
-
\
--out
bindings/
OVM_
CanonicalTransactionChain.go
\
--type
OVM
CanonicalTransactionChain
\
--out
bindings/CanonicalTransactionChain.go
\
--type
CanonicalTransactionChain
\
--bin
$(temp)
rm
$(temp)
go/l2geth-exporter/bindings/CanonicalTransactionChain.go
0 → 100644
View file @
a756c1f3
This diff is collapsed.
Click to expand it.
go/l2geth-exporter/bindings/OVM_CanonicalTransactionChain.go
deleted
100644 → 0
View file @
71bfa3fe
This diff is collapsed.
Click to expand it.
go/l2geth-exporter/collector.go
View file @
a756c1f3
...
...
@@ -6,15 +6,21 @@ import (
//Define the metrics we wish to expose
var
(
ovm
ctcTotalElements
=
prometheus
.
NewGaugeVec
(
ctcTotalElements
=
prometheus
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Name
:
"
ovm
ctc_total_elements"
,
Help
:
"
OVM
CTC GetTotalElements value."
},
Name
:
"
l2geth_
ctc_total_elements"
,
Help
:
"CTC GetTotalElements value."
},
[]
string
{
"state"
},
)
ctcTotalElementsCallSuccess
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"l2geth_ctc_total_elements_call_success"
,
Help
:
"CTC GetTotalElements call success."
},
)
)
func
init
()
{
//Register metrics with prometheus
prometheus
.
MustRegister
(
ovmctcTotalElements
)
prometheus
.
MustRegister
(
ctcTotalElements
)
prometheus
.
MustRegister
(
ctcTotalElementsCallSuccess
)
}
go/l2geth-exporter/go.mod
View file @
a756c1f3
module github.com/
optimisticben
/optimism/go/l2geth-exporter
module github.com/
ethereum-optimism
/optimism/go/l2geth-exporter
go 1.16
require (
github.com/ethereum/go-ethereum v1.10.8
github.com/prometheus/client_golang v1.11.0
// indirect
github.com/prometheus/client_golang v1.11.0
)
go/l2geth-exporter/go.sum
View file @
a756c1f3
This diff is collapsed.
Click to expand it.
go/l2geth-exporter/l1contracts/main.go
View file @
a756c1f3
...
...
@@ -4,28 +4,28 @@ import (
"context"
"math/big"
"github.com/ethereum-optimism/optimism/go/l2geth-exporter/bindings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/optimisticben/optimism/go/l2geth-exporter/bindings"
)
//
OVM
CTC interacts with the OVM CTC contract
type
OVM
CTC
struct
{
// CTC interacts with the OVM CTC contract
type
CTC
struct
{
Ctx
context
.
Context
Address
common
.
Address
Client
*
ethclient
.
Client
}
func
(
ovmctc
*
OVM
CTC
)
GetTotalElements
()
(
*
big
.
Int
,
error
)
{
func
(
ctc
*
CTC
)
GetTotalElements
()
(
*
big
.
Int
,
error
)
{
contract
,
err
:=
bindings
.
New
OVMCanonicalTransactionChainCaller
(
ovmctc
.
Address
,
ovm
ctc
.
Client
)
contract
,
err
:=
bindings
.
New
CanonicalTransactionChainCaller
(
ctc
.
Address
,
ctc
.
Client
)
if
err
!=
nil
{
return
nil
,
err
}
totalElements
,
err
:=
contract
.
GetTotalElements
(
&
bind
.
CallOpts
{
Context
:
ovm
ctc
.
Ctx
,
Context
:
ctc
.
Ctx
,
})
if
err
!=
nil
{
return
nil
,
err
...
...
go/l2geth-exporter/main.go
View file @
a756c1f3
...
...
@@ -6,10 +6,10 @@ import (
"os"
"time"
"github.com/ethereum-optimism/optimism/go/l2geth-exporter/l1contracts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/optimisticben/optimism/go/l2geth-exporter/l1contracts"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
...
...
@@ -19,19 +19,21 @@ func main() {
listenAddress
=
":9100"
}
gethUrl
:=
os
.
Getenv
(
"GETH_URL"
)
if
gethUrl
==
""
{
log
.
Error
(
"GETH_URL environmental variable is required"
)
log
.
Root
()
.
SetHandler
(
log
.
CallerFileHandler
(
log
.
StdoutHandler
))
l1Url
:=
os
.
Getenv
(
"L1_URL"
)
if
l1Url
==
""
{
log
.
Error
(
"L1_URL environmental variable is required"
)
os
.
Exit
(
1
)
}
ovmCtcAddress
:=
os
.
Getenv
(
"OVM_
CTC_ADDRESS"
)
if
ovmC
tcAddress
==
""
{
log
.
Error
(
"
OVM_
CTC_ADDRESS environmental variable is required"
)
ctcAddress
:=
os
.
Getenv
(
"
CTC_ADDRESS"
)
if
c
tcAddress
==
""
{
log
.
Error
(
"CTC_ADDRESS environmental variable is required"
)
os
.
Exit
(
1
)
}
client
,
err
:=
ethclient
.
Dial
(
geth
Url
)
client
,
err
:=
ethclient
.
Dial
(
l1
Url
)
if
err
!=
nil
{
log
.
Error
(
"Problem connecting to
GETH
: %s"
,
err
)
log
.
Error
(
"Problem connecting to
L1
: %s"
,
err
)
}
http
.
Handle
(
"/metrics"
,
promhttp
.
Handler
())
...
...
@@ -44,17 +46,17 @@ func main() {
</body>
</html>`
))
})
go
getCTCTotalElements
(
ovmC
tcAddress
,
client
)
go
getCTCTotalElements
(
c
tcAddress
,
client
)
log
.
Info
(
"
Listening on"
,
listen
Address
)
log
.
Info
(
"
Program starting"
,
"listenAddress"
,
listenAddress
,
"GETH_URL"
,
l1Url
,
"CTC_ADDRESS"
,
ctc
Address
)
if
err
:=
http
.
ListenAndServe
(
listenAddress
,
nil
);
err
!=
nil
{
log
.
Error
(
"Can't start http server
: %s
"
,
err
)
log
.
Error
(
"Can't start http server
"
,
"error
"
,
err
)
}
}
func
getCTCTotalElements
(
address
string
,
client
*
ethclient
.
Client
)
{
ovmCTC
:=
l1contracts
.
OVM
CTC
{
ctc
:=
l1contracts
.
CTC
{
Address
:
common
.
HexToAddress
(
address
),
Client
:
client
,
}
...
...
@@ -62,16 +64,18 @@ func getCTCTotalElements(address string, client *ethclient.Client) {
ticker
:=
time
.
NewTicker
(
30
*
time
.
Second
)
defer
ticker
.
Stop
()
for
{
<-
ticker
.
C
totalElements
,
err
:=
ovmCTC
.
GetTotalElements
()
totalElements
,
err
:=
ctc
.
GetTotalElements
()
if
err
!=
nil
{
log
.
Error
(
"Error calling GetTotalElements: %s"
,
err
)
ctcTotalElementsCallSuccess
.
Set
(
0
)
log
.
Error
(
"Error calling GetTotalElements"
,
"error"
,
err
)
continue
}
ctcTotalElementsCallSuccess
.
Set
(
1
)
totalElementsFloat
,
_
:=
new
(
big
.
Float
)
.
SetInt
(
totalElements
)
.
Float64
()
ovm
ctcTotalElements
.
WithLabelValues
(
ctcTotalElements
.
WithLabelValues
(
"latest"
)
.
Set
(
totalElementsFloat
)
<-
ticker
.
C
}
}
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