diff --git a/.gitignore b/.gitignore index 841f713..ce29c45 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ UNUSED **/.DS_Store # test envs -.env.test tests/test.go # prod envs diff --git a/internal/packages/duty/eventnonce/api/grpc.go b/internal/packages/duty/eventnonce/api/grpc.go index e8321e7..123355e 100644 --- a/internal/packages/duty/eventnonce/api/grpc.go +++ b/internal/packages/duty/eventnonce/api/grpc.go @@ -2,8 +2,10 @@ package api import ( "context" + "crypto/tls" "encoding/json" "fmt" + "strings" "sync" "time" @@ -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), @@ -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()) @@ -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 } @@ -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: "", diff --git a/internal/testutil/.env.test.sample b/internal/testutil/.env.test similarity index 77% rename from internal/testutil/.env.test.sample rename to internal/testutil/.env.test index 243ef9e..430d0c9 100644 --- a/internal/testutil/.env.test.sample +++ b/internal/testutil/.env.test @@ -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= @@ -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= @@ -60,4 +65,7 @@ TEST_BAND_ENDPOINT= TEST_COSMOS_RPC_ENDPOINT= TEST_COSMOS_API_ENDPOINT= TEST_NEUTRON_RPC_ENDPOINT= -TEST_NEUTRON_API_ENDPOINT= \ No newline at end of file +TEST_NEUTRON_API_ENDPOINT= + +# indexer +TEST_DB_DNS="postgres://cvms@localhost:5432/cvms?sslmode=disable"