Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: disable history archive for new user and add advanced setting #14547

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/modules/main/profile_section/advanced/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,12 @@ proc toggleCommunitySection*(self: Controller) =

proc toggleNodeManagementSection*(self: Controller) =
self.events.emit(TOGGLE_SECTION, ToggleSectionArgs(sectionType: SectionType.NodeManagement))

proc isCommunityHistoryArchiveSupportEnabled*(self: Controller): bool =
self.nodeConfigurationService.isCommunityHistoryArchiveSupportEnabled()

proc enableCommunityHistoryArchiveSupport*(self: Controller): bool =
self.nodeConfigurationService.enableCommunityHistoryArchiveSupport()

proc disableCommunityHistoryArchiveSupport*(self: Controller): bool =
self.nodeConfigurationService.disableCommunityHistoryArchiveSupport()
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ method isDebugEnabled*(self: AccessInterface): bool {.base.} =
method isRuntimeLogLevelSet*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")

method isCommunityHistoryArchiveSupportEnabled*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")

method enableCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method disableCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method toggleDebug*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

Expand Down
11 changes: 11 additions & 0 deletions src/app/modules/main/profile_section/advanced/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ method onNimbusProxyToggled*(self: Module) =
method isRuntimeLogLevelSet*(self: Module): bool =
return constants.runtimeLogLevelSet()

method isCommunityHistoryArchiveSupportEnabled*(self: Module): bool =
return self.controller.isCommunityHistoryArchiveSupportEnabled()

method enableCommunityHistoryArchiveSupport*(self: Module) =
if self.controller.enableCommunityHistoryArchiveSupport():
self.view.archiveProtocolEnabledChanged()

method disableCommunityHistoryArchiveSupport*(self: Module) =
if self.controller.disableCommunityHistoryArchiveSupport():
self.view.archiveProtocolEnabledChanged()

method toggleWalletSection*(self: Module) =
self.controller.toggleWalletSection()

Expand Down
13 changes: 13 additions & 0 deletions src/app/modules/main/profile_section/advanced/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ QtObject:
QtProperty[bool] isRuntimeLogLevelSet:
read = getIsRuntimeLogLevelSet

proc archiveProtocolEnabledChanged*(self: View) {.signal.}
proc getArchiveProtocolEnabled*(self: View): bool {.slot.} =
return self.delegate.isCommunityHistoryArchiveSupportEnabled()
QtProperty[bool] archiveProtocolEnabled:
read = getArchiveProtocolEnabled
notify = archiveProtocolEnabledChanged

proc enableCommunityHistoryArchiveSupport*(self: View) {.slot.} =
self.delegate.enableCommunityHistoryArchiveSupport()

proc disableCommunityHistoryArchiveSupport*(self: View) {.slot.} =
self.delegate.disableCommunityHistoryArchiveSupport()

proc toggleWalletSection*(self: View) {.slot.} =
self.delegate.toggleWalletSection()

Expand Down
2 changes: 1 addition & 1 deletion src/app_service/common/network_constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var NODE_CONFIG* = %* {
},
"Networks": NETWORKS,
"TorrentConfig": {
"Enabled": true,
"Enabled": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also change default value here:

torrentConfigEnabled: some(true),

But that's only in master branch

"Port": TORRENT_CONFIG_PORT,
"DataDir": DEFAULT_TORRENT_CONFIG_DATADIR,
"TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR
Expand Down
18 changes: 10 additions & 8 deletions src/app_service/service/node_configuration/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ proc adaptNodeSettingsForTheAppNeed(self: Service) =
self.configuration.LogFile = "./geth.log"
self.configuration.ShhextConfig.BackupDisabledDataDir = "./"

if (not self.isCommunityHistoryArchiveSupportEnabled()):
# Force community archive support true on Desktop
# TODO those lines can be removed in the future once we are sure no one has used a legacy client where it is off
if (self.enableCommunityHistoryArchiveSupport()):
self.configuration.TorrentConfig.Enabled = true
else:
error "Setting Community History Archive On failed"

proc init*(self: Service) =
try:
let response = status_node_config.getNodeConfig()
Expand Down Expand Up @@ -123,6 +115,16 @@ proc enableCommunityHistoryArchiveSupport*(self: Service): bool =
error "error enabling community history archive support: ", errDescription = response.error.message
return false

self.configuration.TorrentConfig.Enabled = true
return true

proc disableCommunityHistoryArchiveSupport*(self: Service): bool =
let response = status_node_config.disableCommunityHistoryArchiveSupport()
if(not response.error.isNil):
error "error disabling community history archive support: ", errDescription = response.error.message
return false

self.configuration.TorrentConfig.Enabled = false
return true

proc getFleet*(self: Service): Fleet =
Expand Down
7 changes: 7 additions & 0 deletions src/backend/node_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ proc enableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] =
result = core.callPrivateRPC("enableCommunityHistoryArchiveProtocol".prefix)
except RpcException as e:
error "error doing rpc request", methodName = "enableCommunityHistoryArchiveProtocol", exception=e.msg
raise newException(RpcException, e.msg)

