diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index 523dff1e4a..e8fc39b9fc 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -69,11 +69,9 @@ func getAppContext( // feed chain params err := appContext.Update( - observertypes.Keygen{}, []chains.Chain{evmChain, chains.ZetaChainMainnet}, nil, chainParams, - "tssPubKey", *sample.CrosschainFlags(), ) require.NoError(t, err) diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index cc967d8e3c..4165021f0e 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -251,13 +251,11 @@ func makeCtx(t *testing.T) context.Context { bscParams := mocks.MockChainParams(chains.BscMainnet.ChainId, 10) err := app.Update( - observertypes.Keygen{}, []chains.Chain{chains.BscMainnet, chains.ZetaChainMainnet}, nil, map[int64]*observertypes.ChainParams{ chains.BscMainnet.ChainId: &bscParams, }, - "tssPubKey", observertypes.CrosschainFlags{}, ) require.NoError(t, err, "unable to update app context") diff --git a/zetaclient/context/app.go b/zetaclient/context/app.go index 8474c3ec87..d796c5beec 100644 --- a/zetaclient/context/app.go +++ b/zetaclient/context/app.go @@ -22,20 +22,14 @@ type AppContext struct { // config is the config of the app config config.Config - // logger is the logger of the app - logger zerolog.Logger - // chainRegistry is a registry of supported chains chainRegistry *ChainRegistry - // currentTssPubKey is the current tss pubKey - currentTssPubKey string - // crosschainFlags is the current crosschain flags state crosschainFlags observertypes.CrosschainFlags - // keygen is the current tss keygen state - keygen observertypes.Keygen + // logger is the logger of the app + logger zerolog.Logger mu sync.RWMutex } @@ -43,16 +37,10 @@ type AppContext struct { // New creates and returns new empty AppContext func New(cfg config.Config, relayerKeyPasswords map[string]string, logger zerolog.Logger) *AppContext { return &AppContext{ - config: cfg, - logger: logger.With().Str("module", "appcontext").Logger(), - - chainRegistry: NewChainRegistry(relayerKeyPasswords), - - crosschainFlags: observertypes.CrosschainFlags{}, - currentTssPubKey: "", - keygen: observertypes.Keygen{}, - - mu: sync.RWMutex{}, + config: cfg, + chainRegistry: NewChainRegistry(relayerKeyPasswords), + crosschainFlags: observertypes.CrosschainFlags{}, + logger: logger.With().Str("module", "appcontext").Logger(), } } @@ -102,32 +90,6 @@ func (a *AppContext) IsInboundObservationEnabled() bool { return a.GetCrossChainFlags().IsInboundEnabled } -// GetKeygen returns the current keygen -func (a *AppContext) GetKeygen() observertypes.Keygen { - a.mu.RLock() - defer a.mu.RUnlock() - - var copiedPubKeys []string - if a.keygen.GranteePubkeys != nil { - copiedPubKeys = make([]string, len(a.keygen.GranteePubkeys)) - copy(copiedPubKeys, a.keygen.GranteePubkeys) - } - - return observertypes.Keygen{ - Status: a.keygen.Status, - GranteePubkeys: copiedPubKeys, - BlockNumber: a.keygen.BlockNumber, - } -} - -// GetCurrentTssPubKey returns the current tss pubKey. -func (a *AppContext) GetCurrentTssPubKey() string { - a.mu.RLock() - defer a.mu.RUnlock() - - return a.currentTssPubKey -} - // GetCrossChainFlags returns crosschain flags func (a *AppContext) GetCrossChainFlags() observertypes.CrosschainFlags { a.mu.RLock() @@ -139,10 +101,8 @@ func (a *AppContext) GetCrossChainFlags() observertypes.CrosschainFlags { // Update updates AppContext and params for all chains // this must be the ONLY function that writes to AppContext func (a *AppContext) Update( - keygen observertypes.Keygen, freshChains, additionalChains []chains.Chain, freshChainParams map[int64]*observertypes.ChainParams, - tssPubKey string, crosschainFlags observertypes.CrosschainFlags, ) error { // some sanity checks @@ -151,9 +111,6 @@ func (a *AppContext) Update( return fmt.Errorf("no chains present") case len(freshChainParams) == 0: return fmt.Errorf("no chain params present") - case tssPubKey == "" && a.currentTssPubKey != "": - // note that if we're doing a fresh start, we ALLOW an empty tssPubKey - return fmt.Errorf("tss pubkey is empty") case len(additionalChains) > 0: for _, c := range additionalChains { if !c.IsExternal { @@ -171,8 +128,6 @@ func (a *AppContext) Update( defer a.mu.Unlock() a.crosschainFlags = crosschainFlags - a.keygen = keygen - a.currentTssPubKey = tssPubKey return nil } diff --git a/zetaclient/context/app_test.go b/zetaclient/context/app_test.go index 2297a3cdec..9df52db1fc 100644 --- a/zetaclient/context/app_test.go +++ b/zetaclient/context/app_test.go @@ -18,17 +18,11 @@ func TestAppContext(t *testing.T) { testCfg = config.New(false) logger = zerolog.New(zerolog.NewTestWriter(t)) - keyGen = types.Keygen{ - Status: types.KeygenStatus_KeyGenSuccess, - GranteePubkeys: []string{"testPubKey1"}, - BlockNumber: 123, - } ccFlags = types.CrosschainFlags{ IsInboundEnabled: true, IsOutboundEnabled: true, GasPriceIncreaseFlags: nil, } - ttsPubKey = "tssPubKeyTest" ) testCfg.BTCChainConfigs[111] = config.BTCConfig{RPCUsername: "satoshi"} @@ -64,8 +58,6 @@ func TestAppContext(t *testing.T) { require.ErrorIs(t, err, ErrChainNotFound) require.Equal(t, testCfg, appContext.Config()) - require.Empty(t, appContext.GetKeygen()) - require.Empty(t, appContext.GetCurrentTssPubKey()) require.Empty(t, appContext.GetCrossChainFlags()) require.False(t, appContext.IsInboundObservationEnabled()) require.False(t, appContext.IsOutboundObservationEnabled()) @@ -89,15 +81,13 @@ func TestAppContext(t *testing.T) { } // ACT - err = appContext.Update(keyGen, newChains, additionalChains, chainParams, ttsPubKey, ccFlags) + err = appContext.Update(newChains, additionalChains, chainParams, ccFlags) // ASSERT require.NoError(t, err) // Check getters assert.Equal(t, testCfg, appContext.Config()) - assert.Equal(t, keyGen, appContext.GetKeygen()) - assert.Equal(t, ttsPubKey, appContext.GetCurrentTssPubKey()) assert.Equal(t, ccFlags, appContext.GetCrossChainFlags()) assert.True(t, appContext.IsInboundObservationEnabled()) assert.True(t, appContext.IsOutboundObservationEnabled()) @@ -132,7 +122,7 @@ func TestAppContext(t *testing.T) { { name: "update with empty chains results in an error", act: func(a *AppContext) error { - return appContext.Update(keyGen, newChains, nil, nil, ttsPubKey, ccFlags) + return appContext.Update(newChains, nil, nil, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "no chain params present") @@ -153,7 +143,7 @@ func TestAppContext(t *testing.T) { chainParamsWithOpt := maps.Clone(chainParams) chainParamsWithOpt[opParams.ChainId] = opParams - return a.Update(keyGen, chainsWithOpt, additionalChains, chainParamsWithOpt, ttsPubKey, ccFlags) + return a.Update(chainsWithOpt, additionalChains, chainParamsWithOpt, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorIs(t, err, ErrChainNotSupported) @@ -164,7 +154,7 @@ func TestAppContext(t *testing.T) { name: "trying to add zeta chain without chain params is allowed", act: func(a *AppContext) error { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParams, ttsPubKey, ccFlags) + return a.Update(chainsWithZeta, additionalChains, chainParams, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -186,7 +176,7 @@ func TestAppContext(t *testing.T) { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParamsWithZeta, ttsPubKey, ccFlags) + return a.Update(chainsWithZeta, additionalChains, chainParamsWithZeta, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -209,7 +199,7 @@ func TestAppContext(t *testing.T) { updatedChainParams[maticParams.ChainId] = maticParams delete(updatedChainParams, chains.ZetaChainMainnet.ChainId) - return a.Update(keyGen, newChains, additionalChains, updatedChainParams, ttsPubKey, ccFlags) + return a.Update(newChains, additionalChains, updatedChainParams, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "unable to locate fresh chain 137 based on chain params") diff --git a/zetaclient/orchestrator/bootstap_test.go b/zetaclient/orchestrator/bootstap_test.go index 322fbf12e0..d5f64c8500 100644 --- a/zetaclient/orchestrator/bootstap_test.go +++ b/zetaclient/orchestrator/bootstap_test.go @@ -443,11 +443,9 @@ func mustUpdateAppContext( chainParams map[int64]*observertypes.ChainParams, ) { err := app.Update( - app.GetKeygen(), chains, additionalChains, chainParams, - "tssPubKey", app.GetCrossChainFlags(), ) diff --git a/zetaclient/orchestrator/contextupdater.go b/zetaclient/orchestrator/contextupdater.go index 02e4b275e0..071ded772c 100644 --- a/zetaclient/orchestrator/contextupdater.go +++ b/zetaclient/orchestrator/contextupdater.go @@ -86,21 +86,11 @@ func UpdateAppContext(ctx context.Context, app *zctx.AppContext, zc Zetacore, lo return errors.Wrap(err, "unable to fetch chain params") } - keyGen, err := zc.GetKeyGen(ctx) - if err != nil { - return errors.Wrap(err, "unable to fetch keygen from zetacore") - } - crosschainFlags, err := zc.GetCrosschainFlags(ctx) if err != nil { return errors.Wrap(err, "unable to fetch crosschain flags from zetacore") } - tss, err := zc.GetTSS(ctx) - if err != nil { - return errors.Wrap(err, "unable to fetch current TSS") - } - freshParams := make(map[int64]*observertypes.ChainParams, len(chainParams)) // check and update chain params for each chain @@ -117,7 +107,7 @@ func UpdateAppContext(ctx context.Context, app *zctx.AppContext, zc Zetacore, lo continue } - if err := observertypes.ValidateChainParams(cp); err != nil { + if err = observertypes.ValidateChainParams(cp); err != nil { logger.Warn().Err(err).Int64("chain.id", cp.ChainId).Msg("Skipping invalid chain params") continue } @@ -126,11 +116,9 @@ func UpdateAppContext(ctx context.Context, app *zctx.AppContext, zc Zetacore, lo } return app.Update( - keyGen, supportedChains, additionalChains, freshParams, - tss.GetTssPubkey(), crosschainFlags, ) } diff --git a/zetaclient/orchestrator/contextupdater_test.go b/zetaclient/orchestrator/contextupdater_test.go index cc28d5ad9e..70bef7dd9a 100644 --- a/zetaclient/orchestrator/contextupdater_test.go +++ b/zetaclient/orchestrator/contextupdater_test.go @@ -43,9 +43,7 @@ func Test_UpdateAppContext(t *testing.T) { zetacore.On("GetSupportedChains", mock.Anything).Return(newChains, nil) zetacore.On("GetAdditionalChains", mock.Anything).Return(nil, nil) zetacore.On("GetChainParams", mock.Anything).Return(newParams, nil) - zetacore.On("GetKeyGen", mock.Anything).Return(observertypes.Keygen{}, nil) zetacore.On("GetCrosschainFlags", mock.Anything).Return(ccFlags, nil) - zetacore.On("GetTSS", mock.Anything).Return(observertypes.TSS{TssPubkey: "0x123"}, nil) // ACT err := UpdateAppContext(ctx, app, zetacore, logger) diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index 4b85ccbb03..8637a47e17 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -627,11 +627,9 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext { // feed chain params err := appContext.Update( - observertypes.Keygen{}, supportedChains, nil, params, - "tssPubKey", *ccFlags, ) require.NoError(t, err, "failed to update app context")