Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update monitoring #375

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
71963c0
pkg/cosmos/client/client.go: add NewClientWithHttpClient
cfal Sep 12, 2023
02d00a0
pkg/monitoring/chain_reader.go: dont create a new cosmosclient each c…
cfal Sep 12, 2023
9b01f5c
pkg/monitoring/config.go: remove unused FCD options
cfal Sep 13, 2023
633954b
pkg/monitoring/testutils.go: remove fcdurl
cfal Sep 13, 2023
e8e30d2
pkg/monitoring/source_envelope.go: replace fcd RPCs
cfal Sep 13, 2023
706c8e7
pkg/monitoring/source_txresults.go: replace fcd, check latest_round_d…
cfal Sep 13, 2023
7ab296d
cmd/monitoring/main.go: remove fcd, construct updated monitors
cfal Sep 13, 2023
25d53b8
pkg/monitoring/fcdclient: remove
cfal Sep 13, 2023
1b4f4eb
pkg/monitoring/source_proxy.go: update ContractState invocation
cfal Sep 13, 2023
d730ff1
.tool-versions: update mockery to match core repo version
cfal Sep 13, 2023
217d3c0
pkg: update mocks
cfal Sep 13, 2023
b715adf
go.mod: update
cfal Sep 13, 2023
b07d745
pkg/monitoring/source_envelope_test.go: update test
cfal Sep 13, 2023
e2fa2d6
pkg/monitoring/source_txresults_test.go: update test
cfal Sep 13, 2023
298cd0f
pkg/monitoring/source_txresults_test.go: fix
cfal Sep 13, 2023
feaee35
pkg/monitoring/config.go: add Bech32Prefix and GasToken fields
cfal Sep 14, 2023
1555dd7
cmd/monitoring/main.go: initialize cosmos sdk
cfal Sep 14, 2023
4483ecd
pkg/monitoring/testutils.go: fix wasm prefixed addresses, dont genera…
cfal Sep 14, 2023
dd472c8
pkg/monitoring/proxy_monitoring_test.go: test fixes
cfal Sep 14, 2023
1fa908f
pkg/monitoring/main_test.go: initialize cosmos sdk for tests
cfal Sep 14, 2023
659e2ab
add NewCosmosMonitor for monitor initialization
cfal Sep 14, 2023
020986e
integration-tests: test monitor in e2e workflow
cfal Sep 14, 2023
4005c93
integration-tests/go.mod: update go.mod
cfal Sep 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ golang 1.20.4
python 3.9.13

# Tools
mockery 2.13.0-beta.1
mockery 2.28.1
golangci-lint 1.51.1
actionlint 1.6.12
shellcheck 0.8.0
Expand Down
43 changes: 7 additions & 36 deletions cmd/monitoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"context"
"log"

"github.com/smartcontractkit/chainlink-relay/pkg/logger"
relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring"

"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/params"
"github.com/smartcontractkit/chainlink-cosmos/pkg/monitoring"
"github.com/smartcontractkit/chainlink-cosmos/pkg/monitoring/fcdclient"
"github.com/smartcontractkit/chainlink-relay/pkg/logger"
)

func main() {
Expand All @@ -30,44 +28,17 @@ func main() {
return
}

chainReader := monitoring.NewChainReader(cosmosConfig, l)
fcdClient := fcdclient.New(cosmosConfig.FCDURL, cosmosConfig.FCDReqsPerSec)

envelopeSourceFactory := monitoring.NewEnvelopeSourceFactory(
chainReader,
fcdClient,
logger.With(l, "component", "source-envelope"),
)
txResultsFactory := monitoring.NewTxResultsSourceFactory(
fcdClient,
params.InitCosmosSdk(
cosmosConfig.Bech32Prefix,
cosmosConfig.GasToken,
)

monitor, err := relayMonitoring.NewMonitor(
ctx,
l,
cosmosConfig,
envelopeSourceFactory,
txResultsFactory,
monitoring.CosmosFeedsParser,
monitoring.CosmosNodesParser,
)
monitor, err := monitoring.NewCosmosMonitor(ctx, cosmosConfig, l)
if err != nil {
l.Fatalw("failed to build monitor", "error", err)
l.Fatalw("failed to create new cosmos monitor", "error", err)
return
}

proxySourceFactory := monitoring.NewProxySourceFactory(
chainReader,
logger.With(l, "component", "source-proxy"),
)
monitor.SourceFactories = append(monitor.SourceFactories, proxySourceFactory)

prometheusExporterFactory := monitoring.NewPrometheusExporterFactory(
logger.With(l, "component", "cosmos-prometheus-exporter"),
monitoring.NewMetrics(logger.With(l, "component", "cosmos-metrics")),
)
monitor.ExporterFactories = append(monitor.ExporterFactories, prometheusExporterFactory)

monitor.Run()
l.Info("monitor stopped")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/gogo/protobuf v1.3.3
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.0
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230814221409-567a8f84b413
Expand Down Expand Up @@ -108,7 +109,6 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
Expand Down
32 changes: 32 additions & 0 deletions integration-tests/common/monitor_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package common

import (
"log"
"net/http"
"testing"
)

func RunHTTPServer(t *testing.T, serverName, serverAddress string, responses map[string][]byte) *http.Server {
handler := http.NewServeMux()

for path, response := range responses {
handler.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s received request for %s\n", serverName, path)
w.Header().Set("Content-Type", "application/octet-stream")
w.Write(response)
})
}

server := &http.Server{
Addr: serverAddress,
Handler: handler,
}

go func() {
if err := server.ListenAndServe(); err != http.ErrServerClosed {
log.Printf("HTTP server ListenAndServe: %v", err)
}
}()

return server
}
7 changes: 7 additions & 0 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/aws/constructs-go/constructs/v10 v10.1.255 // indirect
Expand All @@ -64,6 +65,7 @@ require (
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cometbft/cometbft-db v0.8.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/confluentinc/confluent-kafka-go v1.9.2 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
Expand Down Expand Up @@ -233,6 +235,7 @@ require (
github.com/libp2p/go-ws-transport v0.4.0 // indirect
github.com/libp2p/go-yamux/v2 v2.0.0 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/linkedin/goavro/v2 v2.12.0 // indirect
github.com/linxGnu/grocksdb v1.7.16 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down Expand Up @@ -285,10 +288,12 @@ require (
github.com/pyroscope-io/client v0.7.1 // indirect
github.com/pyroscope-io/godeltaprof v0.1.2 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/riferrei/srclient v0.5.4 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.1.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/scylladb/go-reflectx v1.0.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand All @@ -308,6 +313,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand Down Expand Up @@ -342,6 +348,7 @@ require (
go.starlark.net v0.0.0-20220817180228-f738f5508c12 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
Expand Down
Loading