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

Commit

Permalink
fix: sign the speed up transaction (#651)
Browse files Browse the repository at this point in the history
* fix: sign the speed up transaction

* chore: fix logger
  • Loading branch information
rach-id authored Dec 7, 2023
1 parent 7567562 commit 4f82c1c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (r *Relayer) Start(ctx context.Context) error {
return err
}

err = r.waitForTransactionAndRetryIfNeeded(ctx, ethClient, tx)
err = r.waitForTransactionAndRetryIfNeeded(ctx, ethClient, opts, tx)
if err != nil {
return err
}
Expand Down Expand Up @@ -403,7 +403,7 @@ 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 {
func (r *Relayer) waitForTransactionAndRetryIfNeeded(ctx context.Context, ethClient *ethclient.Client, opts *bind.TransactOpts, tx *coregethtypes.Transaction) error {
r.logger.Debug("submitted transaction", "hash", tx.Hash().Hex(), "gas_price", tx.GasPrice().Uint64())
newTx := tx
for i := 0; i < 10; i++ {
Expand Down Expand Up @@ -455,8 +455,12 @@ func (r *Relayer) waitForTransactionAndRetryIfNeeded(ctx context.Context, ethCli
}
}
r.logger.Debug("transaction still not included. updating the gas price", "retry_number", i)
err = ethClient.SendTransaction(ctx, rawTx)
r.logger.Info("submitted speed up transaction", "hash", newTx.Hash().Hex(), "new_gas_price", newTx.GasPrice().Uint64())
signedTx, err := opts.Signer(opts.From, rawTx)
if err != nil {
return err
}
err = ethClient.SendTransaction(ctx, signedTx)
r.logger.Info("submitted speed up transaction", "hash", signedTx.Hash().Hex(), "new_gas_price", signedTx.GasPrice().Uint64())
if err != nil {
r.logger.Debug("response of sending speed up transaction", "resp", err.Error())
}
Expand Down

0 comments on commit 4f82c1c

Please sign in to comment.