From ad8773ffd130522be972d94e699a74c76144f7d4 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 15 Aug 2024 13:21:15 -0500 Subject: [PATCH] use network name as map index to store relayer key passwords --- cmd/zetaclientd/start.go | 4 ++-- zetaclient/context/app.go | 12 ++++++------ zetaclient/orchestrator/bootstrap.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 0646963e49..afea8291b3 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -58,8 +58,8 @@ func start(_ *cobra.Command, _ []string) error { return errors.Wrap(err, "unable to get passwords") } hotkeyPass, tssKeyPass, solanaKeyPass := passwords[0], passwords[1], passwords[2] - relayerKeyPasswords := map[chains.Network]string{ - chains.Network_solana: solanaKeyPass, + relayerKeyPasswords := map[string]string{ + chains.Network_solana.String(): solanaKeyPass, } //Load Config file given path diff --git a/zetaclient/context/app.go b/zetaclient/context/app.go index 3bb4ab698d..24dc7b26d3 100644 --- a/zetaclient/context/app.go +++ b/zetaclient/context/app.go @@ -37,8 +37,8 @@ type AppContext struct { // keygen is the current tss keygen state keygen observertypes.Keygen - // relayerKeyPasswords maps network id to relayer key password - relayerKeyPasswords map[chains.Network]string + // relayerKeyPasswords maps network name to relayer key password + relayerKeyPasswords map[string]string mu sync.RWMutex } @@ -54,7 +54,7 @@ func New(cfg config.Config, logger zerolog.Logger) *AppContext { crosschainFlags: observertypes.CrosschainFlags{}, currentTssPubKey: "", keygen: observertypes.Keygen{}, - relayerKeyPasswords: make(map[chains.Network]string), + relayerKeyPasswords: make(map[string]string), mu: sync.RWMutex{}, } @@ -141,7 +141,7 @@ func (a *AppContext) GetCrossChainFlags() observertypes.CrosschainFlags { } // SetRelayerKeyPasswords sets the relayer key passwords for given networks -func (a *AppContext) SetRelayerKeyPasswords(relayerKeyPasswords map[chains.Network]string) { +func (a *AppContext) SetRelayerKeyPasswords(relayerKeyPasswords map[string]string) { a.mu.Lock() defer a.mu.Unlock() @@ -149,11 +149,11 @@ func (a *AppContext) SetRelayerKeyPasswords(relayerKeyPasswords map[chains.Netwo } // GetRelayerKeyPassword returns the relayer key password for the given network -func (a *AppContext) GetRelayerKeyPassword(network chains.Network) string { +func (a *AppContext) GetRelayerKeyPassword(networkName string) string { a.mu.RLock() defer a.mu.RUnlock() - return a.relayerKeyPasswords[network] + return a.relayerKeyPasswords[networkName] } // Update updates AppContext and params for all chains diff --git a/zetaclient/orchestrator/bootstrap.go b/zetaclient/orchestrator/bootstrap.go index 5741c04a97..5efc0cb47b 100644 --- a/zetaclient/orchestrator/bootstrap.go +++ b/zetaclient/orchestrator/bootstrap.go @@ -166,7 +166,7 @@ func syncSignerMap( } // try loading Solana relayer key if present - password := app.GetRelayerKeyPassword(rawChain.Network) + password := app.GetRelayerKeyPassword(rawChain.Network.String()) relayerKey, err := keys.LoadRelayerKey(app.Config().GetRelayerKeyPath(), rawChain.Network, password) if err != nil { logger.Std.Error().Err(err).Msg("Unable to load Solana relayer key")