From 3696806c8c87e705dcf1c2c85ba6fc5a11d78376 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 26 Apr 2024 16:54:38 +0200 Subject: [PATCH] fix verification flags error --- contrib/localnet/scripts/start-zetaclientd.sh | 2 +- zetaclient/zetabridge/zetacore_bridge.go | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index a43e8e120f..89c691d52b 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -34,7 +34,7 @@ if [ $HOSTNAME == "zetaclient0" ] then rm ~/.tss/* MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) - zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" + zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" # check if the option is additional-evm # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index 3899d51d82..107a40ade7 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -17,6 +17,7 @@ import ( "github.com/zeta-chain/zetacore/pkg/authz" "github.com/zeta-chain/zetacore/pkg/chains" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" @@ -200,12 +201,12 @@ func (b *ZetaCoreBridge) GetKeys() *keys.Keys { func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCoreContext, init bool, sampledLogger zerolog.Logger) error { bn, err := b.GetZetaBlockHeight() if err != nil { - return err + return fmt.Errorf("failed to get zetablock height: %w", err) } plan, err := b.GetUpgradePlan() - // if there is no active upgrade plan, plan will be nil, err will be nil as well. if err != nil { - return err + // if there is no active upgrade plan, plan will be nil, err will be nil as well. + return fmt.Errorf("failed to get upgrade plan: %w", err) } if plan != nil && bn == plan.Height-1 { // stop zetaclients; notify operator to upgrade and restart b.logger.Warn().Msgf("Active upgrade plan detected and upgrade height reached: %s at height %d; ZetaClient is stopped;"+ @@ -215,7 +216,7 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore chainParams, err := b.GetChainParams() if err != nil { - return err + return fmt.Errorf("failed to get chain params: %w", err) } newEVMParams := make(map[int64]*observertypes.ChainParams) @@ -241,7 +242,7 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore supportedChains, err := b.GetSupportedChains() if err != nil { - return err + return fmt.Errorf("failed to get supported chains: %w", err) } newChains := make([]chains.Chain, len(supportedChains)) for i, chain := range supportedChains { @@ -250,26 +251,33 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore keyGen, err := b.GetKeyGen() if err != nil { b.logger.Info().Msg("Unable to fetch keygen from zetabridge") - return err + return fmt.Errorf("failed to get keygen: %w", err) } tss, err := b.GetCurrentTss() if err != nil { b.logger.Info().Err(err).Msg("Unable to fetch TSS from zetabridge") - return err + return fmt.Errorf("failed to get current tss: %w", err) } tssPubKey := tss.GetTssPubkey() crosschainFlags, err := b.GetCrosschainFlags() if err != nil { b.logger.Info().Msg("Unable to fetch cross-chain flags from zetabridge") - return err + return fmt.Errorf("failed to get crosschain flags: %w", err) } verificationFlags, err := b.GetVerificationFlags() if err != nil { b.logger.Info().Msg("Unable to fetch verification flags from zetabridge") - return err + + // The block header functionality is currently disabled on the ZetaCore side + // The verification flags might not exist and we should not return an error here to prevent the ZetaClient from starting + // TODO: Uncomment this line when the block header functionality is enabled and we need to get the verification flags + // https://github.com/zeta-chain/node/issues/1717 + // return fmt.Errorf("failed to get verification flags: %w", err) + + verificationFlags = lightclienttypes.VerificationFlags{} } coreContext.Update(