Skip to content

Commit

Permalink
log rawTx when fail to send tx
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Kanda <[email protected]>
  • Loading branch information
dai1975 committed Jul 25, 2024
1 parent 28f687f commit 0f900c1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/relay/ethereum/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,25 @@ func (iter *CallIter) sendSingleTx(ctx context.Context, c *Chain) (*gethtypes.Tr
opts.GasLimit = txGasLimit
}

// add raw tx to log attribute
var hexTx string
{
tx, err := c.SendTx(opts, iter.Current(), iter.skipUpdateClientCommitment)
if err != nil {
logger.Error("failed to build tx with real send parameters", err)
return nil, err
}
if rawTxData, err := tx.MarshalBinary(); err != nil {
logger.Error("failed to encode tx", err)
} else {
hexTx = hex.EncodeToString(rawTxData)
}
}

opts.NoSend = false
tx, err := c.SendTx(opts, iter.Current(), iter.skipUpdateClientCommitment)
if err != nil {
logger.Logger = logger.With(logAttrRawTxData, hexTx)
logger.Error("failed to send msg", err)
return nil, err
}
Expand Down Expand Up @@ -660,9 +676,26 @@ func (iter *CallIter) sendMultiTx(ctx context.Context, c *Chain) (*gethtypes.Tra
}

opts.GasLimit = lastOkGasLimit

// add raw tx to log attribute
var hexTx string
{
tx, err := c.multicall3.Aggregate(opts, lastOkCalls)
if err != nil {
logger.Error("failed to build multicall tx with real send parameters", err)
return nil, err
}
if rawTxData, err := tx.MarshalBinary(); err != nil {
logger.Error("failed to encode multicall tx", err)
} else {
hexTx = hex.EncodeToString(rawTxData)
}
}

opts.NoSend = false
tx, err := c.multicall3.Aggregate(opts, lastOkCalls)
if err != nil {
logger.Logger = logger.With(logAttrRawTxData, hexTx)
logger.Error("failed to send multicall tx", err)
return nil, err
}
Expand Down

0 comments on commit 0f900c1

Please sign in to comment.