Skip to content

Commit

Permalink
Remove keystore migrate as all v1 keys should have been migrated by now
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Sep 14, 2023
1 parent 220050f commit 4982867
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 95 deletions.
3 changes: 0 additions & 3 deletions core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,6 @@ func (s *Shell) runNode(c *cli.Context) error {
return fmt.Errorf("error listing legacy evm chains: %w", err)
}
for _, ch := range chainList {
if err = keyStore.Migrate(s.Config.Password().VRF(), ch.ID()); err != nil {
return errors.Wrap(err, "error migrating keystore")
}
if ch.Config().EVM().AutoCreateKey() {
lggr.Debugf("AutoCreateKey=true, will ensure EVM key for chain %s", ch.ID())
err2 := app.GetKeyStore().Eth().EnsureKeys(ch.ID())
Expand Down
76 changes: 0 additions & 76 deletions core/services/keystore/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type Master interface {
StarkNet() StarkNet
VRF() VRF
Unlock(password string) error
Migrate(vrfPassword string, chainID *big.Int) error
IsEmpty() (bool, error)
}

Expand Down Expand Up @@ -151,81 +150,6 @@ func (ks *master) IsEmpty() (bool, error) {
return count == 0, nil
}

func (ks *master) Migrate(vrfPssword string, chainID *big.Int) error {
ks.lock.Lock()
defer ks.lock.Unlock()
if ks.isLocked() {
return ErrLocked
}
csaKeys, err := ks.csa.GetV1KeysAsV2()
if err != nil {
return err
}
for _, csaKey := range csaKeys {
if _, exists := ks.keyRing.CSA[csaKey.ID()]; exists {
continue
}
ks.logger.Debugf("Migrating CSA key %s", csaKey.ID())
ks.keyRing.CSA[csaKey.ID()] = csaKey
}
ocrKeys, err := ks.ocr.GetV1KeysAsV2()
if err != nil {
return err
}
for _, ocrKey := range ocrKeys {
if _, exists := ks.keyRing.OCR[ocrKey.ID()]; exists {
continue
}
ks.logger.Debugf("Migrating OCR key %s", ocrKey.ID())
ks.keyRing.OCR[ocrKey.ID()] = ocrKey
}
p2pKeys, err := ks.p2p.GetV1KeysAsV2()
if err != nil {
return err
}
for _, p2pKey := range p2pKeys {
if _, exists := ks.keyRing.P2P[p2pKey.ID()]; exists {
continue
}
ks.logger.Debugf("Migrating P2P key %s", p2pKey.ID())
ks.keyRing.P2P[p2pKey.ID()] = p2pKey
}
vrfKeys, err := ks.vrf.GetV1KeysAsV2(vrfPssword)
if err != nil {
return err
}
for _, vrfKey := range vrfKeys {
if _, exists := ks.keyRing.VRF[vrfKey.ID()]; exists {
continue
}
ks.logger.Debugf("Migrating VRF key %s", vrfKey.ID())
ks.keyRing.VRF[vrfKey.ID()] = vrfKey
}
if err = ks.keyManager.save(); err != nil {
return err
}
ethKeys, nonces, fundings, err := ks.eth.getV1KeysAsV2()
if err != nil {
return err
}
if len(ethKeys) > 0 {
for i, ethKey := range ethKeys {
if _, exists := ks.keyRing.Eth[ethKey.ID()]; exists {
continue
}
ks.logger.Debugf("Migrating Eth key %s (and pegging to chain ID %s)", ethKey.ID(), chainID.String())
// Note that V1 keys that were "funding" will be migrated as "disabled"
if err = ks.eth.addWithNonce(ethKey, chainID, nonces[i], fundings[i]); err != nil {
return err
}
if err = ks.keyManager.save(); err != nil {
return err
}
}
}
return nil
}

type keyManager struct {
orm ksORM
scryptParams utils.ScryptParams
Expand Down
16 changes: 0 additions & 16 deletions core/services/keystore/mocks/master.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4982867

Please sign in to comment.