From 9e148eab8979ec0a5b08a88c0cfc578cc35cdc04 Mon Sep 17 00:00:00 2001 From: Gheorghe Pinzaru Date: Wed, 16 Sep 2020 10:31:01 +0300 Subject: [PATCH] Dont allow disabling waku (#2040) --- VERSION | 2 +- api/geth_backend.go | 17 +++-------------- multiaccounts/accounts/database.go | 13 +------------ services/accounts/settings.go | 5 +++++ 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/VERSION b/VERSION index 905fae0d2..4d74f3238 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.61.2 +0.62.0 diff --git a/api/geth_backend.go b/api/geth_backend.go index 7b697ccbb..05e158bd3 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -431,21 +431,10 @@ func (b *GethStatusBackend) loadNodeConfig() (*params.NodeConfig, error) { if err != nil { return nil, err } - settings, err := accountDB.GetSettings() - if err != nil { - return nil, err - } - // NodeConfig is denormalized and we can't migrate it easily - // WakuEnabled is pulled from settings and it's the source - // of truth on whether `WakuConfig` or `WhisperConfig` should be enabled - if settings.WakuEnabled { - conf.WakuConfig.Enabled = true - conf.WhisperConfig.Enabled = false - } else { - conf.WakuConfig.Enabled = false - conf.WhisperConfig.Enabled = true - } + conf.WakuConfig.Enabled = true + conf.WhisperConfig.Enabled = false + // NodeConfig.Version should be taken from params.Version // which is set at the compile time. // What's cached is usually outdated so we overwrite it here. diff --git a/multiaccounts/accounts/database.go b/multiaccounts/accounts/database.go index 93e9dca3a..5de648aa8 100644 --- a/multiaccounts/accounts/database.go +++ b/multiaccounts/accounts/database.go @@ -87,7 +87,6 @@ type Settings struct { WalletRootAddress types.Address `json:"wallet-root-address,omitempty"` WalletSetUpPassed bool `json:"wallet-set-up-passed?,omitempty"` WalletVisibleTokens *json.RawMessage `json:"wallet/visible-tokens,omitempty"` - WakuEnabled bool `json:"waku-enabled,omitempty"` WakuBloomFilterMode bool `json:"waku-bloom-filter-mode,omitempty"` WebViewAllowPermissionRequests bool `json:"webview-allow-permission-requests?,omitempty"` } @@ -129,12 +128,10 @@ INSERT INTO settings ( public_key, signing_phrase, wallet_root_address, - waku_enabled, synthetic_id ) VALUES ( ?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?, -?, 'id')`, s.Address, s.Currency, @@ -156,7 +153,6 @@ INSERT INTO settings ( s.PublicKey, s.SigningPhrase, s.WalletRootAddress, - s.WakuEnabled, ) return err @@ -315,12 +311,6 @@ func (db *Database) SaveSetting(setting string, value interface{}) error { case "wallet/visible-tokens": value = &sqlite.JSONBlob{value} update, err = db.db.Prepare("UPDATE settings SET wallet_visible_tokens = ? WHERE synthetic_id = 'id'") - case "waku-enabled": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET waku_enabled = ? WHERE synthetic_id = 'id'") case "appearance": update, err = db.db.Prepare("UPDATE settings SET appearance = ? WHERE synthetic_id = 'id'") case "waku-bloom-filter-mode": @@ -351,7 +341,7 @@ func (db *Database) GetNodeConfig(nodecfg interface{}) error { func (db *Database) GetSettings() (Settings, error) { var s Settings - err := db.db.QueryRow("SELECT address, chaos_mode, currency, current_network, custom_bootnodes, custom_bootnodes_enabled, dapps_address, eip1581_address, fleet, hide_home_tooltip, installation_id, key_uid, keycard_instance_uid, keycard_paired_on, keycard_pairing, last_updated, latest_derived_path, log_level, mnemonic, name, networks, notifications_enabled, push_notifications_server_enabled, push_notifications_from_contacts_only, remote_push_notifications_enabled, send_push_notifications, push_notifications_block_mentions, photo_path, pinned_mailservers, preferred_name, preview_privacy, public_key, remember_syncing_choice, signing_phrase, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers, syncing_on_mobile_network, usernames, appearance, wallet_root_address, wallet_set_up_passed, wallet_visible_tokens, waku_enabled, waku_bloom_filter_mode, webview_allow_permission_requests FROM settings WHERE synthetic_id = 'id'").Scan( + err := db.db.QueryRow("SELECT address, chaos_mode, currency, current_network, custom_bootnodes, custom_bootnodes_enabled, dapps_address, eip1581_address, fleet, hide_home_tooltip, installation_id, key_uid, keycard_instance_uid, keycard_paired_on, keycard_pairing, last_updated, latest_derived_path, log_level, mnemonic, name, networks, notifications_enabled, push_notifications_server_enabled, push_notifications_from_contacts_only, remote_push_notifications_enabled, send_push_notifications, push_notifications_block_mentions, photo_path, pinned_mailservers, preferred_name, preview_privacy, public_key, remember_syncing_choice, signing_phrase, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers, syncing_on_mobile_network, usernames, appearance, wallet_root_address, wallet_set_up_passed, wallet_visible_tokens, waku_bloom_filter_mode, webview_allow_permission_requests FROM settings WHERE synthetic_id = 'id'").Scan( &s.Address, &s.ChaosMode, &s.Currency, @@ -395,7 +385,6 @@ func (db *Database) GetSettings() (Settings, error) { &s.WalletRootAddress, &s.WalletSetUpPassed, &s.WalletVisibleTokens, - &s.WakuEnabled, &s.WakuBloomFilterMode, &s.WebViewAllowPermissionRequests) return s, err diff --git a/services/accounts/settings.go b/services/accounts/settings.go index 92a5a2e66..978e936fd 100644 --- a/services/accounts/settings.go +++ b/services/accounts/settings.go @@ -16,6 +16,11 @@ type SettingsAPI struct { } func (api *SettingsAPI) SaveSetting(ctx context.Context, typ string, val interface{}) error { + // NOTE(Ferossgp): v0.62.0 Backward compatibility, skip this for older clients instead of returning error + if typ == "waku-enabled" { + return nil + } + return api.db.SaveSetting(typ, val) }