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: Trailofbits - make sure block number always increases #1639

Merged
merged 10 commits into from
Jan 31, 2024
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Fixes
* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases
* [1610](https://github.com/zeta-chain/node/issues/1610) - add pending outtx hash to tracker after monitoring for 10 minutes

## Version: v12.1.0
Expand Down
12 changes: 8 additions & 4 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,13 @@ func (ob *BitcoinChainClient) observeInTx() error {
// get and update latest block height
cnt, err := ob.rpcClient.GetBlockCount()
if err != nil {
return fmt.Errorf("observeInTxBTC: error getting block count: %s", err)
return fmt.Errorf("observeInTxBTC: error getting block number: %s", err)
}
if cnt < 0 {
return fmt.Errorf("observeInTxBTC: block count is negative: %d", cnt)
return fmt.Errorf("observeInTxBTC: block number is negative: %d", cnt)
}
if cnt < ob.GetLastBlockHeight() {
return fmt.Errorf("observeInTxBTC: block number should not decrease: current %d last %d", cnt, ob.GetLastBlockHeight())
}
ob.SetLastBlockHeight(cnt)

Expand Down Expand Up @@ -439,7 +442,7 @@ func (ob *BitcoinChainClient) observeInTx() error {
ob.logger.WatchInTx.Error().Err(err).Msgf("observeInTxBTC: error posting to zeta core for tx %s", inTx.TxHash)
return err // we have to re-scan this block next time
} else if zetaHash != "" {
ob.logger.WatchInTx.Info().Msgf("observeInTxBTC: BTC deposit detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.WatchInTx.Info().Msgf("observeInTxBTC: PostVoteInbound zeta tx hash: %s inTx %s ballot %s", zetaHash, inTx.TxHash, ballot)
}
}

Expand Down Expand Up @@ -633,11 +636,12 @@ func FilterAndParseIncomingTx(
}
inTx, err := GetBtcEvent(tx, targetAddress, blockNumber, logger, chainID)
if err != nil {
logger.Error().Err(err).Msg("error getting btc event")
logger.Error().Err(err).Msgf("FilterAndParseIncomingTx: error getting btc event for tx %s in block %d", tx.Txid, blockNumber)
continue
}
if inTx != nil {
inTxs = append(inTxs, inTx)
logger.Info().Msgf("FilterAndParseIncomingTx: found btc event for tx %s in block %d", tx.Txid, blockNumber)
}
}
return inTxs
Expand Down
3 changes: 3 additions & 0 deletions zetaclient/evm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,9 @@ func (ob *EVMChainClient) observeInTX(sampledLogger zerolog.Logger) error {
if err != nil {
return err
}
if blockNumber < ob.GetLastBlockHeight() {
return fmt.Errorf("observeInTX: block number should not decrease: current %d last %d", blockNumber, ob.GetLastBlockHeight())
}
ob.SetLastBlockHeight(blockNumber)

// increment prom counter
Expand Down
Loading