diff --git a/CHANGELOG.md b/CHANGELOG.md index faf4a333..a0a83043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### Bug Fixes + +* [#154](https://github.com/babylonlabs-io/vigilante/pull/154) fix: panic in maybeResendSecondTxOfCheckpointToBTC + ## v0.19.0 ### Bug Fixes diff --git a/config/grpc.go b/config/grpc.go index 8df1c000..080af103 100644 --- a/config/grpc.go +++ b/config/grpc.go @@ -1,10 +1,5 @@ package config -const ( - // DefaultGRPCAddress defines the default address to bind the gRPC server to. - DefaultGRPCAddress = "0.0.0.0:8080" -) - // GRPCConfig defines configuration for the gRPC server. type GRPCConfig struct { OneTimeTLSKey bool `mapstructure:"onetime-tls-key"` diff --git a/config/grpcweb.go b/config/grpcweb.go index fa301452..3debd0a7 100644 --- a/config/grpcweb.go +++ b/config/grpcweb.go @@ -1,10 +1,5 @@ package config -const ( - // DefaultGRPCWebAddress defines the default address to bind the gRPC-web server to. - DefaultGRPCWebAddress = "0.0.0.0:8081" -) - // GRPCWebConfig defines configuration for the gRPC-web server. type GRPCWebConfig struct { Placeholder string `mapstructure:"placeholder"` diff --git a/submitter/relayer/relayer.go b/submitter/relayer/relayer.go index e5122ea3..3001d261 100644 --- a/submitter/relayer/relayer.go +++ b/submitter/relayer/relayer.go @@ -192,16 +192,20 @@ func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpoint return nil } - rl.logger.Debugf("Resending the second tx of the checkpoint %v, old fee of the second tx: %v Satoshis, txid: %s", + rl.logger.Debugf("Maybe resending the second tx of the checkpoint %v, old fee of the second tx: %v Satoshis, txid: %s", ckptEpoch, rl.lastSubmittedCheckpoint.Tx2.Fee, rl.lastSubmittedCheckpoint.Tx2.TxID.String()) - resubmittedTx2, err := rl.resendSecondTxOfCheckpointToBTC(rl.lastSubmittedCheckpoint.Tx2, bumpedFee) + resubmittedTx2, err := rl.maybeResendSecondTxOfCheckpointToBTC(rl.lastSubmittedCheckpoint.Tx2, bumpedFee) if err != nil { rl.metrics.FailedResentCheckpointsCounter.Inc() return fmt.Errorf("failed to re-send the second tx of the checkpoint %v: %w", rl.lastSubmittedCheckpoint.Epoch, err) } + if resubmittedTx2 == nil { + return nil + } + // record the metrics of the resent tx2 rl.metrics.NewSubmittedCheckpointSegmentGaugeVec.WithLabelValues( strconv.FormatUint(ckptEpoch, 10), @@ -255,17 +259,16 @@ func (rl *Relayer) calculateBumpedFee(ckptInfo *types.CheckpointInfo) btcutil.Am return ckptInfo.Tx2.Fee.MulF64(rl.config.ResubmitFeeMultiplier) } -// resendSecondTxOfCheckpointToBTC resends the second tx of the checkpoint with bumpedFee -func (rl *Relayer) resendSecondTxOfCheckpointToBTC(tx2 *types.BtcTxInfo, bumpedFee btcutil.Amount) (*types.BtcTxInfo, error) { - _, status, err := rl.TxDetails(rl.lastSubmittedCheckpoint.Tx2.TxID, - rl.lastSubmittedCheckpoint.Tx2.Tx.TxOut[changePosition].PkScript) +// maybeResendSecondTxOfCheckpointToBTC resends the second tx of the checkpoint with bumpedFee +func (rl *Relayer) maybeResendSecondTxOfCheckpointToBTC(tx2 *types.BtcTxInfo, bumpedFee btcutil.Amount) (*types.BtcTxInfo, error) { + _, status, err := rl.TxDetails(tx2.TxID, tx2.Tx.TxOut[changePosition].PkScript) if err != nil { return nil, err } // No need to resend, transaction already confirmed if status == btcclient.TxInChain { - rl.logger.Debugf("Transaction %v is already confirmed", rl.lastSubmittedCheckpoint.Tx2.TxID) + rl.logger.Debugf("Transaction %v is already confirmed", tx2.TxID) return nil, nil }