Skip to content

Commit

Permalink
Merge branch 'develop' into msg-abort-stuck-cctx
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Jan 25, 2024
2 parents e0186c5 + d940b94 commit 46e6c35
Show file tree
Hide file tree
Showing 17 changed files with 593 additions and 331 deletions.
15 changes: 6 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Unreleased


## Version: v12.1.0

### Tests
Expand All @@ -16,6 +15,8 @@
* [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
* [1650](https://github.com/zeta-chain/node/pull/1605) - exempt (discounted) *system txs* from min gas price check and gas fee deduction
* [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

### CI

Expand All @@ -26,6 +27,10 @@
* [1585](https://github.com/zeta-chain/node/pull/1585) - Updated release instructions
* [1615](https://github.com/zeta-chain/node/pull/1615) - Add upgrade handler for version v12.1.0

### Features

* [1591](https://github.com/zeta-chain/node/pull/1591) - support lower gas limit for voting on inbound and outbound transactions
* [1592](https://github.com/zeta-chain/node/issues/1592) - check inbound tracker tx hash against Tss address and some refactor on inTx observation

## Version: v12.0.0

Expand All @@ -49,8 +54,6 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
* `GetTssAddress` : Changed from `/zeta-chain/observer/get_tss_address/` to `/zeta-chain/observer/getTssAddress/{bitcoin_chain_id}` . Optional bitcoin chain id can now be passed as a parameter to fetch the correct tss for required BTC chain. This parameter only affects the BTC tss address in the response.

### Features

* [1549](https://github.com/zeta-chain/node/pull/1549) - add monitoring for vote tx results in ZetaClient
* [1498](https://github.com/zeta-chain/node/pull/1498) - Add monitoring(grafana, prometheus, ethbalance) for localnet testing
* [1395](https://github.com/zeta-chain/node/pull/1395) - Add state variable to track aborted zeta amount
* [1410](https://github.com/zeta-chain/node/pull/1410) - `snapshots` commands
Expand All @@ -60,8 +63,6 @@ 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
* [1516](https://github.com/zeta-chain/node/issues/1516) - Unprivileged outtx tracker removal
Expand All @@ -80,7 +81,6 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
* [1525](https://github.com/zeta-chain/node/pull/1525) - relax EVM chain block header length check 1024->4096
* [1522](https://github.com/zeta-chain/node/pull/1522/files) - block `distribution` module account from receiving zeta
* [1528](https://github.com/zeta-chain/node/pull/1528) - fix panic caused on decoding malformed BTC addresses
* [1557](https://github.com/zeta-chain/node/pull/1557) - remove decreaseAllowance and increaseAllowance checks
* [1536](https://github.com/zeta-chain/node/pull/1536) - add index to check previously finalized inbounds
* [1556](https://github.com/zeta-chain/node/pull/1556) - add emptiness check for topic array in event parsing
* [1546](https://github.com/zeta-chain/node/pull/1546) - fix reset of pending nonces on genesis import
Expand Down Expand Up @@ -109,7 +109,6 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
* Update --ledger flag hint

### Chores

* [1446](https://github.com/zeta-chain/node/pull/1446) - renamed file `zetaclientd/aux.go` to `zetaclientd/utils.go` to avoid complaints from go package resolver.
* [1499](https://github.com/zeta-chain/node/pull/1499) - Add scripts to localnet to help test gov proposals
* [1442](https://github.com/zeta-chain/node/pull/1442) - remove build types in `.goreleaser.yaml`
Expand All @@ -121,9 +120,7 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
* [1538](https://github.com/zeta-chain/node/pull/1538) - improve stateful e2e testing

### CI

* Removed private runners and unused GitHub Action
* Adding typescript publishing pipeline.

## Version: v11.0.0

Expand Down
1 change: 0 additions & 1 deletion cmd/zetae2e/local/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func erc20TestRoutine(
// run erc20 test
if err := erc20Runner.RunSmokeTestsFromNames(
smoketests.AllSmokeTests,
smoketests.TestMultipleERC20DepositName,
smoketests.TestWithdrawERC20Name,
smoketests.TestMultipleWithdrawsName,
smoketests.TestERC20DepositAndCallRefundName,
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd-genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ else
SEED=$(curl --retry 10 --retry-delay 5 --retry-connrefused -s zetaclient0:8123/p2p)
done
rm ~/.tss/*
zetaclientd init --peer /ip4/172.20.0.21/tcp/6668/p2p/"$SEED" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 0 --keyring-backend "$BACKEND"
zetaclientd init --peer /ip4/172.20.0.21/tcp/6668/p2p/"$SEED" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND"
zetaclientd start
fi
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ else
zetaclientd init \
--peer /ip4/172.20.0.21/tcp/6668/p2p/$SEED \
--pre-params ~/preParams.json --zetacore-url $node \
--chain-id athens_101-1 --operator zeta1lz2fqwzjnk6qy48fgj753h48444fxtt7hekp52 --log-level 0 --hotkey=val_grantee_observer
--chain-id athens_101-1 --operator zeta1lz2fqwzjnk6qy48fgj753h48444fxtt7hekp52 --log-level 1 --hotkey=val_grantee_observer
zetaclientd start
fi
55 changes: 52 additions & 3 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"sync"
"sync/atomic"
"time"

cosmosmath "cosmossdk.io/math"
"github.com/btcsuite/btcd/btcjson"
Expand Down Expand Up @@ -199,6 +200,54 @@ func (ob *BitcoinChainClient) Start() {
go ob.WatchUTXOS()
go ob.WatchGasPrice()
go ob.ExternalChainWatcherForNewInboundTrackerSuggestions()
go ob.RPCStatus()
}

func (ob *BitcoinChainClient) RPCStatus() {
ob.logger.ChainLogger.Info().Msgf("RPCStatus is starting")
ticker := time.NewTicker(60 * time.Second)

for {
select {
case <-ticker.C:
//ob.logger.ChainLogger.Info().Msgf("RPCStatus is running")
bn, err := ob.rpcClient.GetBlockCount()
if err != nil {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: RPC down? ")
continue
}
hash, err := ob.rpcClient.GetBlockHash(bn)
if err != nil {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: RPC down? ")
continue
}
header, err := ob.rpcClient.GetBlockHeader(hash)
if err != nil {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: RPC down? ")
continue
}
blockTime := header.Timestamp
elapsedSeconds := time.Since(blockTime).Seconds()
if elapsedSeconds > 1200 {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: RPC down? ")
continue
}
tssAddr := ob.Tss.BTCAddressWitnessPubkeyHash()
res, err := ob.rpcClient.ListUnspentMinMaxAddresses(0, 1000000, []btcutil.Address{tssAddr})
if err != nil {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: can't list utxos of TSS address; wallet or loaded? TSS address is not imported? ")
continue
}
if len(res) == 0 {
ob.logger.ChainLogger.Error().Err(err).Msg("RPC status check: TSS address has no utxos; TSS address is not imported? ")
continue
}
ob.logger.ChainLogger.Info().Msgf("[OK] RPC status check: latest block number %d, timestamp %s (%.fs ago), tss addr %s, #utxos: %d", bn, blockTime, elapsedSeconds, tssAddr, len(res))

case <-ob.stop:
return
}
}
}

func (ob *BitcoinChainClient) Stop() {
Expand Down Expand Up @@ -385,12 +434,12 @@ func (ob *BitcoinChainClient) observeInTx() error {
// post inbound vote message to zetacore
for _, inTx := range inTxs {
msg := ob.GetInboundVoteMessageFromBtcEvent(inTx)
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, msg)
if err != nil {
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: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.WatchInTx.Info().Msgf("observeInTxBTC: BTC deposit detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}
}

Expand Down Expand Up @@ -470,7 +519,7 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
}

logger.Debug().Msgf("Bitcoin outTx confirmed: txid %s, amount %s\n", res.TxID, amountInSat.String())
zetaHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
res.TxID,
// #nosec G701 always positive
Expand Down
8 changes: 3 additions & 5 deletions zetaclient/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
b.seqNumber[authzSigner.KeyType] = seqNumber
}
}
//b.logger.Info().Uint64("account_number", b.accountNumber).Uint64("sequence_number", b.seqNumber).Msg("account info")

flags := flag.NewFlagSet("zetacore", 0)

Expand All @@ -73,12 +72,13 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
if err != nil {
return "", err
}

builder.SetGasLimit(gaslimit)

// #nosec G701 always in range
fee := sdktypes.NewCoins(sdktypes.NewCoin(config.BaseDenom,
cosmos.NewInt(int64(gaslimit)).Mul(adjustedBaseGasPrice.Ceil().RoundInt())))
builder.SetFeeAmount(fee)
//fmt.Printf("signing from name: %s\n", ctx.GetFromName())
err = b.SignTx(factory, ctx.GetFromName(), builder, true, ctx.TxConfig)
if err != nil {
return "", err
Expand All @@ -94,6 +94,7 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
b.logger.Error().Err(err).Msgf("fail to broadcast tx %s", err.Error())
return "", err
}

// Code will be the tendermint ABICode , it start at 1 , so if it is an error , code will not be zero
if commit.Code > 0 {
if commit.Code == 32 {
Expand All @@ -118,11 +119,8 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
}
return commit.TxHash, fmt.Errorf("fail to broadcast to zetachain,code:%d, log:%s", commit.Code, commit.RawLog)
}
//b.logger.Debug().Msgf("Received a TxHash of %v from the metachain, Code %d, log %s", commit.TxHash, commit.Code, commit.Logs)

// increment seqNum
//seq := b.seqNumber[authzSigner.KeyType]
//atomic.AddUint64(&seq, 1)
b.seqNumber[authzSigner.KeyType] = b.seqNumber[authzSigner.KeyType] + 1

return commit.TxHash, nil
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/btc_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ func (signer *BTCSigner) SignWithdrawTx(
signer.logger.Info().Msgf("sizeLimit %d is less than txSize %d for nonce %d", sizeLimit, txSize, nonce)
}
if txSize < outTxBytesMin { // outbound shouldn't be blocked a low sizeLimit
signer.logger.Warn().Msgf("sizeLimit %d is less than outTxBytesMin %d; use outTxBytesMin", sizeLimit, outTxBytesMin)
signer.logger.Warn().Msgf("txSize %d is less than outTxBytesMin %d; use outTxBytesMin", txSize, outTxBytesMin)
txSize = outTxBytesMin
}
if txSize > outTxBytesMax { // in case of accident
signer.logger.Warn().Msgf("sizeLimit %d is greater than outTxBytesMax %d; use outTxBytesMax", sizeLimit, outTxBytesMax)
signer.logger.Warn().Msgf("txSize %d is greater than outTxBytesMax %d; use outTxBytesMax", txSize, outTxBytesMax)
txSize = outTxBytesMax
}

Expand Down
Loading

0 comments on commit 46e6c35

Please sign in to comment.