Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: zetaclient crash due to out of bound int conversion #1576

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c

### Fixes

* [1576](https://github.com/zeta-chain/node/pull/1576) - Fix zetaclient crash due to out of bound integer conversion and log prints.
* [1575](https://github.com/zeta-chain/node/issues/1575) - Skip unsupported chain parameters by IsSupported flag
* [1554](https://github.com/zeta-chain/node/pull/1554) - Screen out unconfirmed UTXOs that are not created by TSS itself
* [1560](https://github.com/zeta-chain/node/issues/1560) - Zetaclient post evm-chain outtx hashes only when receipt is available
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ func (ob *BitcoinChainClient) LoadLastBlock() error {
if ob.chain.ChainId == 18444 { // bitcoin regtest: start from block 100
ob.SetLastBlockHeightScanned(100)
}
ob.logger.ChainLogger.Info().Msgf("%s: start scanning from block %d", ob.chain.String(), ob.lastBlock)
ob.logger.ChainLogger.Info().Msgf("%s: start scanning from block %d", ob.chain.String(), ob.GetLastBlockHeightScanned())

return nil
}
Expand Down
7 changes: 4 additions & 3 deletions zetaclient/zetacore_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zetaclient

import (
"fmt"
"math"
"strings"
"time"

Expand Down Expand Up @@ -158,7 +159,7 @@ func (co *CoreObserver) startCctxScheduler() {
co.logger.ZetaChainWatcher.Error().Err(err).Msgf("couldn't get operator balance")
} else {
diff := co.lastOperatorBalance.Sub(balance)
if diff.GT(sdkmath.NewInt(0)) {
if diff.GT(sdkmath.NewInt(0)) && diff.LT(sdkmath.NewInt(math.MaxInt64)) {
co.ts.AddFeeEntry(bn, diff.Int64())
co.lastOperatorBalance = balance
}
Expand Down Expand Up @@ -355,7 +356,7 @@ func (co *CoreObserver) getUpdatedChainOb(chainID int64) (ChainClient, error) {
curParams := chainOb.GetChainParams()
if common.IsEVMChain(chainID) {
evmCfg, found := co.cfg.GetEVMConfig(chainID)
if found && curParams != evmCfg.ChainParams {
if found && curParams.String() != evmCfg.ChainParams.String() {
chainOb.SetChainParams(evmCfg.ChainParams)
co.logger.ZetaChainWatcher.Info().Msgf(
"updated chain params for chainID %d, new params: %v",
Expand All @@ -365,7 +366,7 @@ func (co *CoreObserver) getUpdatedChainOb(chainID int64) (ChainClient, error) {
}
} else if common.IsBitcoinChain(chainID) {
_, btcCfg, found := co.cfg.GetBTCConfig()
if found && curParams != btcCfg.ChainParams {
if found && curParams.String() != btcCfg.ChainParams.String() {
chainOb.SetChainParams(btcCfg.ChainParams)
co.logger.ZetaChainWatcher.Info().Msgf(
"updated chain params for Bitcoin, new params: %v",
Expand Down