Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zetaclient should be able to activate/deactivate chains at runtime #2411

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d884d60
adjusted zetaclient initialization flow
ws4charlie Jun 24, 2024
782933b
Merge branch 'develop' of https://github.com/zeta-chain/node into orc…
ws4charlie Jun 25, 2024
fc607d4
organize some AppContext logic into orchestrator
ws4charlie Jun 26, 2024
672a461
remove zetacore context and use app context only; remove BitcoinID fr…
ws4charlie Jun 28, 2024
cef707a
simplified app context create and update; cleanup unused code
ws4charlie Jun 29, 2024
bf0468f
added some unit tests on context updater and chain activator
ws4charlie Jul 1, 2024
0514cad
fix zetacore client query test
ws4charlie Jul 1, 2024
632ce52
take LoadDB() logic out from observer constructors; call LoadDB() onl…
ws4charlie Jul 1, 2024
9ccbae4
Merge branch 'develop' of https://github.com/zeta-chain/node into orc…
ws4charlie Jul 1, 2024
eef51cc
Merge branch 'develop' of https://github.com/zeta-chain/node into orc…
ws4charlie Jul 1, 2024
3c1f245
unified log prints when activating/deactivating chains
ws4charlie Jul 1, 2024
ca9142d
fix unit test conflicts and thread safety
ws4charlie Jul 1, 2024
5d8643a
Merge branch 'develop' into orchestrator-add-new-chain-at-runtime
ws4charlie Jul 2, 2024
d068a70
fix e2e test
ws4charlie Jul 2, 2024
6c56d98
fix unit test
ws4charlie Jul 2, 2024
4f61c38
add unit test to chain activation deactivation; replace pointers of c…
ws4charlie Jul 3, 2024
04aaca1
Merge branch 'develop' of https://github.com/zeta-chain/node into orc…
ws4charlie Jul 3, 2024
b52654f
give more accurate names to methods
ws4charlie Jul 3, 2024
d6eee46
fix unit tests
ws4charlie Jul 3, 2024
14373fb
Merge branch 'develop' of https://github.com/zeta-chain/node into orc…
ws4charlie Jul 3, 2024
e46e0e4
update method names according PR review feedback
ws4charlie Jul 4, 2024
4b850b3
added unit test for orchestrator method Stop()
ws4charlie Jul 4, 2024
58feb66
add error handling to avoid unexpected chain deactivation due to endp…
ws4charlie Jul 5, 2024
e063c2a
fix code generate mocker version
ws4charlie Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
* [1848](https://github.com/zeta-chain/node/issues/1848) - create a method to observe deposits to tss address in one evm block
* [1885](https://github.com/zeta-chain/node/pull/1885) - change important metrics on port 8123 to be prometheus compatible
* [1863](https://github.com/zeta-chain/node/pull/1863) - remove duplicate ValidateChainParams function
* [1914](https://github.com/zeta-chain/node/pull/1914) - move crosschain flags to core context in zetaclient
* [1914](https://github.com/zeta-chain/node/pull/1914) - move crosschain flags to app context in zetaclient
* [1948](https://github.com/zeta-chain/node/pull/1948) - remove deprecated GetTSSAddress query in crosschain module
* [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg
* [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer
Expand Down Expand Up @@ -177,6 +177,7 @@
* [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags
* [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing
* [1825](https://github.com/zeta-chain/node/pull/1825) - add a message to withdraw emission rewards
* [2411](https://github.com/zeta-chain/node/pull/2411) - zetaclient activates and deactivates chains at runtime

### Tests

Expand Down
5 changes: 2 additions & 3 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/rs/zerolog"
"github.com/spf13/cobra"

"github.com/zeta-chain/zetacore/pkg/chains"
Expand Down Expand Up @@ -57,7 +56,7 @@ func debugCmd(_ *cobra.Command, args []string) error {
return err
}

appContext := clientcontext.New(cfg, zerolog.Nop())
appContext := clientcontext.New(cfg)

chainID, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
Expand Down Expand Up @@ -131,7 +130,7 @@ func debugCmd(_ *cobra.Command, args []string) error {
ZetaTokenContractAddress: chainParams.ZetaTokenContractAddress,
Erc20CustodyContractAddress: chainParams.Erc20CustodyContractAddress,
})
evmChainParams, found := appContext.GetEVMChainParams(chainID)
evmChainParams, found := appContext.GetExternalChainParams(chainID)
if !found {
return fmt.Errorf("missing chain params for chain %d", chainID)
}
Expand Down
24 changes: 10 additions & 14 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"github.com/zeta-chain/zetacore/zetaclient/zetacore"
)

func GenerateTss(
// GenerateTSS waits for the keygen block height to arrive and generates a new TSS
func GenerateTSS(
appContext *context.AppContext,
logger zerolog.Logger,
client *zetacore.Client,
Expand All @@ -31,26 +32,17 @@ func GenerateTss(
ts *metrics.TelemetryServer,
tssHistoricalList []observertypes.TSS,
tssPassword string,
hotkeyPassword string) (*mc.TSS, error) {
hotkeyPassword string,
) (*mc.TSS, error) {
keygenLogger := logger.With().Str("module", "keygen").Logger()

// Bitcoin chain ID is currently used for using the correct signature format
// TODO: remove this once we have a better way to determine the signature format
// https://github.com/zeta-chain/node/issues/1397
bitcoinChainID := chains.BitcoinRegtest.ChainId
btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig()
if btcEnabled {
bitcoinChainID = btcChain.ChainId
}

tss, err := mc.NewTSS(
appContext,
peers,
priKey,
preParams,
client,
tssHistoricalList,
bitcoinChainID,
tssPassword,
hotkeyPassword,
)
Expand All @@ -74,7 +66,11 @@ func GenerateTss(
// This loop will try keygen at the keygen block and then wait for keygen to be successfully reported by all nodes before breaking out of the loop.
// If keygen is unsuccessful, it will reset the triedKeygenAtBlock flag and try again at a new keygen block.

keyGen := appContext.GetKeygen()
keyGen, err := client.GetKeyGen()
if err != nil {
keygenLogger.Error().Err(err).Msg("GetKeyGen error")
continue
}
if keyGen.Status == observertypes.KeygenStatus_KeyGenSuccess {
return tss, nil
}
Expand Down Expand Up @@ -107,7 +103,7 @@ func GenerateTss(
}
// Try keygen only once at a particular block, irrespective of whether it is successful or failure
triedKeygenAtBlock = true
err = keygenTss(keyGen, tss, keygenLogger)
err = keygenTss(*keyGen, tss, keygenLogger)
if err != nil {
keygenLogger.Error().Err(err).Msg("keygenTss error")
tssFailedVoteHash, err := client.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_failed)
Expand Down
Loading
Loading