From e9491d25f8d96597e26d85203c59b9115fdba9e7 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 10 Aug 2021 16:31:56 +0200 Subject: [PATCH] node/pkg/publicrpc: add GetCurrentGuardianSet RPC call This is required for network explorers to know about missing guardians (the GetLastHeartbeats call won't contain those nodes at all). Change-Id: I28d8621023d79e6fa94c40f36a239c34aa12f1b0 --- bridge/pkg/publicrpc/publicrpcserver.go | 20 ++++++++++++++++++++ proto/publicrpc/v1/publicrpc.proto | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/bridge/pkg/publicrpc/publicrpcserver.go b/bridge/pkg/publicrpc/publicrpcserver.go index 2ee67634..ae18b0b6 100644 --- a/bridge/pkg/publicrpc/publicrpcserver.go +++ b/bridge/pkg/publicrpc/publicrpcserver.go @@ -113,3 +113,23 @@ func (s *PublicrpcServer) GetSignedVAA(ctx context.Context, req *publicrpcv1.Get VaaBytes: b, }, nil } + +func (s *PublicrpcServer) GetCurrentGuardianSet(ctx context.Context, req *publicrpcv1.GetCurrentGuardianSetRequest) (*publicrpcv1.GetCurrentGuardianSetResponse, error) { + gs := s.gst.Get() + if gs == nil { + return nil, status.Error(codes.Unavailable, "guardian set not fetched from chain yet") + } + + resp := &publicrpcv1.GetCurrentGuardianSetResponse{ + GuardianSet: &publicrpcv1.GuardianSet{ + Index: gs.Index, + Addresses: make([]string, len(gs.Keys)), + }, + } + + for i, v := range gs.Keys { + resp.GuardianSet.Addresses[i] = v.Hex() + } + + return resp, nil +} diff --git a/proto/publicrpc/v1/publicrpc.proto b/proto/publicrpc/v1/publicrpc.proto index e92fbd3a..b030b9a2 100644 --- a/proto/publicrpc/v1/publicrpc.proto +++ b/proto/publicrpc/v1/publicrpc.proto @@ -50,6 +50,13 @@ service Publicrpc { get: "/v1/signed_vaa/{message_id.emitter_chain}/{message_id.emitter_address}/{message_id.sequence}" }; } + + rpc GetCurrentGuardianSet (GetCurrentGuardianSetRequest) returns (GetCurrentGuardianSetResponse) { + option (google.api.http) = { + get: "/v1/guardianset/current" + }; + } + } message GetRawHeartbeatsRequest { @@ -84,3 +91,17 @@ message GetLastHeartbeatResponse { repeated Entry entries = 1; } + +message GetCurrentGuardianSetRequest { +} + +message GetCurrentGuardianSetResponse { + GuardianSet guardian_set = 1; +} + +message GuardianSet { + // Guardian set index + uint32 index = 1; + // List of guardian addresses as human-readable hex-encoded (leading 0x) addresses. + repeated string addresses = 2; +}