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: check crosschain flags to stop inbound/outbound; get rid of outtx tracker iteration timeout #1978

Closed
wants to merge 5 commits into from
Closed
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
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@

* [1861](https://github.com/zeta-chain/node/pull/1861) - fix `ObserverSlashAmount` invalid read
* [1880](https://github.com/zeta-chain/node/issues/1880) - lower the gas price multiplier for EVM chains.
* [1883](https://github.com/zeta-chain/node/issues/1883) - zetaclient should check 'IsSupported' flag to pause/unpause a specific chain
* [1633](https://github.com/zeta-chain/node/issues/1633) - zetaclient should be able to pick up new connector and erc20Custody addresses
* [1944](https://github.com/zeta-chain/node/pull/1944) - fix evm signer unit tests
* [1888](https://github.com/zeta-chain/node/issues/1888) - zetaclient should stop inbound/outbound txs according to cross-chain flags
* [1970](https://github.com/zeta-chain/node/issues/1970) - remove the timeout in the evm outtx tracker processing thread

### Chores

Expand Down
8 changes: 1 addition & 7 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func CreateSignerMap(
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
if !evmChainParams.IsSupported {
continue
}
mpiAddress := ethcommon.HexToAddress(evmChainParams.ConnectorContractAddress)
erc20CustodyAddress := ethcommon.HexToAddress(evmChainParams.Erc20CustodyContractAddress)
signer, err := evm.NewEVMSigner(
Expand Down Expand Up @@ -117,14 +114,11 @@ func CreateChainClientMap(
if evmConfig.Chain.IsZetaChain() {
continue
}
evmChainParams, found := appContext.ZetaCoreContext().GetEVMChainParams(evmConfig.Chain.ChainId)
_, found := appContext.ZetaCoreContext().GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
if !evmChainParams.IsSupported {
continue
}
co, err := evm.NewEVMChainClient(appContext, bridge, tss, dbpath, loggers, evmConfig, ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewEVMChainClient error for chain %s", evmConfig.Chain.String())
Expand Down
259 changes: 143 additions & 116 deletions zetaclient/bitcoin/bitcoin_client.go

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions zetaclient/bitcoin/bitcoin_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,3 @@ func TestCheckTSSVoutCancelled(t *testing.T) {
require.ErrorContains(t, err, "not match TSS address")
})
}

func TestBTCChainClient_ObserveInTx(t *testing.T) {
t.Run("should return error", func(t *testing.T) {
// create mainnet mock client
btcClient := MockBTCClientMainnet()
err := btcClient.ObserveInTx()
require.ErrorContains(t, err, "inbound TXS / Send has been disabled by the protocol")
})
}
31 changes: 19 additions & 12 deletions zetaclient/bitcoin/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ import (
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"
)

func (ob *BTCChainClient) ExternalChainWatcherForNewInboundTrackerSuggestions() {
ticker, err := types.NewDynamicTicker("Bitcoin_WatchInTx_InboundTrackerSuggestions", ob.GetChainParams().InTxTicker)
// WatchIntxTracker watches zetacore for bitcoin intx trackers
func (ob *BTCChainClient) WatchIntxTracker() {
ticker, err := types.NewDynamicTicker("Bitcoin_WatchIntxTracker", ob.GetChainParams().InTxTicker)
if err != nil {
ob.logger.WatchInTx.Err(err).Msg("error creating ticker")
ob.logger.InTx.Err(err).Msg("error creating ticker")
return
}

defer ticker.Stop()
for {
select {
case <-ticker.C():
if flags := ob.coreContext.GetCrossChainFlags(); !flags.IsInboundEnabled {
continue
}
if !ob.GetChainParams().IsSupported {
continue
}
err := ob.ObserveTrackerSuggestions()
if err != nil {
ob.logger.WatchInTx.Error().Err(err).Msg("error observing in tx")
ob.logger.InTx.Error().Err(err).Msgf("error observing intx tracker for chain %d", ob.chain.ChainId)
}
ticker.UpdateInterval(ob.GetChainParams().InTxTicker, ob.logger.WatchInTx)
ticker.UpdateInterval(ob.GetChainParams().InTxTicker, ob.logger.InTx)
case <-ob.stop:
ob.logger.WatchInTx.Info().Msg("ExternalChainWatcher for BTC inboundTrackerSuggestions stopped")
ob.logger.InTx.Info().Msgf("WatchIntxTracker stopped for chain %d", ob.chain.ChainId)
return
}
}
Expand All @@ -39,12 +46,12 @@ func (ob *BTCChainClient) ObserveTrackerSuggestions() error {
return err
}
for _, tracker := range trackers {
ob.logger.WatchInTx.Info().Msgf("checking tracker with hash :%s and coin-type :%s ", tracker.TxHash, tracker.CoinType)
ob.logger.InTx.Info().Msgf("checking tracker with hash :%s and coin-type :%s ", tracker.TxHash, tracker.CoinType)
ballotIdentifier, err := ob.CheckReceiptForBtcTxHash(tracker.TxHash, true)
if err != nil {
return err
}
ob.logger.WatchInTx.Info().Msgf("Vote submitted for inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, coin.CoinType_Gas.String())
ob.logger.InTx.Info().Msgf("Vote submitted for inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, coin.CoinType_Gas.String())
}
return nil
}
Expand All @@ -69,13 +76,13 @@ func (ob *BTCChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool) (st
if len(blockVb.Tx) <= 1 {
return "", fmt.Errorf("block %d has no transactions", blockVb.Height)
}
depositorFee := CalcDepositorFee(blockVb, ob.chain.ChainId, ob.netParams, ob.logger.WatchInTx)
depositorFee := CalcDepositorFee(blockVb, ob.chain.ChainId, ob.netParams, ob.logger.InTx)
tss, err := ob.zetaClient.GetBtcTssAddress(ob.chain.ChainId)
if err != nil {
return "", err
}
// #nosec G701 always positive
event, err := GetBtcEvent(*tx, tss, uint64(blockVb.Height), &ob.logger.WatchInTx, ob.netParams, depositorFee)
event, err := GetBtcEvent(*tx, tss, uint64(blockVb.Height), &ob.logger.InTx, ob.netParams, depositorFee)
if err != nil {
return "", err
}
Expand All @@ -91,10 +98,10 @@ func (ob *BTCChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool) (st
}
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(zetabridge.PostVoteInboundGasLimit, zetabridge.PostVoteInboundExecutionGasLimit, msg)
if err != nil {
ob.logger.WatchInTx.Error().Err(err).Msg("error posting to zeta core")
ob.logger.InTx.Error().Err(err).Msg("error posting to zeta core")
return "", err
} else if zetaHash != "" {
ob.logger.WatchInTx.Info().Msgf("BTC deposit detected and reported: PostVoteInbound zeta tx hash: %s inTx %s ballot %s fee %v",
ob.logger.InTx.Info().Msgf("BTC deposit detected and reported: PostVoteInbound zeta tx hash: %s inTx %s ballot %s fee %v",
zetaHash, txHash, ballot, depositorFee)
}
return msg.Digest(), nil
Expand Down
Loading
Loading