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, staking: Implement facilities for mandatory sidestakes and sidestake GUI #2704

Merged

Conversation

jamescowens
Copy link
Member

@jamescowens jamescowens commented Oct 6, 2023

This PR is responsive to longstanding feature requests regarding sidestaking. It formalizes the SideStake class in Gridcoin and changes the core to use this class rather than simply pulling from the config repeatedly. The registry pattern for other contracts with db backing has been used to support mandatory (contract originated) sidestakes as a future-proofing for sidestake functionality, especially as it relates to the planned benefactor next layer. Mandatory sidestakes will not be available until block v13, the next major protocol change (mandatory), but the local sidestake facilities work correctly now. [Update - mandatory sidestake operation post block v13 fork has been tested, debugged, and verified to operate correctly by using an isolated test network forked from testnet for v13 testing.]

Validation of coinstake transactions by stakers on AcceptBlock to ensure that mandated sidestakes are present with the correct allocation has not yet been implemented. This will be implemented by another PR as we get closer to a v13 hardfork. Full mandatory sidestake validation for block v13+ has been implemented.

The SideStakeRegistry supports both contract originated (mandatory) and local (optional) sidestakes, the latter of which are backed by the client configs. Proper triggering via core signal of the updating of the registry on using changesettings to dynamically change the sidestaking using the command line has been implemented. This allows the miner to simply do an in memory call rather than the more expensive calls to GetArg each miner loop invocations.

Sidestakes can now have descriptions and also have a status. The status values are for local sidestakes
ACTIVE, //!< A user specified sidestake that is active
INACTIVE, //!< A user specified sidestake that is inactive

For mandatory sidestakes
DELETED, //!< A mandatory sidestake that has been deleted by contract
MANDATORY, //!< An active mandatory sidestake by contract

A table view has been added to the options dialog on the staking tab to allow viewing and editing the sidestakes. Only user specified (local - optional) sidestakes can be edited. Editing can be done in place or using the edit button.

Note that the PR is flagged mandatory since it includes code that activates at the next block version, although the GUI part of the PR along with local sidestaking functions beforehand.

The sidestake table in options...
image

Adding a new local sidestake...
image

Editing an existing sidestake in place...
image

Trying to put in an invalid allocation (i.e. total adds up to more than 100%)...
image

Editing an existing sidestake using the edit button...
image

Address validity is checked for the sidestakes on add, and also when signaled from the core.

Note that the maximum total allocation that can be assigned to mandatory sidestakes is 0.25 (25%).

Note that using changesettings rpc to change the settings via the core side will result in a change in the GUI via automatic update of the core and signaling to the GUI model and view.

Here is where the sidestake "state" is stored for local sidestakes. It goes into the gridcoinsettings.json file.
image

If there are traditional sidestake entries in the read-only config file, gridcoinresearch.conf, these will be properly picked up for the core and GUI. If any new sidestake is inserted or edit is made, override values in the new format will be placed into the json file and take precedence over what is in the conf file.

Here is a short video demonstrating the new functionality...
https://www.youtube.com/watch?v=Iy1f5lT71Rk

@47an
Copy link

47an commented Oct 6, 2023

Great to take it to GUI.

@jamescowens jamescowens force-pushed the implement_sidestake_GUI branch 7 times, most recently from 0bf10c5 to 93f0167 Compare October 14, 2023 21:18
@jamescowens jamescowens marked this pull request as ready for review October 14, 2023 23:06
@jamescowens jamescowens requested a review from div72 October 22, 2023 15:06
@jamescowens jamescowens force-pushed the implement_sidestake_GUI branch 4 times, most recently from 3cab464 to 9972ef9 Compare November 1, 2023 16:57
@jamescowens jamescowens force-pushed the implement_sidestake_GUI branch 9 times, most recently from 38fb982 to cbc52f0 Compare December 26, 2023 02:32
This is to support fraction based arithmetic. Currently this is used in sidestake
allocations as a replacement for the double type calculations to eliminate
consensus problems in mandatory sidestakes due to floating point arithmetic.
Remove error banding in mandatory sidestake validation.
This suppresses the percent sign for editing and prevents a
silent rejection due to inclusion of the percent sign in the saved
field.
…ages

Not all errors are where claimed aomount is greater than calculated. With MRC
and mandatory sidestakes, number and destination of outputs are also checked.
@jamescowens jamescowens force-pushed the implement_sidestake_GUI branch 7 times, most recently from de5f29d to 43e0147 Compare January 28, 2024 05:59
@jamescowens jamescowens force-pushed the implement_sidestake_GUI branch from 43e0147 to 83d3f9e Compare January 28, 2024 06:42
@jamescowens
Copy link
Member Author

Holy macro... the msb function. Geez...

