Skip to content

Commit

Permalink
add intx debugger for btc
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Oct 3, 2023
1 parent 306f5ef commit 994ec15
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func DebugCmd() *cobra.Command {
return err
}
if isPending {
return fmt.Errorf("tx is still pending")
}

for _, chainCoreParams := range coreParams {
Expand Down Expand Up @@ -148,6 +149,7 @@ func DebugCmd() *cobra.Command {
}
obBtc.WithZetaClient(bridge)
obBtc.WithLogger(chainLogger)
obBtc.WithChain(*common.GetChainFromChainID(chainID))
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
User: cfg.BitcoinConfig.RPCUsername,
Expand Down
8 changes: 8 additions & 0 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ func (ob *BitcoinChainClient) WithBtcClient(client *rpcclient.Client) {
ob.rpcClient = client
}

func (ob *BitcoinChainClient) WithChain(chain common.Chain) {
ob.Mu.Lock()
defer ob.Mu.Unlock()
ob.chain = chain
}

func (ob *BitcoinChainClient) SetCoreParams(params observertypes.CoreParams) {
ob.Mu.Lock()
defer ob.Mu.Unlock()
Expand Down Expand Up @@ -177,6 +183,7 @@ func (ob *BitcoinChainClient) Start() {
go ob.observeOutTx()
go ob.WatchUTXOS()
go ob.WatchGasPrice()
go ob.ExternalChainWatcherForNewInboundTrackerSuggestions()
}

func (ob *BitcoinChainClient) Stop() {
Expand Down Expand Up @@ -564,6 +571,7 @@ func GetBtcEvent(tx btcjson.TxRawResult, targetAddress string, blockNumber uint6

}
if found {
fmt.Println("found tx: ", tx.Txid)
var fromAddress string
if len(tx.Vin) > 0 {
vin := tx.Vin[0]
Expand Down
1 change: 1 addition & 0 deletions zetaclient/chainclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ type ChainClient interface {
GetPromGauge(name string) (prometheus.Gauge, error)
GetPromCounter(name string) (prometheus.Counter, error)
GetTxID(nonce uint64) string
ExternalChainWatcherForNewInboundTrackerSuggestions()
}
9 changes: 4 additions & 5 deletions zetaclient/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (ob *BitcoinChainClient) ObserveTrackerSuggestions() error {
if err != nil {
return err
}
ob.logger.WatchInTx.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker |BTC Chain| Ballot Identifier : %s", ballotIdentifier)
ob.logger.WatchInTx.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, common.CoinType_Gas.String())
}
return nil
}
Expand All @@ -76,7 +76,6 @@ func (ob *BitcoinChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool)
if err != nil {
return "", err
}
fmt.Println("Tx : ", tx.Txid, tx.Hash)
blockHash, err := chainhash.NewHashFromStr(tx.BlockHash)
if err != nil {
return "", err
Expand Down Expand Up @@ -123,19 +122,19 @@ func (ob *EVMChainClient) ObserveTrackerSuggestions() error {
if err != nil {
return err
}
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker | Ballot Identifier : %s", ballotIdentifier)
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, common.CoinType_Zeta.String())
case common.CoinType_ERC20:
ballotIdentifier, err := ob.CheckReceiptForCoinTypeERC20(tracker.TxHash, true)
if err != nil {
return err
}
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker | Ballot Identifier : %s", ballotIdentifier)
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, common.CoinType_ERC20.String())
case common.CoinType_Gas:
ballotIdentifier, err := ob.CheckReceiptForCoinTypeGas(tracker.TxHash, true)
if err != nil {
return err
}
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker | Ballot Identifier : %s", ballotIdentifier)
ob.logger.ExternalChainWatcher.Info().Msgf("Vote submitted for tracker submitted via inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, common.CoinType_Gas.String())
}
}
return nil
Expand Down

0 comments on commit 994ec15

Please sign in to comment.