From e4291529795b8e953b8e915541a6deb4dccbcc02 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 15 Jul 2024 20:03:46 -0400 Subject: [PATCH] resolve comments 3 --- Makefile | 2 +- cmd/zetaclientd/keygen_tss.go | 22 +++--- cmd/zetaclientd/start.go | 4 +- cmd/zetae2e/config/localnet.yml | 2 +- cmd/zetae2e/local/local.go | 1 - cmd/zetae2e/local/post_migration.go | 6 +- e2e/config/config.go | 10 ++- e2e/e2etests/test_migrate_tss.go | 20 ++--- .../cctx_orchestrator_validate_inbound.go | 1 - .../chains/bitcoin/observer/outbound.go | 10 +-- zetaclient/chains/evm/observer/outbound.go | 75 +++++++++++++++---- zetaclient/tss/tss_signer.go | 17 +++-- zetaclient/zetacore/client_monitor.go | 14 ++-- 13 files changed, 114 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index ab0eac8b99..4cb7375fae 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ build-testnet-ubuntu: go.sum docker rm temp-container install: go.sum - @echo "--> Installing zetacored ,zetaclientd and zetaclientd-supervisor" + @echo "--> Installing zetacored, zetaclientd, and zetaclientd-supervisor" @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd-supervisor diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 7b50479903..71beeb17fe 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -17,7 +17,6 @@ import ( "github.com/zeta-chain/zetacore/pkg/chains" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/chains/interfaces" - "github.com/zeta-chain/zetacore/zetaclient/context" zctx "github.com/zeta-chain/zetacore/zetaclient/context" "github.com/zeta-chain/zetacore/zetaclient/metrics" mc "github.com/zeta-chain/zetacore/zetaclient/tss" @@ -30,12 +29,15 @@ import ( // In case of a successful keygen a TSS success vote is broadcasted to zetacore and the newly generate TSS is tested. The generated keyshares are stored in the correct directory // In case of a failed keygen a TSS failed vote is broadcasted to zetacore. func GenerateTSS( - appContext *context.AppContext, + ctx context.Context, logger zerolog.Logger, zetaCoreClient *zetacore.Client, keygenTssServer *tss.TssServer) error { keygenLogger := logger.With().Str("module", "keygen").Logger() - + app, err := zctx.FromContext(ctx) + if err != nil { + return err + } // If Keygen block is set it will try to generate new TSS at the block // This is a blocking thread and will wait until the ceremony is complete successfully // If the TSS generation is unsuccessful , it will loop indefinitely until a new TSS is generated @@ -62,7 +64,7 @@ func GenerateTSS( // Try generating TSS at keygen block , only when status is pending keygen and generation has not been tried at the block if keyGen.Status == observertypes.KeygenStatus_PendingKeygen { // Return error if RPC is not working - currentBlock, err := zetaCoreClient.GetBlockHeight() + currentBlock, err := zetaCoreClient.GetBlockHeight(ctx) if err != nil { keygenLogger.Error().Err(err).Msg("GetBlockHeight RPC error") continue @@ -83,10 +85,11 @@ func GenerateTSS( } // Try keygen only once at a particular block, irrespective of whether it is successful or failure triedKeygenAtBlock = true - newPubkey, err := keygenTss(keyGen, *keygenTssServer, zetaCoreClient, keygenLogger) + newPubkey, err := keygenTss(ctx, keyGen, *keygenTssServer, zetaCoreClient, keygenLogger) if err != nil { keygenLogger.Error().Err(err).Msg("keygenTss error") - tssFailedVoteHash, err := zetaCoreClient.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_failed) + tssFailedVoteHash, err := zetaCoreClient.PostVoteTSS(ctx, + "", keyGen.BlockNumber, chains.ReceiveStatus_failed) if err != nil { keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore") return err @@ -95,7 +98,7 @@ func GenerateTSS( continue } // If TSS is successful , broadcast the vote to zetacore and also set the Pubkey - tssSuccessVoteHash, err := zetaCoreClient.SetTSS( + tssSuccessVoteHash, err := zetaCoreClient.PostVoteTSS(ctx, newPubkey, keyGen.BlockNumber, chains.ReceiveStatus_success, @@ -123,6 +126,7 @@ func GenerateTSS( // If the keygen is successful, the function returns the new TSS pubkey. // If the keygen is unsuccessful, the function posts blame and returns an error. func keygenTss( + ctx context.Context, keyGen observertypes.Keygen, tssServer tss.TssServer, zetacoreClient interfaces.ZetacoreClient, @@ -140,10 +144,10 @@ func keygenTss( return "", err } index := fmt.Sprintf("keygen-%s-%d", digest, keyGen.BlockNumber) - zetaHash, err := tss.ZetacoreClient.PostVoteBlameData( + zetaHash, err := zetacoreClient.PostVoteBlameData( ctx, &res.Blame, - tss.ZetacoreClient.Chain().ChainId, + zetacoreClient.Chain().ChainId, index, ) if err != nil { diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index edbedb9a66..fef035aee5 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -212,7 +212,7 @@ func start(_ *cobra.Command, _ []string) error { // Generate a new TSS if keygen is set and add it into the tss server // If TSS has already been generated, and keygen was successful ; we use the existing TSS - err = GenerateTSS(appContext, masterLogger, zetacoreClient, server) + err = GenerateTSS(ctx, masterLogger, zetacoreClient, server) if err != nil { return err } @@ -223,7 +223,7 @@ func start(_ *cobra.Command, _ []string) error { bitcoinChainID = btcChain.ChainId } tss, err := mc.NewTSS( - appContext, + ctx, zetacoreClient, tssHistoricalList, bitcoinChainID, diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index 3afb6a3408..cbd703ba6a 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -34,7 +34,7 @@ additional_accounts: private_key: "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" user_migration: bech32_address: "zeta1pvtxa708yvdmszn687nne6nl8qn704daf420xz" - evm_address: "0x0b166ef9e7231bb80a7a3fa73cea7f3827e7d5bd" + evm_address: "0x0B166ef9e7231Bb80A7A3FA73CEA7F3827E7D5BD" private_key: "0bcc2fa28b526f90e1d54648d612db901e860bf68248555593f91ea801c6b482" policy_accounts: emergency_policy_account: diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 63a9bf1974..20e6c72f8e 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -424,7 +424,6 @@ func runTSSMigrationTest(deployerRunner *runner.E2ERunner, logger *runner.Logger logger.Print("❌ post migration tests failed") os.Exit(1) } - } func must[T any](v T, err error) T { diff --git a/cmd/zetae2e/local/post_migration.go b/cmd/zetae2e/local/post_migration.go index c1d34da9a4..f339ce0bc1 100644 --- a/cmd/zetae2e/local/post_migration.go +++ b/cmd/zetae2e/local/post_migration.go @@ -1,10 +1,10 @@ package local import ( - "fmt" "time" "github.com/fatih/color" + "github.com/pkg/errors" "github.com/zeta-chain/zetacore/e2e/config" "github.com/zeta-chain/zetacore/e2e/e2etests" @@ -40,11 +40,11 @@ func postMigrationTestRoutine( testNames..., ) if err != nil { - return fmt.Errorf("postMigrationRunner tests failed: %v", err) + return errors.Wrap(err, "postMigrationRunner tests failed") } if err := postMigrationRunner.RunE2ETests(testsToRun); err != nil { - return fmt.Errorf("postMigrationRunner tests failed: %v", err) + return errors.Wrap(err, "postMigrationRunner tests failed") } if err := postMigrationRunner.CheckBtcTSSBalance(); err != nil { diff --git a/e2e/config/config.go b/e2e/config/config.go index b22b956494..6132dccbbd 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -199,6 +199,7 @@ func (a AdditionalAccounts) AsSlice() []Account { a.UserEther, a.UserMisc, a.UserAdmin, + a.UserMigration, } } @@ -283,19 +284,20 @@ func (c *Config) GenerateKeys() error { if err != nil { return err } - c.PolicyAccounts.EmergencyPolicyAccount, err = generateAccount() + c.AdditionalAccounts.UserMigration, err = generateAccount() if err != nil { return err } - c.PolicyAccounts.OperationalPolicyAccount, err = generateAccount() + + c.PolicyAccounts.EmergencyPolicyAccount, err = generateAccount() if err != nil { return err } - c.PolicyAccounts.AdminPolicyAccount, err = generateAccount() + c.PolicyAccounts.OperationalPolicyAccount, err = generateAccount() if err != nil { return err } - c.AdditionalAccounts.UserMigration, err = generateAccount() + c.PolicyAccounts.AdminPolicyAccount, err = generateAccount() if err != nil { return err } diff --git a/e2e/e2etests/test_migrate_tss.go b/e2e/e2etests/test_migrate_tss.go index 77bd2eff6d..8dc57b3e0a 100644 --- a/e2e/e2etests/test_migrate_tss.go +++ b/e2e/e2etests/test_migrate_tss.go @@ -28,10 +28,10 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) { // Pause inbound procoessing for tss migration r.Logger.Info("Pause inbound processing") msg := observertypes.NewMsgDisableCCTX( - r.ZetaTxServer.GetAccountAddress(0), + r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), false, true) - _, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + _, err := r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msg) require.NoError(r, err) // Migrate btc @@ -53,11 +53,11 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) { // #nosec G701 e2eTest - always in range migrationAmountBTC := sdkmath.NewUint(uint64(btcBalance * 1e8)) msgMigrateFunds := crosschaintypes.NewMsgMigrateTssFunds( - r.ZetaTxServer.GetAccountAddress(0), + r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), btcChain, migrationAmountBTC, ) - _, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgMigrateFunds) + _, err = r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, msgMigrateFunds) require.NoError(r, err) // Fetch migrator cctx for btc migration @@ -78,11 +78,11 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) { // Migrate TSS funds for the eth chain msgMigrateFunds = crosschaintypes.NewMsgMigrateTssFunds( - r.ZetaTxServer.GetAccountAddress(0), + r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), evmChainID.Int64(), tssBalanceUint, ) - _, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgMigrateFunds) + _, err = r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, msgMigrateFunds) require.NoError(r, err) // Fetch migrator cctx for eth migration @@ -110,10 +110,10 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) { return allTss.TssList[i].FinalizedZetaHeight < allTss.TssList[j].FinalizedZetaHeight }) msgUpdateTss := crosschaintypes.NewMsgUpdateTssAddress( - r.ZetaTxServer.GetAccountAddress(0), + r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), allTss.TssList[1].TssPubkey, ) - _, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgUpdateTss) + _, err = r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, msgUpdateTss) require.NoError(r, err) // Wait for atleast one block for the TSS to be updated @@ -174,9 +174,9 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) { require.True(r, ethTSSBalanceNew.Cmp(ethTSSBalanceOld) < 0) msgEnable := observertypes.NewMsgEnableCCTX( - r.ZetaTxServer.GetAccountAddress(0), + r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName), true, true) - _, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgEnable) + _, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgEnable) require.NoError(r, err) } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_inbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_inbound.go index 24d139f76f..2d1dfb030d 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_inbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_inbound.go @@ -83,7 +83,6 @@ func (k Keeper) CheckIfMigrationTransfer(ctx sdk.Context, msg *types.MsgVoteInbo if ethTssAddress.Hex() == msg.Sender { return types.ErrMigrationFromOldTss } - } case chains.IsBitcoinChain(chain.ChainId, additionalChains): bitcoinParams, err := chains.BitcoinNetParamsFromChainID(chain.ChainId) diff --git a/zetaclient/chains/bitcoin/observer/outbound.go b/zetaclient/chains/bitcoin/observer/outbound.go index 80db586c28..c7c1c649d7 100644 --- a/zetaclient/chains/bitcoin/observer/outbound.go +++ b/zetaclient/chains/bitcoin/observer/outbound.go @@ -184,11 +184,11 @@ func (ob *Observer) IsOutboundProcessed( // It's safe to use cctx's amount to post confirmation because it has already been verified in observeOutbound() amountInSat := params.Amount.BigInt() if res.Confirmations < ob.ConfirmationsThreshold(amountInSat) { - ob.logger.Outbound.Debug().Msgf( - "IsOutboundProcessed: outbound not confirmed yet %d: %d", - res.Confirmations, - ob.ConfirmationsThreshold(amountInSat), - ) + ob.logger.Outbound.Debug(). + Int64("currentConfirmations", res.Confirmations). + Int64("requiredConfirmations", ob.ConfirmationsThreshold(amountInSat)). + Msg("IsOutboundProcessed: outbound not confirmed yet") + return true, false, nil } diff --git a/zetaclient/chains/evm/observer/outbound.go b/zetaclient/chains/evm/observer/outbound.go index ac5dbf0152..4b847b52c5 100644 --- a/zetaclient/chains/evm/observer/outbound.go +++ b/zetaclient/chains/evm/observer/outbound.go @@ -9,7 +9,6 @@ import ( "time" "cosmossdk.io/math" - "github.com/ethereum/go-ethereum" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/pkg/errors" @@ -390,11 +389,18 @@ func (ob *Observer) checkConfirmedTx( if err != nil { log.Error(). Err(err). - Msgf("confirmTxByHash: error getting transaction for outbound %s chain %d", txHash, ob.Chain().ChainId) + Str("function", "confirmTxByHash"). + Str("outboundTxHash", txHash). + Int64("chainID", ob.Chain().ChainId). + Msg("error getting transaction for outbound") return nil, nil, false } if transaction == nil { // should not happen - log.Error().Msgf("confirmTxByHash: transaction is nil for txHash %s nonce %d", txHash, nonce) + log.Error(). + Str("function", "confirmTxByHash"). + Str("outboundTxHash", txHash). + Uint64("nonce", nonce). + Msg("transaction is nil for txHash") return nil, nil, false } @@ -404,15 +410,23 @@ func (ob *Observer) checkConfirmedTx( if err != nil { log.Error(). Err(err). - Msgf("confirmTxByHash: local recovery of sender address failed for outbound %s chain %d", transaction.Hash().Hex(), ob.Chain().ChainId) + Str("function", "confirmTxByHash"). + Str("outboundTxHash", transaction.Hash().Hex()). + Int64("chainID", ob.Chain().ChainId). + Msg("local recovery of sender address failed for outbound") return nil, nil, false } if from != ob.TSS().EVMAddress() { // must be TSS address // If from is not TSS address, check if it is one of the previous TSS addresses We can still try to confirm a tx which was broadcast by an old TSS // This is to handle situations where the outbound has already been broad-casted by an older TSS address and the zetacore is waiting for the all the required block confirmations // to go through before marking the cctx into a finalized state - log.Info().Msgf("confirmTxByHash: sender %s for outbound %s chain %d is not current TSS address %s", - from.Hex(), transaction.Hash().Hex(), ob.Chain().ChainId, ob.TSS().EVMAddress().Hex()) + log.Info(). + Str("function", "confirmTxByHash"). + Str("sender", from.Hex()). + Str("outboundTxHash", transaction.Hash().Hex()). + Int64("chainID", ob.Chain().ChainId). + Str("currentTSSAddress", ob.TSS().EVMAddress().Hex()). + Msg("sender is not current TSS address") addressList := ob.TSS().EVMAddressList() isOldTssAddress := false for _, addr := range addressList { @@ -422,14 +436,22 @@ func (ob *Observer) checkConfirmedTx( } if !isOldTssAddress { log.Error(). - Msgf("confirmTxByHash: sender %s for outbound %s chain %d is not current or old TSS address. Current TSS %s", - from.Hex(), transaction.Hash().Hex(), ob.Chain().ChainId, ob.TSS().EVMAddress().Hex()) + Str("function", "confirmTxByHash"). + Str("sender", from.Hex()). + Str("outboundTxHash", transaction.Hash().Hex()). + Int64("chainID", ob.Chain().ChainId). + Str("currentTSSAddress", ob.TSS().EVMAddress().Hex()). + Msg("sender is not current or old TSS address") return nil, nil, false } } if transaction.Nonce() != nonce { // must match cctx nonce log.Error(). - Msgf("confirmTxByHash: outbound %s nonce mismatch: wanted %d, got tx nonce %d", txHash, nonce, transaction.Nonce()) + Str("function", "confirmTxByHash"). + Str("outboundTxHash", txHash). + Uint64("wantedNonce", nonce). + Uint64("gotTxNonce", transaction.Nonce()). + Msg("outbound nonce mismatch") return nil, nil, false } @@ -442,26 +464,41 @@ func (ob *Observer) checkConfirmedTx( // query receipt receipt, err := ob.evmClient.TransactionReceipt(ctx, ethcommon.HexToHash(txHash)) if err != nil { - log.Error().Err(err).Msgf("confirmTxByHash: TransactionReceipt error, txHash %s nonce %d", txHash, nonce) + log.Error(). + Err(err). + Str("function", "confirmTxByHash"). + Str("outboundTxHash", txHash). + Uint64("nonce", nonce). + Msg("transactionReceipt error") return nil, nil, false } if receipt == nil { // should not happen - log.Error().Msgf("confirmTxByHash: receipt is nil for txHash %s nonce %d", txHash, nonce) + log.Error(). + Str("function", "confirmTxByHash"). + Str("outboundTxHash", txHash). + Uint64("nonce", nonce). + Msg("receipt is nil") return nil, nil, false } ob.LastBlock() // check confirmations - lastHeight, err := ob.evmClient.BlockNumber(context.Background()) + lastHeight, err := ob.evmClient.BlockNumber(ctx) if err != nil { log.Error(). + Str("function", "confirmTxByHash"). Err(err). - Msgf("confirmTxByHash: error getting block number for chain %d", ob.GetChainParams().ChainId) + Int64("chainID", ob.GetChainParams().ChainId). + Msg("error getting block number for chain") return nil, nil, false } if !ob.HasEnoughConfirmations(receipt, lastHeight) { log.Debug(). - Msgf("confirmTxByHash: txHash %s nonce %d included but not confirmed: receipt block %d, current block %d", - txHash, nonce, receipt.BlockNumber, lastHeight) + Str("function", "confirmTxByHash"). + Str("txHash", txHash). + Uint64("nonce", nonce). + Uint64("receiptBlock", receipt.BlockNumber.Uint64()). + Uint64("currentBlock", lastHeight). + Msg("txHash included but not confirmed") return nil, nil, false } @@ -469,7 +506,13 @@ func (ob *Observer) checkConfirmedTx( // Note: a guard for false BlockNumber in receipt. The blob-carrying tx won't come here err = ob.CheckTxInclusion(transaction, receipt) if err != nil { - log.Error().Err(err).Msgf("confirmTxByHash: checkTxInclusion error for txHash %s nonce %d", txHash, nonce) + log.Error(). + Err(err). + Str("function", "confirmTxByHash"). + Str("errorContext", "checkTxInclusion"). + Str("txHash", txHash). + Uint64("nonce", nonce). + Msg("checkTxInclusion error") return nil, nil, false } diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index 65bc1a9a21..7db6f27a8e 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -33,7 +33,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/chains/interfaces" "github.com/zeta-chain/zetacore/zetaclient/config" - appcontext "github.com/zeta-chain/zetacore/zetaclient/context" + zctx "github.com/zeta-chain/zetacore/zetaclient/context" "github.com/zeta-chain/zetacore/zetaclient/keys" "github.com/zeta-chain/zetacore/zetaclient/metrics" ) @@ -92,7 +92,6 @@ type TSS struct { // NewTSS creates a new TSS instance which can be used to sign transactions func NewTSS( ctx context.Context, - appContext *appcontext.AppContext, client interfaces.ZetacoreClient, tssHistoricalList []observertypes.TSS, bitcoinChainID int64, @@ -100,23 +99,27 @@ func NewTSS( tssServer *tss.TssServer, ) (*TSS, error) { logger := log.With().Str("module", "tss_signer").Logger() + app, err := zctx.FromContext(ctx) + if err != nil { + return nil, err + } newTss := TSS{ Server: tssServer, Keys: make(map[string]*Key), - CurrentPubkey: appContext.GetCurrentTssPubKey(), + CurrentPubkey: app.GetCurrentTssPubKey(), logger: logger, ZetacoreClient: client, KeysignsTracker: NewKeysignsTracker(logger), BitcoinChainID: bitcoinChainID, } - err := newTss.LoadTssFilesFromDirectory(appContext.Config().TssPath) + err = newTss.LoadTssFilesFromDirectory(app.Config().TssPath) if err != nil { return nil, err } - _, pubkeyInBech32, err := keys.GetKeyringKeybase(appContext.Config(), hotkeyPassword) + _, pubkeyInBech32, err := keys.GetKeyringKeybase(app.Config(), hotkeyPassword) if err != nil { return nil, err } @@ -137,7 +140,7 @@ func NewTSS( } metrics.NumActiveMsgSigns.Set(0) - newTss.Signers = appContext.GetKeygen().GranteePubkeys + newTss.Signers = app.GetKeygen().GranteePubkeys return &newTss, nil } @@ -305,8 +308,6 @@ func (tss *TSS) Sign( return [65]byte{}, fmt.Errorf("signuature verification fail") } - fmt.Print("Successfully signed the digest") - return sigbyte, nil } diff --git a/zetaclient/zetacore/client_monitor.go b/zetaclient/zetacore/client_monitor.go index 6c124ced48..b505af90a1 100644 --- a/zetaclient/zetacore/client_monitor.go +++ b/zetaclient/zetacore/client_monitor.go @@ -168,15 +168,11 @@ func retryWithBackoff(call func() error, attempts int, minInternal, maxInterval if attempts < 1 { return errors.New("attempts must be positive") } + bo := backoff.NewExponentialBackOff() + bo.InitialInterval = minInternal + bo.MaxInterval = maxInterval - bo := backoff.WithMaxRetries( - backoff.NewExponentialBackOff( - backoff.WithInitialInterval(minInternal), - backoff.WithMaxInterval(maxInterval), - ), - // #nosec G115 always positive - uint64(attempts), - ) + backoffWithRetry := backoff.WithMaxRetries(bo, uint64(attempts)) - return retry.DoWithBackoff(call, bo) + return retry.DoWithBackoff(call, backoffWithRetry) }