Skip to content

Commit

Permalink
fix verification flags error
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Apr 26, 2024
1 parent acbaeab commit 3696806
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 17 additions & 9 deletions zetaclient/zetabridge/zetacore_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Check warning on line 204 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L204

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

Check warning on line 209 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L209

Added line #L209 was not covered by tests
}
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;"+
Expand All @@ -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)

Check warning on line 219 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L219

Added line #L219 was not covered by tests
}

newEVMParams := make(map[int64]*observertypes.ChainParams)
Expand All @@ -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)

Check warning on line 245 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L245

Added line #L245 was not covered by tests
}
newChains := make([]chains.Chain, len(supportedChains))
for i, chain := range supportedChains {
Expand All @@ -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)

Check warning on line 254 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L254

Added line #L254 was not covered by tests
}

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)

Check warning on line 260 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L260

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

Check warning on line 267 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L267

Added line #L267 was not covered by tests
}

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{}

Check warning on line 280 in zetaclient/zetabridge/zetacore_bridge.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetabridge/zetacore_bridge.go#L280

Added line #L280 was not covered by tests
}

coreContext.Update(
Expand Down

0 comments on commit 3696806

Please sign in to comment.