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

gui, rpc: Implement dynamic stakesplitting control, settings changes via rpc, and dynamic changes to sidestaking via rpc #2164

Conversation

jamescowens
Copy link
Member

@jamescowens jamescowens commented Jun 6, 2021

This PR builds on the implementation of the ArgsManager. This implements dynamic GUI settings in a new staking tab in the options dialog to dynamically control the status of stake splitting for staking optimization, and the associated settings: the staking efficiency and the minimum post stake split UTXO value.

Validation is performed on the fields to ensure that the stakingefficiency is between 75% and 98%, and the minstakesplitvalue is 800 or greater.

Note that we are making use of the new updateRwSetting() implemented with the ArgsManager port, which saves runtime settings to a read-write JSON settings file and transparently integrates those settings when using GetArg, etc. Settings in this file take precedence over the read-only settings in the config file. The tool tips warn the user about this order-of-precedence (override), so they are not confused later.

Here are some screenshots:

If you already have entries in your config file, they will come up here by default...
image

If you try to put in an invalid value...
image

If you turn off stake splitting the other relevant fields are hidden...
image

The selections are immediately active in the wallet after pressing apply/ok without restarting...
image
image

Here is what the gridcoinsettings.json file looks like...
{ "enablestakesplit": true, "minstakesplitvalue": 1000, "stakingefficiency": 85 }
and this overrides the entries in the gridcoinresearch.conf file...
enablestakesplit=1
minstakesplitvalue=800
stakingefficiency=98

On restart the settings in the gridcoinsettings.json take precedence over those in the config file...
image

If no entries are in the gridcoinresearch.conf or gridcoinsettings.json, then when first visiting the staking tab this is what is seen...
image

Changing the checkbox state results in the default values being filled in...
image

These can be changed to the desired values and then saved and will be immediately active.

@jamescowens jamescowens self-assigned this Jun 6, 2021
@jamescowens jamescowens added this to the Ingrid milestone Jun 6, 2021
@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch 11 times, most recently from bc234c4 to 189d28a Compare June 8, 2021 11:22
@jamescowens
Copy link
Member Author

jamescowens commented Jun 8, 2021

The dynamic change settings file only accepts one instance of a key. That is a problem to use it for sidestake multiple entries. I probably am going to have to implement and support an alternative specification for sidestaking in the form of

sidestakeaddresses=address1,address2,...,addressn
sidestakeallocation=alloc1,alloc2,...,allocn

in addition to the traditional one. Ugh. It also means that entries in the config file will have to be overridden by an zeroing out entry in the form of

sidestakeaddress=address_to_override,otheraddress,etc
sidestakeallocations=0,other_alloc,etc

Ugh.

@jamescowens
Copy link
Member Author

jamescowens commented Jun 8, 2021

@cyrossignol Please take a look. The first commit is ready. The other two are still draft ... I am not that good with intricate argument handling I think, but I did a reasonable stab at both a listsettings and changesettings, which allow dynamically changing settings from rpc while the wallet is running.

@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch 2 times, most recently from 08d62ba to 44c211f Compare June 9, 2021 21:53
@jamescowens jamescowens changed the title gui: Implement dynamic stakesplitting control gui, rpc: Implement dynamic stakesplitting control, settings changes via rpc, and dynamic changes to sidestaking via rpc Jun 9, 2021
@jamescowens
Copy link
Member Author

Ok. dynamic changes to sidestaking have been implemented via passing appropriate settings to the new changesettings rpc command.

@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch 5 times, most recently from eac91a6 to cfd1321 Compare June 13, 2021 00:13
@jamescowens
Copy link
Member Author

Note that I added a checkbox to be able to turn staking on and off without restarting the wallet. It defaults to "enabled".
image

@jamescowens
Copy link
Member Author

jamescowens commented Jun 13, 2021

Some commentary on the current implementation of the changesettings. When updating the settings this way, it stores them as string values in the read-write JSON file, rather than int64_t (number), boolean true/false, or string. This is ok, because the ArgsManager GetArg is very tolerant of string based representations of the typed primitives in the settings file and deals with them appropriately. This is a little ugly from a purely technical perspective, but works quite well pragmatically. I could fix the type on these by changing the flags from ALLOW_ANY on the AddArg entries to ALLOW_BOOL, ALLOW_INT, or ALLOW_STRING as appropriate, and then the flags would help to type the writes into the r-w file, but this might break arg handling with people using legacy values. I am reticent to introduce that brittleness just for the sake of recording 800 in the JSON instead of "800", or "1" instead of true,