@jamescowens jamescowens merged commit c31376c into gridcoin-community:development Jan 29, 2024
17 checks passed
@jamescowens jamescowens mentioned this pull request Feb 5, 2024
jamescowens added a commit to jamescowens/Gridcoin-Research that referenced this pull request Mar 2, 2024
Added
 - contrib: add nix file for compilation environment gridcoin-community#2660 (@div72)
 - gui: Make main Gridcoin window geometry save unique to datadir location gridcoin-community#2661 (@jamescowens)
 - build: Initial CMake support gridcoin-community#2676 (@CyberTailor)
 - util: Add `-shutdownnotify` and `startupnotify` options from upstream gridcoin-community#2688 (@barton2526)
 - gui, staking: Implement facilities for mandatory sidestakes and sidestake GUI gridcoin-community#2704 (@jamescowens)
 - gui, voting: Implement poll result caching and poll stale indicator gridcoin-community#2709 (@jamescowens)
 - gui, projects: Implement greylist state for projects in GUI projects table gridcoin-community#2715 (@jamescowens)
 - gui, poll: Implement poll expiration reminders gridcoin-community#2716 (@jamescowens)
 - serialize: allow variants to be serialized gridcoin-community#2729 (@div72)
 - gui: Implement poll field length limiters in GUI forms gridcoin-community#2742 (@jamescowens)

Changed
 - consensus, contract, scraper, protocol, project, beacon, rpc: Replace remaining appcache sections with native structures gridcoin-community#2639 (@jamescowens)
 - build: update libsecp256k1 to v0.3.0 gridcoin-community#2655 (@div72)
 - build: Replace $(AT) with .SILENT gridcoin-community#2674 (@barton2526)
 - build: allow system bdb gridcoin-community#2675 (@div72)
 - Resize Header Column with Additional Text gridcoin-community#2683 (@PrestackI)
 - rpc: use RPCErrorCode everywhere gridcoin-community#2687 (@Pythonix)
 - wallet: SecureString to allow null characters gridcoin-community#2690 (@barton2526)
 - random: port some upstream changes gridcoin-community#2696 (@div72)
 - depends: Bump dependencies gridcoin-community#2692 (@barton2526)
 - doc: Update link to Discord server gridcoin-community#2693 (@adriaanjoubert)
 - rpc: Change capitalization, remove whitespace of rpc keys gridcoin-community#2711 (@Pythonix)
 - ci: bump MacOS version to 12 gridcoin-community#2713 (@div72)
 - depends: no-longer nuke libc++abi.so* in native_clang package gridcoin-community#2719 (@div72)
 - doc: update windows `-fstack-clash-protection` doc gridcoin-community#2720 (@div72)
 - Silence `-Wcast-function-type` warning gridcoin-community#2721 (@div72)
 - build: Use newest `config.{guess,sub}` available gridcoin-community#2722 (@div72)
 - refactor: use the try_lock result in TryEnter gridcoin-community#2723 (@div72)
 - Updates for file src/qt/locale/bitcoin_en.ts in pt_PT gridcoin-community#2726 (@gridcoin-community)
 - ci: do not silently fail gridcoin-community#2727 (@div72)
 - Properly include Boost Array header gridcoin-community#2730 (@theMarix)
 - build: Update depends zlib to 1.3.1 gridcoin-community#2734 (@jamescowens)
 - util: Enhance Fraction class overflow resistance gridcoin-community#2735 (@jamescowens)
 - refactor: Fix compilation warnings gridcoin-community#2737 (@jamescowens)
 - gui, util: Improve upgrade dialog gridcoin-community#2738 (@jamescowens)
 - util: Improve allocation class gridcoin-community#2740 (@jamescowens)
 - translations: translation updates for Miss Piggy release gridcoin-community#2745 (@jamescowens)

Removed
 - gui: Disable snapshot GUI action gridcoin-community#2700 (@jamescowens)
 - build, crypto, script: remove most of OpenSSL usage gridcoin-community#2705 (@div72)
 - util: remove WSL 1 workaround in fs gridcoin-community#2717 (@div72)

Fixed
 - diagnostics: fix missing arg in ETTS warning gridcoin-community#2684 (@div72)
 - misc: fix include guard in netaddress.h gridcoin-community#2695 (@div72)
 - gui: Fix expired pending beacon display gridcoin-community#2698 (@jamescowens)
 - consensus: Fix 20230904 testnet forking issue gridcoin-community#2703 (@jamescowens)
 - gui: Fix filter by type in Transaction View gridcoin-community#2708 (@jamescowens)
 - depends: make fontconfig build under clang-16 gridcoin-community#2718 (@div72)
 - diag: fix researcher mode check gridcoin-community#2725 (@div72)
 - gui: Add missing switch cases for ALREADY_IN_MEMPOOL gridcoin-community#2728 (@jamescowens)
 - beacon, registry: Fix beacon history stall gridcoin-community#2731 (@jamescowens)
 - build: Implement comp_double comparison function in certain tests gridcoin-community#2741 (@jamescowens)
 - ci: change Qt path in CMake CI gridcoin-community#2743 (@div72)
 - net: Correct -tor argument handling gridcoin-community#2744 (@jamescowens)
@jamescowens jamescowens deleted the implement_sidestake_GUI branch July 21, 2024 15:51
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.

3 participants