Skip to content

Commit

Permalink
use network name as map index to store relayer key passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Aug 15, 2024
1 parent dd56b78 commit ad8773f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions zetaclient/context/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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{},
}
Expand Down Expand Up @@ -141,19 +141,19 @@ 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()

Check warning on line 146 in zetaclient/context/app.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/context/app.go#L144-L146

Added lines #L144 - L146 were not covered by tests

a.relayerKeyPasswords = relayerKeyPasswords

Check warning on line 148 in zetaclient/context/app.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/context/app.go#L148

Added line #L148 was not covered by tests
}

// 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()

Check warning on line 154 in zetaclient/context/app.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/context/app.go#L152-L154

Added lines #L152 - L154 were not covered by tests

return a.relayerKeyPasswords[network]
return a.relayerKeyPasswords[networkName]

Check warning on line 156 in zetaclient/context/app.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/context/app.go#L156

Added line #L156 was not covered by tests
}

// Update updates AppContext and params for all chains
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/orchestrator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 170 in zetaclient/orchestrator/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/orchestrator/bootstrap.go#L169-L170

Added lines #L169 - L170 were not covered by tests
if err != nil {
logger.Std.Error().Err(err).Msg("Unable to load Solana relayer key")
Expand Down

0 comments on commit ad8773f

Please sign in to comment.