proc disableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] =
try:
result = core.callPrivateRPC("disableCommunityHistoryArchiveProtocol".prefix)
except RpcException as e:
error "error doing rpc request", methodName = "disableCommunityHistoryArchiveProtocol", exception=e.msg
raise newException(RpcException, e.msg)
11 changes: 10 additions & 1 deletion ui/app/AppLayouts/Communities/controls/Options.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ ColumnLayout {
StatusCheckBox {
id: archiveSupportToggle
width: (parent.width-12)
checked: true
checked: false
jrainville marked this conversation as resolved.
Show resolved Hide resolved
leftSide: false
padding: 0
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Community history service")

StatusToolTip {
text: qsTr('For this Community Setting to work, you also need to activate "Archive Protocol Enabled" in Advanced Settings')
visible: hoverHandler.hovered
}
HoverHandler {
id: hoverHandler
enabled: true
}
}
}

Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Profile/ProfileLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ StatusSectionLayout {
sourceComponent: MessagingView {
implicitWidth: parent.width
implicitHeight: parent.height
advancedStore: root.store.advancedStore
messagingStore: root.store.messagingStore
sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.messaging)
contactsStore: root.store.contactsStore
Expand Down
12 changes: 12 additions & 0 deletions ui/app/AppLayouts/Profile/stores/AdvancedStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ QtObject {
readonly property bool isWakuV2ShardedCommunitiesEnabled: localAppSettings.wakuV2ShardedCommunitiesEnabled ?? false
property int logMaxBackups: advancedModule ? advancedModule.logMaxBackups : 1
property bool isRuntimeLogLevelSet: advancedModule ? advancedModule.isRuntimeLogLevelSet: false
readonly property bool archiveProtocolEnabled: advancedModule ? advancedModule.archiveProtocolEnabled : false

property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : []

Expand Down Expand Up @@ -150,6 +151,17 @@ QtObject {
localAppSettings.createCommunityEnabled = !localAppSettings.createCommunityEnabled
}

function toggleArchiveProtocolEnabled() {
if(!advancedModule)
return

if (root.archiveProtocolEnabled) {
advancedModule.disableCommunityHistoryArchiveSupport()
} else {
advancedModule.enableCommunityHistoryArchiveSupport()
}
}

function toggleManageCommunityOnTestnet() {
root.isManageCommunityOnTestModeEnabled = !root.isManageCommunityOnTestModeEnabled
}
Expand Down
11 changes: 11 additions & 0 deletions ui/app/AppLayouts/Profile/views/AdvancedView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ SettingsContentBase {
}
}

StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
text: qsTr("Archive Protocol Enabled")
isSwitch: true
switchChecked: root.advancedStore.archiveProtocolEnabled
onClicked: {
root.advancedStore.toggleArchiveProtocolEnabled()
}
}

Separator {
width: parent.width
}
Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Profile/views/MessagingView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SettingsContentBase {
id: root

property MessagingStore messagingStore
property AdvancedStore advancedStore
property ContactsStore contactsStore

ColumnLayout {
Expand Down