From af26d743492beab80a0c6723acc361975a837a89 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 4 Apr 2024 23:36:39 -0500 Subject: [PATCH] initial commit to simply IsSendOutTxProcessed func --- cmd/zetaclientd/start.go | 2 +- zetaclient/evm/evm_client.go | 338 +++++------------------ zetaclient/evm/outbounds.go | 125 +++++++++ zetaclient/zetabridge/tx.go | 4 +- zetaclient/zetabridge/zetacore_bridge.go | 3 +- 5 files changed, 195 insertions(+), 277 deletions(-) create mode 100644 zetaclient/evm/outbounds.go diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 56d77e0950..de1633ad6f 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -124,7 +124,7 @@ func start(_ *cobra.Command, _ []string) error { // Initialize core parameters from zetacore appContext := appcontext.NewAppContext(corecontext.NewZetaCoreContext(cfg), cfg) - err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true) + err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true, startLogger) if err != nil { startLogger.Error().Err(err).Msg("Error getting core parameters") return err diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index f94536be25..cc7e4c74d3 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -317,298 +317,90 @@ func (ob *ChainClient) Stop() { ob.logger.Chain.Info().Msgf("%s observer stopped", ob.chain.String()) } -// returns: isIncluded, isConfirmed, Error -// If isConfirmed, it also post to ZetaCore +// IsSendOutTxProcessed checks outtx status and returns (isIncluded, isConfirmed, error) +// It also posts vote to zetacore if the tx is confirmed func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger) (bool, bool, error) { sendHash := cctx.Index cointype := cctx.InboundTxParams.CoinType nonce := cctx.GetCurrentOutTxParam().OutboundTxTssNonce // skip if outtx is not confirmed - params := ob.GetChainParams() - receipt, transaction := ob.GetTxNReceipt(nonce) - if receipt == nil || transaction == nil { // not confirmed yet + if !ob.isTxConfirmed(nonce) { return false, false, nil } - - sendID := fmt.Sprintf("%s-%d", ob.chain.String(), nonce) + receipt, transaction := ob.GetTxNReceipt(nonce) + sendID := fmt.Sprintf("%d-%d", ob.chain.ChainId, nonce) logger = logger.With().Str("sendID", sendID).Logger() + // get connector and erce20Custody contracts + connectorAddr, connector, err := ob.GetConnectorContract() + if err != nil { + return false, false, errors.Wrapf(err, "error getting zeta connector for chain %d", ob.chain.ChainId) + } + custodyAddr, custody, err := ob.GetERC20CustodyContract() + if err != nil { + return false, false, errors.Wrapf(err, "error getting erc20 custody for chain %d", ob.chain.ChainId) + } + + // define a few common variables + txHash := receipt.TxHash.Hex() + var receiveValue *big.Int + var receiveStatus chains.ReceiveStatus + // compliance check, special handling the cancelled cctx if compliance.IsCctxRestricted(cctx) { - recvStatus := chains.ReceiveStatus_Failed + // use cctx's amount to bypass the amount check in zetacore + receiveValue = cctx.GetCurrentOutTxParam().Amount.BigInt() + receiveStatus := chains.ReceiveStatus_Failed if receipt.Status == 1 { - recvStatus = chains.ReceiveStatus_Success - } - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - // use cctx's amount to bypass the amount check in zetacore - cctx.GetCurrentOutTxParam().Amount.BigInt(), - recvStatus, - ob.chain, - nonce, - coin.CoinType_Cmd, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) + receiveStatus = chains.ReceiveStatus_Success } + ob.PostVoteOutbound(sendHash, receipt, transaction, receiveValue, receiveStatus, nonce, cointype, logger) return true, true, nil } - if cointype == coin.CoinType_Cmd { - recvStatus := chains.ReceiveStatus_Failed - if receipt.Status == 1 { - recvStatus = chains.ReceiveStatus_Success - } - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - transaction.Value(), - recvStatus, - ob.chain, - nonce, - coin.CoinType_Cmd, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - - } else if cointype == coin.CoinType_Gas { // the outbound is a regular Ether/BNB/Matic transfer; no need to check events - if receipt.Status == 1 { - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - transaction.Value(), - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Gas, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } else if receipt.Status == 0 { // the same as below events flow - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_Gas, - ) - if err != nil { - logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - } else if cointype == coin.CoinType_Zeta { // the outbound is a Zeta transfer; need to check events ZetaReceived - if receipt.Status == 1 { - logs := receipt.Logs - for _, vLog := range logs { - confHeight := vLog.BlockNumber + params.ConfirmationCount - // TODO rewrite this to return early if not confirmed - connectorAddr, connector, err := ob.GetConnectorContract() - if err != nil { - return false, false, fmt.Errorf("error getting connector contract: %w", err) - } - receivedLog, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReceived(*vLog) - if err == nil { - logger.Info().Msgf("Found (outTx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - // sanity check tx event - err = ValidateEvmTxLog(vLog, connectorAddr, transaction.Hash().Hex(), TopicsZetaReceived) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on ZetaReceived event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - sendhash := vLog.Topics[3].Hex() - //var rxAddress string = ethcommon.HexToAddress(vLog.Topics[1].Hex()).Hex() - mMint := receivedLog.ZetaValue - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendhash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - mMint, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - revertedLog, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReverted(*vLog) - if err == nil { - logger.Info().Msgf("Found (revertTx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - // sanity check tx event - err = ValidateEvmTxLog(vLog, connectorAddr, transaction.Hash().Hex(), TopicsZetaReverted) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on ZetaReverted event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - sendhash := vLog.Topics[2].Hex() - mMint := revertedLog.RemainingZetaValue - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendhash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - mMint, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - } - } else if receipt.Status == 0 { - //FIXME: check nonce here by getTransaction RPC - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - } else if cointype == coin.CoinType_ERC20 { - if receipt.Status == 1 { - logs := receipt.Logs - addrCustody, ERC20Custody, err := ob.GetERC20CustodyContract() - if err != nil { - logger.Warn().Msgf("NewERC20Custody err: %s", err) - } - for _, vLog := range logs { - event, err := ERC20Custody.ParseWithdrawn(*vLog) - confHeight := vLog.BlockNumber + params.ConfirmationCount - if err == nil { - logger.Info().Msgf("Found (ERC20Custody.Withdrawn Event) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - // sanity check tx event - err = ValidateEvmTxLog(vLog, addrCustody, transaction.Hash().Hex(), TopicsWithdrawn) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on Withdrawn event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - event.Amount, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_ERC20, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - } - } else { - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_ERC20, - ) - if err != nil { - logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } + // parse the received value from the outtx receipt + receiveStatus, receiveValue, err = ParseOuttxReceivedValue(receipt, transaction, cointype, connectorAddr, connector, custodyAddr, custody, sendHash, txHash) + if err != nil { + logger.Error().Err(err).Msgf("IsSendOutTxProcessed: error parsing outtx event for chain %d txhash %s", ob.chain.ChainId, txHash) + return false, false, err } - return false, false, nil + // post vote to zetacore + ob.PostVoteOutbound(sendHash, receipt, transaction, receiveValue, receiveStatus, nonce, cointype, logger) + return true, true, nil +} + +// PostVoteOutbound posts vote to zetacore for the confirmed outtx +func (ob *ChainClient) PostVoteOutbound( + sendHash string, + receipt *ethtypes.Receipt, + transaction *ethtypes.Transaction, + receiveValue *big.Int, + receiveStatus chains.ReceiveStatus, + nonce uint64, + cointype coin.CoinType, + logger zerolog.Logger, +) { + chainID := ob.chain.ChainId + zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( + sendHash, + receipt.TxHash.Hex(), + receipt.BlockNumber.Uint64(), + receipt.GasUsed, + transaction.GasPrice(), + transaction.Gas(), + receiveValue, + receiveStatus, + ob.chain, + nonce, + cointype, + ) + if err != nil { + logger.Error().Err(err).Msgf("PostVoteOutbound: error posting vote for chain %d nonce %d outtx %s ", chainID, nonce, receipt.TxHash) + } else if zetaTxHash != "" { + logger.Info().Msgf("PostVoteOutbound: posted vote for chain %d nonce %d outtx %s vote %s ballot %s", chainID, nonce, receipt.TxHash, zetaTxHash, ballot) + } } // WatchOutTx watches evm chain for outgoing txs status diff --git a/zetaclient/evm/outbounds.go b/zetaclient/evm/outbounds.go new file mode 100644 index 0000000000..2420919b23 --- /dev/null +++ b/zetaclient/evm/outbounds.go @@ -0,0 +1,125 @@ +package evm + +import ( + "fmt" + "math/big" + + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/pkg/errors" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.non-eth.sol" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" +) + +// ParseZetaEvent either returns a parsed ZetaReceived or ZetaReverted event +func ParseZetaEvent( + receipt *ethtypes.Receipt, + connectorAddr ethcommon.Address, + connector *zetaconnector.ZetaConnectorNonEth, + sendHash string, + txHash string) (*zetaconnector.ZetaConnectorNonEthZetaReceived, *zetaconnector.ZetaConnectorNonEthZetaReverted, error) { + for _, vLog := range receipt.Logs { + receivedEvent, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReceived(*vLog) + if err == nil { + // sanity check tx event + err = ValidateEvmTxLog(vLog, connectorAddr, txHash, TopicsZetaReceived) + if err != nil { + return nil, nil, errors.Wrapf(err, "error validating ZetaReceived event from outtx %s", txHash) + } + if vLog.Topics[3].Hex() != sendHash { + return nil, nil, fmt.Errorf("cctx index mismatch in ZetaReceived event from outtx %s, want %s got %s", txHash, sendHash, vLog.Topics[3].Hex()) + } + return receivedEvent, nil, nil + } + revertedEvent, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReverted(*vLog) + if err == nil { + // sanity check tx event + err = ValidateEvmTxLog(vLog, connectorAddr, receipt.TxHash.Hex(), TopicsZetaReverted) + if err != nil { + return nil, nil, errors.Wrapf(err, "error validating ZetaReverted event from outtx %s", txHash) + } + return nil, revertedEvent, nil + } + } + return nil, nil, fmt.Errorf("no ZetaReceived/ZetaReverted event found in outtx %s", txHash) +} + +// ParseERC20WithdrawnEvent returns a parsed ERC20CustodyWithdrawn event from the outtx receipt +func ParseERC20WithdrawnEvent( + receipt *ethtypes.Receipt, + custodyAddr ethcommon.Address, + custody *erc20custody.ERC20Custody, + txHash string) (*erc20custody.ERC20CustodyWithdrawn, error) { + for _, vLog := range receipt.Logs { + withdrawnEvent, err := custody.ParseWithdrawn(*vLog) + if err == nil { + // sanity check tx event + err = ValidateEvmTxLog(vLog, custodyAddr, receipt.TxHash.Hex(), TopicsWithdrawn) + if err != nil { + return nil, errors.Wrapf(err, "error validating ERC20CustodyWithdrawn event from outtx %s", txHash) + } + return withdrawnEvent, nil + } + } + return nil, fmt.Errorf("no ERC20CustodyWithdrawn event found in outtx %s", txHash) +} + +// ParseOuttxReceivedValue parses the received value from the outtx receipt +func ParseOuttxReceivedValue( + receipt *ethtypes.Receipt, + transaction *ethtypes.Transaction, + cointype coin.CoinType, + connectorAddress ethcommon.Address, + connector *zetaconnector.ZetaConnectorNonEth, + custodyAddress ethcommon.Address, + custody *erc20custody.ERC20Custody, + sendHash string, + txHash string) (chains.ReceiveStatus, *big.Int, error) { + // determine the receive status and value + var receiveStatus chains.ReceiveStatus + var receiveValue *big.Int + switch receipt.Status { + case ethtypes.ReceiptStatusSuccessful: + receiveStatus = chains.ReceiveStatus_Success + receiveValue = transaction.Value() + case ethtypes.ReceiptStatusFailed: + receiveStatus = chains.ReceiveStatus_Failed + receiveValue = big.NewInt(0) + default: + // https://docs.nethereum.com/en/latest/nethereum-receipt-status/ + return chains.ReceiveStatus_Failed, nil, fmt.Errorf("unknown tx receipt status %d for outtx %s", receipt.Status, receipt.TxHash) + } + + // parse receive value from the outtx receipt for Zeta and ERC20 + switch cointype { + case coin.CoinType_Zeta: + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + receivedLog, revertedLog, err := ParseZetaEvent(receipt, connectorAddress, connector, sendHash, txHash) + if err != nil { + return chains.ReceiveStatus_Failed, nil, err + } + // use the value in ZetaReceived/ZetaReverted event for vote message + if receivedLog != nil { + receiveValue = receivedLog.ZetaValue + } else if revertedLog != nil { + receiveValue = revertedLog.RemainingZetaValue + } + } + case coin.CoinType_ERC20: + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + withdrawn, err := ParseERC20WithdrawnEvent(receipt, custodyAddress, custody, txHash) + if err != nil { + return chains.ReceiveStatus_Failed, nil, err + } + // use the value in Withdrawn event for vote message + receiveValue = withdrawn.Amount + } + case coin.CoinType_Gas, coin.CoinType_Cmd: + // nothing to do for CoinType_Gas/CoinType_Cmd, no need to parse event + default: + return chains.ReceiveStatus_Failed, nil, fmt.Errorf("unknown coin type %s for outtx %s", cointype, txHash) + } + return receiveStatus, receiveValue, nil +} diff --git a/zetaclient/zetabridge/tx.go b/zetaclient/zetabridge/tx.go index 90e44b16f5..9eef0007bd 100644 --- a/zetaclient/zetabridge/tx.go +++ b/zetaclient/zetabridge/tx.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/zeta-chain/go-tss/blame" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -130,11 +131,12 @@ func (b *ZetaCoreBridge) SetTSS(tssPubkey string, keyGenZetaHeight int64, status func (b *ZetaCoreBridge) CoreContextUpdater(appContext *appcontext.AppContext) { b.logger.Info().Msg("CoreContextUpdater started") ticker := time.NewTicker(time.Duration(appContext.Config().ConfigUpdateTicker) * time.Second) + sampledLogger := b.logger.Sample(&zerolog.BasicSampler{N: 10}) for { select { case <-ticker.C: b.logger.Debug().Msg("Running Updater") - err := b.UpdateZetaCoreContext(appContext.ZetaCoreContext(), false) + err := b.UpdateZetaCoreContext(appContext.ZetaCoreContext(), false, sampledLogger) if err != nil { b.logger.Err(err).Msg("CoreContextUpdater failed to update config") } diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index d8a29fa665..e7be6fd8c1 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -195,7 +195,7 @@ func (b *ZetaCoreBridge) GetKeys() *keys.Keys { // UpdateZetaCoreContext updates core context // zetacore stores core context for all clients -func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCoreContext, init bool) error { +func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCoreContext, init bool, sampledLogger zerolog.Logger) error { bn, err := b.GetZetaBlockHeight() if err != nil { return err @@ -220,7 +220,6 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore var newBTCParams *observertypes.ChainParams // check and update chain params for each chain - sampledLogger := b.logger.Sample(&zerolog.BasicSampler{N: 10}) for _, chainParam := range chainParams { if !chainParam.GetIsSupported() { sampledLogger.Info().Msgf("Chain %d is not supported yet", chainParam.ChainId)