Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
chore: better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Dec 2, 2023
1 parent eb72458 commit d89c564
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions evm/evm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package evm
import (
"context"
"errors"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"

gethcommon "github.com/ethereum/go-ethereum/common"
coregethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down
14 changes: 7 additions & 7 deletions relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"encoding/hex"
stderrors "errors"
"fmt"
"github.com/ethereum/go-ethereum/ethclient"
"math/big"
"strconv"
"time"

"github.com/ethereum/go-ethereum/ethclient"

"github.com/ipfs/go-datastore"
badger "github.com/ipfs/go-ds-badger2"

Expand Down Expand Up @@ -377,24 +378,23 @@ func (r *Relayer) SaveDataCommitmentSignaturesToStore(ctx context.Context, att c
// waitForTransactionAndRetryIfNeeded waits for transaction to be mined. If it's not mined in the provided timeout, it will
// attempt to speed it up via updating the gas price.
func (r *Relayer) waitForTransactionAndRetryIfNeeded(ctx context.Context, ethClient *ethclient.Client, tx *coregethtypes.Transaction) error {
r.logger.Debug("submitted transaction", "hash", tx.Hash().Hex(), "gas_price", tx.GasPrice().Uint64())
for i := 0; i < 10; i++ {
_, err := r.EVMClient.WaitForTransaction(ctx, ethClient, tx, r.RetryTimeout)
if err != nil {
if stderrors.Is(err, context.DeadlineExceeded) {
r.logger.Debug("transaction still not included. updating the gas price", "retry_number", i, "err", err.Error())
r.logger.Debug("transaction still not included. updating the gas price", "retry_number", i)
newGasPrice, err := ethClient.SuggestGasPrice(ctx)
if err != nil {
return err
}
newTx := toLegacyTransaction(tx)
newTx.GasPrice = newGasPrice.Mul(newGasPrice, big.NewInt(2))
newTx.GasPrice = newGasPrice
newTx2 := coregethtypes.NewTx(newTx)
err = ethClient.SendTransaction(ctx, newTx2)
r.logger.Debug("submitted speed up transaction", "hash", newTx2.Hash().Hex(), "new_gas_price", newTx2.GasPrice().Uint64())
if err != nil {
_, err := ethClient.TransactionReceipt(ctx, tx.Hash())
if err == nil {
return nil
}
r.logger.Debug("response of sending speed up transaction", "resp", err.Error())
}
} else {
return err
Expand Down

0 comments on commit d89c564

Please sign in to comment.