Skip to content

Commit

Permalink
channel capacity increase (#151)
Browse files Browse the repository at this point in the history
* channel capacity increase

* timeout

* increasing test timeout duration

* changing log level
  • Loading branch information
dixitaniket authored Aug 9, 2023
1 parent fb2be64 commit a6d970b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cw-relayer/relayer/client/chain_subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewBlockHeightSubscription(
newEvent := &EventSubscribe{
logger: logger.With().Str("event", tickEventType).Logger(),
// assuming 15-second price update
Tick: make(chan struct{}, 4),
Tick: make(chan struct{}, 100),
timeout: timeout,
maxTickTimeout: maxTickTimeout,
rpcAddress: rpcAddress,
Expand Down
9 changes: 7 additions & 2 deletions cw-relayer/relayer/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ func (r *passReader) Read(p []byte) (n int, err error) {

// BroadcastTx attempts to broadcast a signed transaction. If it fails, a few re-attempts
// will be made until the transaction succeeds or ultimately times out or fails.
func (oc RelayerClient) BroadcastTx(nextBlockHeight, timeoutHeight int64, msgs ...sdk.Msg) error {
func (oc RelayerClient) BroadcastTx(timeoutDuration time.Duration, nextBlockHeight, timeoutHeight int64, msgs ...sdk.Msg) error {
maxBlockHeight := nextBlockHeight + timeoutHeight
lastCheckHeight := nextBlockHeight - 1
start := time.Now()

clientCtx, err := oc.CreateClientContext()
if err != nil {
Expand All @@ -178,6 +179,10 @@ func (oc RelayerClient) BroadcastTx(nextBlockHeight, timeoutHeight int64, msgs .
}

if latestBlockHeight <= lastCheckHeight {
if time.Since(start).Seconds() >= timeoutDuration.Seconds() {
return fmt.Errorf("timeout duration exceeded")
}

continue
}

Expand All @@ -201,7 +206,7 @@ func (oc RelayerClient) BroadcastTx(nextBlockHeight, timeoutHeight int64, msgs .
hash = resp.TxHash
}

oc.logger.Debug().
oc.logger.Error().
Err(err).
Int64("max_height", maxBlockHeight).
Int64("last_check_height", lastCheckHeight).
Expand Down
2 changes: 1 addition & 1 deletion cw-relayer/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (r *Relayer) tick(ctx context.Context) error {
}

logs.Msg("broadcasting execute to contract")
if err := r.relayerClient.BroadcastTx(nextBlockHeight, r.timeoutHeight, msgs...); err != nil {
if err := r.relayerClient.BroadcastTx(r.resolveDuration, nextBlockHeight, r.timeoutHeight, msgs...); err != nil {
r.missedCounter += 1
return err
}
Expand Down
1 change: 1 addition & 0 deletions cw-relayer/tests/e2e/config/relayer-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gas_prices = "0.2stake"
median_duration = 1
deviation_duration = 1
ignore_median_errors = false
resolve_duration = "30s"

missed_threshold = 2
event_type = "ojo.oracle.v1.EventSetFxRate"
Expand Down

0 comments on commit a6d970b

Please sign in to comment.