Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make grpc client's dial-timeout configurable #14

Merged
merged 1 commit into from
Jan 15, 2024
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
16 changes: 9 additions & 7 deletions proto/relayer/provers/lcp/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ message ProverConfig {
google.protobuf.Any origin_prover = 1;
// hex string
string lcp_service_address = 2;
// unit: seconds
uint64 lcp_service_dial_timeout = 3;
// hex string
string mrenclave = 3;
repeated string allowed_quote_statuses = 4;
repeated string allowed_advisory_ids = 5;
string mrenclave = 4;
repeated string allowed_quote_statuses = 5;
repeated string allowed_advisory_ids = 6;
// unit: seconds
uint64 key_expiration = 6;
string elc_client_id = 7;
bool message_aggregation = 8;
uint64 message_aggregation_batch_size = 9;
uint64 key_expiration = 7;
string elc_client_id = 8;
bool message_aggregation = 9;
uint64 message_aggregation_batch_size = 10;
}
14 changes: 13 additions & 1 deletion relay/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import (
"encoding/hex"
"fmt"
"strings"
"time"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
lcptypes "github.com/datachainlab/lcp-go/light-clients/lcp/types"
"github.com/hyperledger-labs/yui-relayer/core"
)

const DefaultMessageAggregationBatchSize = 8
const (
DefaultDialTimeout = 20 // seconds
DefaultMessageAggregationBatchSize = 8
)

var _ core.ProverConfig = (*ProverConfig)(nil)

Expand All @@ -37,6 +41,14 @@ func (pc ProverConfig) Build(chain core.Chain) (core.Prover, error) {
return NewProver(pc, chain, prover)
}

func (pc ProverConfig) GetDialTimeout() time.Duration {
if pc.LcpServiceDialTimeout == 0 {
return DefaultDialTimeout * time.Second
} else {
return time.Duration(pc.LcpServiceDialTimeout) * time.Second
}
}

func (pc ProverConfig) GetMrenclave() []byte {
mrenclave, err := decodeMrenclaveHex(pc.Mrenclave)
if err != nil {
Expand Down
127 changes: 79 additions & 48 deletions relay/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion relay/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ func NewProver(config ProverConfig, originChain core.Chain, originProver core.Pr
config.LcpServiceAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
grpc.WithTimeout(config.GetDialTimeout()),
)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to connect to LCP service: %w", err)
}
return &Prover{config: config, originChain: originChain, originProver: originProver, lcpServiceClient: NewLCPServiceClient(conn)}, nil
}
Expand Down