Skip to content

Commit

Permalink
fix: timeout for transcation opts. and unlock route lock when errors
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Jun 10, 2024
1 parent 60c8bf4 commit 9b07548
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions relayer/chains/evm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ func (p *Provider) GetTransationOpts(ctx context.Context) (*bind.TransactOpts, e
if err != nil {
return nil, err
}
ctx, cancel := context.WithTimeout(ctx, defaultReadTimeout)
defer cancel()
txOpts.Nonce = p.NonceTracker.Get(wallet.Address)
gasPrice, err := p.client.SuggestGasPrice(ctx)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions relayer/chains/evm/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ func (p *Provider) SendTransaction(ctx context.Context, opts *bind.TransactOpts,

opts.GasLimit = gasLimit + (gasLimit * p.cfg.GasAdjustment / 100)

p.log.Info("gas info",
p.log.Info("transaction info",
zap.Uint64("gas_cap", opts.GasFeeCap.Uint64()),
zap.Uint64("gas_tip", opts.GasTipCap.Uint64()),
zap.Uint64("estimated_limit", gasLimit),
zap.Uint64("adjusted_limit", opts.GasLimit),
zap.Uint64("nonce", opts.Nonce.Uint64()),
zap.String("event_type", message.EventType),
zap.String("src", message.Src),
zap.Uint64("sn", message.Sn.Uint64()),
)

Expand Down Expand Up @@ -148,15 +149,20 @@ func (p *Provider) LogSuccessTx(message *providerTypes.MessageKey, receipt *type
zap.String("tx_hash", receipt.TxHash.String()),
zap.Int64("height", receipt.BlockNumber.Int64()),
zap.Uint64("gas_used", receipt.GasUsed),
zap.String("contract_address", receipt.ContractAddress.Hex()),
)
}

func (p *Provider) LogFailedTx(messageKey *providerTypes.MessageKey, result *types.Receipt, err error) {
p.log.Info("failed transaction",
p.log.Error("failed transaction",
zap.String("tx_hash", result.TxHash.String()),
zap.Int64("height", result.BlockNumber.Int64()),
zap.Uint64("gas_used", result.GasUsed),
zap.Uint("tx_index", result.TransactionIndex),
zap.String("event_type", messageKey.EventType),
zap.Uint64("sn", messageKey.Sn.Uint64()),
zap.String("src", messageKey.Src),
zap.String("contract_address", result.ContractAddress.Hex()),
zap.Error(err),
)
}
Expand Down

0 comments on commit 9b07548

Please sign in to comment.