From 3ae445d9f4d8d2525452673c2aa8403991716af3 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 25 Jan 2024 10:33:49 -0600 Subject: [PATCH 1/4] make sure block number always increases --- zetaclient/bitcoin_client.go | 7 +++++-- zetaclient/evm_client.go | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index a82e3a44cb..9514238f64 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -323,10 +323,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) diff --git a/zetaclient/evm_client.go b/zetaclient/evm_client.go index d88ee980f9..35390a1d1d 100644 --- a/zetaclient/evm_client.go +++ b/zetaclient/evm_client.go @@ -867,6 +867,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 From 305fc8fee157a07b7b480cbe05b83ff2c25f1289 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 25 Jan 2024 11:38:17 -0600 Subject: [PATCH 2/4] update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 037accc506..8af90cbcc4 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ * [1535](https://github.com/zeta-chain/node/issues/1535) - Avoid voting on wrong ballots due to false blockNumber in EVM tx receipt * [1588](https://github.com/zeta-chain/node/pull/1588) - fix chain params comparison logic +* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases * [1650](https://github.com/zeta-chain/node/pull/1605) - exempt (discounted) *system txs* from min gas price check and gas fee deduction ### CI From 3ba6f7e89fc3f72542dce4737aa69888c6c23e35 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 25 Jan 2024 23:22:57 -0600 Subject: [PATCH 3/4] added log prints --- zetaclient/bitcoin_client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index 3cff685b68..5dee82bdb8 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -442,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) } } @@ -636,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 From f70a0ddba4bcb1011e2ba40682f2eddf5cb41f6b Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Fri, 26 Jan 2024 11:47:53 -0600 Subject: [PATCH 4/4] update changelog --- changelog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 93340481f5..9d707e19e0 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixes +* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases + ## Version: v12.1.0 ### Tests @@ -12,7 +15,6 @@ ### Fixes * [1535](https://github.com/zeta-chain/node/issues/1535) - Avoid voting on wrong ballots due to false blockNumber in EVM tx receipt * [1588](https://github.com/zeta-chain/node/pull/1588) - fix chain params comparison logic -* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases * [1650](https://github.com/zeta-chain/node/pull/1605) - exempt (discounted) *system txs* from min gas price check and gas fee deduction * [1632](https://github.com/zeta-chain/node/pull/1632) - set keygen to `KeygenStatus_KeyGenSuccess` if its in `KeygenStatus_PendingKeygen`. * [1576](https://github.com/zeta-chain/node/pull/1576) - Fix zetaclient crash due to out of bound integer conversion and log prints.