Skip to content

Commit

Permalink
feat: add gnohealth cli tool (#3158)
Browse files Browse the repository at this point in the history
This PR adds a tool to the contribs dedicated to adding subcommands for
health checks. The first available subcommand simply detects timestamp
drift on a given chain.

This test was useful in the context of this issue:
#1950.

However, it could later run on a dedicated server or on a GitHub Actions
cron job to alert us in case significant drift occurs again.

Results on test5 :
```
> gnohealth timestamp -ws -remote 'wss://rpc.test5.gno.land:443/websocket' -verbose
block 411344 drifted of 3.094940942s (max 10s): OK
block 411345 drifted of 2.368750176s (max 10s): OK
block 411346 drifted of 2.310184977s (max 10s): OK
block 411347 drifted of 2.158713327s (max 10s): OK
block 411348 drifted of 2.203484957s (max 10s): OK
block 411349 drifted of 2.156479203s (max 10s): OK
block 411350 drifted of 2.155613458s (max 10s): OK
block 411351 drifted of 2.296832155s (max 10s): OK
block 411352 drifted of 2.132230389s (max 10s): OK
block 411353 drifted of 2.181071735s (max 10s): OK
block 411354 drifted of 2.575055701s (max 10s): OK
block 411355 drifted of 2.034728695s (max 10s): OK
block 411356 drifted of 2.285932658s (max 10s): OK
block 411357 drifted of 2.330991247s (max 10s): OK
block 411358 drifted of 2.365136593s (max 10s): OK
block 411359 drifted of 2.035198868s (max 10s): OK
block 411360 drifted of 2.128274141s (max 10s): OK
block 411361 drifted of 2.48608003s (max 10s): OK
block 411362 drifted of 2.072144703s (max 10s): OK
block 411363 drifted of 2.297280076s (max 10s): OK
block 411364 drifted of 2.224310386s (max 10s): OK
no timestamp drifted beyond the maximum delta (average 2.280639734s)
```

Results on test4 :
```
> gnohealth timestamp -ws -remote 'wss://rpc.test4.gno.land:443/websocket' -verbose
block 3618022 drifted of 3.765561468s (max 10s): OK
block 3618023 drifted of 3.697091353s (max 10s): OK
block 3618024 drifted of 3.576602477s (max 10s): OK
block 3618025 drifted of 3.542585771s (max 10s): OK
block 3618026 drifted of 3.72231133s (max 10s): OK
block 3618027 drifted of 3.751154575s (max 10s): OK
block 3618028 drifted of 8.312827308s (max 10s): OK
block 3618029 drifted of 3.712806121s (max 10s): OK
block 3618030 drifted of 3.65324572s (max 10s): OK
no timestamp drifted beyond the maximum delta (average 4.192687347s)
```

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
</details>
  • Loading branch information
aeddi authored Nov 20, 2024
1 parent b3800b7 commit 7188b1c
Show file tree
Hide file tree
Showing 6 changed files with 466 additions and 0 deletions.
17 changes: 17 additions & 0 deletions contribs/gnohealth/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rundep := go run -modfile ../../misc/devdeps/go.mod
golangci_lint := $(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint


.PHONY: install
install:
go install .

.PHONY: build
build:
go build -o build/gnohealth .

lint:
$(golangci_lint) --config ../../.github/golangci.yml run ./...

test:
@echo "XXX: add tests"
46 changes: 46 additions & 0 deletions contribs/gnohealth/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module github.com/gnolang/gno/contribs/gnohealth

go 1.22.4

replace github.com/gnolang/gno => ../..

require github.com/gnolang/gno v0.0.0-00010101000000-000000000000

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.6 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 7188b1c

Please sign in to comment.