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: zetaclient should check 'IsSupported' flag to pause/unpause a specific chain #1969

Merged
merged 7 commits into from
Apr 3, 2024
Merged
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

* [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

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
237 changes: 127 additions & 110 deletions zetaclient/bitcoin/bitcoin_client.go

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions zetaclient/bitcoin/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@
"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)

Check warning on line 15 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L14-L15

Added lines #L14 - L15 were not covered by tests
if err != nil {
ob.logger.WatchInTx.Err(err).Msg("error creating ticker")
ob.logger.InTx.Err(err).Msg("error creating ticker")

Check warning on line 17 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L17

Added line #L17 was not covered by tests
return
}

defer ticker.Stop()
for {
select {
case <-ticker.C():
if !ob.GetChainParams().IsSupported {
continue

Check warning on line 26 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L25-L26

Added lines #L25 - L26 were not covered by tests
}
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)

Check warning on line 30 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L30

Added line #L30 was not covered by tests
}
ticker.UpdateInterval(ob.GetChainParams().InTxTicker, ob.logger.WatchInTx)
ticker.UpdateInterval(ob.GetChainParams().InTxTicker, ob.logger.InTx)

Check warning on line 32 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L32

Added line #L32 was not covered by tests
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)

Check warning on line 34 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L34

Added line #L34 was not covered by tests
return
}
}
Expand All @@ -39,12 +43,12 @@
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)

Check warning on line 46 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L46

Added line #L46 was not covered by tests
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())

Check warning on line 51 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L51

Added line #L51 was not covered by tests
}
return nil
}
Expand All @@ -69,13 +73,13 @@
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)

Check warning on line 76 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L76

Added line #L76 was not covered by tests
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)

Check warning on line 82 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L82

Added line #L82 was not covered by tests
if err != nil {
return "", err
}
Expand All @@ -91,10 +95,10 @@
}
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")

Check warning on line 98 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L98

Added line #L98 was not covered by tests
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",

Check warning on line 101 in zetaclient/bitcoin/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/bitcoin/inbound_tracker.go#L101

Added line #L101 was not covered by tests
zetaHash, txHash, ballot, depositorFee)
}
return msg.Digest(), nil
Expand Down
Loading
Loading