Skip to content

Commit

Permalink
Merge pull request #97 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare for release v1.0.1
  • Loading branch information
alexgao001 authored Oct 17, 2023
2 parents ff65f3a + 4378f3b commit 6afcf08
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
3 changes: 1 addition & 2 deletions assembler/greenfield_assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions executor/bsc_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions executor/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

)
16 changes: 6 additions & 10 deletions metric/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions vote/greenfield_vote_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6afcf08

Please sign in to comment.