Skip to content

Commit 09bd263

Browse files
committed
chore_: Remove legacy mobile v1 migration workaround
It seems to affect the new mobile app. Cannot login on failed sync because this workaround fails.
1 parent c3bd89f commit 09bd263

File tree

2 files changed

+0
-92
lines changed

2 files changed

+0
-92
lines changed

api/geth_backend.go

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -558,68 +558,6 @@ func (b *GethStatusBackend) LoginAccount(request *requests.Login) error {
558558
return nil
559559
}
560560

561-
// This is a workaround to make user be able to login again, the root cause is where the node config migration
562-
// failed caused by adding new columns to the node config table, it's been fixed in PR: https://github.com/status-im/status-go/pull/6248.
563-
// Details for the issue: it prevent user from login, it happens when old mobile user ignore upgrade the app to the version which introduced the node config migration
564-
// and choose to upgrade a higher version instead, after upgrading, user first attempt to login will fail because the node config migration will fail.
565-
// and second attempt to login will cause an empty node config saved in the db.
566-
func (b *GethStatusBackend) workaroundToFixBadMigration(request *requests.Login) (err error) {
567-
if !gocommon.IsMobilePlatform() { // this issue only happens on mobile platform
568-
return nil
569-
}
570-
571-
b.mu.Lock()
572-
defer b.mu.Unlock()
573-
574-
var (
575-
currentConf *params.NodeConfig
576-
defaultNodeConf *params.NodeConfig
577-
)
578-
currentConf, err = nodecfg.GetNodeConfigFromDB(b.appDB)
579-
if err != nil {
580-
return err
581-
}
582-
583-
// check if we saved a empty node config because of node config migration failed
584-
if currentConf.NetworkID == 0 &&
585-
currentConf.NodeKey == "" {
586-
// check if exist old node config
587-
oldNodeConf := &params.NodeConfig{}
588-
err = b.appDB.QueryRow("SELECT node_config FROM settings WHERE synthetic_id = 'id'").Scan(&sqlite.JSONBlob{Data: oldNodeConf})
589-
if err != nil && err != sql.ErrNoRows {
590-
return err
591-
}
592-
if err == sql.ErrNoRows {
593-
return errors.New("failed to migrate node config as there's no data in settings")
594-
}
595-
596-
// the createAccount contains all the fields that are needed to create the default node config
597-
createAccount := b.convertLoginRequestToAccountRequest(request)
598-
defaultNodeConf, err = DefaultNodeConfig(oldNodeConf.ShhextConfig.InstallationID, request.KeyUID, createAccount)
599-
if err != nil {
600-
return err
601-
}
602-
603-
b.overridePartialWithOldNodeConfig(defaultNodeConf, oldNodeConf)
604-
var tx *sql.Tx
605-
tx, err = b.appDB.BeginTx(context.Background(), &sql.TxOptions{})
606-
if err != nil {
607-
return err
608-
}
609-
defer func() {
610-
if err == nil {
611-
err = tx.Commit()
612-
return
613-
}
614-
// don't shadow original error
615-
_ = tx.Rollback()
616-
}()
617-
err = nodecfg.SaveConfigWithTx(tx, defaultNodeConf)
618-
}
619-
620-
return nil
621-
}
622-
623561
func (b *GethStatusBackend) overridePartialWithOldNodeConfig(conf *params.NodeConfig, oldNodeConf *params.NodeConfig) {
624562
// rootDataDir should be set by InitializeApplication or UpdateRootDataDir already
625563
conf.RootDataDir = b.rootDataDir
@@ -686,11 +624,6 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
686624
return errors.Wrap(err, "failed to open database")
687625
}
688626

689-
//relate PR: https://github.com/status-im/status-go/pull/6248
690-
if err := b.workaroundToFixBadMigration(request); err != nil {
691-
return errors.Wrap(err, "failed to workaround bad migration")
692-
}
693-
694627
defaultCfg := &params.NodeConfig{
695628
// why we need this? relate PR: https://github.com/status-im/status-go/pull/4014
696629
KeycardPairingDataFile: filepath.Join(b.rootDataDir, DefaultKeycardPairingDataFileRelativePath),

api/old_mobile_v1_user_login_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/stretchr/testify/suite"
77
"go.uber.org/zap"
88

9-
"github.com/status-im/status-go/common"
109
"github.com/status-im/status-go/protocol/requests"
1110
"github.com/status-im/status-go/t/utils"
1211
)
@@ -51,27 +50,3 @@ func (s *OldMobileV1_10_UserLoginTest) TestLoginWithSuccessNodeConfigMigration()
5150
s.Require().NoError(b.LoginAccount(loginRequest))
5251
s.Require().NoError(b.Logout())
5352
}
54-
55-
// without workaroundToFixBadMigration, this test would login fail
56-
func (s *OldMobileV1_10_UserLoginTest) TestLoginWithFailNodeConfigMigration() {
57-
bkFunc := common.IsMobilePlatform
58-
common.IsMobilePlatform = func() bool {
59-
return true
60-
}
61-
defer func() {
62-
common.IsMobilePlatform = bkFunc
63-
}()
64-
65-
s.tmpdir = s.T().TempDir()
66-
copyDir(v1_10_AfterUpgradeFolder, s.tmpdir, s.T())
67-
68-
b := NewGethStatusBackend(s.logger)
69-
b.UpdateRootDataDir(s.tmpdir)
70-
s.Require().NoError(b.OpenAccounts(true))
71-
loginRequest := &requests.Login{
72-
KeyUID: v1_10_keyUID,
73-
Password: v1_10_passwd,
74-
}
75-
err := b.LoginAccount(loginRequest)
76-
s.Require().NoError(err)
77-
}

0 commit comments

Comments
 (0)