src/gridcoin/staking/status.cpp Outdated Show resolved Hide resolved
src/qt/bitcoingui.cpp Outdated Show resolved Hide resolved
src/qt/optionsdialog.cpp Show resolved Hide resolved
src/qt/optionsdialog.cpp Show resolved Hide resolved
src/rpc/misc.cpp Outdated Show resolved Hide resolved
src/rpc/misc.cpp Show resolved Hide resolved
src/util/system.cpp Outdated Show resolved Hide resolved
src/util/system.cpp Outdated Show resolved Hide resolved
src/miner.cpp Outdated Show resolved Hide resolved
src/rpc/misc.cpp Outdated Show resolved Hide resolved
@cyrossignol
Copy link
Member

I like the dynamic controls!

@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch from f9ec023 to ae23e10 Compare June 13, 2021 18:13
This commit builds on the implementation of the ArgsManager and implements
GUi settings in a new staking tab in the options dialog to dynamically
control the status of stake splitting for staking optimization, and the
associated settings, the staking efficiency and the minimum post stake split
UTXO value.

Validation is performed on the fields to ensure that the efficiency is between
75% and 98%, and the minstakesplitvalue is 800 or greater.

Note that we are making use of the new updateRwSetting implemented with the
ArgsManager port, which saves runtime settings to a read-write JSON settings file.
Settings in this file take precedence over the read-only settings in the config
file. The tool tips warn the user about this order-of-precedence (override), so
they are not confused later.

This also includes a check-box to disable/enable staking.
This provides an rpc command to list all settings in rpc format.
@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch from ae23e10 to 089329a Compare June 13, 2021 18:20
This commit introduces two new settings for sidestaking,
-sidestakeaddresses=address1,address2,..., addressN
-sidestakeallocations=alloc1,alloc2,...,allocN

These may be used in both the config file and with changesettings as an alternative to the original
sidestake=address,allocation entries. If the new entries are present, are not empty, and are correctly
filled out then they will take precedence over the older entries. The reason this is necessary is that
the read-write settings file does not support multiple instances of the same setting, so a restructure
was required to support the r-w override.
@jamescowens jamescowens force-pushed the gui_implement_stakesplitting_control branch from 089329a to 14a5646 Compare June 13, 2021 18:35
@jamescowens jamescowens merged commit fa5b8a4 into gridcoin-community:development Jun 13, 2021
@jamescowens jamescowens deleted the gui_implement_stakesplitting_control branch June 13, 2021 23:53
jamescowens added a commit to jamescowens/Gridcoin-Research that referenced this pull request Aug 1, 2021
Added
 - util, rpc. gui: Changes for snapshotdownload and add feature sync from zero gridcoin-community#2093 (@iFoggz)
 - gui: Implement GUI version of consolidateunspent (coin control part) gridcoin-community#2111 (@jamescowens)
 - gui: Implement consolidateunspent wizard gridcoin-community#2125 (@jamescowens)
 - qt: Add antialiasing to traffic graph widget gridcoin-community#2150 (@barton2526)
 - util: Port of ArgsManager and a significant subset of src/util gridcoin-community#2146 (@jamescowens)
 - doc: add issue templates for bug reports and feature requests gridcoin-community#2147 (@Pythonix)
 - gui, rpc: Implement dynamic stakesplitting control, settings changes via rpc, and dynamic changes to sidestaking via rpc gridcoin-community#2164 (@jamescowens)
 - rpc: Implement getblocksbatch gridcoin-community#2205 (@jamescowens)
 - voting, rpc, gui: Implement demand loading of historical poll by poll id and AVW calculation gridcoin-community#2210 (@jamescowens)
 - gui: Show GUI error dialog if command line parsing fails gridcoin-community#2218 (@jamescowens)
 - gui: Implement close confirmation. gridcoin-community#2216 (@denravonska)
 - build: Use -fstack-reuse=none gridcoin-community#2232 (@barton2526)

