diff --git a/assembler/greenfield_assembler.go b/assembler/greenfield_assembler.go index c201cd0..2d598fe 100644 --- a/assembler/greenfield_assembler.go +++ b/assembler/greenfield_assembler.go @@ -249,9 +249,8 @@ func (a *GreenfieldAssembler) processTx(tx *model.GreenfieldRelayTransaction, no // sequence update, so they can track next start seq from chain if !isInturnRelyer { if err = a.daoManager.GreenfieldDao.UpdateTransactionClaimedTxHash(tx.Id, txHash.String()); err != nil { - return err + return fmt.Errorf("failed to update transaciton status, err=%s", err.Error()) } - return fmt.Errorf("failed to update transaciton status, err=%s", err.Error()) } if err = a.daoManager.GreenfieldDao.UpdateTransactionStatusAndClaimedTxHash(tx.Id, db.Delivered, txHash.String()); err != nil { diff --git a/executor/bsc_executor.go b/executor/bsc_executor.go index 2dcfe33..0710654 100644 --- a/executor/bsc_executor.go +++ b/executor/bsc_executor.go @@ -571,21 +571,20 @@ func (e *BSCExecutor) ClaimRewardLoop() { continue } logging.Logger.Infof("current relayer balance is %v", balance) + balance.Div(balance, BSCBalanceThreshold) + e.metricService.SetBSCBalance(float64(balance.Int64())) // should not claim if balance > 1 BNB if balance.Cmp(BSCBalanceThreshold) > 0 { - e.metricService.SetBSCLowBalance(false) continue } rewardBalance, err := e.getRewardBalance() if err != nil { - e.metricService.SetBSCLowBalance(true) logging.Logger.Errorf("failed to get relayer reward balance err=%s", err.Error()) continue } logging.Logger.Infof("current relayer reward balance is %v", balance) if rewardBalance.Cmp(BSCRewardThreshold) <= 0 { - e.metricService.SetBSCLowBalance(true) continue } // > 0.1 BNB diff --git a/executor/const.go b/executor/const.go index a38c25b..7f9632f 100644 --- a/executor/const.go +++ b/executor/const.go @@ -19,4 +19,5 @@ const ( var ( BSCBalanceThreshold = big.NewInt(1000000000000000000) // when relayer is lower than 1BNB, it should try to claim rewards BSCRewardThreshold = big.NewInt(100000000000000000) // if reward is lower than 0.1 BNB, it will not be claimed. + ) diff --git a/metric/service.go b/metric/service.go index 87e8a94..43e01dc 100644 --- a/metric/service.go +++ b/metric/service.go @@ -27,7 +27,7 @@ const ( MetricNameNextSendSequenceForChannel = "next_send_seq_for_channel" MetricNameNextReceiveSequenceForChannel = "next_receive_seq_for_channel" - MetricNameBSCLowBalance = "bsc_low_balance" + MetricNameBSCBalance = "bsc_balance" MetricNameHasTxDelay = "tx_delay" ) @@ -165,10 +165,10 @@ func NewMetricService(config *config.Config) *MetricService { } bscLowBalanceMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameBSCLowBalance, - Help: "BSC relayer balance is lower than 1BNB, and not enoght reward(<0.1BNB)", + Name: MetricNameBSCBalance, + Help: "BSC relayer balance", }) - ms[MetricNameBSCLowBalance] = bscLowBalanceMetric + ms[MetricNameBSCBalance] = bscLowBalanceMetric prometheus.MustRegister(bscLowBalanceMetric) hasTxDelayMetric := prometheus.NewGauge(prometheus.GaugeOpts{ @@ -260,12 +260,8 @@ func (m *MetricService) SetNextReceiveSequenceForChannel(channel uint8, seq uint m.MetricsMap[fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, channel)].(prometheus.Gauge).Set(float64(seq)) } -func (m *MetricService) SetBSCLowBalance(isLow bool) { - var flag float64 - if isLow { - flag = 1 - } - m.MetricsMap[MetricNameBSCLowBalance].(prometheus.Gauge).Set(flag) +func (m *MetricService) SetBSCBalance(balance float64) { + m.MetricsMap[MetricNameBSCBalance].(prometheus.Gauge).Set(balance) } func (m *MetricService) SetHasTxDelay(hasDelay bool) { diff --git a/vote/greenfield_vote_processor.go b/vote/greenfield_vote_processor.go index ed15dab..9672728 100644 --- a/vote/greenfield_vote_processor.go +++ b/vote/greenfield_vote_processor.go @@ -60,8 +60,7 @@ func (p *GreenfieldVoteProcessor) SignAndBroadcastLoop() { func (p *GreenfieldVoteProcessor) signAndBroadcast() error { txs, err := p.daoManager.GreenfieldDao.GetTransactionsByStatusWithLimit(db.Saved, p.config.VotePoolConfig.VotesBatchMaxSizePerInterval) if err != nil { - logging.Logger.Errorf("failed to get transactions from db, error: %s", err.Error()) - return err + return fmt.Errorf("failed to get transactions from db, error: %s", err.Error()) } if len(txs) == 0 { return nil @@ -97,7 +96,6 @@ func (p *GreenfieldVoteProcessor) signAndBroadcast() error { if err != nil { return fmt.Errorf("failed to submit vote for event with channel id %d and sequence %d, err=%s", tx.ChannelId, tx.Sequence, err.Error()) } - return nil }, retry.Context(context.Background()), rcommon.RtyAttem, rcommon.RtyDelay, rcommon.RtyErr); err != nil { return err