Skip to content

Commit

Permalink
make grpc client's dial-timeout configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jan 15, 2024
1 parent d1aae15 commit bcc6549
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 57 deletions.
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

0 comments on commit bcc6549

Please sign in to comment.