Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ UNUSED
**/.DS_Store

# test envs
.env.test
tests/test.go

# prod envs
Expand Down
42 changes: 31 additions & 11 deletions internal/packages/duty/eventnonce/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package api

import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"strings"
"sync"
"time"

Expand All @@ -15,18 +17,12 @@ import (
"github.com/jhump/protoreflect/dynamic/grpcdynamic"
"github.com/jhump/protoreflect/grpcreflect"
"google.golang.org/grpc"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
reflectpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
)

// NOTE: debug
// func init() {
// logger := grpclog.NewLoggerV2(os.Stdout, os.Stdout, os.Stderr)
// grpclog.SetLoggerV2(logger)
// }

func GetEventNonceStatusByGRPC(
c *common.Exporter,
commonOrchestratorPath string, commonOrchestratorParser func([]byte) (string, error),
Expand All @@ -36,10 +32,21 @@ func GetEventNonceStatusByGRPC(
ctx, cancel := context.WithTimeout(context.Background(), common.Timeout)
defer cancel()

// NOTE: currently it don't support nginx grpc proxy ssl server like grpc.cosmostation.io:443
creds := insecure.NewCredentials()

// check the port is 443 or not
if strings.Contains(c.GetGRPCEndPoint(), ":443") {
tlsConf := &tls.Config{
NextProtos: []string{"h2"}, // only allow HTTP/2
MinVersion: tls.VersionTLS12,
}

creds = credentials.NewTLS(tlsConf)
}

// create grpc connection
grpcConnection, err := grpc.NewClient(c.GetGRPCEndPoint(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithTransportCredentials(creds),
)
if err != nil {
c.Errorf("grpc request error: %s", err.Error())
Expand Down Expand Up @@ -115,7 +122,20 @@ func GetEventNonceStatusByGRPC(
)

if err != nil {
c.Errorf("grpc error: %s", err)
// NOTE: we need to modify this logic in the future for general cases

// case.1 : not registered validators for gravity-bridge
if strings.Contains(err.Error(), "codespace gravity code 3: invalid: No validator") {
c.Infof("got empty orchestrator address for %s, so saved empty string", validatorOperatorAddress)
ch <- helper.Result{Success: true, Item: types.ValidatorStatus{
ValidatorOperatorAddress: validatorOperatorAddress,
OrchestratorAddress: "",
Moniker: validatorMoniker,
}}
return
}

c.Errorf("grpc error: %s for %s", err, commonOrchestratorPayload)
ch <- helper.Result{Success: false, Item: nil}
return
}
Expand All @@ -129,7 +149,7 @@ func GetEventNonceStatusByGRPC(

if orchestratorAddress == "" {
// not registered validators
c.Warnf("got empty orchestrator address for %s, so saved empty string", validatorOperatorAddress)
c.Infof("got empty orchestrator address for %s, so saved empty string", validatorOperatorAddress)
ch <- helper.Result{Success: true, Item: types.ValidatorStatus{
ValidatorOperatorAddress: validatorOperatorAddress,
OrchestratorAddress: "",
Expand Down
16 changes: 12 additions & 4 deletions internal/testutil/.env.test.sample → internal/testutil/.env.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# test monikers
TEST_MONIKER=
# test indexer db
TEST_DB_DNS=
TEST_MONIKER=Cosmostation

# test helper module
TEST_COSMOS_ENDPOINT_1=
TEST_COSMOS_ENDPOINT_2=
Expand Down Expand Up @@ -50,6 +49,12 @@ TEST_INJECTIVE_GRPC_ENDPOINT=
TEST_GRAVITY_GRPC_ENDPOINT=
TEST_SOMMELIER_GRPC_ENDPOINT=

# eventnonce package test
TEST_INJECTIVE_GRPC_ENDPOINT=injective-grpc.publicnode.com:443
TEST_GRAVITY_GRPC_ENDPOINT=gravity-grpc.polkachu.com:14290
TEST_SOMMELIER_GRPC_ENDPOINT=sommelier-grpc.polkachu.com:14190


# axelar-evm package test
TEST_AXELAR_ENDPOINT=

Expand All @@ -60,4 +65,7 @@ TEST_BAND_ENDPOINT=
TEST_COSMOS_RPC_ENDPOINT=
TEST_COSMOS_API_ENDPOINT=
TEST_NEUTRON_RPC_ENDPOINT=
TEST_NEUTRON_API_ENDPOINT=
TEST_NEUTRON_API_ENDPOINT=

# indexer
TEST_DB_DNS="postgres://cvms@localhost:5432/cvms?sslmode=disable"