diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 726fda11ee..16f79581b5 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -74,10 +74,7 @@ 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, found := appContext.ZetaCoreContext().GetKeygen() - if !found { - return nil, fmt.Errorf("keygen not found") - } + keyGen := appContext.ZetaCoreContext().GetKeygen() if keyGen.Status == observertypes.KeygenStatus_KeyGenSuccess { return tss, nil } diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 6881120c15..c66a516968 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -190,10 +190,7 @@ func start(_ *cobra.Command, _ []string) error { // For existing keygen, this should directly proceed to the next step ticker := time.NewTicker(time.Second * 1) for range ticker.C { - keyGen, found := appContext.ZetaCoreContext().GetKeygen() - if !found { - return fmt.Errorf("keygen not found") - } + keyGen := appContext.ZetaCoreContext().GetKeygen() if keyGen.Status != observerTypes.KeygenStatus_KeyGenSuccess { startLogger.Info().Msgf("Waiting for TSS Keygen to be a success, current status %s", keyGen.Status) continue diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 94871b03a6..ee0c1dd171 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -15,7 +15,7 @@ import ( // these are initialized and updated at runtime at every height type ZetaCoreContext struct { coreContextLock *sync.RWMutex - keygen *observertypes.Keygen + keygen observertypes.Keygen chainsEnabled []common.Chain evmChainParams map[int64]*observertypes.ChainParams bitcoinChainParams *observertypes.ChainParams @@ -41,21 +41,11 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { } } -func (c *ZetaCoreContext) GetKeygen() (observertypes.Keygen, bool) { +func (c *ZetaCoreContext) GetKeygen() observertypes.Keygen { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() - if c.keygen == nil { - return observertypes.Keygen{}, false - } - copiedPubkeys := make([]string, len(c.keygen.GranteePubkeys)) - copy(copiedPubkeys, c.keygen.GranteePubkeys) - - return observertypes.Keygen{ - Status: c.keygen.Status, - GranteePubkeys: copiedPubkeys, - BlockNumber: c.keygen.BlockNumber, - }, true + return c.keygen } func (c *ZetaCoreContext) GetCurrentTssPubkey() string { @@ -148,7 +138,7 @@ func (c *ZetaCoreContext) Update( } } } - c.keygen = keygen + c.keygen = *keygen c.chainsEnabled = newChains // update chain params for bitcoin if it has config in file if c.bitcoinChainParams != nil && btcChainParams != nil { diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index 6b559ccca2..08060d1181 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -18,8 +18,7 @@ func TestNewZetaCoreContext(t *testing.T) { require.NotNil(t, zetaContext) // assert keygen - keyGen, keyGenFound := zetaContext.GetKeygen() - require.False(t, keyGenFound) + keyGen := zetaContext.GetKeygen() require.Equal(t, observertypes.Keygen{}, keyGen) // assert enabled chains @@ -136,8 +135,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ) // assert keygen updated - keyGen, keyGenFound := zetaContext.GetKeygen() - require.True(t, keyGenFound) + keyGen := zetaContext.GetKeygen() require.Equal(t, keyGenToUpdate, keyGen) // assert enabled chains updated @@ -223,8 +221,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ) // assert keygen updated - keyGen, keyGenFound := zetaContext.GetKeygen() - require.True(t, keyGenFound) + keyGen := zetaContext.GetKeygen() require.Equal(t, keyGenToUpdate, keyGen) // assert enabled chains updated