Skip to content

Commit

Permalink
wrap a few log prints into fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Nov 25, 2024
1 parent 82a08fa commit 5644b3c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zetaclient/chains/bitcoin/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (signer *Signer) TryProcessOutbound(
logger.Error().Err(err).Msg("cannot get signer address")
return
}
lf["signer"] = signerAddress.String()

// get size limit and gas price
sizelimit := params.CallOptions.GasLimit
Expand Down Expand Up @@ -457,35 +458,34 @@ func (signer *Signer) TryProcessOutbound(
_, err = zetacoreClient.GetObserverList(ctx)
if err != nil {
logger.Warn().
Err(err).
Msgf("unable to get observer list, observation %s", observertypes.ObservationType_OutboundTx.String())
Err(err).Stringer("observation_type", observertypes.ObservationType_OutboundTx).
Msg("unable to get observer list, observation")
}
if tx != nil {
outboundHash := tx.TxHash().String()
logger.Info().Msgf("signed outboundHash %s signer %s", outboundHash, signerAddress)
lf[logs.FieldTx] = outboundHash

// try broacasting tx with increasing backoff (1s, 2s, 4s, 8s, 16s) in case of RPC error
backOff := broadcastBackoff
for i := 0; i < broadcastRetries; i++ {
time.Sleep(backOff)
err := signer.Broadcast(tx)
if err != nil {
logger.Warn().Err(err).Msgf("broadcasting tx %s to chain %s, retry %d", outboundHash, chain.Name, i)
logger.Warn().Err(err).Fields(lf).Msgf("Broadcasting Bitcoin tx, retry %d", i)
backOff *= 2
continue
}
logger.Info().Msgf("Broadcast success: chain %s outboundHash %s", chain.String(), outboundHash)
logger.Info().Fields(lf).Msgf("Broadcast Bitcoin tx successfully")
zetaHash, err := zetacoreClient.PostOutboundTracker(
ctx,
chain.ChainId,
outboundTssNonce,
outboundHash,
)
if err != nil {
logger.Err(err).
Msgf("Unable to add to tracker on zetacore: chain %s outboundHash %s", chain.Name, outboundHash)
logger.Err(err).Fields(lf).Msgf("Unable to add Bitcoin outbound tracker")
}
logger.Info().Msgf("Broadcast to core successful %s", zetaHash)
logger.Info().Msgf("Add Bitcoin outbound tracker successfully %s", zetaHash)

// Save successfully broadcasted transaction to btc chain observer
btcObserver.SaveBroadcastedTx(outboundHash, outboundTssNonce)
Expand Down

0 comments on commit 5644b3c

Please sign in to comment.