Skip to content

Commit

Permalink
fix: Trailofbits - make sure block number always increases (#1639)
Browse files Browse the repository at this point in the history
* make sure block number always increases

* update changelog

* added log prints

* update changelog

---------

Co-authored-by: Lucas Bertrand <[email protected]>
  • Loading branch information
ws4charlie and lumtis authored Jan 31, 2024
1 parent 6c9afe0 commit 83568e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases
* [1672](https://github.com/zeta-chain/node/pull/1672) - paying 50% more than base gas price to buffer EIP1559 gas price increase
* [1642](https://github.com/zeta-chain/node/pull/1642) - Change WhitelistERC20 authorization from group1 to group2
* [1610](https://github.com/zeta-chain/node/issues/1610) - add pending outtx hash to tracker after monitoring for 10 minutes
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 @@ -940,6 +940,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

0 comments on commit 83568e2

Please sign in to comment.