From b2924515e447b9411f644f1f9ddee1f1ec2c0ee7 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Mon, 8 Jul 2024 21:56:15 +0530 Subject: [PATCH 1/2] server: add status endpoint from tendermint (#1175) * feat: expose status endpoint from rest-server * call status directly * remove public endpoint * remove endpoint from checkpoint module * server: add /status endpoint * server: only return sync info * server: rename fn to sync info * server: fix milestone grpc endpoint * server: rename sync_info to status --- server/gRPC/gRPC.go | 2 +- server/root.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/gRPC/gRPC.go b/server/gRPC/gRPC.go index 48db961e9..6b4ef5a4e 100644 --- a/server/gRPC/gRPC.go +++ b/server/gRPC/gRPC.go @@ -18,7 +18,7 @@ const ( eventRecordList = "/clerk/event-record/list" fetchCheckpointCount = "/checkpoints/count" fetchCheckpoint = "/checkpoints/%s" - fetchMilestoneCount = "/checkpoints/count" + fetchMilestoneCount = "/milestone/count" fetchMilestone = "/milestone/latest" fetchMilestoneNoAck = "/milestone/noAck/%s" fetchLastNoAckMilestone = "/milestone/lastNoAck" diff --git a/server/root.go b/server/root.go index 7b58967e8..ee46e354e 100644 --- a/server/root.go +++ b/server/root.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/rest" "github.com/go-kit/log" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -26,6 +27,7 @@ import ( "github.com/maticnetwork/heimdall/app" tx "github.com/maticnetwork/heimdall/client/tx" "github.com/maticnetwork/heimdall/helper" + hmRest "github.com/maticnetwork/heimdall/types/rest" // unnamed import of statik for swagger UI support "github.com/maticnetwork/heimdall/server/gRPC" @@ -264,6 +266,9 @@ func RegisterRoutes(ctx client.CLIContext, mux *mux.Router) { rpc.RegisterRPCRoutes(ctx, mux) tx.RegisterRoutes(ctx, mux) + // Register the status endpoint here (as it's generic) + mux.HandleFunc("/status", statusHandlerFn(ctx)).Methods("GET") + // auth.RegisterRoutes(rs.CliCtx, rs.Mux) // bank.RegisterRoutes(rs.CliCtx, rs.Mux) @@ -285,3 +290,15 @@ func registerSwaggerUI(mux *mux.Router) { staticServer := http.FileServer(statikFS) mux.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer)) } + +func statusHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + status, err := cliCtx.Client.Status() + if err != nil { + hmRest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + rest.PostProcessResponse(w, cliCtx, status.SyncInfo) + } +} From 1f76118751d7481cf360b8ce2a520508fa65e8e3 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Tue, 16 Jul 2024 12:45:49 +0530 Subject: [PATCH 2/2] bump version to v1.0.8-beta --- packaging/deb/heimdalld/DEBIAN/control | 4 ++-- packaging/templates/package_scripts/control | 2 +- packaging/templates/package_scripts/control.arm64 | 2 +- packaging/templates/package_scripts/control.profile.amd64 | 2 +- packaging/templates/package_scripts/control.profile.arm64 | 2 +- packaging/templates/package_scripts/control.validator | 4 ++-- packaging/templates/package_scripts/control.validator.arm64 | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packaging/deb/heimdalld/DEBIAN/control b/packaging/deb/heimdalld/DEBIAN/control index 795e7502e..126d5dacc 100644 --- a/packaging/deb/heimdalld/DEBIAN/control +++ b/packaging/deb/heimdalld/DEBIAN/control @@ -3,11 +3,11 @@ Section: develop Priority: Testing Maintainer: Polygon Build-Depends: debhelper-compat (= 13) -Standards-Version: v1.0.7 +Standards-Version: v1.0.8-beta Homepage: https://polygon.technology Rules-Requires-Root: no Package: heimdalld -Version: 1.0.7 +Version: 1.0.8-beta Architecture: amd64 Multi-Arch: foreign Depends: diff --git a/packaging/templates/package_scripts/control b/packaging/templates/package_scripts/control index 3b20a23dc..767647527 100755 --- a/packaging/templates/package_scripts/control +++ b/packaging/templates/package_scripts/control @@ -1,5 +1,5 @@ Source: heimdalld -Version: 1.0.7 +Version: 1.0.8-beta Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.arm64 b/packaging/templates/package_scripts/control.arm64 index ab1ebbd1b..a63a3ec90 100755 --- a/packaging/templates/package_scripts/control.arm64 +++ b/packaging/templates/package_scripts/control.arm64 @@ -1,5 +1,5 @@ Source: heimdalld -Version: 1.0.7 +Version: 1.0.8-beta Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.profile.amd64 b/packaging/templates/package_scripts/control.profile.amd64 index 998919b94..582aac422 100755 --- a/packaging/templates/package_scripts/control.profile.amd64 +++ b/packaging/templates/package_scripts/control.profile.amd64 @@ -1,5 +1,5 @@ Source: heimdalld-profile -Version: 1.0.7 +Version: 1.0.8-beta Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.profile.arm64 b/packaging/templates/package_scripts/control.profile.arm64 index ccc03c727..ac09e86e0 100755 --- a/packaging/templates/package_scripts/control.profile.arm64 +++ b/packaging/templates/package_scripts/control.profile.arm64 @@ -1,5 +1,5 @@ Source: heimdalld-profile -Version: 1.0.7 +Version: 1.0.8-beta Section: develop Priority: standard Maintainer: Polygon diff --git a/packaging/templates/package_scripts/control.validator b/packaging/templates/package_scripts/control.validator index f39277b13..988618e5c 100755 --- a/packaging/templates/package_scripts/control.validator +++ b/packaging/templates/package_scripts/control.validator @@ -3,11 +3,11 @@ Section: develop Priority: Testing Maintainer: Polygon Build-Depends: debhelper-compat (= 13) -Standards-Version: v1.0.7 +Standards-Version: v1.0.8-beta Homepage: https://polygon.technology Rules-Requires-Root: no Package: heimdalld-profile -Version: 1.0.7 +Version: 1.0.8-beta Architecture: amd64 Multi-Arch: foreign Depends: rabbitmq-server diff --git a/packaging/templates/package_scripts/control.validator.arm64 b/packaging/templates/package_scripts/control.validator.arm64 index b4da0046d..80a06af12 100755 --- a/packaging/templates/package_scripts/control.validator.arm64 +++ b/packaging/templates/package_scripts/control.validator.arm64 @@ -3,11 +3,11 @@ Section: develop Priority: Testing Maintainer: Polygon Build-Depends: debhelper-compat (= 13) -Standards-Version: v1.0.7 +Standards-Version: v1.0.8-beta Homepage: https://polygon.technology Rules-Requires-Root: no Package: heimdalld-profile -Version: 1.0.7 +Version: 1.0.8-beta Architecture: arm64 Multi-Arch: foreign Depends: rabbitmq-server