Changed
 - doc: Update build doc gridcoin-community#2078 (@iFoggz)
 - gui: Normalize button and input control appearance gridcoin-community#2096 (@cyrossignol)
 - consensus: Implement GetMinimumRequiredConnectionsForStaking gridcoin-community#2097 (@jamescowens)
 - refactor: move CTransaction to primitives gridcoin-community#2006 (@div72)
 - consensus, refactor, test: Merkle gridcoin-community#2094 (@div72)
 - gui: Update diagnostics gridcoin-community#2095 (@jamescowens)
 - gui: Refresh UI styles and sidebar/statusbar design gridcoin-community#2102 (@cyrossignol)
 - gui: Set standard base Qt style on Windows and macOS gridcoin-community#2114 (@cyrossignol)
 - build, refactor: bump to C++17 gridcoin-community#2113 (@div72)
 - util, rpc, gui: Implement GetMaxInputsForConsolidationTxn() gridcoin-community#2119 (@jamescowens)
 - gui: Refresh overview page design gridcoin-community#2117 (@cyrossignol)
 - depends: change boost mirror gridcoin-community#2122 (@div72)
 - refactor: small cleanup gridcoin-community#2123 (@div72)
 - build: Update depends Qt recipe to version 5.12.10 gridcoin-community#2129 (@cyrossignol)
 - build: Bump Codespell to 2.0.0 gridcoin-community#2135 (@barton2526)
 - gui: Refresh "send coins" page design gridcoin-community#2126 (@cyrossignol)
 - gui: Optimize locks to improve responsiveness gridcoin-community#2137 (@cyrossignol)
 - gui: Refresh "receive payment" page design gridcoin-community#2138 (@cyrossignol)
 - gui: Add empty placeholder to recent transactions list gridcoin-community#2140 (@cyrossignol)
 - gui: Refresh transaction history page design gridcoin-community#2143 (@cyrossignol)
 - gui: Refresh address book page design gridcoin-community#2145 (@cyrossignol)
 - doc: Update http to https where possible gridcoin-community#2148 (@barton2526)
 - depends: Update dependencies gridcoin-community#2153 (@barton2526)
 - depends: Bump python to 3.6 gridcoin-community#2159 (@barton2526)
 - test: Update cppcheck linter to c++17 gridcoin-community#2157 (@barton2526)
 - test: Drop Travis specific workarounds, Mention commit id in error, Fix typos, Update spellcheck ignore words gridcoin-community#2158 (@barton2526)
 - gui: Overhaul the voting UI gridcoin-community#2151 (@cyrossignol)
 - wallet: simplify nTimeSmart calculation gridcoin-community#2144 (@div72)
 - gui: Refresh checkbox and radio button styles gridcoin-community#2170 (@cyrossignol)
 - build: Bump libevent to 2.1.11 gridcoin-community#2172 (@barton2526)
 - build: Update native_mac_alias, Remove big sur patch file in qt recipe gridcoin-community#2173 (@barton2526)
 - docs: Misc Grammar gridcoin-community#2176 (@barton2526)
 - build: miniupnpc 2.2.2 gridcoin-community#2179 (@barton2526)
 - rpc: Refresh rainbymagnitude gridcoin-community#2163 (@jamescowens)
 - util: optimize HexStr gridcoin-community#2185 (@div72)
 - refactor: misc style changes gridcoin-community#2177 (@div72)
 - rpc: consolidatemsunspent changes. gridcoin-community#2136 (@iFoggz)
 - refactor: Replace "GlobalStatus" state management gridcoin-community#2183 (@cyrossignol)
 - rpc, util: Remove use of ArgsManager::NETWORK_ONLY for now gridcoin-community#2190 (@jamescowens)
 - doc: Replace hidden service with onion service, Capitalize "Tor" gridcoin-community#2193 (@barton2526)
 - gui: Update Qt Linguist localization files gridcoin-community#2192 (@cyrossignol)
 - script: Shell script cleanups gridcoin-community#2195 (@barton2526)
 - build: set minimum required Boost to 1.58.0 gridcoin-community#2194 (@barton2526)
 - build, util: Prevent execution for Windows versions less than Windows 7 gridcoin-community#2203 (@jamescowens)
 - build: Tweak NSIS Windows installer gridcoin-community#2204 (@jamescowens)
 - build: Add bison in depends gridcoin-community#2206 (@iFoggz)
 - build: macOS toolchain bump gridcoin-community#2207 (@div72)
 - doc: Update build-unix.md gridcoin-community#2212 (@springfielddatarecovery)
 - build: Bump minimum python version to 3.6, Remove python2 references gridcoin-community#2219 (@barton2526)
 - depends: Change openSSL source path to Github gridcoin-community#2237 (@barton2526)
 - doc: Fix typo in bug report template gridcoin-community#2243 (@jamescowens)
 - ci: fold depends output gridcoin-community#2244 (@div72)

Removed
 - wallet: remove dead hardcoded addnodes gridcoin-community#2116 (@sweede-se)
 - rpc: Remove readconfig gridcoin-community#2248 (@jamescowens)
 - rpc: Remove obsolete comparesnapshotaccrual RPC function gridcoin-community#2100 (@jamescowens)
 - rpc: Remove memorypool RPC Command gridcoin-community#2214 (@RoboticMind)
 - rpc: Remove deprecated RPC commands gridcoin-community#2101 (@jamescowens)
 - Remove CCT from README, add Discord gridcoin-community#2134 (@barton2526)
 - refactor: Remove obsolete pubsub method definitions gridcoin-community#2191 (@barton2526)
 - refactor: Remove msMiningErrorsIncluded & msMiningErrorsExcluded gridcoin-community#2215 (@RoboticMind)
 - qt: Remove obsolete topLevelWidget(), Remove obsolete QRegExpValidator gridcoin-community#2198 (@barton2526)
 - net: Drop support of the insecure miniUPnPc versions gridcoin-community#2178 (@barton2526)
 - log: remove deprecated db log category gridcoin-community#2201 (@barton2526)
 - doc: Remove CCT from README and release process docs gridcoin-community#2175 (@barton2526)
 - build: Remove travis references gridcoin-community#2156 (@barton2526)

Fixed
 - gui: Fix macOS and designer font sizes gridcoin-community#2098 (@cyrossignol)
 - gui: Have the TrafficGraphWidget respect the selected stylesheet. gridcoin-community#2107 (@jamescowens)
 - gui: Fix macOS display inconsistencies gridcoin-community#2106 (@cyrossignol)
 - gui: Fix RPC console auto-complete background color gridcoin-community#2108 (@cyrossignol)
 - gui: Avoid reloading redundant stylesheets gridcoin-community#2109 (@cyrossignol)
 - gui: Fix "no active beacon" status gridcoin-community#2110 (@cyrossignol)
 - gui: Fix dark theme link text color visibility gridcoin-community#2115 (@cyrossignol)
 - scraper, util, qt: Fix several deprecations and warnings gridcoin-community#2131 (@jamescowens)
 - gui: Fix duplicate time in GUIUtil::dateTimeStr() gridcoin-community#2139 (@cyrossignol)
 - gui: Fix debug console traffic graph legend colors gridcoin-community#2142 (@cyrossignol)
 - gui: Fix nomenclature gridcoin-community#2104 (@jamescowens)
 - doc: Fix Typos gridcoin-community#2149 (@barton2526)
 - doc: Fix "master" branch build status badge in readme gridcoin-community#2167 (@cyrossignol)
 - gui: Fix Inter font rendering on Windows with FreeType gridcoin-community#2169 (@cyrossignol)
 - gui: Fix assert on non-existent data directory and GUI datadir chooser corner case issues gridcoin-community#2174 (@jamescowens)
 - gui: Fix display artifact in poll loading indicator gridcoin-community#2180 (@cyrossignol)
 - rpc, logging: Minor fixes for sidestake logging gridcoin-community#2187 (@jamescowens)
 - gui: Fix fractional scaling for dialog sizes gridcoin-community#2189 (@cyrossignol)
 - doc: Random fixes gridcoin-community#2197 (@barton2526)
 - doc: getbalance should say GRC not "btc" gridcoin-community#2199 (@barton2526)
 - net: Add missing verification of IPv6 address in CNetAddr::GetIn6Addr¦ gridcoin-community#2200 (@barton2526)
 - doc: remove duplicate line from .gitignore gridcoin-community#2202 (@Pythonix)
 - util: Tweak exception handling in MilliTimer class to eliminate compiler warnings gridcoin-community#2233 (@jamescowens)
 - depends: patch missing include in qt gridcoin-community#2234 (@div72)
 - wallet, rpc: Check each input for IsMine() in GetAddressGroupings gridcoin-community#2242 (@jamescowens)
 - util, qt: Fix snapshot download gridcoin-community#2246 (@jamescowens)
 - gui: Fix Column Widths in RPC Console. Elide long strings in their center. Indent user agent. gridcoin-community#2241 (@barton2526)
 - qt: Fix crash during download snapshot on macOS gridcoin-community#2250 (@jamescowens)
 - qt: Don't allow to open the debug window during splashscreen & verification state gridcoin-community#2245 (@barton2526)
 - gui: Fix address book selected model record when editing gridcoin-community#2253 (@cyrossignol)
 - researcher: Check wallet status before beacon renewal gridcoin-community#2254 (@cyrossignol)
 - qt: Prevent pasting (no label) as label in consolidation transaction gridcoin-community#2255 (@jamescowens)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants